akhauriyash/Code-Regression huggingface dataset:
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000ll)

//global
int n;
pair<int,int> a[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	cin >> n;
	int ca = 0;
	rep(i,0,n){
		cin >> a[i].first;
		a[i].second = i+1;
	}
	sort(a,a+n);
	rep(i,0,n){
		if((a[i].second&1) != ((i+1)&1)){
			ca++;
		}
	}
	cout << ca/2;
	return 0;
}

Measured memory_bytes: 1024
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 9999999999

def ddprint(x):
  if DBG:
    print(x)

def ws(dist):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j],
                              dist[i][k]+dist[k][j])

n,m,l = inm()
dst = [ [] for i in range(n) ]
for i in range(m):
    a,b,c = inm()
    dst[a-1].append((b-1,c))
    dst[b-1].append((a-1,c))

dist1 = [ [BIG]*n for i in range(n) ]
for i in range(n):
    dist1[i][i] = 0
    for j,c in dst[i]:
        dist1[i][j] = c

ws(dist1)

dist2 = [ [BIG]*n for i in range(n) ]
for i in range(n):
    dist2[i][i] = 0
    for j in range(n):
        if dist1[i][j] <= l:
            dist2[i][j] = 1

ws(dist2)

q = inn()
for i in range(q):
    s,t = inm()
    d = dist2[s-1][t-1]
    print(d-1 if d<BIG else -1)


Measured memory_bytes: 66904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int ans = 3000;
  for (int i = 0; i < s.size() - 2; ++i)
  {
    int num = 100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + (s[i + 2] - '0');
    if (abs(753 - ans) > abs(753 - num))
      ans = num;
  }
  cout << abs(753 - ans) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 
string s;
 
main () {
	cin >> s;
	for (auto c : s)
		if (c == '7') {
			cout << "Yes\n";
			return 0;
		}
 
	cout << "No";
 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
  ll n;
  cin >> n;

  vector<ll> a(n, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  map<ll, ll> mp;
  for(int i = 0; i < n; i++){
    mp[a[i]]++;
  }

  ll ans = 0;
  for(auto p: mp){
    ll x = p.first;
    ll n = p.second;
    if(n < x) ans += n;
    else ans += n - x;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std ;
int main(){
    string s ;
    cin >> s ;
    int len = s.length() ;
    bool flag = true ;
    if ( s[0] != 'A' ) flag = false ;
    int cnt = 0 ;
    for( int i = 2 ; i <= len - 2 ; i++ )
        if ( s[i] == 'C' ) cnt++ ;
    if ( cnt != 1 ) flag = false ;
    for( int i = 1 ; i <= len - 1 ; i++ )
        if ( s[i] != 'C' && s[i] <= 90 ) flag = false ;
    if ( s[1] == 'C' ) flag = false ;
    if ( s[len - 1] == 'C' ) flag = false ;
    if ( flag ) cout << "AC" << endl ;
    else cout << "WA" << endl ;
    return 0 ;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    B = list(map(int,input().split()))
    B.reverse()
    Ap = B[0]
    S = 0
    for Bi in B:
        A = min(Bi,Ap)
        if Bi > Ap:
            Ap = Bi
        else:
            Ap = A
        S += A
    S += Ap
    print(S)
          

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;

typedef signed long long ll;
const int MX = 1e6 + 5;
int tree[MX], A[MX];

void update(int id, int val){
	for(; id < MX ; tree[id] += val, id += id & -id);
}

int query(int id){
	int sum = 0;
	for(; id > 0 ; sum += tree[id], id -= id & -id);
	return sum;
}

int main() {
	int n, m;
	int ans = 0;
	cin >> n;
	
	for(int i = 0; i < n; cin >> A[i], i++);
	
	for(int i = 0; i < n; i++) {
		m = A[i];
		int x = query(m - 1);
		if(x == 0) ans++;
		update(m, 1);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
 
int a, b, c;
int n5, n7;
 
void check(int u){
 if(u == 5) ++n5;
 if(u == 7) ++n7;
}
 
int main(){
  n5 = n7 = 0;
  cin >> a >> b >> c;
  check(a);
  check(b);
  check(c);
  if(n5 == 2 && n7 == 1){
   cout << "YES" << endl; 
  }else{
   cout << "NO" << endl; 
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque

h, w = list(map(int, input().split()))
f = []
q = deque()
for i in range(h):
    l = input()
    for j, c in enumerate(l):
        if c == '#':
            q.append((0, i, j))
    f.append(l)

visited = [[False] * w for _ in [0] * h]
for d, i, j in q:
    visited[i][j] = True

ans = 0
move = [(0, 1), (0, -1), (1, 0), (-1, 0)]

while q:
    d, i, j = q.popleft()
    ans = d
    for di, dj in move:
        ni, nj = i + di, j + dj
        if ni < 0 or h <= ni or nj < 0 or w <= nj:
            continue
        if visited[ni][nj]:
            continue
        visited[ni][nj] = True
        q.append((d + 1, ni, nj))

print(ans)


Measured memory_bytes: 134492
n = int(input())
s = [input() for _ in range(n)]
new_s = []
cnt = {}
ans = 0

for i in s:
    new_s.append(str(sorted(i)))

for i in new_s:
    if i in cnt.keys():
        cnt[i] += 1
    else:
        cnt[i] = 1
for v in cnt.values():
    ans += v * (v-1) // 2

print(ans)

Measured memory_bytes: 31376
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPS(i, n) for (int i = 1; i <= (n); i++)
#define RREPS(i, n) for (int i = (n); i > 0; i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H + 2);
  REP(i, H + 2) {
    if (i == 0 || i == H + 1) {
      s[i] = "";
      REP(j, W + 2) s[i] += '.';
    }
    else {
      string t;
      cin >> t;
      s[i] = "." + t + ".";
    }
  }
  bool ans = true;
  REPS(i, H) {
    REPS(j, W) {
      if (s[i][j] == '.') continue;
      if (s[i - 1][j] != '#' && s[i][j - 1] != '#' && s[i + 1][j] != '#' && s[i][j + 1] != '#') {
        ans = false;
        break;
      }
    }
    if (!ans) break;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define errOut(s) \
  { std::cerr << __LINE__ << ":" << #s << ":" << (s) << std::endl; }

#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>
//#include <boost/range/adaptors.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

static constexpr int64_t MOD = 1000000007;

int64_t solve(int64_t  /*n*/, std::vector<int64_t> as) {
  int64_t s = 0;
  for (auto const a : as) {
    s += a;
    s %= MOD;
  }

  int64_t ret = 0;
  for (auto const a : as) {
    s += MOD;
    s -= a;
    s %= MOD;
    auto as = a * s;
    as %= MOD;
    ret += as;
    ret %= MOD;
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  auto const res = solve(n, std::move(as));
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n, m, c;
  cin >> n >> m >> c;

  vector<int> b(m);
  vector<vector<int>> a(n, vector<int>(m));

  for(int i = 0; i < m; i++){
    cin >> b.at(i);
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a.at(i).at(j);
    }
  }

  int count = 0;

  for(int i = 0; i < n; i++){
    int sum = c;
    for(int j = 0; j < m; j++){
      sum += a.at(i).at(j) * b.at(j);
    }
    if(sum > 0){
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long Long;


int main(){

   ios::sync_with_stdio(0);
   cin.tie(0);

   Long n;
   cin >> n;
   double Vmax = n*n*n/27.0;
   cout << fixed << setprecision(12) << Vmax;
   return 0;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;

void input(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';                 // char → int 変換
}

int totalSearch(const vector<int>& cnrvnNum)
{
  for (int nCtl = 0; nCtl < ( 1 << 3 ) - 1; nCtl++)
  {
    int nSum = cnrvnNum[0];
    for (int nEach = 0; nEach < 3; nEach++)
      if (nCtl & ( 1 << nEach )) nSum += cnrvnNum[nEach + 1];
      else                       nSum -= cnrvnNum[nEach + 1];

    if (nSum == 7)  return nCtl;
  }
  return ( 1 << 3 ) - 1;                       // 必ず答えが存在するため
}
    
void outputReslt(const vector<int>& cnrvnNum, int nReslt)
{
  cout << cnrvnNum[0];
  for (int nEach = 0; nEach < 3; nEach++)
  {
    if (nReslt & ( 1 << nEach )) cout << "+";
    else                         cout << "-";

    cout << cnrvnNum[nEach + 1];
  }
  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  
  input(vnNum);
  int nReslt = totalSearch(vnNum);
  outputReslt(vnNum, nReslt);

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<long> vec(n+1);
	vec[0] = 2;
	vec[1] = 1;

	if (n < 2) {
		cout << vec[n] << endl;
		return 0;
	}

	for (int i = 2; i < n + 1; i++) {
		vec[i] = vec[i-1] + vec[i-2];
	}

	cout << vec[n] << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 1000;

int main() {
    int n;
    cin >> n;

    long long T, A;
    cin >> T >> A;

    for (int i = 1; i < n; ++i) {
        int t, a; cin >> t >> a;
        long long dt = (T + t - 1) / t;
        long long da = (A + a - 1) / a;
        long long d = max(dt, da);
        T = t * d;
        A = a * d;
    }

    cout << T + A << endl;

    return 0;
}


Measured memory_bytes: 256
d=[0,0,0,0]
for i in range(3):
    a,b=map(int,input().split())
    d[a-1]+=1
    d[b-1]+=1

if d[0] <= 2 and d[1] <= 2 and d[2] <= 2 and d[3] <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9180
//2019.8.18 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int n;
    int val[50+10];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)val[i]=read();
        sort(val+1,val+n+1);
        RG db sum=1.0*(val[1]+val[2])/2;
        for(res i=3;i<=n;i++)sum=(sum+val[i])/2;
        printf("%.10lf\n",sum);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
string S;
int main()
{
	cin>>n>>S;
	for(i=0;i<n;i++)
	{
		switch(S[i])
		{
			case 'I':z++;break;
			case 'D':z--;break;
		}
		if(z>y)
		{
			y=z;
		}
	}
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
  
  vector<string> E(H);
   for(int i = 0; i < H; i++) {
     cin >> E.at(i);
   }
  
   for(int k = 0; k <= W+1; k++) {
     cout << "#";
   }
  cout << endl;
  
   for(int l = 0; l < H; l++) {
     cout << '#' << E.at(l) << '#' << endl;
   }
  
   for(int m = 0; m <= W+1; m++) {
     cout << "#";
   }
  cout << endl;
}
       
      


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

map<string,long long>mp;
string s;
void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        sort(s.begin(), s.end());
        mp[s]++;  
    }
    long long ans = 0,x;
    for(auto it:mp){
        x = it.Y-1;
    //    printf("x = %lld\n",x );
        ans += (x+1)*x/2;
     //   printf("ans = %lld\n",ans );
    }
    printf("%lld\n",ans );
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s,t;
  cin >> s >> t;
  vvi pos(26);
  int slen = sz(s);
  int tlen = sz(t);
  rep(i,slen) {
    pos[s[i]-'a'].push_back(i);
  }
  int ans = 0;
  int now = -1;
  rep(i,tlen) {
    int x = t[i]-'a';
    int k = upper_bound(rng(pos[x]),now) - pos[x].begin();
    if(k < sz(pos[x])) {
      now = pos[x][k];
      continue;
    }
    now = -1;
    ans++;
    k = upper_bound(rng(pos[x]),now) - pos[x].begin();
    if(k < sz(pos[x])) {
      now = pos[x][k];
      continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << 1ll*ans*slen+now+1 << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N, K;
int num[100000];
int tmp[100000];

int main() {
	while(scanf("%d %d", &N, &K), N || K) {
		rep(i, N) scanf("%d", &num[i]);
		FOR(i, 1, N) num[i] += num[i - 1];
		int ans = num[K - 1];
		FOR(i, K, N) ans = max(num[i] - num[i - K], ans);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3568
solve :: Int -> Int -> Int -> String
solve k a b = if any (\x -> x `mod` k == 0) [a..b]
                 then "OK"
                 else "NG"

main :: IO ()
main = do
  k <- readLn
  [a, b] <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ solve k a b


Measured memory_bytes: 3880
#include <iostream>
typedef  long long ll;
using namespace std;
 
 
int main(void) {
	ll a, b, ans = 0;
	cin >> a >> b;
	for (int i = 0; i < 8000; i++)
	{
		if ((int)(i * 0.08) == a && (int)(i * 0.1) == b)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;

struct StTrgLen
{
  StTrgLen() : m_nLenA(0), m_nLenB(0), m_nLenC(0) { }

  int m_nLenA;
  int m_nLenB;
  int m_nLenC;
};

struct StMatrl
{
  StMatrl() : m_nLenA(0), m_nLenB(0), m_nLenC(0) { }

  int m_nLenA;
  int m_nLenB;
  int m_nLenC;
};

void fnInput(StTrgLen& roTrgLen, vector<int>& rvnMatLen)
{
  int nMatLenSiz;
  cin >> nMatLenSiz >> roTrgLen.m_nLenA >> roTrgLen.m_nLenB >> roTrgLen.m_nLenC;
  rvnMatLen.resize(nMatLenSiz);

  for (int& rnMatLen : rvnMatLen)
    cin >> rnMatLen;
}

int fnDfs(int nDpth, StTrgLen oTrgLen, StMatrl oMatrl, const vector<int>& cnrvnMatLen)
{
  if (nDpth == cnrvnMatLen.size())
    if ( oMatrl.m_nLenA && oMatrl.m_nLenB && oMatrl.m_nLenC )
      return  abs(oTrgLen.m_nLenA - oMatrl.m_nLenA)
            + abs(oTrgLen.m_nLenB - oMatrl.m_nLenB) 
            + abs(oTrgLen.m_nLenC - oMatrl.m_nLenC);
    else
      return 1 << 30; 

  int nMinMp = 0; 
  int nAddMp;

  nMinMp = fnDfs(nDpth + 1, oTrgLen, oMatrl, cnrvnMatLen);

  StMatrl oMatrlA(oMatrl);
  nAddMp = oMatrlA.m_nLenA ? 10 : 0;
  oMatrlA.m_nLenA += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlA, cnrvnMatLen) + nAddMp);

  StMatrl oMatrlB(oMatrl);
  nAddMp = oMatrlB.m_nLenB ? 10 : 0;
  oMatrlB.m_nLenB += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlB, cnrvnMatLen) + nAddMp);

  StMatrl oMatrlC(oMatrl);
  nAddMp = oMatrlC.m_nLenC ? 10 : 0;
  oMatrlC.m_nLenC += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlC, cnrvnMatLen) + nAddMp);

  return nMinMp;
}

int fnMinCostTrgLen(StTrgLen oTrgLen, const vector<int>& cnrvnMatLen)
{
  StMatrl oMatrl;

  return fnDfs(0, oTrgLen, oMatrl, cnrvnMatLen);
}
 
int main()
{
  StTrgLen oTrgLen;
  vector<int> vnMatLen;

  fnInput(oTrgLen, vnMatLen);
  cout << fnMinCostTrgLen(oTrgLen, vnMatLen) << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll mod = (long long)1e9 + 7;
  int N;
  cin >> N;
  vector<int> As(1e5 + 1, 0);
 
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    As[A]++;
    if (As[A] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  if (N % 2 == 1 && As[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for (int i = 0; i < N/2; ++i) ans = ans * 2 % mod;

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
bool solver(string N)
{
    ll ans = 0;
    rep(i, 0, N.size())
    {
        ans += N[i] - '0';
    }
    return ans % 9 == 0 ? true : false;
}
int main()
{
    string N;
    cin >> N;
    if (solver(N))
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (long long int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    
    vector<int> vec(M);
    rep(i, M) {
        cin >> vec[i];
    }
    sort(ALL(vec));
    vector<int> sub;
    rep(i, M -1) {
        sub.push_back(vec[i + 1] - vec[i]);
    }
    sort(ALL(sub));
    int ans = 0;
    rep(i, M - N) {
        ans += sub[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int h[] = new int[n];
        int result = 1000000000;
        for(int i = 0;i<n;i++){
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        for(int i = 0;i<n-(k-1);i++){
            int minh = h[i];
            int maxh = h[i+(k-1)];
            int sah = maxh - minh;
            if(sah<result){
                result = sah;
            }
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 62340
n, m = map(int, input().split())

nlis = [list(input()) for _ in range(n)]
mlis = [list(input()) for _ in range(m)]

f = 0

for i in range(n):
    for j in range(n):
        if i+m-1 >=n or j+m-1 >=n:
            continue

        flag = 1
        for k in range(m):
            for l in range(m):
                if nlis[i+k][j+l] != mlis[k][l]:
                    flag = 0
        
        if flag:
            f = 1

if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;


int main(){
   int a,b,x;
   cin>>a>>b>>x;
   if(x-a<=b && a<=x){
      cout<<"YES"<<endl;
   }
   else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
MOD=10**9+7
MAX=10**6+2
for i in range(2, MAX):
  fac.append(fac[i - 1] * i % MOD)
  inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)
  finv.append(finv[i - 1] * inv[i] % MOD)
def COM(n, k):
  if n < k: 
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
X,Y=[int(s) for s in input().split()]
if (X+Y)%3!=0:
  print(0)
else:
  A=(X+Y)//3
  X-=A
  Y-=A
  if X<0 or Y<0:
    print(0)
  else:
    print(COM(X+Y,X))


Measured memory_bytes: 128584
require "prime"

X = gets.chomp.to_i

if Prime.prime?(X) then
  puts X
  exit
end

list = (2..X).to_a

primes = []

while list.first < Math.sqrt(X) do
  prime = list.first
  list = list.select{|n| n % prime != 0}
  primes << prime
end

last = list.last + 1
while true do
  if Prime.prime?(last) then
    puts last
    break
  end
  last += 1
end



Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int h,w;cin>>h>>w;vector<string>Grid(h);
    rep(i,h)cin>>Grid.at(i);
    vector<vector<int>>Min(h,vector<int>(w,-1));
    Min.at(0).at(0)=1;
    queue<pair<int,int>>q;
    q.push(make_pair(0,0));
    while(q.empty()==false){
        int f=q.front().first;int s=q.front().second;q.pop();
        if(f<h-1&&Grid[f+1][s]=='.'&&Min[f+1][s]==-1){Min[f+1][s]=Min[f][s]+1;q.push(make_pair(f+1,s));}
        if(s<w-1&&Grid[f][s+1]=='.'&&Min[f][s+1]==-1){Min[f][s+1]=Min[f][s]+1;q.push(make_pair(f,s+1));}
        if(f>0&&Grid[f-1][s]=='.'&&Min[f-1][s]==-1){Min[f-1][s]=Min[f][s]+1;q.push(make_pair(f-1,s));}
        if(s>0&&Grid[f][s-1]=='.'&&Min[f][s-1]==-1){Min[f][s-1]=Min[f][s]+1;q.push(make_pair(f,s-1));}
    }
    int count=0;
    if(Min[h-1][w-1]==-1)cout<<-1<<endl;
    else{
        rep(i,h){
            rep(j,w){
                if(Grid[i][j]=='#')count++;
            }
        }
        int ans=h*w-count-Min[h-1][w-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // start
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b >= a * c ? c : b / a) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  char a1,a2,a3,a4,a5,a6,a7,a8,a9;
  cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6 >> a6 >> a8 >> a9;
  cout << a1 << a5 << a9 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int W, H, N, x, y, a, i, l, r, u, d;
  
  scanf("%d %d %d", &W, &H, &N);
  l = d = 0;
  u = H;
  r = W;
  for (i = 0; i < N; i++){
    scanf("%d %d %d", &x, &y, &a);
    if(a == 1 && l < x){
      l = x;
    } else if(a == 2 && r > x){
      r = x;
    } else if(a == 3 && d < y){
      d = y;
    } else if(a == 4 && u > y){
      u = y;
    }
  }
  
  if(u > d && r > l){
    printf("%d\n", (u - d)*(r - l));
  } else {
    printf("0\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/ruby

def main
  n = gets().to_i
  return false if n == 0

  # ????????¨?????????
  rule = Hash.new
  n.times do
    from, to = gets().split(/\s*/)
    rule[from] = to
  end

  # ???????????????
  n = gets().to_i
  str = ''
  n.times do
    ch = gets().chomp!
    if rule[ch]
      str << rule[ch]
    else
      str << ch
    end
  end
  puts str
  return true
end

while(main)
end

Measured memory_bytes: 9000
n = gets.to_i
baggage = gets.split.map(&:to_i)
sorted = baggage.sort
pos = {}
n.times{ |i| pos[sorted[i]] = i }
cost = 0
used = [false] * n
n.times do |s|
  next if used[s]
  cur = s
  count = 0
  loop do
    count += 1
    used[cur] = true
    w = baggage[cur]
    cost += w
    cur = pos[w]
    break if used[cur]
  end
  cost += [sorted[cur] * (count - 2), sorted[cur] + sorted[0] * (count + 1)].min
end
p cost

Measured memory_bytes: 8916
#include <iostream>
#include <string>
#include <math.h>
 
using namespace std;
 
int main(){
    int k, s;
    cin >> k >> s;
    int o = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            if(x+y<=s && (s-x-y) <= k){
                o++;
                // cout << x << " " << y << " " << s-(x+y) << endl;
            }
        }
    }
    cout << o << endl;   
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, maxA;
  cin >> N;
  maxA = 0;
  vector<int> A(N), B(N-1);

  for (int i = 0; i < N-1; i++) cin >> B.at(i);
  maxA += B.at(0);
  for (int i = 1; i < N-1; i++)  maxA += min(B.at(i-1), B.at(i));
  maxA += B.at(N-2);
  
  cout << maxA << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a,b;
  cin>>a>>b;
  vector<int> s(3);
  s[0]=a+b;
  s[1]=a-b;
  s[2]=a*b;
  asort(s);
  cout<<s[2];
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

double dp[3000][3000];

int main(){
  setprecision(14);
  int N;
  cin >> N;
  double p;
  dp[0][0]=1.0;
  for(int i = 0; i < N; i++){
    cin >> p;
    for(int j = 0; j < N; j++){
      dp[i+1][j] += dp[i][j]*(1-p);
      dp[i+1][j+1] += dp[i][j]*p;
    }
  }
  double ans = 0.0;
  for(int i = (N+1)/2; i <= N; i++){
    ans+=dp[N][i];
  }
  printf("%.14f",ans);
  //cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70528
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String str = sc.next();
      	char target = 'x';
 
      int count = 0;
      for(char x:str.toCharArray()){
        if(x == target) {
          count++;
        }
      }
      
    // 出力

      
      if(count<=7){
              System.out.println("YES");
      }
      else{
        System.out.println("NO");
    }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a[3];

main() {
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    ct(abs(a[0]-a[1])+abs(a[1]-a[2]))
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main() {

    int kazu1,kazu2;
    vector<int> ans;
    int j;
    char tempstr;
    while(tempstr!='?'){

        cin>>kazu1>>tempstr>>kazu2;
        switch(tempstr){
            case '+':
                ans.push_back(kazu1+kazu2);
                break;
            case '-':
                ans.push_back(kazu1-kazu2);
                break;
            case '/':
                ans.push_back(kazu1/kazu2);
                break;
            case '*':
                ans.push_back(kazu1*kazu2);
                break;
        }

    }
   for(j=0;j<ans.size();j++){
       cout<<ans[j]<<endl;
   }
    //std::cout << "Hello, World!" << std::endl;
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

int main()
{
	long N;
	cin >> N;
	vector<long> sectionNum(5);
	for (int i = 0; i < 5; i++)
	{
		cin >> sectionNum[i];
	}
	
	// 都市の区間の中から一番小さい区間の人数を算出する
	long minNum = LONG_MAX;
	for (int i = 0; i < 5; i++)
	{
		minNum = min(sectionNum[i], minNum);
	}
	
	
	// 最小区間はN / minNumの切り上げの値 + 他の区間の合計の最短時間
	// (N + minNum - 1) / minNum + 4
	long answer = (N + minNum - 1) / minNum + 4;
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n];For(i,0,n) cin>>a[i];
	ll p[n][21];
	For(i,0,n) For(k,0,21) p[i][k]=n;
	Fod(i,n,0) For(k,0,21){
		if(i!=n-1) p[i][k]=p[i+1][k];
		if((a[i]&(1LL<<k))!=0){
			p[i][k]=i;
		}
	}

	// For(i,0,n){
	// 	For(k,0,21){
	// 		cout<<p[i][k]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	ll ans=0;
	For(i,0,n){
		ll temp = (n-i);
		if(i!=n-1){
			For(k,0,21) {
				ll c = 0;
				if((a[i]&(1LL<<k))!=0){
					c = p[i+1][k]-i;
				}
				else{
					ll t = p[i+1][k];
					if(t==n || t==n-1) c = n-i;
					else{
						c = p[t+1][k]-i;
					}
				}
				temp = min(temp,c);
			}
		}
		ans+=temp;
	}
	cout<<ans<<endl;










	
}

Measured memory_bytes: 34688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int l; cin >> l;
    vector<tuple<int, int, int>> ans;
    int r = log2(l);
    for(int i = 1; i <= r; i++){
        ans.push_back(make_tuple(i, i+1, 0));
        ans.push_back(make_tuple(i, i+1, 1<<(i-1)));
    }

    for(int i = r; i >= 1; i--){
        int a = l - (1<<(i-1));
        if(a < (1<<r)) continue;
        ans.push_back(make_tuple(i, r+1, a));
        l = a;
    }

    int n = r+1;
    int m = ans.size();
    cout << n << " " << m << endl;
    for(auto t : ans) cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
}


Measured memory_bytes: 256
N, = map(int, input().split())
As = [0] + list(map(int, input().split()))
Bs = [0] * (N+1)
for i in range(N):
    i = N - i
    tmp = 0
    for j in range(N//i-1):
        tmp += Bs[i * (j+2)]
    tmp %= 2
    if As[i]:
        Bs[i] = 1 - tmp
    else:
        Bs[i] = tmp
print(sum(Bs))
rs = []
for i, v in enumerate(Bs):
    if v:
        rs.append(i)
print(*rs)


Measured memory_bytes: 69212
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

flag = [0] * n
mm = [0] * n
clear = 0
miss = 0
for i in range(m):
    p, s = stdin.readline().rstrip().split()
    if flag[int(p)-1] == 0:
        if s == "AC":
            clear += 1
            flag[int(p)-1] += 1
            miss += mm[int(p)-1]
        else:
            mm[int(p)-1] += 1

print(str(clear) + ' ' + str(miss))



Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
*/

int checkpoint_num=0;
void pcheck(){
    cout << "----------------" << endl << checkpoint_num << endl << "----------------" << endl;
    checkpoint_num +=1;
}

template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
}

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
}




int main(void){
    std::cout<<std::fixed<<std::setprecision(10);
    string s;
    cin >>s;
    int ans = 0;
    for (int i = 0; i < 3; ++i){
        if (s[i] == '1'){
            ans += 1;
        }
    }
    cout << ans << endl;
    


};


Measured memory_bytes: 256
N, q = gets.split.map(&:to_i)
S = "<#{gets.chomp}>"
Q = q.times.map{gets.chomp}
l,r = [1, N]

def move(pos, op)
  label = op[0]
  dir = op[2]
  S[pos] != label ? pos : (dir == 'L' ? pos - 1 : pos + 1)
end

Q.reverse_each do |op|
  l = (l - 1 .. l + 1).each do |pos| 
    break pos if move(pos, op) >= l
  end
  r = (r - 1 .. r + 1).reverse_each do |pos| 
    break pos if move(pos, op) <= r
  end
  break if r < l
end

puts r < l ? 0 : r - l + 1


Measured memory_bytes: 18360
n = int(input())

table = {}

for num in range(1, n + 1):
    l = num % 10
    tmp = num
    while tmp >= 10:
        tmp //= 10
    m = tmp % 10

    if (l, m) not in table:
        table[(l, m)] = 1
    else:
        table[(l, m)] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        if (i, j) in table and (j, i) in table:
            ans += table[(i, j)] * table[(j, i)]

print(ans)


Measured memory_bytes: 73264
#include<stdio.h>
signed main(){

int k=4,t=2,a,b,i,x,y;

scanf("%d %d",&x,&y);

if(x*2<=y && y<=x*4 && y%2==0){

printf("Yes\n");

}else{
printf("No\n");

}


return(0);
}

Measured memory_bytes: 1652
#include <stdio.h>

int main(void){
	bool a[1000000];
	int n = 0;
	int c = 0;
	while(scanf("%d", &n) != EOF){
		switch(n){
		case 1:
			c = 0;
			break;
		case 2:
			c = 1;
			break;
		default:
			c = 1;
			for(int i=3; i<=n; i+=2){
				a[i] = true;
			}
			for(int i=3; i<=n; i+=2){
				if(a[i] == false){ continue; }
				c++;
				for(int j=i; j<=n; j+=i){
					a[j] = false;
				}
			}
			break;
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
import java.io.*;
 
public class Main{
 
    public static int stringToInt(char i, int[] a){
        if(i == 'A') return a[0];
        if(i == 'B') return a[1];
        if(i == 'C') return a[2];
        return 0;
    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int K = s.nextInt();
        double[] p = new double[N];
        for(int i = 0; i < N; i++){
            p[i] = s.nextDouble();
        }
 
        double exam = 0;
        for(int i = 0; i < K; i++){
            exam += (p[i]+1.0)/2.0;
        }
        
        double max = exam;
        for(int i = K; i < N; i++){
            double newExam = exam + (p[i]+1.0)/2.0 - (p[i-K]+1.0)/2.0;
            if(max <= newExam) max = newExam;
            exam = newExam;
        }
        
        System.out.println(max);
        
        
	}
} 

Measured memory_bytes: 158748
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int num4 = 0;
    int num2 = 0;

    rep(i, n) {
        if (a[i] % 4 == 0)
            num4++;
        else if (a[i] % 2 == 0)
            num2++;
    }

    int ans = num4 * 2;
    int diff = n - ans;
    if (ans < n - 1) {
        ans += num2 - 1;
    }
    if (ans >= n - 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3776
use proconio::input;

fn main() {
  let mut _c : i128 ;
  let mut _a :i128;
  let mut _b :i128;
let x = 1 ;
let y = 2 ; 

   input! {
    c : i128 ,
  
 }
 if c == x {
  println!("Hello World");
}else{
  input!{

    a : i128 ,
    b : i128 ,
  }
  println!("{}",a+b);
}

}


Measured memory_bytes: 2100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int i;
    char s[200000]={};
    scanf("%s",&s);
    int l=strlen(s);
    for(i=0;i<l;i++){
        if(s[i]=='?') printf("D");
        else printf("%c",s[i]);
    }
    return 0;
}


Measured memory_bytes: 1860
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<iomanip>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>t(n + 2, 0);
	t[0] = t[n + 1] = 0;
	for (int i = 1; i < n + 1; i++) cin >> t[i];
	vector<int>v(n + 2, 0);
	v[0] = v[n + 1] = 0;
	for (int i = 1; i < n + 1; i++)cin >> v[i];
	int totalTime = 0;
	for (int i = 0; i < n + 2; i++)totalTime += t[i];
	vector<double>maxv(2 * totalTime + 1, 0);
	int timeSum = 0;
	for (int i = 1; i < t.size()-1; i++) {
		maxv[timeSum] = min(v[i], v[i - 1]);
		for (int j = timeSum + 1; j < timeSum + 2 * t[i]; j++) {
			maxv[j] = v[i];
		}
		timeSum += 2 * t[i];
	}
	maxv[0] = maxv[2*totalTime] = 0;

	for (int i = 1; i < maxv.size(); i++) {
		maxv[i] = min(maxv[i], maxv[i - 1] + 0.5);
	}
	for (int i = maxv.size() - 2; i >= 0; i--) {
		maxv[i] = min(maxv[i], maxv[i + 1] + 0.5);
	}
	double distance = 0;
	for (int i = 0; i < maxv.size() - 1; i++) {
		distance += 0.5*0.5*(maxv[i + 1] + maxv[i]);
	}
	cout << std::fixed<<setprecision(4)<<distance << endl;
	//printf("%.10f\n", distance);
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
using namespace std;
#include<cstring>
char s[3000];
int pt=0;
char z[3000];
int main()
{
	long long ans;
	while(cin>>s)
	{ 
	pt=0;
	for (int i=0;i<strlen(s);i++)
	{
		if (pt<0) pt=0;
		if (s[i]=='0'||s[i]=='1')
		{
			z[pt++]=s[i];
		}
		else
		{
			pt--;
		}
	}
	if (pt<0) pt=0;
	z[pt]=0;
	cout<<z<<endl;
	} 
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define vecadd emplace_back

int main(){
  int n;
  cin>>n;
  
  if(n>9){}
  else{
    cout<<n;
  return 0;
  }
  
  if(n>99){}
  else{
    cout<<9;
  return 0;
  }
  
  if(n>999){}
  else{
    cout<<9+n-99;
  return 0;
  }
  
  if(n>9999){}
  else{
    cout<<9+900;
  return 0;
  }
  if(n>99999){
    cout<<9+900+90000;
  return 0;
  }
  else{
    cout<<9+900+n-9999;
  return 0;
  }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
using namespace std;

const int MaxN = 1e5 + 6;
typedef long long LL;
const int inf = 1 << 30;
int a[MaxN], b[MaxN];

int gcd(int x, int y){
	if(y == 0) return x;
	return gcd(y, x % y);
}

int main(){
	int n, x;
	cin>>n>>x;
	int ans = inf;
	int sum = inf;
	int cnt = 0;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++){
		b[++cnt] = abs(x-a[i]);
	}
	for(int i = 1; i <= cnt; i++){
		ans = min(gcd(b[i], b[1]),ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        for(;;){
            String str = sc.next();
            sc.nextLine();
            
            if(str.equals("-")) break;
            
            int m = sc.nextInt();
            sc.nextLine();
            
            String head = "";
            String tail = "";
            
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                sc.nextLine();
                
                head = str.substring(0,h);
                tail = str.substring(h,str.length());
                tail += head;
                str = tail;
            }
            System.out.println(tail);
        }
    }
}


Measured memory_bytes: 26648
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    k=c
    for j in range(m):
        k+=a[j]*b[j]
    if k>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060