akhauriyash/Code-Regression huggingface dataset:
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
using namespace std;
int main(){
  int N,A;
  cin>>N>>A;
  int ans = N*N-A;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
 string s;
 cin >> s;
 cout << 700 + ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o')) * 100 << "\n";

}

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

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

    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    sort(a,a + N, greater<int>());

    int alice = 0, bob = 0;

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

    int ans = alice - bob;
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main (String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        sc.nextLine();

        int s[] = new int[N];
        int t[] = new int[N];
        int c[] = new int[N];
        for (int i = 0; i < N; i++) {
            s[i] = sc.nextInt();
            t[i] = sc.nextInt();
            c[i] = sc.nextInt();
            sc.nextLine();
        }
        sc.close();

        int channelTotalTable[] = new int[100001];
        for(int i = 0; i < 100001; i++) {
            channelTotalTable[i] = 0;
        }

        int channelTable[][] = new int[C][100001]; 
        for (int i = 0; i < C; i++) {
            for (int j = 0; j < 100001; j++) {
                channelTable[i][j] = 0;
            }
            for (int k = 0; k < N; k++) {
                if (c[k] == i + 1) {
                    if (s[k] == 1) {
                        channelTable[i][0] = 1;
                    } else if (channelTable[i][s[k] - 1] == -1) {
                        channelTable[i][s[k] - 1] = 0;
                    } else {
                        channelTable[i][s[k] - 1] += 1;
                    }
                    channelTable[i][t[k]] -= 1;
                }
            }
            for (int l = 1; l < 100001; l++) {
                channelTable[i][l] += channelTable[i][l - 1];
            }
            for (int m = 0; m < 100001; m++) {
                if (channelTable[i][m] > 0) {
                    channelTotalTable[m]++;
                }
            }
        }

        int max = 0;
        for (int i = 0; i < 100000; i++) {
            if (max < channelTotalTable[i]) {
                max = channelTotalTable[i];
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 159252
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

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

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

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(long long int &x){int k;x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=x*10+k-48;}}

long long int N, M, d[364364], p[364364], a[364364], i, m;
priority_queue<long long int, vector<long long int>, greater<long long>> q;

int main(){
    read(N);
    M = N + (N << 1);
    for(; i < M; ++i){
        read(a[i]);
        q.push(a[i]);
        m += a[i];
        if(i == N - 1){
            d[0] = m;
        }
        if(N <= i && i <= N * 2){
            m -= q.top();
            q.pop();
            d[i - N + 1] = m;
        }
    }
    q = priority_queue<long long int, vector<long long int>, greater<long long>>();
    m = 0;
    for(i = M; --i >= 0;){
        q.push(-a[i]);
        m += a[i];
        if(i == N * 2){
            p[i - N] = m;
        }
        if((N <= i) && (i < N * 2)){
            m += q.top();
            q.pop();
            p[i - N] = m;
        }
    }
    //m = -922337203685477580LL;
    m = *d - *p;
    for(i ^= i; i <= N; ++i){
        m = max(m, d[i] - p[i]);
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 12020
from collections import deque

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = tuple(map(lambda x: int(x)-1, input().split()))
  G[a].append(b)
  G[b].append(a)

color = [0]*N
color[0] = 1
color[N-1] = -1
q = deque([])
q.append(0)
q.append(N-1)

while q:
  node = q.popleft()
  c = color[node]
  for to in G[node]:
    if color[to] == 0:
      color[to] = c
      q.append(to)

b = color.count(1)
w = color.count(-1)

if b > w:
  print('Fennec')
else:
  print('Snuke')

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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;
const DB PI = acos(-1);

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	Point operator / (DB k) { return Point(x / k, y / k); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
	bool operator < (const Point &a) const { int d1 = sgn(x-a.x), d2 = sgn(y-a.y); return d1 < 0 || (d1 == 0 && d2 < 0); }
};

struct Circle { Point P; DB r; };

Point Proj(Point P, Point P1, Point P2) {
	Point v = P2-P1; DB t = (P-P1)%v / (v%v);
	return P1 + t*v;
}

Point GetLineInter(Point P1, Point P2, Point Q1, Point Q2) {
	Point v = P2-P1, w = Q2-Q1; DB t = (Q1-P1)/w / (v/w);
	return P1 + t*v;
}

int Direct1(Point P, Point P1, Point P2) { return sgn((P1-P)%(P2-P)); }
int Direct2(Point P, Point P1, Point P2) { return sgn((P1-P)/(P2-P)); }

Point A, B, C;

Circle GetInnerCir(Point A, Point B, Point C) {
	Point v1 = B-A, v2 = C-A, v3 = C-B;
	/*
	printf("%.10lf %.10lf\n", v1.x, v1.y);
	printf("%.10lf\n", DB(v1));
	*/
	v1 = v1/DB(v1), v2 = v2/DB(v2), v3 = v3/DB(v3);
	//printf("%.10lf %.10lf\n", v1.x, v1.y);
	Point A0 = A+1e4*(v1+v2), B0 = B+1e4*(v3-v1), P = GetLineInter(A, A0, B, B0);
	return (Circle){P, DB(P-Proj(P, A, B))};
}

int main() {
	scanf("%lf%lf%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
	Circle X = GetInnerCir(A, B, C);
	printf("%.10lf %.10lf %.10lf\n", X.P.x, X.P.y, X.r);
	return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    bool arr[100005];
    for(int i=0;i<100005;i++)
    {
        arr[i]=false;
    }
    arr[0]=false;
    for(int i=0;i<n;i++)
    {
        arr[a[i]]=true;
    }
    for(int i=1;i<=k;i++)
    {
        if(arr[i]==true)
            continue;
        for(int j=0;j<n;j++)
        {
            if(a[j]>i)
            {
                break;
            }
            else
            {
                if(arr[i-a[j]]==false)
                {
                    arr[i]=true;
                    break;
                }
            }
        }
    }
    if(arr[k]== true)
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int W, H, N;
vector<pair<int, int> > v;
int Xmax[100000];
int main() {
	cin >> W >> H >> N;
	rep(i, 0, N){
		int num[2];
		cin >> num[0] >> num[1];
		pair<int, int> p;
		p.first = num[0];
		p.second = num[1];
		v.push_back(p);
	}
	
	rep(i, 0, N) {
		Xmax[v[i].second] = max(Xmax[v[i].second],v[i].first);
	}
	int maxpos = Xmax[H - 1];
	int oldmaxx = Xmax[H - 1];
	Xmax[H - 1] = 0;
	urep(i, H-2, 0) {
		if (maxpos < oldmaxx) {
			
			maxpos = oldmaxx;
		}
		oldmaxx = Xmax[i];
		Xmax[i] = maxpos;
	}
	int ans = 10000000;
	rep(i, 0, H) {
		ans = min(ans, Xmax[i]+i);
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}


Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;

  mint(ll x=0):x((x%mod+mod)%mod){}

  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  mint ans = 0;
  rep(k,60) {
    mint n1 = 0;
    rep(i,N) {
      if((A[i] >> k) & 1) n1+=1;
    }
    ans += n1*(mint(N)-n1)*mint(2).pow(k);
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int W, H, x, y, r;

int main(){
	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
	if (x + r <= W && y + r <= H && x - r >= 0 && y - r >=0){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


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

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

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

struct UnionFind
{
	vector<int> d;
	UnionFind(int n = 0) : d(n, -1) {}

	int find(int x)
	{
		// not visited or parent
		if (d[x] < 0)
			return x;
		return d[x] = find(d[x]); // dont really need to assign again
	}

	bool unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (x > y)
			swap(x, y);
		if (d[x] > d[y])
			swap(x, y);
		d[x] += d[y];
		d[y] = x;

		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }

	int size(int x) { return -d[find(x)]; }
};

int main()
{
	fast;
	int n, m, k;
	cin >> n >> m >> k;
	vvi fr(n), bl(n);
	UnionFind uf(n);
	FOR(m)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		fr[x].pb(y);
		fr[y].pb(x);
		uf.unite(x, y);
	}
	FOR(k)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		bl[x].pb(y);
		bl[y].pb(x);
	}
	FOR(n)
	{
		// total connected - self node - edges
		int ans = uf.size(i) - 1 - fr[i].size();
		for (auto &x : bl[i])
			if (uf.same(i, x))
				ans--;
		// printf("%d%c", ans, (i == n - 1 ? '\n' : ' '));
		cout << ans << " ";
	}
	cout << en;
	// for (auto c : uf.d)
	// {
	// 	cout << c << " ";
	// }
	// cout << en;
}

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

int main() {
   int N;
   string MOJI;
   cin >> N;
   cin >> MOJI;
   for(int i=0 ; i<MOJI.size() ; i++){
     for (int j=0 ; j<N ; j++){
       if (MOJI.at(i)=='Z')
       MOJI.at(i)='A';
       else MOJI.at(i)++;
     }
   }
   cout << MOJI << endl;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        long[] DP = new long[W+1];
        for(int j=0;j<N;j++){
            str = Console.ReadLine().Split(' ');
            int v = int.Parse(str[0]);
            int w = int.Parse(str[1]);
            for(int i=W;i>=w;i--){
                DP[i] = Math.Max(DP[i],DP[i-w]+v);
            }
        }
        sb.Append(DP[W]+"\n");
    }
}

Measured memory_bytes: 9260
#include<iostream>
#include<cstdlib> 
#include<sstream>
#include<cstdio>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=1111122;
const int M=200005;
int main()
{
    std::ios::sync_with_stdio(false);
    int n,i,j,m;
    cin>>n;
    int ans=0;
    int a[M];
    int maxx=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        maxx=max(maxx,a[i]);
        ans+=a[i];
    }
    if(maxx<ans-maxx)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 1e10
int n;
long long a,b;
long long sum=0,Min=INF;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lld %lld",&a,&b);
		sum+=a;
		if(a>b) Min=min(Min,b);
	}
	if(Min==INF)
		printf("0\n");
	else printf("%lld\n",sum-Min);
}

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

using namespace std;

int main() {

    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;

    bool flag = false;
    for(int i = a; i<=b;i++)
    {
        if(i%k == 0)
            {
                flag = true;
                break;
            }
    }

    if(flag)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
	int a,b,c,d,p;
	int x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d); 
	scanf("%d",&p); 
	
	x=a*p;

	if(p < c){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	
	if(x < y){
		printf("%d\n",x);
	}else{
		printf("%d\n",y);
	}

	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
int main(void)
{
	int i;
	int N;
	long cnt = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++)
	{
		if ((i % 3) == 0)
		{
			;
		}
		else if ((i % 5) == 0)
		{
			;
		}
		else
		{
			cnt += i;
		}
	}
	printf("%ld\n", cnt);
	return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int n, a;
	int *data;

	scanf("%d", &n);

	data = (int*)malloc(n * sizeof(int));

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

	for (int i = 0; i < n - 1; i++)
	{
		scanf("%d", &a);
		data[a - 1]++;
	}

	for (int i = 0; i < n; i++)
		printf("%d\n", data[i]);

	free(data);

	return 0;
}

Measured memory_bytes: 2244
n,k = map(int,raw_input().split())

arr = map(int,raw_input().split())

ans = float("inf")
import bisect
t = bisect.bisect_right(arr,0)
arr.insert(t,0)
for i in range(n+1):
	if i-k > -1:
		ans = min(ans, abs(arr[i-k]) + abs(arr[i]) + min(abs(arr[i-k]), abs(arr[i])))

print ans

Measured memory_bytes: 11320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N;
    	long[] T;
    	
    	long findGcd(long a, long b) {
    		if (b == 0) {
    			return a;
    		} else {
    			return findGcd(b, a % b);
    		}
    	}
    	
    	long findLcm(long a, long b) {
    		return a/findGcd(a, b)*b;
    	}
    	
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	T = in.nextLongArray(N);
        	
        	long ans = 1;
        	for (long t : T) ans = findLcm(t, ans);
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 21588
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String[] ary = sc.next().split("");
        if(!ary[A].equals("-")){
            System.out.println("No");
            System.exit(0);
        }else if(ary.length != (A + B + 1)){
            System.out.println("No");
            System.exit(0);
        }
        for(int i = 0; i < ary.length; i++){
            if(i != A){
                if(!ary[i].matches("[0-9]")){
                    System.out.println("No");
                    System.exit(0);
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 22868
import math

# N = 4
# ARR = [10, 30, 40, 20]

N, K = 5, 3
ARR = [10, 30, 40, 50, 20]

#
# N,K = 3, 1
# ARR = [10, 20, 10]

# N,K = 2, 100
# ARR = [10, 10]


N, K = map(int, input().split())
ARR = list(map(int, input().split()))

def calculate(n, k, arr):
    result = [math.inf for i in range(n)]

    result[0] = 0
    result[1] = abs(arr[1] - arr[0])


    for i in range(2, n):
        srr = []
        for j in range(i-1, i -1 - k, -1):
            srr.append(abs(arr[i] - arr[j]) + result[j])

        result[i] = min(srr)

    print(result[-1])


calculate(N, K, ARR)

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

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;

int main()
{
    int L;
    string S;
    cin >> L >> S;
    int c = 0;

    for(int i = 0; i < L; i++){
        if(S[i] == 'A'){
            i++;
            if(S[i] == 'B'){
                i++;
                if(S[i] == 'C'){
                    c++;
                }
                else
                    i-=2;
            }
            else
                i--;
        }
    }
    cout << c << endl;
    
}

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

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

    vector<int>num(100100);
    vector<int>odd(100100);
    vector<int>even(100100);
    bool flag=false;
    int a;
    for(int i=0;i<N;i++){
        cin >> num[i];
        if(N%2==1) odd[num[i]]++;
        else even[num[i]]++;

        if(N%2==1 && num[i]%2==1)flag=true;
        else if(N%2==0 && num[i]%2==0) flag=true;

        if((num[i]!=1 && odd[num[i]]>2) || odd[0]>1) flag=true;
        else if(even[num[i]]>2) flag=true;
    }
    if(flag){
        cout << 0 << endl;
        return 0;
    }
    long long ans=1;
    for(int i=0;i<N/2;i++){
        ans=(ans*2)%(1000000007);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());

      String[] lines;
      int[] max = {0, 0};
      // int[] min = {1_100_000_000, 0};
      int a,b;
      TreeMap<Integer,Integer> map = new TreeMap<>();
      for(int i=0; i<n; i++) {
        lines = in.readLine().split(" ");
        a = Integer.parseInt(lines[0]);
        b = Integer.parseInt(lines[1]);
        if(a > max[0]) {
          max[0] = a;
          max[1] = b;
        }
        // else if(a < min[0]) {
        //   min[0] = a;
        //   min[1] = b;
        // }
      }

      int ans = max[0] + max[1];

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 47204
#D

h,w = (int(x) for x in input().split())

s = []
for i in range(h):
    x = input()
    s.append(x)

y = [[0] * w for i in range(h)]
t = [[0] * w for i in range(h)]

#横
for i in range(h):
    mi = -1
    count = 0
    for j in range(w):
        this_s = s[i][j]
        
        if this_s == ".":
            count += 1
            if mi == -1:
                mi = j
        if this_s == "#" and not(mi == -1):
            y[i][mi:j] = [count] * (j-mi)
            mi = -1
            count = 0
    else:
        if not(mi == -1):
            y[i][mi:w] = [count] * (w-mi)
#print(y)
        
#縦
for j in range(w):
    mi = -1
    count = 0
    for i in range(h):
        this_s = s[i][j]
        
        if this_s == ".":
            count += 1
            if mi == -1:
                mi = i
        if this_s == "#" and not(mi == -1):
            for k in range(mi,i):
                t[k][j] = count
            mi = -1
            count = 0
    else:
        if not(mi == -1):
            #t[mi:h][j] = [count] * (h-mi)
            for k in range(mi,h):
                t[k][j] = count
#print(t)

count = 0
for i in range(h):
    for j in range(w):
        this_count = y[i][j] + t[i][j] -1
        count = max(count, this_count)
        
print(count)








Measured memory_bytes: 123352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    int sum = 0;
    for(auto x : s)
        sum += (x - '0');
    cout << ((sum % 9) ? "No\n" : "Yes\n");
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cstring>
char s[1000009], t[10009];
int main() {
	int sl = 0, tl = 0;
	while ((s[sl++] = getchar_unlocked()) != '\n'); sl--;
	while ((t[tl++] = getchar_unlocked()) != '\n'); tl--;
	unsigned long long hs = 0, ht = 0, pw = 1;
	for (int i = 0; i < tl; i++) {
		hs = (hs << 8) + hs + s[i];
		ht = (ht << 8) + ht + t[i];
		pw = (pw << 8) + pw;
	}
	for (int i = tl; i <= sl; i++) {
		if (hs == ht) printf("%d\n", i - tl);
		hs = (hs << 8) + hs + s[i] - s[i - tl] * pw;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){ 
	if(A == 1 || B ==1){
		if(A == 1 && B == 1){
			printf("Draw\n");
		}else{
			if(A > B){
				printf("Bob\n");
			}else if(A < B){
				printf("Alice\n");
			}
		}
	}else{
		if(A > B){
			printf("Alice\n");
		}else if(A < B){
			printf("Bob\n");
		}else{
			printf("Draw\n");
		}
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> A >> B;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Sieve:
    def __init__(self, n):
        self.plist = [2]  # n以下の素数のリスト
        min_prime_factor = [2, 0] * (n // 2 + 5)
        for x in range(3, n + 1, 2):
            if min_prime_factor[x] == 0:
                min_prime_factor[x] = x
                self.plist.append(x)
                if x ** 2 > n: continue
                for y in range(x ** 2, n + 5, 2 * x):
                    if min_prime_factor[y] == 0:
                        min_prime_factor[y] = x
        self.min_prime_factor = min_prime_factor

    def isprime(self, x):
        return self.min_prime_factor[x] == x

    # これが素因数分解(prime factorization)
    def pfct(self, x):
        pp, ee = [], []
        while x > 1:
            mpf = self.min_prime_factor[x]
            if pp and mpf == pp[-1]:
                ee[-1] += 1
            else:
                pp.append(mpf)
                ee.append(1)
            x //= mpf
        return ee

def main():
    sv=Sieve(10**7+5)
    n=II()
    ans=0
    for a in range(1,n+1):
        f=1
        for e in sv.pfct(a):
            f*=e+1
        ans+=a*f
    print(ans)

main()

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

int main() {
	int n; cin >> n;
	map<int, int>a;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		a[tmp-1]++;
	}

	int ans = 0;
	for (auto x : a) {
		if ((x.first + 1) < x.second)ans += x.second - (x.first+1);
		else if ((x.first + 1) > x.second) ans += x.second;
	}
	 
	cout << ans << endl;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N; string T;
  cin >> N;
  cin >> T;

  if(N%2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  REP(n,N/2) {
    if(T[n] != T[N/2 + n]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		double k = in.nextInt();
		
		double pair = Math.ceil(k / 2) * Math.ceil((k - 1) / 2);
		System.out.println((int)pair);

	}

}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void) {
    int num, i, n, next=1, cout=0;

    scanf("%d", &num);
    for (i=0; i<num; i++) {
        scanf("%d", &n);
        if (n == next) {
            next++;
        } else {
            cout++;
        }
    }

    if (next == 1) {
        printf("%d", -1);
    } else {
        printf("%d", cout);
    }
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc136/tasks/abc136_c

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	h := make([]int, N)
	for i := range h {
		fmt.Scanf("%d", &h[i])
	}

	curr := 10000000000
	for i := len(h) - 1; i >= 0; i-- {
		if h[i] > curr+1 {
			fmt.Println("No")
			return
		} else if h[i] == curr+1 {
		} else {
			curr = h[i]
		}
	}
	fmt.Println("Yes")
}


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

string solve() {
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    reverse(H.begin(), H.end());
    for (int i = 1; i < N; i++) {
        if (H[i - 1] > H[i])
            continue;
        else if (H[i - 1] == H[i])
            continue;
        else if (H[i - 1] + 1 == H[i])
            H[i]--;
        else
            return "No";
        // if (H[i - 1] == H[i] + 1) {
        //     H[i]--;
        // } else if (H[i - 1] == H[i]) {
        //     continue;
        // } else if (H[i - 1] > H[i]) {
        //     continue;
        // } else {
        //     return "No";
        // }
    }
    return "Yes";
}

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

    cin >> N;
    cout << solve() << endl;
}

Measured memory_bytes: 640
import sys
F = sys.stdin
N = int(F.readline().strip("\n"))
A = list(map(int, F.readline().strip("\n").split()))
A.sort()

pair_sum = 0
A_dict = dict()
for a in A:
    if a not in A_dict: A_dict[a] = 1
    else: A_dict[a] += 1

for i in reversed(range(1, N)):
    if A_dict[A[i]] > 0:
        nowA = A[i]
        temp_a = A[i]
        k = 0
        while temp_a > 0:
            temp_a //= 2
            k += 1
        opposite = 2 ** k - nowA
        if opposite in A_dict:
            if opposite == nowA and A_dict[opposite] > 1:
                pair_sum += 1
                A_dict[opposite] -= 2
            elif opposite != nowA and A_dict[opposite] > 0:
                pair_sum += 1
                A_dict[opposite] -= 1
                A_dict[nowA] -= 1

print(pair_sum)

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

const int M = 50;

int n, m,g[M+10][M+10];
pair<int, int> a[M+10];
bool bo[M + 10];

void dfs(int x)
{
	if (bo[x]) return;
	bo[x] = true;
	for (int i = 1;i <= n;i++)
		if (i!=x && g[x][i])
			dfs(i);
}

int main()
{
	//freopen("F:\\rush.txt", "r", stdin);
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		g[x][y] = g[y][x] = 1;
		a[i] = make_pair(x, y);
	}

	int ans = 0;
	for (int i = 1; i <= m; i++)
	{
		g[a[i].first][a[i].second] = 0;
		g[a[i].second][a[i].first] = 0;
		for (int j = 1; j <= n; j++) bo[j] = 0;
		dfs(1);
		int ok = false;
		for (int j = 1; j <= n; j++)
			if (bo[j] == 0)
				ok = 1;
		ans += ok;
		g[a[i].first][a[i].second] = 1;
		g[a[i].second][a[i].first] = 1;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main (void) {
	cin.tie(0);
	cin.sync_with_stdio(false);
	int n, m, c, count = 0;
	cin >> n >> m >> c;
	int b[m];
	for (int i = 0; i < m; i ++) 
		cin >> b[i];
	for (int i = 0; i < n; i ++) {
		int result = 0;
		for (int j = 0; j < m; j ++) {
			int tmp;
			cin >> tmp;
			result += b[j] * tmp;
		}
		if (result + c > 0) 
			count ++;
	}
	cout << count << '\n';
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
C=[]
for i in range(H):
    c=input().split()
    C.append(c)

ans=[]
for i in range(H-1):
    ans.append(C[i])
    ans.append(C[i])

ans.append(C[H-1])
ans.append(C[H-1])

for i in range(len(ans)):
    s=""
    for j in range(len(ans[i])):
        s+=s+ans[i][j]
    print(s)

Measured memory_bytes: 3064
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ull N, X, M, val, a, b, f, l, out = 0;
    vector<ull> cycle;
    cin >> N >> X >> M;
    if(N < M)
    {
        while(N > 0 && X > 0)
        {
            out += X;
            X *= X;
            X = X - ((X/M)*M);
            N--;
        }
    }
    else
    {
        val = 2*M;
        while(val > 0)
        {
            cycle.PB(X);
            X *= X;
            X = X - ((X/M)*M);
            val--;
        }
        a = 1, b = 2;
        while(cycle[a] != cycle[b])
        {
            a++;
            b += 2;
        }
        a = 0;
        while(cycle[a] != cycle[b])
        {
            a++;
            b++;
        }
        f = a;
        b = a+1;
        l = 1;
        while(cycle[a] != cycle[b])
        {
            b++;
            l++;
        }
        for(ull i = 0; i < f; i++)
        {
            out += cycle[i];
        }
        a = (N-f)/l;
        b = (N-f)%l;
        for(ull i = f; i < f+l; i++)
        {
            out += a*cycle[i];
        }
        for(ull i = f; i < f+b; i++)
        {
            out += cycle[i];
        }
    }
    cout << out << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 5320
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	
	int n,m;
	cin >> n >> m;
	vector<vector<int>> s(m);
	rep(i, m) {
		int k;
		cin >> k;
		s[i].resize(k);
		rep(j, k) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	vector<int> p(m);
	rep(i, m) {
		cin >> p[i];
	}
	int ans = 0;
	vector<int> on(n);
	rep(i0, POW(2, n)) {
		int i = i0;
		rep(j, n) {
			on[j] = i % 2;
			i /= 2;
			
		}
		rep(j, m) {
			int onC = 0;
			rep(k, s[j].size()) {
				if (on[s[j][k]] == 1) {
					onC++;
				}
			}
			if (onC % 2 != p[j]) {
				break;
			}
			if (j == m - 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 512
N = int(input())
A, B = map(int, input().split())
Pn = list(map(int, input().split()))
a = 0
b = 0
c = 0
for p in Pn:
    if p <= A:
        a += 1
    elif p <= B:
        b += 1
    else:
        c += 1
print(min([a,b,c]))


Measured memory_bytes: 3060
program ABC
    implicit none
    integer(8) a, b, c, d, LCM
    read*, a, b, c, d
    a = a - 1
    LCM = c * d / GCD(c, d)
    print"(i0)", ((b - b / c - b / d + b / LCM) - (a - a / c - a / d + a / LCM))
contains
    !GCDを求めるよ！
    recursive integer(8) function GCD (a, b) result (res)
        implicit none
        integer(8) a, b
        if (b > 0) then
            res = GCD(b, mod(a, b))
        else 
            res = a
        end if
    end function
end program ABC

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int arr[maxn];
int mx=0,n;
int b[maxn*2];
int bj[maxn];
int lowbit(int x){return x&(-x);}
void add(int x){for(int i=x;i<maxn*2;i+=lowbit(i))b[i]+=1;}
int query(int x){int ans=0;for(int i=x;i>0;i-=lowbit(i))ans+=b[i];return ans;}
bool check(int x){
    memset(b,0,sizeof(b));
    for(int i=1;i<=n;i++){
        if(arr[i]>=x)bj[i]=1;
        else bj[i]=-1;
    }
    for(int i=1;i<=n;i++)bj[i]+=bj[i-1];
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=query(bj[i]+100001);
        add(bj[i]+100001);
    }
    if(ans>=1ll*(n)*(n+1)/4)return 1;
    else return 0;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]),mx=max(mx,arr[i]);
    int l=1,r=mx,ans;
    while(l<=r){
        int mid=(l+r)/2;
        //cout<<mid<<endl;
        if(check(mid))l=mid+1,ans=mid;
        else r=mid-1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


main(){
	int a,b,k;
	cin >> a >> b >> k;
	int ans=101;
	for(int i=0;i<k;i++){
		ans--;
		while(a%ans!=0 || b%ans!=0){
			ans--;
		}
	}
	cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, z, c = 1, p = 998244353;
ll pw(ll x, ll y) {
	ll re = 1;
	for (; y > 0; y >>= 1) {
		if (y & 1) {
			re = re * x % p;
		}
		x = x * x % p;
	}
	return re;
}
int main() {
	cin >> k >> n;
	z = pw(2, n - 1);
	for (int i = 0; i < k; i++) {
		if ((k - i) % 2 == 0) {
			z = (z + p - c) % p;
		}
		c = c * (n - i) % p * pw(i + 1, p - 2) % p;
	}
	cout << z << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int cnt = 0;
    bool ok = true;
    while (ok == true) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) a[i] = a[i] / 2;
            else{
                ok = false;
                break;
            } 
        }
        if (ok == true) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    long a, b, c, d;
    cin >> a >> b >> c >> d;

    long gcd_cd = gcd(c, d);
    long lcm = c * d / gcd_cd;
    long num_b_c = b / c;
    long num_b_d = b / d;
    long b_multi = b / lcm;
    //cout << lcm << endl;
    //cout << num_b_c << " " << num_b_d << " " << b_multi << endl;

    a--;
    long num_a_c = a / c;
    long num_a_d = a / d;
    long a_multi = a / lcm;
    //cout << num_a_c << " " << num_a_d << " " << a_multi << endl;

    long ans = (b - (num_b_c + num_b_d - b_multi)) - (a - (num_a_c + num_a_d - a_multi));
    cout << ans << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

int N,M,K;
int A[222222],B[222222];

signed main(){
	cin>>N>>M>>K;
	rep(i,N){
		cin>>A[i+1];
		A[i+1]+=A[i];
	}

	rep(i,M){
		cin>>B[i+1];
		B[i+1]+=B[i];
	}


	int ans=0;
	rep(i,N+1){
		if(A[i]>K)break;
		int num=upper_bound(B,B+M+1,K-A[i])-B-1;
		chmax(ans,i+num);
	}
	cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);

    for(int i = 0; i < m; i++){
        cin >> x[i];
    }

    sort(x.begin(),x.end());
    vector<int> d(m-1);
    for(int i = 0; i < m-1; i++){
        d[i] = x[i+1] - x[i];
    }

    sort(d.begin(),d.end());

    int ans = 0;
    for(int i = 0; i < m-n; i++){
        ans += d[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s[2];
    cin >> s;
    s[0]++; 
    cout << s << "\n"; 

    
    
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.size();

    bool kaiten1 = false;
    for (int i = 0; i < n; ++i) {
        bool kaiten2 = true;
        for (int j = 0; j < n; ++j) {
            if (S[j] != T[(j + i) % n]) {
                kaiten2 = false;
                break;
            }
        }
        if (kaiten2) {
                kaiten1 = true;
                break;
        }
    }

    if (kaiten1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  int n=S.size();
  vector<vector<int>> dp(n,vector<int>(2,0));
  int x=S.at(0)-'0';
  dp.at(0).at(0)=x;
  dp.at(0).at(1)=x-1;
  for(int i=1;i<n;i++){
    x=S.at(i)-'0';
    if(x==0){
      dp.at(i).at(0)=dp.at(i-1).at(0);
      dp.at(i).at(1)=dp.at(i-1).at(1)+9;
    }else{
      dp.at(i).at(0)=dp.at(i-1).at(0)+x;
      dp.at(i).at(1)=max(dp.at(i-1).at(1)+9,dp.at(i-1).at(0)+x-1);
    }
  }
  cout<<max(dp.at(n-1).at(0),dp.at(n-1).at(1))<<endl;
}


Measured memory_bytes: 256