akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int 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 itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector <int> bit(62);
    int n; cin>>n;
    vector <int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        rrep(j,62){
            if(a[i] & (1LL<<j)) bit[j]++;
            
        }
    }
    int ans = 0;
    rep(i,62){
        int tmp = (1LL << i);
        tmp %= MOD;
        tmp *= ((n-bit[i])*bit[i]) % MOD;

        /*ans += ((n-bit[i])*bit[i]*((1LL << (i))%MOD)) % MOD;
        ans %= MOD;*/
        ans += tmp;
        ans %= MOD;
    }
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    string s, t;
    cin >> s >> t;
    rep(i, s.length()){
        char b = s[s.length() - 1];
        s = b + s;
        s.erase(s.begin()+ s.length() - 1);
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
import sys
N=int(input())
A=list(map(int,input().split()))

plus=[]
minus=[]

if min(A)>=0:
    tmp=min(A)
    print(sum(A)-tmp*2)
    if len(A)==2:
        print(max(A),min(A))
        sys.exit()
    tmpind=A.index(tmp)
    if tmpind==len(A)-1:
        tmpind=0
        aa=A[0]
        A[0]=A[-1]
        A[-1]=aa
    for i in range(len(A)-1):
        if i==tmpind:continue
        print(tmp,A[i])
        tmp-=A[i]
    print(A[-1],tmp)
    
elif max(A)<=0:
    tmp=max(A)
    print(-(sum(A)-tmp*2))
    if len(A)==2:
        print(max(A),min(A))
        sys.exit()
    tmpind=A.index(tmp)
    if tmpind==len(A)-1:
        tmpind=0
        aa=A[0]
        A[0]=A[-1]
        A[-1]=aa
    for i in range(len(A)-1):
        if i==tmpind:continue
        print(tmp,A[i])
        tmp-=A[i]
    print(tmp,A[-1])
    
else:
    print(sum(map(abs,A)))
    for i in range(len(A)):
        if A[i]>0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    if len(plus)==1 and len(minus)==1:
        print(plus[0],minus[0])
    elif len(minus)==1:
        tmp=minus[0]
        for i in range(len(plus)-1):
            print(tmp,plus[i])
            tmp-=plus[i]
        print(plus[-1],tmp)
    else:
        for i in range(1,len(minus)):
            print(plus[-1],minus[i])
            plus[-1]-=minus[i]
        tmp=minus[0]
        for i in range(len(plus)-1):
            print(tmp,plus[i])
            tmp-=plus[i]
        print(plus[-1],tmp)


Measured memory_bytes: 14036
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int H, W;
	cin >> H >> W;

	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;

	for (int i = 0; i < H; i++) {
		string S;
		cin >> S;
		cout << '#' << S << '#' << endl;
	}

	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const int INF = 1e5;
vector<int> dist(10, INF);

struct edge
{
    int to;
    int cost;
};

void dijkstra(const vector<vector<edge>> &G, int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
        P p1 = que.top();
        que.pop();
        int v = p1.second;
        if (dist[v] < p1.first)
            continue;

        for (auto e : G[v])
        {
            if (dist[e.to] > dist[v] + e.cost)
            {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
}

int main() {
    int H,W; cin >> H >> W;
    vector<vector<edge>> G(10, vector<edge>());
    REP(i,10) REP(j,10) {
        int c; cin >> c;
        if(i == j) continue;
        edge e = {j, c};
        G[i].push_back(e);
    }
    veci cost(10); // i -> 1に変える最小値
    REP(i,10) {
        if(i == 1) cost[i] = 0;
        else {
            dist.assign(10,INF);
            dijkstra(G,i);
            cost[i] = dist[1];
        }
    }
    ll ans = 0;
    REP(i,H) REP(j,W) {
        int a; cin >> a;
        if(a == -1 || a == 1) continue;
        ans += cost[a];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
char=[chr(i) for i in range(97, 97+26)]

ans=["a"]
before=0

for i in range(2,n+1):
    for c in range(len(ans)):
        From=char.index(sorted(list(ans[c]))[-1])
        for m in range(From+2):
            ans.append(ans[c]+char[m])
    #print(ans)
    
b=[]

for g in range(len(ans)):
    if len(ans[g])==n:
        b.append(ans[g])

b.sort()

for i in range(len(b)):
    print(b[i])

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M;

    cin >> N >> M;
    vector<ll> array(N, 0);
    ll total = 0;
    REP(i, N){ cin >> array[i];
        total += array[i];
    }

    sort(array.begin(), array.end());
    reverse(array.begin(), array.end());

    for(ll i= 0; i < M; i++ ){
        if( array[i] * 4 * M < total ){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))

    for i in range(N//2, 0, -1):
        sum_m = sum([A[i*j] for j in range(2, N//i+1)])
        if A[i] == 0:
            if sum_m % 2 == 1:
                A[i] = 1
        else:
            if sum_m % 2 == 1:
                A[i] = 0

    sum_b = sum(A)
    print(sum_b)
    if sum_b:
        ans = [str(i) for i, v in enumerate(A) if v == 1]
        print('\n'.join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 15796
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll a,b;
ll x;
ll f(ll y){
  if(y<0){
    return 0;
  }
  return y/x+1;
}

int main(){
  cin >> a >> b >> x;
  cout << f(b)-f(a-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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


    int x,a; cin >> x >> a;

    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
    
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
h_l = list(map(int,input().split()))
ab = []
for _ in range(m):
    ab.append(list(map(int,input().split())))

good = [1]*n
for a, b in ab:
    h1 = h_l[a-1]
    h2 = h_l[b-1]
    if h1 > h2:
        good[b-1] = 0
    elif h1 < h2:
        good[a-1] = 0
    else:
        good[a-1] = 0
        good[b-1] = 0

ans = 0
for val in good:
    ans += val

print(ans)


Measured memory_bytes: 32016
import sys
input = sys.stdin.readline


h, w = map(int, input().split())
inf = float('INF')
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)

D = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        D[i][j] = abs(A[i][j] - B[i][j])


def slide_down(y, x, possible):
    new = set()
    delta = D[y+1][x]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible):
    new = set()
    delta = D[y][x+1]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {D[0][0]}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)

Measured memory_bytes: 774152
#include <iostream>
#include <algorithm>
#include <vector>

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

  int n;
  std::cin>>n;

  std::vector<int64_t>a(n);
  for(int i=0;i!=n;i++)
  {
    std::cin>>a[i];
  }

  std::sort(a.rbegin(),a.rend());

  int64_t result=a[0];
  int j=1;
  bool flag=false;
  for(int i=1;i<n-1;i++)
  {
    result+=a[j];
    if(flag)
    {
      j++;
    }
    flag=!flag;
  }

  std::cout<<result<<std::endl;

  return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 60
#define F(a,b) for(register int (a)(0);(a)^(b);(a)++)
using namespace std;
int n,m,a[szxb],b[szxb],c[szxb],d[szxb];
signed main()
{
	scanf("%d%d",&n,&m);
	F(i,n){scanf("%d%d",&a[i],&b[i]);}F(i,m){scanf("%d%d",&c[i],&d[i]);}
	F(i,n){int ans(0),cnt(0x7fffffff);F(j,m){int t(((abs(a[i]-c[j]))+(abs(b[i]-d[j]))));if(t<cnt){cnt=t,ans=j;}}printf("%d",(ans+1)),putchar(10);}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static int WIDTH  = 5;
    private static int VANISH = 3;

    public static void main(String[] args) {
        int height;
        while((height = scn.nextInt()) > 0) {
            Puzzle puzzle = new Main().new Puzzle(height);
            puzzle.proc();
            System.out.println(puzzle.showScore());
        }
    }

    class Puzzle {
        int score;
        int[][] numbers;

        Puzzle(int height) {
            score = 0;
            numbers = new int[height][WIDTH];

            for(int i = 0; i < height; i++) {
                for(int j = 0; j < WIDTH; j++) {
                    numbers[i][j] = scn.nextInt();
                }
            }
        }

        int showScore() {
            return score;
        }

        void proc() {
            int lines;
            while((lines = vanishPhase()) > 0) {
                dropPhase(lines);
            }
        }

        private int vanishPhase() {
            int lines = 0;
            for(int i = 0; i < numbers.length; i++) {
                for(int j = 0; j <= WIDTH - VANISH; j++) {
                    int base = numbers[i][j];
                    if(base > 0) {
                        int count = 1;
                        while(j + count < WIDTH && base == numbers[i][j + count]) {
                            count++;
                        }
                        if(count >= VANISH) {
                            score += base * count;
                            while(count-- > 0) {
                                numbers[i][j + count] = 0;
                            }
                            lines++;
                            break;
                        }
                    }
                }
            }
            return lines;
        }

        private void dropPhase(int lines) {
            while(lines-- > 0) {
                for(int i = ~-numbers.length; i > 0; i--) {
                    for(int j = 0; j < WIDTH; j++) {
                        if(numbers[i][j] == 0) {
                            numbers[i][j]   ^= numbers[~-i][j];
                            numbers[~-i][j] ^= numbers[i][j];
                            numbers[i][j]   ^= numbers[~-i][j];
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 55088
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall


def main():
    n = int(input())
    s = [list(map(int, input())) for _ in range(n)]

    s = np.array(s)

    g = csgraph_from_dense(s)

    dist_mat = floyd_warshall(g).astype(np.int32)

    dist_max = dist_mat.max()

    a = np.where(dist_mat[0] % 2 == 0)
    b = np.where(dist_mat[0] % 2 == 1)
    bl = (s[a][:,a] == 0).all() and (s[b][:,b] == 0).all()

    ans = dist_max + 1 if bl else -1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23560
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int n,m;
    cin >> n >> m;
    ll ans=0;
    rep(i,m){
        ll f;
        cin >> f;
        ans+=f;
    }
    if (n<ans) cout << -1 << endl;
    else cout << n-ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    static int N;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        N = nextInt();
        int Po = calc();
        int Qo = calc();
        System.out.println(Math.abs(Po-Qo));
    }

    public static int calc() throws Exception {
        int res = 1;
        boolean used[] = new boolean[N+1];
        int order = 1;
        for (int i = N; i > 0; i--) {
            int digit = nextInt();
            int rank = 0;
            for (int j = 1; j <= N; j++) {
                if (digit == j) {
                    used[j] = true;
                    break;
                } else if (used[j]) {
                    continue;
                } else {
                    rank++;
                }
            }
            res += fact(i-1) * (rank);
        }
        return res;
    }

    public static int fact(int i) {
        return i == 0 ? 1 : i * fact(i-1);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}


Measured memory_bytes: 21204
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut aa = aa;
    let max_v = *aa.iter().max().unwrap();
    let min_v = *aa.iter().min().unwrap();
    let v = if max_v.abs() > min_v.abs() { max_v } else { min_v };
    let vi = aa.iter().position(|&v2| v2 == v).unwrap();

    debug!(aa);
    let mut ops = vec![];
    for i in 0..n {
        if i != vi {
            aa[i] += v;
            ops.push((vi, i));
        }
        if aa[i] < 0 {
            aa[i] = -1 * aa[i];
        }
    }
    debug!(aa);

    let rev = v < 0;
    if rev {
        aa.reverse();
    }

    for i in 1..n {
        let a = aa[i-1];
        let b = aa[i];
        if a > b {
            aa[i] = aa[i] + a;

            if rev {
                ops.push((n-i, n-i-1));
            } else {
                ops.push((i-1, i));
            }
        }
    }
    debug!(aa);
    println!("{}", ops.len());
    for &(x, y) in ops.iter() {
        println!("{} {}", x+1, y+1);
    }
}


Measured memory_bytes: 4352
n = int(input())
s = list(input() for i in range(n))

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if s[i] == "AC":
        ac+=1
    elif s[i] == "WA":
        wa += 1
    elif s[i] == "TLE":
        tle += 1
    else:
        re += 1

print("AC x", str(ac))
print("WA x",str(wa))
print("TLE x",str(tle))
print("RE x",str(re))

Measured memory_bytes: 15940
#include <stdio.h>
int gcd(int x,int y){
  int tmp;
  if(y>x){
    tmp=y;
    y=x;
    x=tmp;
  }
  if(y==0){
    return x;
  }else{
    return gcd(y,x%y);
  }
}

int main(){
  int n,a,b,c,gcd_1,gcd_2;
  long result=0;
  
  scanf("%d",&n);
  
  for(a=1;a<=n;a++){
    for(b=1;b<=n;b++){
      for(c=1;c<=n;c++){
        gcd_1=gcd(a,b);
        gcd_2=gcd(gcd_1,c);
        //printf("%d %d\n",gcd_1,gcd_2);
        result+=gcd_2;
      }
    }
  }
  printf("%ld",result);
}

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

int main() {
    int N;
    int sum = 0;
    cin >> N;  
    vector<int> vec(N);
    for(int i = 0;i < N;i++)
      cin >> vec[i];
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    for(int i = 0;i < N;i++){
      if(i%2==1)
        sum -= vec[i];
      else if(i==0)
        sum += vec[i];
      else
        sum += vec[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
#define ent '\n'

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    
    int x;
    cin>>x;
    int q=x/100;
    int r=x%100;
    if(r>q*5){
        cout<<0;
    }
    else{
        cout<<1;
    }






        
    


    return 0;
}

Measured memory_bytes: 256
package main

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

const Mod = 998244353

func main() {
	N := nextInt()
	Ds := nextInts(N)
	fmt.Println(solve(Ds))
}

func solve(Ds []int) int {
	if Ds[0] != 0 {
		return 0
	}

	foundMax := 0
	counts := make([]int, len(Ds))
	for _, d := range Ds {
		if foundMax < d {
			foundMax = d
		}
		counts[d]++
	}
	if counts[0] != 1 {
		return 0
	}

	ans := 1
	for i := 1; i <= foundMax; i++ {
		if counts[i] == 0 {
			return 0
		}
		ans = (ans * PowerMod(counts[i-1], counts[i])) % Mod
	}
	return ans
}

func PowerMod(a, b int) int {
	ret := 1
	for i := 0; i < b; i++ {
		ret = (ret * a) % Mod
	}
	return ret
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 2816
import Debug.Trace
import qualified Data.Map as Map

scan :: [Int] -> Int -> Int
scan xs = iter 0 where
    iter s e
        | e - s == 1 = e
        | check m xs = iter s m
        | otherwise  = iter m e
        where m = div (s+e) 2
    check m = iter Map.empty 0 where
        iter ps _ [] = True
        iter ps pl (x:xs)
            | pl <  x   = iter ps x xs
--            | pl <  x   = trace ("tr0 m:" ++ show m ++  " nl:"++ show x ++ " ns:" ++ show ps ++ " xs:" ++ show xs) $ iter ps x xs
            | otherwise = case next (Map.filterWithKey (\k _ -> k < x) ps) x of
                Just ns -> iter ns x xs
--                Just ns -> trace ("tr1 m:" ++ show m ++ " nl:"++ show x ++ " ns:" ++ show ns ++ " xs:" ++ show xs) $ iter ns x xs
                Nothing -> False
            where
                next _ 0 = Nothing
                next ns x = case Map.lookup k ns of 
                        Just v  -> if p v   then Just (Map.update (\_ -> Just (v+1)) k ns)
                                            else next (Map.delete k ns) (x-1)
                        Nothing -> if p 0   then Just (Map.insert k 1 ns)
                                            else Nothing
                    where
                        k = x - 1
                        p v = m - 1 > v

readData :: IO [Int]
readData = do
    line1 <- getLine
    let xs = map (\x -> read x :: Int) (words line1)
    return xs

main :: IO() 
main = do
    n  <- readLn :: IO Int
    la <- readData
    let ans = scan (take n la) n
    print ans

Measured memory_bytes: 60924
//Link : https://codeforces.com/problemset/problem/821/D

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200005
int a[N],b[N];

int ids[N];

bool cmp(int x,int y) {
  ll r = (ll)(a[x]+b[x])*a[y] + b[y] + a[y];
  ll u = (ll)(a[y] + b[y])*a[x] + b[x] + a[x];
  return r<u;
}
void solve() {
  int n,T;scanf("%d %d ", &n,&T);
  ll dp[N];

  vector<int> ones;
  int pos = 0;
  for(int i=0;i<n;++i) {
    scanf("%d %d ", &a[i],&b[i]);
    ++a[i];
    if(a[i]!=1) {
      ids[pos++] = i;
    } else {
      ones.push_back(b[i]);
    }
  }
  sort(ones.begin(),ones.end());
  if(pos>0) {
    sort(ids,ids+pos,cmp);
  }
  int ret = 0;
  const int MAX_LEN = 60;
  for(int i=0;i<=MAX_LEN;++i) {
    dp[i] = 1e18;
  }
  dp[0] = 0;
  for(int i=0;i<pos;++i) {
    int id = ids[i];
    for(int j= MAX_LEN-1;j>=0;--j) {
      if(dp[j]<=T) {
        dp[j+1] = min(dp[j+1], dp[j]*a[id]+b[id] + a[id]);
      }
    }
  }
  int size = ones.size();
  ll sum = 0;
  for(int num : ones) {
    sum += num + 1;
  }
  for(int i=0;i<=MAX_LEN;++i) {
    ll c = dp[i];
    if(c<=T) {
      while(size>0 && c + sum>T) {
        sum -= ones[size-1] + 1;
        --size;
      }
      ret = max(ret, i + size);
    } else {
      continue;
    }
  }

  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 2680
<?php
$input = array_map('intval', explode(" ", trim(fgets(STDIN))));
$N = $input[0];
$A = $input[1];
$B = $input[2];
$num = 0;
$total = 0;

for ($i=1; $i < $N+1; $i++) {
    $a =$i;
    for ($j=0; $j < strlen($i); $j++) {
        $num += $a%10;
        $a = (integer)($a/10);
    }
    if (($A<=$num)and($B>=$num)) {

        $total += $i;
    }
    $num = 0;
}
print $total;

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N, A, B; cin >> N >> A >> B;
  ll h[N]; rep(i, N) cin >> h[i];

  ll l=0, r=pow(10,10), m=0; 
  while(l!=r) {
    m = (l+r)/2;
    ll count = 0;
    rep(i, N) count += max((ll)0, (h[i]-B*m+(A-B-1))/(A-B));
    if (count<=m) r = (r-l==1) ? l : m;
    else l = (r-l==1) ? r : m;
    // cout << l << " " << r << endl;
  }


  cout << l << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
using namespace std;
bool debug=false;

int dfs(int n,int i){
  int cnt=0;
  if(n==i)return 1;
  else if(i>n)return 0;
  else{
    cnt+=dfs(n,i+1);
    cnt+=dfs(n,i+2);
    cnt+=dfs(n,i+3);
    return cnt;
  }
}

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    cout<<dfs(n,0)/3650+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    REP(i, m) cin >> a[i];

    int num = (int)(lower_bound(all(a), x) - a.begin());
    cout << min(num, m - num) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[100];
  int n;cin >> n;
  for(int j=0;j<n;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  
  bool ff = true;
  for(int k=0;k<n-1;k++){
    for(int l=k+1;l<n;l++){
      bool f=false;
      for(int i=0;i<4;i++){
	d[l].roll('R');
	for(int j=0;j<4;j++){
	  d[l].roll('N');
	  if(same(d[k],d[l])) f=true;
	}
      }
      d[l].roll('E');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      
      d[l].roll('W');
      d[l].roll('W');
      for(int j=0;j<4;j++){
	d[l].roll('N');
	if(same(d[k],d[l])) f=true;
      }
      if(f) ff=false;
    }
  }
  
  cout << (ff?"Yes":"No") << endl;
  return 0;
}



Measured memory_bytes: 3112
int main
  (){      char
 xxx,       yyy;
scanf       ("%c"
" %c"       ,&xxx    ,        &
yyy)         ;if(    xxx   >yyy
)puts       (">")     ;else if(
 xxx<       yyy)       printf
  ("<"     "\n"       );   else
     printf(         "="   "\n")
       ;}

Measured memory_bytes: 128
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 10;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];

void solve()
{
	int n, r;
	cin >> n >> r;
	if(n >= 10) cout << r;
	else cout << r + 100 * (10 - n);
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    	solve();
    return 0;
}

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


int main() {
    int H,W;cin >> H >> W;
    char s[H][W] = {};
    int d[H][W] = {};
    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            cin >> s[i][j];
        }
    }

    if (s[0][0] == '.') d[0][0] = 0;
    else d[0][0] = 1;

    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            if (i == 0 && j == 0) continue;
            if (i == 0){
                if (s[i][j] == '#') {
                    if (s[i][j - 1] == '#') d[i][j] = d[i][j - 1];
                    else d[i][j] = d[i][j - 1] + 1;
                }
                else d[i][j] = d[i][j - 1];
            }
            else{
                if (j == 0){
                    if (s[i][j] == '#') {
                        if (s[i - 1][j] == '#' ) d[i][j] = d[i - 1][j];
                        else d[i][j] = d[i - 1][j] + 1;
                    }
                    else d[i][j] = d[i - 1][j];
                }
                else{
                    if (s[i][j] == '#') {
                        int d1,d2;
                        if (s[i - 1][j] == '#') d1 = d[i - 1][j];
                        else  d1 = d[i - 1][j] + 1;

                        if (s[i][j - 1] == '#')  d2 = d[i][j - 1];
                        else  d2 = d[i][j - 1] + 1;

                        d[i][j] = min(d1,d2);
                    }
                    else d[i][j] = min(d[i - 1][j],d[i][j - 1]);
                }
            }
        }
    }
    cout << d[H - 1][W - 1] << endl;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, M; cin >> N >> M;
    int ans = (1900 * M + 100 * (N - M)) * pow(2, M);
    cout << ans << "\n";
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let h: usize = input();
    let w: usize = input();
    let mut s: Vec<Vec<i32>> = vec![vec![0; w + 2]; h + 2];
    for i in 1..h + 1 {
        let line: Vec<char> = input::<String>().chars().collect();
        for j in 1..w + 1 {
            if line[j - 1] == '#' {
                s[i][j] = 1;
            }
        }
    }

    let mut ok = true;
    for i in 1..h + 1 {
        for j in 1..w + 1 {
            if s[i][j] == 1 && s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1] == 0 {
                ok = false;
            }
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
    }
    int ix = -1;
    bool flag = false;
    rep(i,N){
        if(p[i]!=(i+1)){
            if(flag && p[i] != ix){
                cout << "NO" << endl;
                return 0;
            }
            flag = true;
            ix = i+1;
        }
    }
    cout << "YES" << endl;    
    return 0;
}

Measured memory_bytes: 256
def cont(ob,j):
    if (ob <= 0):
            return 0
    for i in range(len(j)):
        ob -= j[i]
        if (ob <= 0):
            return i+1
    return 9999
 
d,ob = map(int,input().split())
lst = []
point = []
kai = [[0 for i in range(ob//100)] for j in range(d)]
 
for i in range(d):
    lst =[]
    a = list(map(int,input().split()))
    for j in range(a[0]):
        lst.append((i+1)*100)
    lst[j] += a[1]
    point.append(lst)
 
 
for i in range(len(kai)):
    for j in range(len(kai[0])):
        if i == 0:
            kai[i][j] = cont((j+1)*100,point[i])
        else:
            if(sum(point[i])<(j+1)*100):
                a = kai[i-1][j]
                b = len(point[i]) + kai[i-1][j-sum(point[i])//100 ]
                if a>b:
                    kai[i][j] = b
                else:
                    kai[i][j] = a
            else:
                a = kai[i-1][j]
                b = cont((j+1)*100,point[i])
                if a>b:
                    kai[i][j] = b
                else:
                    kai[i][j] = a
        #print(kai)
 
#print(point)
print(kai[len(kai)-1][len(kai[0])-1])

Measured memory_bytes: 109168
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << c - (d - b) << ' ' << d + (c - a) << ' ' << a - (d - b) << ' ' << b + (c - a) << endl;
}

Measured memory_bytes: 256
numbers = gets
capline = gets

length, num = numbers.split(/\s/).map(&:to_i)
caps = capline.split("")

if caps[num-1] == "A"
    caps[num-1] = "a"
end

if caps[num-1] == "B"
    caps[num-1] = "b"
end

if caps[num-1] == "C"
    caps[num-1] = "c"
end

puts(caps.join(''))

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {

    string s;
    getline( cin, s );

    for( int i = 0; i < s.length(); i++){
        if( isalpha( s[ i ] ) ) {
            if( islower( s[ i ] ) )
                s[ i ] = toupper( s[ i ] );
            else
                s[ i ] = tolower( s[ i ] );
        }
        cout << s[ i ];
    }

    cout << endl;
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
int n,a[105],ans[105];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--){
		for (int j=i;j>=1;j--){
			if (a[j]==j){
				ans[i]=j;
				for (int k=j;k<i;k++) a[k]=a[k+1];
				break;
			}
		}
		if (!ans[i]){
			puts("-1");
			return 0;
		}
	}
	for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
} 

Measured memory_bytes: 256
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
(x, y) = map(int, input().split(" "))

if x in a and y in a or x in b and y in b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
typedef long long int ll;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};


int IsPrime(int num)
{
    if (num < 2) return 0;
    else if (num == 2) return 0;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く
    int i;
    double sqrtNum = sqrt(num);
    for (i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

int Prime[1000010];
int ans=0;int pans=0;
int G[3000][3000];
int color[3000][3000];
int dmax[3000][3000];
void dfs(int x,int y,int d){
	if(dmax[x][y]>d)return;
	if(dmax[x][y]!=0&&dmax[x][y]==d)return;
	chmax(dmax[x][y],d);

	int i=0;
	for(i=-1;i<=1;i++){
		int nx=x+1,ny=y+i;
		if(nx>=0&&nx<3000&&ny>=0&&ny<3000){
			if(G[nx][ny]!=-1){
				if(color[nx][ny]==0){
					color[nx][ny]=1;
					if(Prime[G[nx][ny]]==0){
						d++;
						if(ans<d){
							ans=d;
							pans=G[nx][ny];
						}
						else if(ans<=d){
							chmax(pans,G[nx][ny]);
						}
					}
					dfs(nx,ny,d);
					color[nx][ny]=0;
					if(Prime[G[nx][ny]]==0)d--;
				}
			}
		}
	}
}

int main(void)
{
	int n,m;scanf("%d %d",&m,&n);
	int i,j,k;

	Prime[0]=1;Prime[1]=1;
	for(i=2;i<1000001;i++){
		if(Prime[i]==0)
		for(j=2;i*j<=1000000;j++){
			Prime[i*j]=1;
		}
	}


	while(n>0&&m>0){
		ans=0;pans=0;
		for(i=0;i<3000;i++){
			for(j=0;j<3000;j++){
				G[i][j]=-1;
			}
		}
		memset(color,0,sizeof(color));
		memset(dmax,0,sizeof(dmax));
		i=1500;j=1500;
		int now=1;int turn =0;int len=1;
		int cnt=0;
		while(m){
			//G[i][j]=now++;
			for(k=0;k<len;k++){
				G[i][j]=now++;
				if(turn==0)j++;
				else if(turn==1)i--;
				else if(turn==2)j--;
				else i++;
				m--;
				if(m<=0)break;
			}
			if(turn==0)turn =1;
			else if(turn==1)turn=2;
			else if(turn==2)turn=3;
			else turn =0;
			if(cnt==0)cnt++;
			else{
				cnt=0;
				len++;
			}
		}
		/*
		for(i=0;i<20;i++){
			for(j=0;j<20;j++){
				printf("%d  ",G[i][j]);
			}
			printf("\n");
		}
		*/
		int x=0,y=0;
		for(x=0;x<3000;x++){
			for(y=0;y<3000;y++){
				if(G[x][y]==n){
					break;
				}
			}
			if(G[x][y]==n){
				break;
			}
		}
		//printf("%d %d %d\n",x,y,n);
		int d=0;
		if(Prime[n]==0){
			d=1;
			ans=1;
			pans=n;
		}
		color[x][y]=1;
		dfs(x,y,d);
		printf("%d %d\n",ans,pans);
		scanf("%d %d",&m,&n);
	}
    return 0;
}


Measured memory_bytes: 111204
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;

    while(cin >> n, n){
        vi series;
        bool player = true;
        int count = 0;
        for(int i=0; i < n; i++){
            int m;
            cin >> m;
            series.push_back(m);
        }
        int hajiki = 32;
        while(0 < hajiki){
            if(player){
                hajiki -= (hajiki-1)%5;
            }else{
                hajiki -= series[count%n];
                count++;
            }
            player = !player;

            if(0 < hajiki) cout << hajiki << endl;
            else cout << 0 << endl;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int x = n;
    int mod = 0;
    while(n>0){
        mod += n%10;
        n /= 10;
    }
    if(x%mod==0) cout << "Yes";
    else cout << "No";
}


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

int main(){
    int N,K,ans=0;
    cin>>N>>K;
    vector<int> l(N);
    for(int i=0;i<N;++i) cin>>l[i];
    sort(l.rbegin(),l.rend());
    for(int i=0;i<K;++i) ans += l[i];
    cout<<ans<<endl; 
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll no_of_div(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}

ll abc(ll x)
{
  ll cnt_f=0,cnt_s=0;
  while(x)
  {
    ll dig=x%10;
    if(dig==4)cnt_f++;
    else cnt_s++;
    x/=10;
  }
  return (cnt_f==cnt_s);
}

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

ll n;
cin>>n;
ll x=10;
ll cnt=0;
while(n/x)
{
  cnt+=n/x;
  x*=5;
}
if(n&1)cnt=0;
cout<<cnt<<"\n";

  return 0;



}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main(){
int h,w,d,a;
cin>>h>>w>>d;
vector<pair<int,int>> vp(h*w+1);
rep(i,h)
  rep(j,w){
     cin>>a;
     vp[a].first=i;
     vp[a].second=j;
  }
  int v[h*w+1]={};
  for(int i=1;i<=d;i++){
     int f=vp[i].first,s=vp[i].second,b=0;
     for(int j=i+d;j<=h*w;j+=d){
        v[j]=abs(vp[j].first-f)+abs(vp[j].second-s)+b;
        b=v[j];
        f=vp[j].first;
        s=vp[j].second; 
     }
  }
  int q,l,r;
  cin>>q;
  rep(i,q){
     cin>>l>>r;
     cout<<v[r]-v[l]<<endl; 
  }
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

char grid[100][100];
vector<int> rows, columns;

void solve()
{
    int H, W;
    cin >> H >> W;
    rows.assign(H, 0);
    columns.assign(W, 0);
    for(int i = 0; i < H; i++)
    {
        for(int k = 0; k < W; k++)
        {
            cin >> grid[i][k];
            if(grid[i][k] == '#')
            {
                rows[i] = 1;
                columns[k] = 1;
            }
        }
    }
    
    for(int i = 0; i < H; i++)
    {
        if(rows[i] == 0)
        {
            continue;
        }
        
        for(int k = 0; k < W; k++)
        {
            if(columns[k] == 0)
            {
                continue;
            }
            
            cout << grid[i][k];
        }
        
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	for (char &d : s) {
		if (d == 'a') {
			a++;
		}
		if (d == 'b') {
			b++;
		}
		if (d == 'c') {
			c++;
		}
	}
	cout << (max({a, b, c}) - min({a, b, c}) <= 1 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 512