akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = list(map(int,input().split()))

from itertools import accumulate

tot=sum(l)
ans=2020202020*100000
for i in list(accumulate(l)):
    if i <= tot//2:
        ans=min(ans, abs(tot-(i*2)))

for i in list(accumulate(l[::-1])):
    if i <= tot//2:
        ans=min(ans, abs(tot-(i*2)))

print(ans)

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

int main(){
    long long n;
    cin >> n;
    int mi=int(to_string(n).size());
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            mi = min(max(int(to_string(i).size()), int(to_string(n/i).size())),mi);
        }
    }
    cout << mi << '\n';
}


Measured memory_bytes: 3688
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int P;
int C[6];
const int coin[6] = {1, 5, 10, 50, 100, 500};

int main(void) {
    while (1) {
        cin >> P >> C[0] >> C[1] >> C[2] >> C[3] >> C[4] >> C[5];
        if (P == 0) break;
        int ret = INF;
        for (int value = P; value <= P + 500; value++) {
            int num1 = 0; // 支払う硬貨の枚数
            int tmp = value;
            for (int i = 5; i >= 0; i--) {
                num1 += min(tmp/coin[i], C[i]);
                tmp -= min(tmp/coin[i], C[i]) * coin[i];
            }
            int num2 = 0; // おつりの枚数
            tmp = value - P;
            for (int i = 5; i >= 0; i--) {
                num2 += tmp/coin[i];
                tmp -= (tmp/coin[i]) * coin[i];
            }
            ret = min(ret, num1+num2);
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(110));
    rep(i,2) rep(j,n) cin >> a.at(i)[j];
    // rep(i,2){
    //     rep(j,n) cout << a.at(i)[j] << ' ';
    //     cout << endl;
    // }
    int sum_0=0,sum_1=0;
    int ame=0;
    int ame_max=0;
    rep(p,n){
        sum_0 = 0;
        sum_1 = 0;
        for(int i=0;i<p+1;++i){
            sum_0 += a.at(0)[i];
        }
        for(int j=p;j<n;++j){
            sum_1 += a.at(1)[j];
        }
        ame = sum_0 + sum_1;
        if(ame_max<ame) ame_max = ame;
    }
    cout<<ame_max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>
#include <cmath>
#define V_MAX 100001

int main(){
  int n;
  cin >> n;
  
  vector<int> v0(n/2), v1(n/2);
  for(int i = 0; i < n/2; i++)
    cin >> v0[i] >> v1[i];
  
  vector<pair<int, int>> pair0(V_MAX), pair1(V_MAX);
  for(int i = 0; i < n/2; i++){
    pair0[v0[i]].first--;
    pair0[v0[i]].second = v0[i];
    pair1[v1[i]].first--;
    pair1[v1[i]].second = v1[i];
  }
  
  sort(pair0.begin(), pair0.end());
  sort(pair1.begin(), pair1.end());
  if(pair0[0].second == pair1[0].second){
    //reverse plus minus
    if(pair0[0].first + pair1[1].first < \
       pair1[0].first + pair0[1].first)
      cout << n + (pair0[0].first + pair1[1].first) << endl;
    else
      cout << n + (pair1[0].first + pair0[1].first) << endl;
  }
  else
    cout << n + (pair0[0].first + pair1[0].first) << endl;
  

}

Measured memory_bytes: 2176
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
#include <queue>
using namespace std;

struct state { int y, x; };
static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
        int h, w;
        scanf("%d %d", &h, &w);
        vector<string> s(h);
        int white = 0;
        for (int i = 0; i < h; i ++) {
                cin >> s[i];
                for (int j = 0; j < w; j ++) {
                        white += s[i][j] == '.';
                }
        }
        int sy = 0, sx = 0;
        vector<vector<int>> used(h, vector<int> (w, -1));
        queue<state> q;
        q.push({sy, sx});
        used[sy][sx] = 0;
        while (!q.empty()) {
                state p = q.front(); q.pop();
                for (int d = 0; d < 4; d ++) {
                        int xx = p.x + dx[d], yy = p.y + dy[d];
                        if (xx < 0 || xx >= w || yy < 0 || yy >= h) continue;
                        if (used[yy][xx] != -1 || s[yy][xx] == '#') continue;
                        used[yy][xx] = used[p.y][p.x] + 1;
                        q.push({yy, xx});
                }
        }
        int len = used[h - 1][w - 1] + 1;
        if (len == 0) {
                puts("-1");
                return 0;
        }
        printf("%d\n", white - len);
        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for(vector<int> &c : a) {
    for(int &d : c) {
      cin >> d;
    }
  }
  vector<vector<bool>> atob(3, vector<bool>(3, 0));
  
  int n, b; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> b;
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if(a.at(j).at(k) == b) {
          atob.at(j).at(k) = 1;
        }
      }
    }
  }
  if(atob.at(0).at(0) && atob.at(0).at(1) && atob.at(0).at(2)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(1).at(0) && atob.at(1).at(1) && atob.at(1).at(2)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(2).at(0) && atob.at(2).at(1) && atob.at(2).at(2)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(0).at(0) && atob.at(1).at(0) && atob.at(2).at(0)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(0).at(1) && atob.at(1).at(1) && atob.at(2).at(1)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(0).at(2) && atob.at(1).at(2) && atob.at(2).at(2)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(0).at(0) && atob.at(1).at(1) && atob.at(2).at(2)) {
    cout << "Yes" << endl;
  }
  else if(atob.at(0).at(2) && atob.at(1).at(1) && atob.at(2).at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
from sys import stdin
 
N = int(input())
A = sorted(int(x) for x in input().split())
max_num = A[-1] + 1
count = [0] * max_num

for i in A:
    if count[i] != 0:
        count[i] = 2
        continue
    else:
        for j in range(i, max_num, i):
            count[j] += 1

sum_num = sum(count[i] == 1 for i in A)
print(sum_num)


Measured memory_bytes: 32180
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();//小さい
        long b = sc.nextLong();//大きい

        if (a%2 == b%2) System.out.println((b-a)/2);
        else
        {
            System.out.println(Math.min((a-1),n-b) + 1 + ((b-a-1)/2));
        }
        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! iから始まる文字列とjから始まる文字列の部分文字列が最長
ll dp[5005][5005];

int main()
{
    ll N;
    string S;
    cin >> N >> S;
    memset(dp, 0, sizeof(dp));
    for (int i = N - 1; i >= 0; --i)
    {
        for (int j = i - 1; j >= 0; --j)
        {
            if (S[i] != S[j])
                continue;
            dp[i][j] = 1;
            if (i + 1 < N && j + 1 < N && S[i + 1] == S[j + 1])
                dp[i][j] += std::min(dp[i + 1][j + 1], (ll)(i - j - 1));
        }
    }

    ll max = 0;
    REP(i, N)
    {
        REP(j, N)
        {
            max = std::max(max, dp[i][j]);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 196096
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

char[8][8] s;
void bom(int x,int y){
    s[y][x] = '0';
    for(int dx=-3;dx<=3;dx++){
	int nx = x + dx;
	if(0<=nx&&nx<8)
	    if(s[y][nx]=='1'){
		bom(nx,y);
	    }
    }
    for(int dy=-3;dy<=3;dy++){
	int ny = y + dy;
	if(0<=ny&&ny<8)
	    if(s[ny][x]=='1'){
		bom(x,ny);
	    }
    }
}

void main(){

    int n = readln().chomp().to!int;
    for(int i=0;i<n;i++){
	readln();
	for(int j=0;j<8;j++){
	    string ss = readln().chomp();
	    for(int k=0;k<8;k++) s[j][k] = ss[k];
	}
	int x = readln().chomp().to!int;
	int y = readln().chomp().to!int;
	bom(x-1,y-1);
	writeln("Data ",i+1,":");
	for(int k=0;k<8;k++){
	    for(int l=0;l<8;l++){
		write(s[k][l]);
	    }
	    writeln();
	}
    }
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	int n;
	cin >> n;
	vi a(n + 1);
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
	V<vi> dp(n + 1, vi(n + 1));
	for(int r = 1; r <= n; r++) {
		for(int l = r - 1; l >= 1; l--) {
			dp[l][r] = 1e18;
			for(int m = l; m < r; m++) {
				dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r] + a[r] - a[l-1]);
			}
		}
	}
	cout << dp[1][n] << endl;
	
}



Measured memory_bytes: 4500
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		out.println((char)(s[0]+1));
	}
}


Measured memory_bytes: 23380
#include<cstdio>
#include<algorithm>
using namespace std;

long long Abs(long long x) {
	if(x<0)return -x;
	else return x;
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	long long x,y;
	scanf("%lld %lld\n",&x,&y);
	puts(Abs(x-y)>=2?"Alice":"Brown");
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
l = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

queue = [0]
isSearched = [False]*(n+1)
isSearched[0] = True
cnt_l = [0]*(n+1)
pre = [-1]*n
def bfs():
    while(queue):
        now = queue.pop(0)
        
        for x in l[now]:
            if(isSearched[x]):
                continue
            cnt_l[x] = cnt_l[now]+1
            pre[x] = now+1
            isSearched[x] = True
            queue.append(x)
bfs()

print('Yes')
for i in range(1,n):
    print(pre[i])

Measured memory_bytes: 38180
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int x,curr,sum;

int main(){
    scanf("%d",&x);
    while(sum<x){
        curr++;
        sum+=curr;
    }
    printf("%d\n",curr);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int count=0;
  for (int i=1;i<=N;i++){
    int ans=0;
    if(i%2==1){
      for(int j=1;j<=i;j++) 
        if(i%j==0) ans++;
    }
     if(ans==8) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
<?php
while($n = trim(fgets(STDIN))) {
	$pattern = step($n);
	echo ceil($pattern / 3650) . "\n";
}

function step($n) {
	static $_cache = array(
		1 => 1,
		2 => 2,
		3 => 4,
	);
	if (isset($_cache[$n])) {
		return $_cache[$n];
	}
	if ($n == 1) {
		return 1;
	}
	if ($n == 2) {
		return 2;
	}
	if ($n == 3) {
		return 4;
	}
	return $_cache[$n] = step($n-1) + step($n-2) + step($n-3);
}

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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int a, b;
    cin >> a >> b;
    if(a<=b){
        for(int i=0; i<b; i++){
            cout << a;
        }
    }else{
        for(int i=0; i<a; i++){
            cout << b;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	int b[n+1];
	int sum=0;
	cin>>a[1];
	sum=a[1];
	for(int i=2;i<=n;i++){
		cin>>a[i];
		sum=sum^a[i];
	}
	for(int i=1;i<=n;i++){
		b[i]=sum^a[i];
		cout<<b[i]<<' ';
	}
	return 0;
} 

Measured memory_bytes: 5056
S = input()
f = int(S[:2])
s = int(S[2:])
if 1 <= f <= 12:
  if 1 <= s <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 1 <= s <= 12:
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 100;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, A[MAX_N];

void solve() {
  int mn = INFI, mx = -1;
  for (int i = 0; i < N; i++) {
    mn = min(mn, A[i]);
    mx = max(mx, A[i]);
  }

  cout << mx - mn << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        long a = Integer.parseInt(sc.next());
        long b = Integer.parseInt(sc.next());
        long c = Integer.parseInt(sc.next());
        
        long x = a*b*4;
        long y = (c-a-b);
        
        System.out.println((y>0 && x<y*y)?"Yes":"No");
    }
}


Measured memory_bytes: 23892
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
A = [int(input()) for _ in range(N)]
sort_a = sorted(A, reverse=True)

for a in A:
    print(sort_a[0] if a != sort_a[0] else sort_a[1])

# max_a = max(A)
# max_idx = [i for i, x in enumerate(A) if x == max_a]
#
# if len(max_idx) > 1:
#     for i in range(N):
#         print(max_a)
#     exit()
# else:
#     for i in max_idx:
#         A[i] = NIL
#     second_max = max(A)
#
#     for i in range(N):
#         if i in max_idx:
#             print(second_max)
#         else:
#             print(max_a)


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N >> M;
  if (N < 10 && M < 10) {
    cout << N * M << endl;
  } else {
    cout << -1 << endl;
  };
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
    a[i]--;
  }
  bool tmp=false;
  int res=0;
  rep(i, n) {
    if (a[i]==res) {
      res++;
      tmp=true;
    }
  }
  if (tmp) cout<<n-res<<endl;
  else cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

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

long lcm(long a, long b)
{
	return (a / gcd(a, b) * b);
}

int main(void)
{
	long a, b;
	
	while (scanf("%ld %ld", &a, &b) != EOF)
		printf("%ld %ld\n", gcd(a, b), lcm(a, b));
	
	return (0);
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define DUP(x, y) (((x) + (y) - 1) / (y))
#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")

using ll = std::int64_t;
using vint = std::vector<int>;
using vll = std::vector<ll>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum =0;
for i in range(len(a)):
    sum += b[a[i]-1]
    if i +1 < n and a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)

Measured memory_bytes: 3064
m,d = map(int,input().split())
ans = 0
for M in range(1,m+1):
    for D in range(1,d+1):
        D = '0' + str(D)
        if int(D[-1]) * int(D[-2]) == M and int(D[-2]) >= 2 and int(D[-1]) >= 2:
            ans-=-1


print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	char a[4], s = '\0', t = '\0';
	gets(a);
	s = a[0];
	for (int i = 1; i < 4; i++){
		if (a[i] != s && t == '\0')
			t = a[i];
		else if (a[i] != s && a[i] != t){
			printf("No");
			return 0;
		}
	}
	if (t == '\0'){
		printf("No");
	}else{
		printf("Yes");
	}
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
char a[105];
int main(){
	scanf("%s",a);
	for(int i=0;i<=strlen(a)-1;i++){
		if(a[i]=='C')
			for(int j=strlen(a)-1;j>i;j--)
				if(a[j]=='F'){
					printf("Yes");
					return 0;
				}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable

object Main{
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, k) = in.readLine().split("\\s+").map(_.toInt)

    val snk = mutable.HashSet.empty[Int]
    for(_ <- 0 until k) {
      val _ = in.readLine()
      val as = in.readLine().split("\\s+").map(_.toInt)
      snk.addAll(as)
    }

    out.println(n - snk.size)

    out.flush()
  }
}


Measured memory_bytes: 55108
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<list>
using namespace std;

int a[100005];
int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
		{
			scanf("%d", &a[i]);
		}
	int result = 0;
	int j = 0;
	for (int i = 0; i < N; i++, j++) {
		if (j == K) {
			result++;
			j = 1;
		}
	}
	if (j > 1) result++;
	printf("%d", result);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = 0;
    int y = 0;
    if(a>b){
      x = a;
      y = b;
    }else{
      x = b;
      y = a;
    }
    if(x-y>=2){
      System.out.println(2*x-1);
    }else{
      System.out.println(x+y);
    }
  }
}


Measured memory_bytes: 21716
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    a,b= map(int, sys.stdin.readline().split(' '))
    if a>=10:
        print(b)
    else:
        print(b+100*(10-a))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=2005;
int n;
int a[N];
bitset <N*N> S;
int main(){
	n=read();
	S.reset();
	S[0]=1;
	int sum=0;
	For(i,1,n){
		a[i]=read();
		sum+=a[i];
		S|=S<<a[i];
	}
	For(i,1,sum)
		if (S[i]&&i*2>=sum){
			printf("%d\n",i);
			break;
		}
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;
const ll MOD = 998244353;

bool f[maxn];

int main() {
	int N; string s;
	cin >> N;
	cin >> s;

	ll ans = 0;

	ll all = 0;
	{
		ll x = 0;
		rep(i, s.size()) {
			f[i] = s[i] - '0';
			x = (x * 2 + f[i]) % MOD;
		}
		all = (x + 1) * (N * 2) % MOD;
	}

	//dump(all);

	int u = 0;
	{
		int n = N;
		while (n % 2 == 0) {
			n /= 2;
			++u;
		}
		u = (1 << (u + 1));
	}

	set<int> st;

	vector<ll> dv;
	vector<ll> way;

	for (int d = 1; d < N; ++d) {
		if (d % u != 0) continue;

		int gg = __gcd(d, N);
		if (st.count(gg)) continue;
		st.insert(gg);

		ll num = 0;

		rep(i, gg) {
			num = (num * 2 + f[i]) % MOD;
		}

		bool ok = 1;
		vi t(N);
		rep(i, gg) t[i] = f[i];
		for (int i = gg; i < N; ++i) {
			t[i] = t[i - gg] ^ 1;
		}

		rep(i, N) {
			if (t[i] == f[i]) {
				continue;
			}
			if (t[i] && !f[i]) {
				ok = 0;
			}
			break;
		}
		if (ok) {
			num++;
		}

		rep(i, dv.size()) {
			if (gg % dv[i] == 0) {
				num -= way[i];
				if (num < 0) num += MOD;
			}
		}

		dv.pb(gg);
		way.pb(num);

		ll dec = num * (N * 2 - d) % MOD;
		all -= dec;
		if (all < 0) all += MOD;

	}

	cout << all << endl;

	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	y=n/c;
	if(0!=n%a){
		x=x+1;
	}
	if(0!=n%c){
		y=y+1;
	}
	x=x*b;
	y=y*d;
	if(x<=y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}



Measured memory_bytes: 2096
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char str[12];
    cin >> a >> b >> str;
    for(int i=0;i<a;i++){
        if(!('0'<=str[i]&&str[i]<='9')){
            cout << "No" << endl;
            return 0;
        }
    }
    if(str[a]!='-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i=a+1;i<=a+b;i++){
        if(!('0'<=str[i]&&str[i]<='9')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

typedef unsigned long long ll;
ll B=100000007ULL;
ll b[300002];
ll h[300002];
set<ll> s;
int main(){
    int n,m;
    string str,q;
    cin>>n>>m>>str;
    
    b[0]=1;
    h[0]=str[0];
    for(int i=1;i<str.length();i++){
        b[i]=b[i-1]*B;
        h[i]=h[i-1]*B+str[i];
    }
    
    int l=0,r=0;
    for(int i=0;i<m;i++){
        cin>>q;
        if(q=="L++"){
            l++;
        }
        else if(q=="L--"){
            l--;
        }
        else if(q=="R++"){
            r++;
        }
        else if(q=="R--"){
            r--;
        }
        ll lr=b[r-l+1]*h[l-1]-h[r];
//        cout<<"b[r-l+1]: "<<b[r-l+1]<<"      h[l-1]: "<<h[l-1]<<"    h[r]: "<<h[r]<<endl;
//        cout<<"l: "<<l<<"    r: "<<r<<"    lr: "<<lr<<endl<<endl;;
        s.insert(lr);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 20220
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main() {
  int n;
  char s[10010];
  cin>>n;
  cin>>s;

  int len = strlen(s);
  for(int i = 0; i < len; i++){
    int x = s[i] - 'A';
    x = (x + n)%26;
    putchar('A' + x);
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int a[200][3];
    int c[100][3];
    int res[200];
    scanf("%d",&n);
    fill(c[0],c[0]+300,0);
    fill(res,res+200,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
            c[a[i][j]-1][j]++;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(c[a[i][j]-1][j]==1) res[i]+=a[i][j];
        }
        printf("%d\n",res[i]);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll k,s;
ll ans;
int main(void){
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(0<=s-x-y&&s-x-y<=k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3564
//abc154_d.cpp
//Sat Mar 28 17:50:22 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	double table[1001];
	double sum[1001];
	sum[0] = 0.0;
	for (int i=1;i<=1000;i++){
		sum[i] = sum[i-1]+i;
		table[i] = sum[i]/i;
	}

	double dice[n];
	for (int i=0;i<n;i++){
		int p;
		cin >> p;
		dice[i] = table[p];
	}

	double ans = 0;
	double tmp = 0;
	for (int i=0;i<n;i++){
		if (i<k){
			ans += dice[i];
			tmp += dice[i];
		}else {
			tmp -= dice[i-k];
			tmp += dice[i];
			ans = max(tmp,ans);
		}
	}
	printf("%.8f\n",ans);
}

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define inf 1<<30

struct edge { int to,cap,rev; };

vector<edge> g[203];
bool used[203];

void add_edge(int from,int to,int cap){
  g[from].pb((edge){to,cap,g[to].size()});
  g[to].pb((edge){from,0,g[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v == t) return f;
  used[v] = true;
  rep(i,g[v].size()){
    edge &e = g[v][i];
    if(!used[e.to] && e.cap>0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	g[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,inf);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  int n; cin >> n;
  vi a(n),b(n),c(n),d(n);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,n) cin >> c[i] >> d[i];

  rep(i,n) add_edge(2*n,i,1);
  rep(i,n) add_edge(n+i,2*n+1,1);

  rep(i,n) rep(j,n){
    if(a[i] < c[j] and b[i] < d[j]) add_edge(i,n+j,1);
  }

  cout << max_flow(2*n,2*n+1) << endl;
}


Measured memory_bytes: 384
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  string s; cin>>s;
  rep(i,3){
    if(s[i]-'0'==7){
      cout<<"Yes"; return;
    }
  }
  cout<<"No";
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll val;
        cin>>val;
        a.push_back(2*val);
    }
    ll qw = a[0];
    vector<ll> ans;
    for(int i=1;i<n;i++){
        qw = a[i]-qw;
    }
    ans.push_back(qw/2);
    for(int i=1;i<n-1;i++){
        ans.push_back(a[i-1]-ans[i-1]);
    }
    ans.push_back(a[n-1]-ans[0]);
    for(auto q:ans){
        cout<<q<<" ";
    }
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 3060
import Control.Monad (replicateM)
import Data.List (sortBy)
import Data.Ord (comparing)

data Direction = Parallel | Orthogonal deriving (Enum, Show)
type Edge a = (a, Direction)

minCost :: Integral a => a -> a -> [Edge a] -> [Edge a] -> a
minCost w h ps qs = f (w + 1) (h + 1) 0 edges
    where
        edges = sortBy (comparing fst) $ ps ++ qs
        f _ _ r [] = r
        f a b r (e : es) = case e of
            (x, Parallel) -> f (a - 1) b (r + b * x) es
            (x, Orthogonal) -> f a (b - 1) (r + a * x) es

main :: IO ()
main = do
    [w, h] <- fmap read . words <$> getLine
    ps <- fmap ((\x -> (x, Parallel)) . read) <$> replicateM w getLine
    qs <- fmap ((\x -> (x, Orthogonal)) . read) <$> replicateM h getLine
    print $ minCost w h ps qs


Measured memory_bytes: 124924
INF = 10 ** 10
q=int(input())
M=100000

def erato(n):
    primes = [0] * 2 + [1] * (n - 1)
    for i in range(4,n + 1,2):
        primes[i] = 0
    for i in range(3,n + 1,2):
        if i * i > n:
            break
        if primes[i]:
            for j in range(i * i,n + 1,i):
                primes[j] = 0

    ret = []
    for i in range(2,n + 1):
        if primes[i]:
            ret.append(i)
    return ret

prime=erato(M)
cnt=[0]*M
for i in range(len(prime)):
  cnt[prime[i]]+=0.6
  if 2*prime[i]-1<M:
    cnt[2*prime[i]-1]+=0.6
 
for i in range(1,M):
  if cnt[i]>1:
    cnt[i]=cnt[i-1]//1+1
  else:
    cnt[i]=cnt[i-1]//1
    
#print(cnt)
for i in range(q):
  l,r=map(int,input().split())
  print(cnt[r]-cnt[l-1])

Measured memory_bytes: 6700
import sys
sys.setrecursionlimit(int(1e9))

class UnionFind():
    def __init__(self, n):
        self.p = list(range(n))
    
    def find(self, x):
        if self.p[x] == x:  return x
        self.p[x] = self.find(self.p[x])
        return self.p[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:  self.p[x] = y

N,M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a,b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(1, N):
    if uf.find(0) != uf.find(i):
        uf.unite(0, i)
        ans += 1

print(ans)


Measured memory_bytes: 17828
#include <iostream>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k;
  cin>>a>>b;
  int f=0;
  for(int i=a;i<=b;i++)
  {
     if(i%k==0)
     {
       f=1;
       break;
     }
  }
  if(f==0)
    cout<<"NG";
  else
    cout<<"OK";
  return 0;
}

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

int main() {
  long long N,K;
  cin >> N >> K;
  
  long long ans=N%K;
  if(ans>=(K+1)/2)
    ans=K-ans;
  
  cout << ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll> a;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        a.push(tmp);
    }
    rep(i,m){
        ll v = a.top(); a.pop();
        v /= 2;
        a.push(v);
    }
    ll ans=0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N=3;
  vector<int> vec(N);
  REP(i,0,3){
    cin>>vec[i];
  }
  sort(all(vec));
  int ans=0;
  if((vec[0]%2!=vec[1]%2)&&(vec[1]%2!=vec[2]%2)){
    vec[2]++;vec[0]++;
    ans++;
  }
  else if((vec[1]%2!=vec[2]%2)&&(vec[2]%2!=vec[0]%2)){
    vec[0]++;vec[1]++;
    ans++;
  }  
  else if((vec[2]%2!=vec[0]%2)&&(vec[0]%2!=vec[1]%2)){
    vec[1]++;vec[2]++;
    ans++;
  }
  ans+=(vec[2]-vec[0])/2+(vec[2]-vec[1])/2;
  print(ans)
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
const int MAXN = 3e3 + 5;
const int MAXS = 3e3 + 5;
const int mod = 998244353;

int a[MAXN], f[MAXN][MAXS];

int main(void)
{
	int n,s;
	scanf("%d%d",&n,&s);
	for(int i=1; i<=n; ++i)
		scanf("%d",&a[i]);
	
	f[0][0] = 1;
	for(int i=1; i<=n; ++i)
		for(int j=0; j<=s; ++j)
		{
			f[i][j] = f[i-1][j]*2 %mod;
			if(j>=a[i])
				f[i][j] = (f[i][j] + f[i-1][j-a[i]]) %mod;
		}
	printf("%d",f[n][s]);
	return 0;
}

Measured memory_bytes: 39048
import java.util.*;

public class Main {

    static int[][] m = new int[12][12];

    static void dfs(int i, int j){
        if(0 <= i && i < 12 && 0 <= j && j < 12){
            if(m[i][j] == 1){
                m[i][j] = -1;
                dfs(i + 1, j);
                dfs(i - 1, j);
                dfs(i, j + 1);
                dfs(i, j - 1);
            }
        }
    }

    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       while(sc.hasNext()){
           for(int i = 0; i < 12; i++){
               String s = sc.next();
               for(int j = 0; j < 12; j++){
                   String c = s.substring(j, j + 1);
                   if(c.equals("1")) m[i][j] = 1;
                   else m[i][j] = 0;
               }
           }
           int cnt = 0;
           for(int i = 0; i < 12; i++){
               for(int j = 0; j < 12; j++){
                   if(m[i][j] == 1){
                       cnt++;
                       dfs(i, j);
                   }
               }
           }
           System.out.println(cnt);
       }
   }
}


Measured memory_bytes: 26184
#include <iostream>
#include <string>
#include <sstream>

using namespace std;
int main()
{
	string str;
	getline(cin, str);

	int size = str.size();

	for (int i = 0; i < size; i++) {
		string str1;
		str1 = str.substr(i, 1);
		if (str1 == "9") cout << "1";
		else if (str1 == "1") cout << "9";
		else cout << str1;
	}
	cout << endl;
	return 0;


}

Measured memory_bytes: 256
init=int(input())

ans=[]
for K in range(2,int(init**0.5)+1):
    N=init
    while N%K==0:
        N/=K
    if N-(N//K)*K==1:
        ans.append(K)
        
tgt=init-1
cand=[]
for i in range(1,int(init**0.5)+1):
    if tgt%i==0:
        cand.append(i)
        if i!=tgt//i:
            cand.append(tgt//i)
ans=list(set(ans+cand))
print(len(ans))

    

Measured memory_bytes: 3188
#define boost
#ifdef boost
	#pragma GCC target ("avx2")
	#pragma GCC optimization ("O3")
	#pragma GCC optimization ("unroll-loops")
#endif
#include<bits/stdc++.h>
#define int long long
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
#define __ read()
using namespace std;
const int maxn(2e5+5);
void rda(int *a,int n){for(int i=1;i<=n;++i)a[i]=__;}
void print(int *a,int n){for(int i=1;i<=n;++i)printf("%lld ",a[i]);puts("");}
int n,a[maxn];
signed main()
{
	n=__;rda(a,n);int ans=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans;
}




Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
#define N 200
const ll inf=1e9+7;
ll n,ans=inf,k;
ll ketasu(ll x){
	ll ans=0;
	while(x){
		ans++;
		x/=10;
	}
	return ans;
}

int main(){
	cin>>n;
	FOR(i,1,sqrt(n)+1){
		k=n/i;
		if(n%i==0){
			k=max(k,i);
			ans=min(ans,ketasu(k));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    vector<int> P(2020, 0);

    int N;
    cin >> N;
    vector<int> X(N + 1);
    for (int i = 1; i <= N; i++)
    {
        cin >> X[i];
        P[X[i]] = i;
    }

    int M;
    cin >> M;
    for (int j = 0; j < M; j++)
    {
        int A;
        cin >> A;
        int p = X[A];
        if (p < 2019 && P[p + 1] == 0)
        {
            P[p] = 0;
            P[p + 1] = A;
            X[A] += 1;
        }
    }

    for (int i = 1; i <= N; i++)
    {
        cout << X[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

ll dp[55][55][2600];

int main(void)
{
    int N,A;
    cin >> N >> A;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    SORT(x);

    // vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(N+1, vector<ll>(N*x.back()+1)));

    dp[0][0][0] = 1;
    REP(k, N){
       REP(s, k+1){
            REP(t, N*A+1){
                if(dp[k][s][t]){
                    dp[k+1][s+1][t+x[k]] += dp[k][s][t];
                    dp[k+1][s][t] += dp[k][s][t];
                }
            }
       } 
    }

    ll ans = 0;
    Rep(k, N, N+1){
       Rep(s, 1, k+1){
           ans += dp[k][s][A*s];
       } 
    }
    pr(ans);
}

Measured memory_bytes: 55552
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end

  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end

  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, v) = InputLine.to_ia
  (b, w) = InputLine.to_ia
  t = InputLine.to_i

  p1 = a + t * v
  q1 = b + t * w
  p2 = a - t * v
  q2 = b - t * w

  f1 = (a < b) && (p1 >= q1)
  f2 = (a > b) && (p2 <= q2)
  puts ((f1 || f2) ? 'YES' : 'NO')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14296
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n;
  cin >> n;
  n--;
  string ans = "";
  while(n >= 0) {
    ll a = n % 26;
    ans += 'a' + a;
    if(n == 0) break;
    n -= a;
    n /= 26;
    n--;
  }
  reverse(ALL(ans));
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3648
import sys
from collections import defaultdict, deque


def solve():
    N, M = map(int, sys.stdin.readline().split())
    m = map(int, sys.stdin.read().split())
    G = defaultdict(list)
    in_edge = [0] * N
    for x, y in zip(m, m):
        G[y-1].append(x-1)
        in_edge[x-1] += 1

    dp = [0] * N
    q = deque(i for i, x in enumerate(in_edge) if not x)
    q_enqueue = q.append
    q_dequeue = q.popleft
    while(q):
        x = q_dequeue()
        for j in G[x]:
            in_edge[j] -= 1
            if not in_edge[j]:
                q_enqueue(j)
                if dp[j] < dp[x] + 1:
                    dp[j] = dp[x] + 1
    return max(dp)


if __name__ == "__main__":
    answer = solve()
    print(answer)


Measured memory_bytes: 41176
import numpy as np

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
  
n=int(input())
data=list(map(int,input().split()))

tmp=data[0]
for i in range(n-1):
  tmp=gcd(tmp,data[i+1])
  
print(tmp)

Measured memory_bytes: 27828
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  for (int i = 0; i < S.size() - 1; ++i) {
    if (S[i] == S[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,d,t;cin>>N;deque<int>D;
  for(int i=0;i<N;i++){cin>>d;D.push_back(d);}
  cin>>M;deque<int>T;
  for(int i=0;i<M;i++){cin>>t;T.push_back(t);}
  sort(D.begin(),D.end());
  sort(T.begin(),T.end());
  while(!T.empty()){
    while(T.front()>D.front()){
      D.pop_front();
      if(D.empty())break;
    }
    if(D.empty()||D.front()!=T.front())break;
    T.pop_front();
    D.pop_front();
  }
  if(T.empty())cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 1920
#include <iomanip>
#include <iostream>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int X, N;
  cin >> X >> N;
  unordered_set<int> P;
  rep(i, N) {
    int p;
    cin >> p;
    P.emplace(p);
  }

  rep(i, 1000) {
    int X1 = X - i;
    if (P.count(X1) == 0) {
      cout << X1 << endl;
      return 0;
    }

    int X2 = X + i;
    if (P.count(X2) == 0) {
      cout << X2 << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3648