akhauriyash/Code-Regression huggingface dataset:
// TeamNichoen
// g++ -O2 -Wall -Wextra -Wshadow problemA.cpp 

#include "bits/stdc++.h"

using namespace std;

typedef long long int LL;
typedef long long int ll;

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int solve(vector<vector<int> > &mp,int sx,int sy,int gx,int gy,int dir,int dep){
    if(dep>=11){
        return 9999;
    }
    if(mp[sx+dx[dir]][sy+dy[dir]]==0)
    {
        while(mp[sx+dx[dir]][sy+dy[dir]]==0){
            sx+=dx[dir];
            sy+=dy[dir];
            if(sx==gx&&sy==gy){
                return 0;//goal
            }
        }

        if(mp[sx+dx[dir]][sy+dy[dir]]==1){
            mp[sx+dx[dir]][sy+dy[dir]]=0;
            int mini=99999;
            REP(i,4){
                int val=solve(mp,sx,sy,gx,gy,i,dep+1)+1;
                if(val<mini){
                    mini=val;
                }
            }
            mp[sx+dx[dir]][sy+dy[dir]]=1;
            return mini;
        }else{
            return 9999;
        }
    }
    else
    {
        return 9999;
    }
}

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

    while(true){

    int w,h;
    cin>>w>>h;
    if(w==0){
        break;
    }

    vector<vector<int> > mp(w+2,vector<int>(h+2,-1));

    int startx;
    int starty;
    int goalx;
    int goaly;
    REP(j,h){
        REP(i,w){
            int hoge;
            cin>>hoge;
            if(hoge==0||hoge==1)
            {
                mp[i+1][j+1]=hoge;
            }else
            if(hoge==2){
                mp[i+1][j+1]=0;
                startx=i+1;
                starty=j+1;
            }else{
                mp[i+1][j+1]=0;
                goalx=i+1;
                goaly=j+1;

            }
        }   
    }

    int mini=99999;
    REP(i,4){
        int val=solve(mp,startx,starty,goalx,goaly,i,0)+1;
        if(val<mini){
            mini=val;
        }
    }
    if(mini>10){
        cout<<-1<<endl;
    }else{
    cout<<mini<<endl;
    }
    }
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());
	int alice = 0, bob = 0;

	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    static int[] A;
    static int[] use;
    static Set<Integer> set = new HashSet<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        A = new int[n];
        use = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        sumCombination();
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            if (set.contains(sc.nextInt())) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }


    }

    static void sumCombination() {
        int i = 0;
        rec(i);
    }

    static void rec(int i) {
        if (i == use.length) {
            int sum = 0;
            for (int j = 0; j < A.length; j++) {
                if (use[j] == 1) {
                    sum += A[j];
                }
            }
            set.add(sum);
            return;
        }
        use[i] = 1;
        rec(i + 1);
        use[i] = 0;
        rec(i + 1);
    }
}

Measured memory_bytes: 47604
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fastio
    map<int,int>m;
    for(int i=0;i<3;i++){
        int x;cin>>x;
        m[x]++;
    }
    if(m.size()==2) cout<<"Yes";
    else            cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

#define rev(s) (vector<char>((s).rbegin(), (s).rend()))
#define HASH_SIZE 30011
#define a 1049

int hash(vector<char> str)
{
  int n = 0;
  int pow = 1;
  for (unsigned int i = 0; i < str.size(); i++) {
    n += (pow * (str[i] - 'a')) % HASH_SIZE;
    pow *= 26;
    pow %= HASH_SIZE;
  }
  return n % HASH_SIZE;
}

class hash_table {
public:
  vector<vector<char> > h;
  bool operator[](vector<char> str) {
    int key = hash(str);
    //cout << string(str.begin(), str.end()) << ":" << key << endl;
    for (int i = 0; i < HASH_SIZE; i++) {
      if (h[key].empty()) {
	h[key] = str;
	return true;
      } else if (str == h[key]) {
	return false;
      } else {
	//printf("hit!\n");
	key = (key * key + a) % HASH_SIZE;
      }
    }
    //printf("!!\n");
    h[key] = str;
    return true;
  }
  hash_table():h(HASH_SIZE) {}
};

vector<char>operator+(const vector<char>& lhs, const vector<char>& rhs)
{
  vector<char> result = lhs;
  result.insert(result.end(), rhs.begin(), rhs.end());
  return result; 
}

int getline(char* str)
{
  char c;
  int idx = 0;
  while ((c = getchar()) != EOF) {
    //printf("%d\n", idx);
    if (c == '\n') {break;}
    str[idx++] = c;
    //printf("%c\n", str[idx - 1]);
  }
  return idx;
}

int main() {
  int N;
  scanf("%d ", &N);
  while (N--) {
    char str[100];
    int end = getline(str);
    //if (N == 3) {printf("hoge\n");}
   
    hash_table bag;

    int c = 0;
    bag[vector<char>(str, str + end)];
    c++;
    for (int i=1; i< end; i++) {
      vector<char> head(str, str + i);
      vector<char> tail(str + i, str + end);
      
      //if (bag[head + tail]) c++;
      if (bag[rev(head) + tail]) c++;
      if (bag[head + rev(tail)]) c++;
      if (bag[rev(head) + rev(tail)]) c++;
      if (bag[tail + head]) c++;
      if (bag[rev(tail) + head]) c++;
      if (bag[tail + rev(head)]) c++;
      if (bag[rev(tail) + rev(head)]) c++;
    }
    printf("%d\n", c);
  }
  return 0;
}

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int ap[114514] = {};

signed main() {
    int max_a = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        max_a = max(max_a, a);
        ap[a]++;
    }
    if (max_a == 1 && N != 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    if (max_a % 2 == 0) {
        ap[max_a / 2]--;
    } else if (ap[max_a / 2 + 1] != 2) {
        cout << "Impossible" << endl;
        return 0;
    }
    for (int i = 1; i <= 100; i++) {
        if ((i > max_a || i <= max_a / 2)) {
            if (ap[i] != 0) {
                cout << "Impossible" << endl;
                return 0;
            }
        } else {
            if (ap[i] < 2) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
    return 0;
}


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

int main(){
  ll N,K;
  ll m = 1e9;
  cin>>N>>K;
  vector<ll> vec(N);
  
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  
  for(int i=0;i<N-K+1;i++){
    ll kyori;
    if(vec.at(i)*vec.at(i+K-1)>0)
      kyori=max(abs(vec.at(i)),abs(vec.at(i+K-1)));
    else
      kyori=2*min(abs(vec.at(i)),abs(vec.at(i+K-1)))+max(abs(vec.at(i)),abs(vec.at(i+K-1)));
    m = min(m,kyori);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 1024
store = "ABCDE"

while 1:
    s1, s2 = map(int, input().split())
    if s1 == 0 and s2 == 0:
        break

    s = store[0]
    ans = s1 + s2

    for i in range(4):
        s1, s2 = map(int, input().split())
        if s1 + s2 > ans:
            s, ans = store[i+1], s1 + s2

    print(s, ans)



Measured memory_bytes: 5600
def problemInput():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    peopleNum, peopleList = problemInput()

    maxHeight = 0
    totalStepHeight = 0

    for ind in range(peopleNum):
        lookingPerson = peopleList[ind]
        if lookingPerson <= maxHeight:
            totalStepHeight += maxHeight-lookingPerson
        else:
            maxHeight = lookingPerson
    
    print(totalStepHeight)


if __name__ == "__main__":
    main()


Measured memory_bytes: 94164
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

S = readline().rstrip().decode()
N = len(S)

def rui(a):
    ret = [0] * (len(a) + 1)
    for i in range(len(a)):
        ret[i + 1] = ret[i] + (1 if a[i] == '1' else 0)
    return ret
r = rui(S)
#print(r)

# k未満を使わずに反転可能な最大のKは？
ok = 0
ng = N + 1

while ok + 1 < ng:
    med = (ng + ok) // 2
    # medで一発が必要なのは？
    le = N - med
    ri = med
    #print(le,ri)
    if le >= ri:
        ok = med
    else:
        ru = r[ri] - r[le]
        if ru == 0 or ru == ri - le:
            ok = med
        else:
            ng = med

print(ok)


Measured memory_bytes: 40304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        // 人数
        int n = sc.nextInt();
        // 種類
        int k = sc.nextInt();

        boolean[] sunuke = new boolean[n];

        for (int i = 0; i < k; i++) {
            int jmax = sc.nextInt();
            for (int j = 0; j < jmax; j++) {
                sunuke[sc.nextInt() - 1] = true;
            }
        }

        int ans = 0;

        for (boolean isTrue : sunuke) {
            if (isTrue)
                ans++;
        }
        System.out.println(n - ans);
        sc.close();
    }
}

Measured memory_bytes: 37232
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pss pair <string, string>
#define pssss pair <pss, pss>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6;
const ll inf = 1e16;

ll mod;

ll n, m, k, t;

ll D[maxn];

ll C[maxn];

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n >> mod;
    ll mid = n / 2;
    ll mid1;
    if (n % 2 == 1) {
        mid1 = mid + 1;
    }
    else {
        mid1 = mid;
    }
    // cout << mid << " " << mid1 << endl;
    for (q = 1; q < n; q++) {
        C[q] = 0;
        if (q <= mid) {
            C[q] -= (mid - q + 1);
        }
        if (q >= mid1) {
            C[q] += (n - q);
        }
        else {
            C[q] += n - mid1;
        }
    }
    D[0] = 1;
    ll cnt0 = 0;
    for (q = 1; q < n; q++) {
        C[q]++;
        // cout << q << " " << C[q] << " C" << endl;
        for (w = 0; w <= 2 * n; w++) {
            if (w - C[q] >= 0) {
                D[w] += D[w - C[q]];
                D[w] %= mod;
            }
        }
    }
    ll ans = 0;
    for (q = 0; q < n; q++) {
        ans += (D[q] * (n - q));
        ans %= mod;
    }
    cout << ans;
    return 0;
}

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

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  
  int res=0; 
  for(int i=0; i<(n-1); i++){
    for(int j=i+1; j<n; j++){
      int k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
      res += max(k - (j+1), 0);
    }
  }
  
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	var cnt [26]int
	for i := 0;i < 4; i++ {
		cnt[int(s[i]-'A')] += 1
	}

	var cnt2 int

	for _, i := range cnt {
		if i == 2 {
			cnt2 += 1
		}
	}
	if cnt2 == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int MOD = 924844033;
const int N = 2005;

using namespace std;

int n, k;
int dp1[N][N][4], dp2[N][N]; 
ll dp[N], f[N], rf[N];

ll binpow(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if (b & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll sum(ll a, ll b)
{	
	a += b;
	while(a >= MOD)
		a -= MOD;
	while(a < 0)
		a += MOD;
	return a;
}

ll C(int x, int y)
{	
	return f[x] * rf[y] % MOD * rf[x - y] % MOD;
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> k;
	//~precalc_f
	f[0] = rf[0] = 1;
	forn(i, n)	
	{
		f[i] = f[i - 1] * i % MOD;
		rf[i] = binpow(f[i], MOD - 2);
	}
	//~calc_dp1
	dp1[1][0][0] = 1;
	for (int i = 2; i <= 1 + (n - 1) / k; i++)
	{	
		for (int j = 0; j <= n; j++)
		{	
			dp1[i][j][0] = (0ll + dp1[i - 1][j][0] + dp1[i - 1][j][1] + dp1[i - 1][j][2] + dp1[i - 1][j][3]) % MOD;			
			if (j > 0)
			{
				dp1[i][j][1] = (0ll + dp1[i - 1][j - 1][0] + dp1[i - 1][j - 1][1]) % MOD;
			}	
			if (j > 0)
			{
				dp1[i][j][2] = (0ll + dp1[i - 1][j - 1][0] + dp1[i - 1][j - 1][2]) % MOD;
			}
			if (j > 1)
			{        
				dp1[i][j][3] = dp1[i - 1][j - 2][0];
			}
		}
	}	
	//~calc_dp2
	dp2[0][0] = 1;
	for (int i = 1; i <= min(k, n); i++)
	{
		for (int j = 0; j <= n; j++)
		{
			int m = 1 + (n - i) / k;
			for (int x = 0; x <= min(j, m); x++)
			{	
				dp2[i][j] = sum(dp2[i][j], 1ll * (0ll + dp1[m][x][0] + dp1[m][x][1] + dp1[m][x][2] + dp1[m][x][3]) % MOD * dp2[i - 1][j - x] % MOD);
			}
		} 		
	}
	//~calc_dp
	for (int i = n; i >= 0; i--)
	{
		dp[i] = dp2[min(k, n)][i] * f[n - i] % MOD;
		for (int j = i + 1; j <= n; j++)
		{
			dp[i] = (dp[i] - (dp[j] * C(j, i)) % MOD + MOD) % MOD;
		}
	}
	cout << dp[0];

	return 0;
}



Measured memory_bytes: 64512
#include <iostream>

using namespace std;

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

    int fn = 0;
    for (int i = n; i > 0; i /= 10) {
        fn += i % 10;
    }

    cout << (n % fn == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#pragma GCC optimize "O3,omit-frame-pointer,inline"
#pragma GCC target "tune=native"
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template<typename T>inline
#define USE2(T, U) template<typename T,typename U>inline
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template<typename T>using duo=std::pair<T,T>;
template<typename T>using vec=std::vector<T>;
using ll=long long;
using pii=duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T=int)vec<T>in(int n,T a){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>()+a);return v;}
USE1(T)vec<std::pair<T,int>>enume(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() { //
  int H = in(), W = in();
  rep(i, H) {
    rep(j, W) {
      auto s = in<string>();
      if (s == "snuke") {
        cout << (char)('A' + j);
        cout << i + 1 << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

vector<vector<int>> z(55);
int a[55], b[55];
bool ch[55], fa[55];
int acc = 0;

void check(int s){
	int N = z[s].size();
	for (int j = 0; j < N; j++) {
		if (fa[s] && fa[z[s][j]])continue;
		else if (!ch[z[s][j]]) {
			acc++;
			ch[z[s][j]] = true;
			check(z[s][j]);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		z[a[i]].push_back(b[i]);
		z[b[i]].push_back(a[i]);
	}
	fill(fa + 1, fa + N + 1, false);
	int ans = 0;
	for (int i = 0; i < M; i++) {
		acc = 0;
		fa[a[i]] = true;
		fa[b[i]] = true;
		fill(ch + 1, ch + N + 1, false);
		ch[a[i]] = true;
		acc++;
		check(a[i]);
		fa[a[i]] = false;
		fa[b[i]] = false;
		if (acc != N)ans++;
	}
	cout << ans;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

void solve(){
  string s; cin>>s;
  int x = 0;
  for(char c:s){
    x += ctoi(c);
    x %= 9;
  }
  if(x%9==0){cout << Liny;}
  else{ cout << Linn;}
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

ll a[2002], mod = 1e9 + 7;
ll s;

ll f(ll su){
    if(su < 0)return 0;
    if(su == 0)return 1;
    if(a[su] != -1){
        return a[su];
    }
    ll ans = 0;
    for(ll i = 3; i <= su; i++){
        ans += f(su - i);
        ans %= mod;
    }
    return a[su] = ans;
}
void doit(){
    cin >> s;
    memset(a,-1,sizeof(a));
    cout << f(s) << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main()
{
    int n,x,i,j,c=0;
    cin>>n;

    int arr[n];
    for(i=0; i<n; i++)
    {


        cin>>arr[i];
    }



    for (int i = 1; i < n - 1; i++)
    {
        if (arr[i - 1] < arr[i] && arr[i] < arr[i + 1] || arr[i + 1] < arr[i] && arr[i] < arr[i - 1])


            c++;
    }

    cout << c << endl;

    return 0;

}


Measured memory_bytes: 256
package com.example.alds1.nine

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val h = IntArray(n + 1)
    IntRange(1, n).forEachIndexed { _, v ->
        h[v] = sc.nextInt()
    }

    buildMaxHeap(h)

    h.forEachIndexed { i, v ->
        if (i == 0) {
            return@forEachIndexed
        }
        print(" $v")
    }
    println()
}

fun buildMaxHeap(h: IntArray) {
    for (i in (h.size /2) downTo 1) {
        maxHeapify(h, i)
    }
}

fun maxHeapify(h: IntArray, i: Int) {
    val l = i * 2
    val r = i * 2 + 1
    var maxi = i
    if (l <= h.size - 1 && h[l] > h[i]) {
        maxi = l
    }
    if (r <= h.size - 1 && h[r] > h[maxi]) {
        maxi = r
    }
    if (maxi != i) {
        val tmp = h[i]
        h[i] = h[maxi]
        h[maxi] = tmp
        maxHeapify(h, maxi)
    }
}

//fun buildMaxHeap(h: IntArray) {
//    for (i in (h.size / 2) downTo 1) {
//        maxHeapify(h, i)
//    }
//}
//
//fun maxHeapify(h: IntArray, i: Int) {
//    val l = i * 2
//    val r = i * 2 + 1
//    var largest = i
//    if (l <= h.size - 1 && h[l] > h[i]) {
//        largest = l
//    }
//    if (r <= h.size - 1 && h[r] > h[largest]) {
//        largest = r
//    }
//    if (largest != i) {
//        val tmp = h[i]
//        h[i] = h[largest]
//        h[largest] = tmp
//        maxHeapify(h, largest)
//    }
//}
//



Measured memory_bytes: 169840
#coding:utf-8

from collections import defaultdict

if __name__ == "__main__":
    N, M = map(int, input().split(" "))

    roads = defaultdict(int)
    for i in range(M):
        a, b = map(int, input().split(" "))
        roads[a] += 1
        roads[b] += 1

    for j in range(1, N + 1):
        print (roads[j])


Measured memory_bytes: 3444
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int N = int.Parse(imp[0]);
            int i = int.Parse(imp[1]);
            
            Console.Write(N-i+1);
           
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()

def Base_10_to_n(i10, n, ans_list:list):
    # 各桁を0-indexにするために1減らす
    i10 -= 1
    if(int(i10/n)):
        ans_list.append(Base_10_to_n(int(i10/n), n, ans_list))
        return str(i10%n)
    return str(i10%n)


def resolve():
    n = int(input().rstrip())
    n_list = []
    ans_list = []

    n_list.append(Base_10_to_n(n, 26, n_list))

    for n26 in n_list:
        string = ord("a") + int(n26)
        ans_list.append(chr(string))

    ans_string = ""
    for st in ans_list:
        ans_string += st
    print(ans_string.rstrip())

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61844
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    tmp = 0
    s = str(i)
    if len(s) == 1:
        tmp = int(s)
    else:
        for n in s:
            tmp += int(n)
    if a <= tmp <= b:
        ans += i
print(ans)

Measured memory_bytes: 40048
N = int(input())
S = input()

count = 0
for d in range(1, N//2+2):
    for i in range(N-2*d):
        if S[i] != S[i+d] and S[i+2*d] != S[i+d] and S[i+2*d] != S[i]:
            count += 1


cntR = cntG = cntB = 0
for i in range(N):
    if S[i] == 'R':
        cntR += 1
    elif S[i] == 'G':
        cntG += 1
    else:
        cntB += 1

ans = cntR*cntG*cntB - count
print(ans)


Measured memory_bytes: 73144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

type bomb struct {
	h int
	w int
}

func main() {
	_, _, m := scanInt(), scanInt(), scanInt()
	bs := make(map[bomb]bool, m)

	bh := map[int]int{}
	bw := map[int]int{}
	for i := 0; i < m; i++ {
		a, b := scanInt(), scanInt()
		bh[a-1]++
		bw[b-1]++
		bs[bomb{a - 1, b - 1}] = true
	}

	var mh int
	var hs []int
	for k, v := range bh {
		if v > mh {
			mh = v
			hs = append([]int{}, k)
		} else if v == mh {
			hs = append(hs, k)
		}
	}
	var mw int
	var ws []int
	for k, v := range bw {
		if v > mw {
			mw = v
			ws = append([]int{}, k)
		} else if v == mw {
			ws = append(ws, k)
		}
	}
	var s bool
	for _, h := range hs {
		for _, w := range ws {
			if !bs[bomb{h, w}] {
				s = true
				break
			}
		}
	}

	if s {
		fmt.Println(mh + mw)
	} else {
		fmt.Println(mh + mw - 1)
	}
}


Measured memory_bytes: 66432
#include <iostream>

using namespace std;

int main( void )
{
  int a, b, c;
  bool flag = false;
  cin >> a >> b >> c;
  if( a < b ){
    if( b < c ){
      flag = true;
    }
  }
  if( flag ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return( 0 );
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    B.at(i)=A.at(i);
    }
  sort(B.begin(),B.end());
  for(int i=0;i<N;i++){
    if(B.at(N-1)==A.at(i))
      cout<<B.at(N-2)<<endl;
    else
      cout<<B.at(N-1)<<endl;
    }
  }

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

long long a,b,c,x,ams;

int main()
{
	ios::sync_with_stdio(0);
	 cin>>a>>b>>c>>x;
	 for(int i=0;i<=a;i++)
	 	for(int j=0;j<=b;j++)
	 		for(int k=0;k<=c;k++)
	 			if(i*500+j*100+k*50==x)
	 				ams++;
	 cout<<ams<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<ll> a(N);
    vector<ll> sum(N+1,0);
    rep(i,N){
        cin>>a.at(i);
        sum.at(i+1)=sum.at(i)+a.at(i);
    }
    ll ans=1e18;
    rep(i,N+1){
        if(i==0 || i==N) continue;
        ll snuke = sum.at(i)-sum.at(0);
        ll arai = sum.at(N)-sum.at(i);
        ll tmp = abs(snuke-arai);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#define GODSPEED ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define f(i,x,n) for(i=x;i<n;i++)
#define rf(i,x,n) for(i=n;i>x;i--)
#define ll long long
#define GCD(a,b) __gcd(a,b)
#define adios return 0;

/*
SHERAJUL ARIFIN
Dept. of CSE,
IUT.
*/


#include <bits/stdc++.h>
using namespace std;

int main()
{
    GODSPEED;
    ll t,n,a,b,c,d,s=0,i,j,flag;
    cin>>a>>b;
    ll arr[2000];
    f(i,0,a)
    {
        arr[i]=i+1;
    }
    cout<<arr[a-b]<<endl;



    adios;
}


Measured memory_bytes: 256
N = gets.strip.to_i
A = gets.split.map(&:to_i)
res = Array.new
res << A.join(' ') + "\n"
for i in 1..(N-1)
  key = A[i]
  j = i - 1
  while j >= 0 and A[j] > key
    A[j+1] = A[j]
    j=j-1
  end
  A[j+1] = key
  res << A.join(' ') + "\n"
end
print res.join

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

int main(){
    
    int X, N;
    cin >> X >> N;
    map<int, int> dict;

    for (int i=0; i<N; i++){
        int temp;
        cin >> temp;
        dict[temp]++;
    }

    int ans = 1e4;
    for (int i=0; i<101; i++){
        int lbuf, rbuf, l = 1e4, r = 1e4; 
        lbuf = X - i;
        rbuf = X + i;

//        cout << lbuf << " " << rbuf << endl;

        if (!dict.count(lbuf)) l = lbuf;
        if (!dict.count(rbuf)) r = rbuf;
        ans = min(l, r);
        if (ans != 1e4) break;
    }

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

Measured memory_bytes: 3620
def solve(Balls,Left,Right,i):
	if i==len(Balls):#???????????¶
		return True

	#????????\????????´???
	if len(Left)==0 or Left[-1]<Balls[i]:
		Left.append(Balls[i])
		return solve(Balls,Left,Right,i+1)

	#????????\????????´???
	if len(Right)==0 or Right[-1]<Balls[i]:
		Right.append(Balls[i])
		return solve(Balls,Left,Right,i+1)
	
	return False#??\???????????????



if __name__ == "__main__":
	n=int(input())
	for i in range(n):
		Balls = [int(i) for i in input().split()]
		Left=[]
		Right=[]
		i=0
		if solve(Balls,Left,Right,0):
			print("YES")
		else:
			print("NO")

Measured memory_bytes: 7684
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll a,b,x;
    cin >> a>>b>>x;

    ll ans = b/x;
    ans -= (a==0)?(-1):(a-1)/x; 

    cout << ans << endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int cnt[10100];
int main() {
	int n; cin >> n;
	for(int x = 1; x * x <= n; ++x) {
		for(int y = 1; x * x + y * y <= n; ++y) {
			for(int z = 1; x * x + y * y + z * z <= n; ++z) {
				int sum = x * x + y * y + z * z + x * y + y * z + z * x;
				if(sum <= n) {
					cnt[sum]++;
				}
			}
		}
	}
	for(int i = 1; i <= n; ++i) {
		cout << cnt[i] << '\n';
	}
	return 0;
}

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

int main() {
   char s[4];
	cin>>s;
    int a = atoi(s); 
    int b[4];
    int i=0;
while(a!=0)
{
	b[i]=a%10;
	a=a/10;
	i++;
}
for(int j=0;j<3;j++)
{
	if(b[j]==b[j+1])
	{   
		cout<<"Bad"<<endl;
		break;
	}
	else{
	if(j==2 && b[j]!=b[j+1])
	{
		cout<<"Good"<<endl;
	}
	}
}
	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    string N;
    cin >> N;
    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int k=a+b;
	if (k%2==1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		k=k/2;
		cout<<k<<endl;
	 } 
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n,m,x;
        cin>>n>>m>>x;
        ll a[n];f(i,0,n)cin>>a[i];
        ll b[m];f(i,0,m)cin>>b[i];
        ll sum=0,i=0,j=0;
        ll cnt=0;
        while(i<n && sum+a[i]<=x){
            sum+=a[i];
            i++;
        }
        cnt=i;
        while(j<m && i>=0){
            sum+=b[j];
            j++;
            while(sum>x && i>0){
                i--;
                sum-=a[i];
            }
            if(sum<=x && i+j>cnt)cnt=i+j;
        }
        cout<<cnt<<endl;
    return 0;  
} 





Measured memory_bytes: 6720
n,*a=map(int,open(0).read().split());k=1000000007
c=(1<<n)%k-1
for l in a:
	X=Y=j=Z=1;d=k-2
	for i in range(l):X=X*(n-i)%k
	while j<=l:Y=Y*j%k;j+=1
	while d>0:Z=Z*Y%k if d&1==1 else Z;Y=Y*Y%k;d>>=1
	c-=X*Z%k
print(c%k)

Measured memory_bytes: 263412
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k; cin>>k;
        cout<<a[k-1];
    }   
}


Measured memory_bytes: 3572
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int solve(const vector<int> &as, const int n) {
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, -1));

    function<int(int, int)> rec = [&](int l, int r) -> int {
        // [l, r)
        if (dp[l][r] >= 0) {
            return dp[l][r];
        }

        int cand = 0;

        if (r - l <= 1) {
            // do nothing
        } else if (r - l == 2) {
            if (abs(as[l] - as[l + 1]) <= 1) {
                cand = 2;
            }
        } else {
            for (int i = l + 1; i < r; i++) {
                chmax(cand, rec(l, i) + rec(i, r));
            }

            if ((r - l) % 2 == 0 && rec(l + 1, r - 1) == (r - l - 2) && abs(as[l] - as[r - 1]) <= 1) {
                chmax(cand, rec(l + 1, r - 1) + 2);
            }
        }

        dp[l][r] = cand;
        return cand;
    };

    int ans = rec(0, n);

    // printf("table: \n");
    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return ans;
}

int main(void) {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

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

        cout << solve(as, n) << endl;
    }

    return 0;
}



Measured memory_bytes: 3408
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


int main(){
  ll H,W; cin >> H >> W;
  ll ans = INF;
  for(ll h = 1; h < H; h++) {
    vl v = {h*W, (H-h)*(W/2), (H-h)*(W-W/2)};
    sort(all(v));
    chmin(ans,v[2]-v[0]);
    vl v2 = {h*W, ((H-h)/2)*W, (H-h - (H-h)/2) *W};
    sort(all(v2));
    chmin(ans,v2[2]-v2[0]);
  }

  swap(H,W);
  for(ll h = 1; h < H; h++) {
    vl v = {h*W, (H-h)*(W/2), (H-h)*(W-W/2)};
    sort(all(v));
    chmin(ans,v[2]-v[0]);
    vl v2 = {h*W, ((H-h)/2)*W, (H-h - (H-h)/2) *W};
    sort(all(v2));
    chmin(ans,v2[2]-v2[0]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b, k; cin >> a >> b >> k;
    set<int> st;
    for (int i = a; i < a+k && i <= b; i++) {
        st.insert(i);
    }
    for (int i = b; i >= b-k+1 && i >= a; i--) {
        st.insert(i);
    }
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        cout << *itr << endl;
    } 
}

Measured memory_bytes: 256
b = []

while True:
    inp = input()
    a = inp.split()
    a[0] = int(a[0])
    a[1] = int(a[1])
    a[2] = int(a[2])
    if a[0] == -1 and a[1] == -1 and a[2] == -1:
        break
    else:
        b.append(a)

for i in b:
    if i[0] == -1 or i[1] == -1:
        print("F")
    elif i[0]+i[1] >= 80:
        print("A")
    elif i[0]+i[1] >= 65:
        print("B")
    elif i[0]+i[1] >= 50:
        print("C")
    elif i[0]+i[1] < 30:
        print("F")
    elif i[2] >= 50:
        print("C")
    else:
        print("D")


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    set<ll> st;
    rep(i, n) {
        int a;
        cin >> a;
        if(*st.find(a) != a)
            st.insert(a);
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main() {
	int A,B,K,i,j,l;
	cin >> A >> B >> K;
	if ((B-(A+1))-(2*(K-1)) <= 0){
		for(i = 0; i < ((B+1)-A); i++)
			cout << (A+i) << endl;
	}
	else {
		for(j = 0; j < K; j++)
			cout << (A+j) << endl;
		for(l = 0; l < K; l++)
			cout << B-(K-1)+l << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    ll n, k;
    cin >> n >> k;
    ll seed = (n + k - 1ll) / k;
    ll neg = -1 * (n - seed * k);
    cout << min(n % k, neg) << endl;
}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

bool check(string s) {

    int l = 0;
    int r = s.size()/2;

    while(r != s.size()) {
        if(s[l] != s[r]) {
            return false;
        }
        l++;
        r++;
    }

    return true;
}

vector<long long> fac(20 + 1);

void fact() {
    fac[0] = 1;
    for(int i = 1; i <= 20; i++) {
        fac[i] = fac[i - 1] * i;
    }
}

void solve() {
    int n;
    cin >> n;

    int k = n;
    int sum = 0;

    while(k) {
        sum += k % 10;
        k/=10;
    }

    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    //fact();
    int t = 1;
    //cin >> t;

    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>

int main() {
	std::string s;
	std::cin >> s;
	bool ok = true;
	int hasta = s.size() / 2, hasta2, hasta3;
	for (int i = 0; i < hasta && ok; ++i) {
		ok = s[i] == s[s.size()-i-1];
	}
	hasta2 = hasta/2;
	for (int i = 0; i < hasta2 && ok; ++i) {
		ok = s[i] == s[hasta - i- 1];
	}
	hasta3 = hasta + hasta2;
	for (int i = hasta + 1, j = 1; i < hasta3 && ok; ++i, ++j) {
		ok = s[i] == s[s.size() - j];
	}
	if (ok)std::cout << "Yes\n";
	else std::cout << "No\n";

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define HAR BAR LAGTA HAI APUN HI J BHAGWAAN HAI!!
    #define UTSAV  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define ll long long int
    #define MAX 1e9
    #define MIN -1e9
    #define md 1000000007
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define debug(x) cerr<<#x<<'='<<(x)<<endl;
    #define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
    #define mxn 200005
    using namespace std;
    int main()
    {
        UTSAV
        int n;
        ll ans =0;
        cin>>n;
        for(int i=1;i<=n/2;i++){
            if(n%i==0) ans+=n/i - 1;
            else 
            ans+=n/i;
        }
        if(n%2==0)  cout<<ans + n/2 - 1<<endl;
        else  cout<<ans + n/2 <<endl;
       
        return 0;
    }


Measured memory_bytes: 3644
#include<algorithm>
#include<iostream>
#define ll long long
#define N 100003
using namespace std;
ll res[N << 2];
ll p[N], q[N], r[N];

int main()
{
	int a, b, c, x, y;
	cin >> x >> y >> a >> b >> c;
	int i;
	int ttttt = 11111111321;
	for (i = 1; i <= a; i++) cin >> p[i];
	for (i = 1; i <= b; i++) cin >> q[i];
	for (i = 1; i <= c; i++) cin >> r[i];
	int len=0;
	int tttt = 11111121;
	sort(p + 1, p + 1 + a);
	int tfsttt = 11111121;
	sort(q + 1, q + 1 + b);
	for (i = 1; i <= x; i++)
	{
		len++;
		int tqewtqtttt = 11111121;
		res[len] = p[a - i + 1];
	}
	for (i = 1; i <= y; i++)
	{
		int tfasdfttt = 11111121;
		len++;
		int tfsdaffttt = 11111121;
		res[len] = q[b - i + 1];
	}
	for (i = 1; i <= c; i++)
	{
		len++;
		int tttqeqweqwet = 11111121;
		res[len] = r[c - i + 1];
	}
	sort(res + 1, res + len + 1, greater<ll>());
	ll ans = 0;
	int tfdasfasttt = 11111121;
	int ttqqqtt = 11111121;

	for (i = 1; i <= x + y; i++) ans += res[i];
	int ttddddtt = 11111121;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

#include<cassert>

string s;
int ls;
int nps[205]={};

bool isnum(char c){
	return ('0'<=c && c<='9');
}
	

lli getnum(int& p){
	lli res=0;
	for(;;){
		if(p>=ls)break;
		char c=s[p];
		if(isnum(c)){
			res*=10;
			res+=(c-'0');
			p++;
		}
		else break;
	}
	return res;
}

char ops[5]="+-*/";
bool isope(char c){
	rep(i,4){
		if(c==ops[i])return true;
	}
	return false;
}
			

int npt[15]; //yuusenndo

bool ok;

lli expr(int& p,int pr){
	//printf("expr %d %d\n",p,pr);
	
	if(pr>11){
		return getnum(p);
	}
	else if(pr==10){
		if(s[p]=='('){
			p++;
			lli res=expr(p,0);
			assert(s[p]==')');
			p++;
			return res;
		}
	}
	//assert(isnum(s[p]));
	lli a1=expr(p,pr+1);
	if(p>=ls || s[p]==')')return a1;
	if(!isope(s[p])){
		printf("%dgyo %d %c",__LINE__,p,s[p]);
		assert(false);
	}
	//printf("nps_npt %d\n",npt[nps[p]]);
	if(npt[nps[p]]==pr){
		char c=s[p]; p++;
		lli a2=expr(p,pr+1);
		if(c=='+')return (a1+a2);
		else if(c=='-')return (a1-a2);
		else if(c=='*')return (a1*a2);
		else if(c=='/'){
			//printf("%lld %lld\n",a1,a2);
			if(a2==0){
				ok=false;
				return 0;
			}
			else return (a1/a2);
		}
		else assert(false);
	}
	else{
		return a1;
	}
}

int main(void){
	for(;;){
		cin >> s;
		ls=s.size();
		if(s[0]=='#')break;
		
		memset(nps,-1,sizeof(nps));
		int ct=0;
		rep(i,ls){
			if(isope(s[i])){
				nps[i]=ct;
				ct++;
			}
		}

		rep(i,ct)npt[i]=i;
		
		vector<lli> anss;
		do{
			int p=0;
			ok = true;
			lli na=expr(p,0);
			//printf("kekka .. %s %lld\n",ok?"ok":"ng",na);
			if(ok)anss.push_back(na);
		}while(next_permutation(npt,npt+ct));
		
		sort(anss.begin(),anss.end());
		anss.erase(unique(anss.begin(),anss.end()),anss.end());
		
			
		printf("%d\n",anss.size());
	}
	return 0;
}

Measured memory_bytes: 8912
// https://atcoder.jp/contests/keyence2020
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, N;
    cin >> H >> W >> N;
    cout << DIV(N, max(H, W)) << endl;
    return 0;
}


Measured memory_bytes: 256