akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int lg(int n , int k)
{
	ld x = log(n);
	ld y = log(k);
	
	x = x/y;
	int ans = x+1;
	return ans;
}
int32_t main(){
	fast;
	int n,r;
	cin >> n >> r;
	cout << lg(n,r);
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int m1, d1;
    cin >> m1 >> d1;
    int m2, d2;
    cin >> m2 >> d2;
    int ans;
    if( m1 != m2 ){
        ans = 1;
    }else {
        ans = 0;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int mod=1000000000+7;

int main(){

	int n;
	cin>>n;
	long long int a[n];
	long long int ans=0;
	long long int sum=0;
	for(int i=0;i<n;i++){
	
		cin>>a[i];
		sum+=a[i];
		sum%=mod;
	}
	for(int i=0;i<n;i++){	

		sum-=a[i];
		if(sum<0){
			sum+=mod;
		}
		ans+=(a[i]*sum)%mod;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m;
	vl a(m);
	FOR(i,0,m) cin >> a[i];
	cin >> n;
	vl b(n);
	FOR(i,0,n) cin >> b[i];
	sort(all(a)), sort(all(b));

	ll i = 0;
	FOR(j,0,n) {
		while (i < m && a[i] != b[j]) i++;

		if (i == m) {
			cout << "NO" << endl;
			return 0;
		}
		i++;
	}
	cout << "YES" << endl;
}



Measured memory_bytes: 3456
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            if (S == T.Substring(0 , S.Length))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 25836
N,X,M=map(int,input().split())
A=[X]
A1=X
ans=0
for i in range(1,N):
    if 2*A1>M:
        A2=((M-A1)**2)%M
    else:
        A2=(A1**2)%M
    if A2 in A:
        num=A.index(A2)
        loop=i-num
        loop_A=A[num::]
        loop_val=sum(loop_A)
        rest=N-i
        x=rest%loop
        for _ in range(x):
            ans+=A[num]
            num+=1
        ans=ans+(rest//loop)*loop_val
        break
    else:
       A1=A2 
       A.append(A2)

print(sum(A)+ans)

Measured memory_bytes: 81396
import java.util.Arrays;
import java.util.Scanner;

class Main {

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

  private static Scanner sc = new Scanner(System.in);

  int countBomb(int x, int y, int H, int W, char[][] grid){
    int res = 0;
    for (int i = -1; i <= 1 ; i++) {
      for (int j = -1; j <= 1; j++) {
        if (x + j < 0 || x + j >= W || y + i < 0 || y + i >= H) {
          continue;
        }

        if (grid[y+i][x+j] == '#') {
          res++;
        }
      }
    }

    return res;
  }

  private void run() {
    int H = Integer.parseInt(sc.next());
    int W = Integer.parseInt(sc.next());

    char[][] grid = new char[H][W];

    for (int i = 0; i < H; i++) {
      grid[i] = sc.next().toCharArray();
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int bomb = countBomb(j, i, H, W, grid);
        if (grid[i][j] == '.') {
          grid[i][j] = Character.forDigit(bomb, 10);
        }
      }
    }

    for (int i = 0; i < H; i++) {
      System.out.println(grid[i]);
    }
  }
}


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

m = [[0 for _ in range(n+1)] for _ in range(n+1)]
mm = [[] for _ in range(n+1)]

for _ in range(n):
	tmp = [int(x) for x in input().split()]
	u,k,l = tmp[0],tmp[1],tmp[2:]
	mm[u] += tmp[2:]
	for x in l:
		m[u][x] = 1
		
dp = [float('inf') for _ in range(n+1)]
dp[1] = 0
queue = [1]

'''
while queue:
	t = queue.pop(0)
	for i,x in enumerate(m[t]):
		if x == 1:
			if dp[i] > dp[t] + 1:
				dp[i] = dp[t] + 1
				queue.append(i)
			else:
				pass
		else:
			pass
'''

while queue:
	t = queue.pop(0)
	for x in mm[t]:
		if dp[x] > dp[t] + 1:
			dp[x] = dp[t] + 1
			queue.append(x)
			
for i,x in enumerate(dp):
	if i == 0:
		pass
	else:
		if x == float('inf'):
			print(i, -1)
		else:
			print(i, x)
			

	


Measured memory_bytes: 5736
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

	int Q;
	cin >> Q;

	deque<char> q(s.begin(), s.end());
	bool forward = true;

	rep(i, Q)
	{
		int T;
		cin >> T;

		if (T == 1)
		{
			forward = !forward;
		}
		else
		{
			int F;
			char C;
			cin >> F >> C;

			if (F == 1 && forward || F == 2 && !forward)
			{
				q.push_front(C);
			}
			else
			{
				q.push_back(C);
			}
		}
	}

	if (forward)
	{
		for (auto itr = q.begin(); itr != q.end(); ++itr)
		{
			cout << *itr;
		}
	}
	else
	{
		for (auto itr = q.rbegin(); itr != q.rend(); ++itr)
		{
			cout << *itr;
		}
	}

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	long int csum = 0;

	for(int i =0; i<N;){
		i++;
		int wari;
		wari = 0;
		wari = (i%3) * (i%5);
		
		if(wari>0){
			csum = csum + i;
			}
	
	}
	
	cout << csum << endl;


}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 1e5 + 10;
int n;
int arr[105];
int dp[105][205];
int rek(int at, int prev_color){
    if(at == n) {
        return 0;
    }
    if(dp[at][prev_color] != -1){
        return dp[at][prev_color];
    }
    int ret = INF;
    if(arr[at] == prev_color){
        for(int i = 1; i <= 200; i ++){
            if(arr[at] != i){
                ret = min(ret, rek(at + 1, i) + 1);
            }
        }
    }
    else{
        ret = min(ret, rek(at + 1, arr[at]));
    }
    return dp[at][prev_color] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    int ret = INF;
    for(int i = 1; i <= 200; i ++){
        if(i == arr[0]){
            ret = min(ret, rek(1, arr[0]));
        }
        else{
            ret = min(ret, rek(1, i) + 1);
        }
    }
    printf("%d\n", ret);
    return 0;
}





Measured memory_bytes: 384
N,K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

after_sum = 0
whole_sum = 0
for i in range(N):
    before = 0
    after = 0
    for j in range(N):
        if A[i] > A[j]:
            if i < j:
                after += 1
            elif j < i:
                before += 1
    # print(before, after)
    whole = before + after
    after_sum = (after_sum + after) % MOD
    whole_sum = (whole_sum + whole) % MOD

a = (K * after_sum) % MOD
b = ((K - 1) * K // 2) % MOD
b = (b * whole_sum) % MOD
print((a + b) % MOD)


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

int main()
{
    int a,b,i,s=0,c=0;
    cin>>a>>b;
    int arr[a],brr[a+1];

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

    for(i=0;i<a+1;i++)
    {
        brr[i]=s;
        s=s+arr[i];
    }

    for(i=0;i<a+1;i++)
    {
        if(brr[i]<=b)
            c++;
    }
    cout<<c<<endl;

    return 0;
}




Measured memory_bytes: 256
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

if len(input_A) >= len(input_T):
    for i in range(len(input_A)-len(input_T), -1, -1):
        clear_flg = True
        for j in range(len(input_T)):
            if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
                clear_flg = False
                break

        if clear_flg is True:
            input_A[i:i + len(input_T)] = input_T
            input_A = ''.join(input_A).replace('?', 'a')
            break
else:
    clear_flg = False

if clear_flg is True:
    print(input_A)
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		int sum = 0;
		for(int i = 0; i < N ; i++) {
			T[i] = sc.nextInt();
			sum += T[i];
		}

		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i = 0; i < M; i++) {
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}

		for(int i = 0; i < M; i++) {
			System.out.println(sum - (T[P[i]-1] - X[i]));
		}
	}

}


Measured memory_bytes: 20560
N = int(input())
Xi = list(map(int, input().split()))

#計算しやすいよう、原点と末尾に0を足す。
Xi.insert(0, 0)
Xi.append(0)

Ci = [0]
total = 0
for i in range(1, N + 2):
    total += abs(Xi[i] - Xi[i - 1])
    Ci.append(total)
for i in range(1, N + 1):
    left = Ci[i - 1]
    right = Ci[-1] - Ci[i + 1]
    ans = left + right + abs(Xi[i + 1] - Xi[i - 1])
    print(ans)

Measured memory_bytes: 14176
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long int;

const ll INF = 1LL << 60;
ll dist[100010][2];
vector<int> G[100010];

struct Elem {
  int cur, mod2;
  ll distance;
  Elem(int a, int b, ll c) : cur(a), mod2(b), distance(c) {}
  bool operator<(const Elem& e) const {
    return distance > e.distance;
  }
};

const int SIZE = 2000010;
vector<int> get_primes() {
  vector<int> is_prime(SIZE+10, 1);
  for(int i=2; i<SIZE; i++) {
    if(is_prime[i] == false) continue;
    for(int k=2*i; k<SIZE; k+=i) {
      is_prime[k] = false;
    }
  }

  vector<int> res;
  for(int i=3; i<SIZE; i++) {
    if(is_prime[i] == true) {
      // if(i < 100) cerr << i << endl;
      res.push_back(i);
    }
  }
  return res;
}

int main() {
  vector<int> primes = get_primes();

  int N, M, S, T; cin >> N >> M >> S >> T;
  fill(dist[0], dist[N], INF);
  for(int i=0; i<M; i++) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  S--; T--;
  dist[S][0] = 0;
  priority_queue<Elem> que;
  que.push(Elem{S, 0, 0});
  while(que.size()) {
    Elem e = que.top(); que.pop();
    int pos = e.cur, mo = e.mod2;
    ll di = e.distance;
    if(dist[pos][mo] < di) continue;
    for(auto to : G[pos]) {
      int nmod = 1 - mo;
      int ndi = e.distance + 1;
      if(dist[to][nmod] > ndi) {
	dist[to][nmod] = ndi;
	que.push(Elem{to, nmod, ndi});
      }
    }
  }

  if(dist[T][0] == 2) cout << 2 << endl;
  else {
    auto it = lower_bound(primes.begin(), primes.end(), dist[T][1]);
    if(it == primes.end()) cout << -1 << endl;
    else cout << *it << endl;
  }
  return 0;
}



Measured memory_bytes: 13912
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var SA = Console.ReadLine();
            var SB = Console.ReadLine();
            var SC = Console.ReadLine();
            var ia = 0;
            var ib = 0;
            var ic = 0;
            var answer = 'a';
            var next = 'a';
            while (true)
            {
                if (next == 'a' && ia == SA.Length) break;
                else if (next == 'b' && ib == SB.Length) break;
                else if (next == 'c' && ic == SC.Length) break;

                switch (next)
                {
                    case 'a': next = SA[ia++]; break;
                    case 'b': next = SB[ib++]; break;
                    case 'c': next = SC[ic++]; break;
                }

                answer = Char.ToUpper(next);
            }
            Console.WriteLine(answer);
        }
    }
}


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

#pragma GCC optimize("02")
#pragma GCC target("tune=native")

using namespace std;

#define ll long long int
#define lu unsigned long long int
#define fi first
#define se second
#define edge pair<long long int,long long int>
#define weighted_edge pair<long long int,pair<long long int,long long int>>

int main() {

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

	string s; cin >> s;
	char prev = s[0];
	int ans = 0;

	for(int i = 1; i < s.size(); i++) {

		if(s[i] != prev) {
			ans++;
			prev = s[i];
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 512
k = int(input())

def hantei(n):
    string = str(n)
    length = len(string)
    ret = True
    for i in range(length-1):
        if abs(int(string[i]) - int(string[i+1])) > 1:
            ret = False
            break
    return ret

lst = [i for i in range(10)]
dic = {}
dic[1] = lst.copy()
keta = 2
while len(lst) < k+1:
    new = []
    for i in range(1, 10):
        tasu = i*(10**(keta-1))
        for j in sorted(dic.keys()):
            temp_lst = dic[j]
            bit = 0
            for youso in temp_lst:
                num = tasu + youso
                if hantei(num):
                    new.append(num)
                    bit = 1
                elif bit == 1:
                    break
    dic[keta] = new.copy()
    lst.extend(new)
    keta += 1

print(lst[k])

Measured memory_bytes: 14788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=3e5+5;
int inf=1e18;

int n,m,k;
int r[maxn],c[maxn];
set<pair<int,int>> s;

void solve(){
    cin>>n>>m>>k;
    rep(i,0,k){
        int x,y;cin>>x>>y;
        r[x]++;
        c[y]++;
        s.insert({x,y});
    }
    int ans=0;
    int rmx=max_element(r,r+maxn)-r;
    int cmx=max_element(c,c+maxn)-c;

    rep(i,0,maxn){
        int res1=r[i]+c[cmx]-s.count({i,cmx});
        int res2=c[i]+r[rmx]-s.count({rmx,i});
        ans=max({ans,res1,res2});
    }
    cout<<ans;

}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 27056
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void)
{
    int a,b,c,d,i,j,wa = 0,sa = 0,n;
    scanf("%d",&n);
    a = n / 1000;
    b = (n / 100) % 10;
    c = (n / 10) % 10;
    d = n % 10;
    if(a + b + c + d == 7)
    {
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    }
    else if (a + b + c - d == 7)
    {
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    }
    else if (a + b - c + d == 7)
    {
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    }
    else if (a - b + c + d == 7)
    {
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    }
    else if (a + b - c - d == 7)
    {
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    }
    else if (a - b - c - d == 7)
    {
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
    }
    else if (a - b - c + d == 7)
    {
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    }
    else if (a - b + c - d == 7)
    {
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,A,B = inputMap()
    
    ans = min(B, N*A)
    print(ans)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
s = input()
n = s.count("N")
ss = s.count("S")
w = s.count("W")
e = s.count("E")
if (n == 0 and ss > 0) or (ss == 0 and n > 0):
  print("No")
  exit()
if (w == 0 and e > 0) or (e == 0 and w > 0):
  print("No")
  exit()
print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>

using namespace std ;

int main()
{
	int a = 0 ,b[ 4 ] ;
	short cnt = 0 ,lp = 4 ;
	while( lp-- )
	{
		scanf( "%d" ,&a ) ;
		b[ lp ] = a ;
	}
	sort( b ,b + 4 ) ;
	if( b[ 0 ] == b[ 1 ] && b[ 2 ] == b[ 3 ] )
		printf( "yes\n" ) ;
	else
		printf( "no\n" ) ;
	return 0 ;
}

Measured memory_bytes: 2672
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#from bisect import bisect_right #二分探索用のモジュール bisect_right(a_list,value)

#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]

x,y = map(int,input().split())


if x*2 <= y <= x*4 and y % 2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61848
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n / 2; i++)
	{
		if (i != n - i)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

const static int MAX = 10;
char S[MAX];
string s;
int tmp, ans;

int main() {
    scanf("%s", S);
    s = S;
    tmp = 0;
    ans = 0;

    for ( int i = 0; i < (int)s.length(); i++ ) {
        if ( (s[i] == 'A') or (s[i] == 'C') or (s[i] == 'G') or (s[i] == 'T') ) {
            tmp++;
        } else {
            ans = max(tmp, ans);
            tmp = 0;
        }
    }

    ans = max(tmp, ans);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll k; string s; cin >> k >> s;
	if(s.size() <= k) cout << s << endl;
	else{
		cout << s.substr(0,k) << "..." << endl;
	}
}

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

int main() {
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  for(int i = 1; i <= b; i++) {
    if ((i * a) % b == c) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            //string u;

            //string[] ab;
            //int a;
            //int b;

            //string[] st = Console.ReadLine().Split(' ');

            //string s = st[0];
            //string t = st[1];

            //ab = Console.ReadLine().Split(' ');

            //a = int.Parse(ab[0]);
            //b = int.Parse(ab[1]);

            //u = Console.ReadLine();

            //if(s == u)
            //{
            //    a--;
            //}

            //else if(t == u)
            //{
            //    b--;
            //}

            //Console.WriteLine(a + " " + b);

            int s = Console.ReadLine().Length;

            string output = "";

            for (int i = 0; i < s; i++)
            {
                output = output + "x";
            }

            Console.WriteLine(output.ToString());

        }
    }
}


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

class Dice {
 public:
  vector<int> numbers;
  explicit Dice(vector<int> nums) : numbers{nums} {};
  auto roll(int i, int j, int k, int l) {
    auto tmp = numbers.at(i);
    numbers.at(i) = numbers.at(j);
    numbers.at(j) = numbers.at(k);
    numbers.at(k) = numbers.at(l);
    numbers.at(l) = tmp;
  };

  auto roll_S() { roll(0, 4, 5, 1); };
  auto roll_E() { roll(0, 3, 5, 2); };
  auto roll_C() { roll(1, 2, 4, 3); };  // clock wise
  auto out() {
    cout << "out" << endl;
    for (auto e : numbers) {
      cout << e << endl;
    }
  }
};
int main() {
  vector<int> numbers(6);

  vector<vector<int>> combo(24, vector<int>(3));
  int q, top, front;

  for (size_t i = 0; i < 6; i++) {
    cin >> numbers.at(i);
  }

  Dice d(numbers);

  int cnt = 0;
  for (size_t i = 0; i < 6; i++) {
    if (i % 2 == 0) {
      d.roll_S();
    } else {
      d.roll_E();
    }
    for (size_t j = 0; j < 4; j++) {
      combo.at(cnt) =
          vector<int>{d.numbers.at(0), d.numbers.at(1), d.numbers.at(2)};
      d.roll_C();
      cnt++;
    }
  }
  cin >> q;

  for (size_t i = 0; i < q; i++) {
    cin >> top >> front;

    cout << find_if(combo.begin(), combo.end(),
                    [&](vector<int> vec) {
                      return (vec.at(0) == top) && (vec.at(1) == front);
                    })
                ->at(2)
         << endl;
  }
}



Measured memory_bytes: 3148
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 400000+10;
stack<int> st;
bool first = true;
int k;
vl g[10];
int sum =0;
int lev;
void dfs(int i, int l){
  st.push(i);
 
  if(l==lev&&k==sum+1){
    vl ans;
    while(!st.empty())
      {ans.push_back(st.top());
      st.pop();}
    reverse(ans.begin(),ans.end());
    bool f  = 0;
    for(int i =  0;i<ans.size();i++){
      if(ans[i]!=0){
        f = 1;
      }
      if(f){
        cout<<ans[i];
      }
      
    }
    exit(0);
  }
  if(l==lev){
      st.pop();
      sum++;
      return ;
    }
    int sum = 0;
  for(auto x:g[i]){
    dfs(x,l+1);
  }

  st.pop();
  return ;
}
int32_t main()
{

   IOS
  cin>>k;
  for(int i = 0;i<=9;i++){
    for(int j = max(0ll,i-1);j<=(min(9ll,i+1));j++){
      g[i].push_back(j);
    }
  }  

  for(int i=  1;i<=70;i++){
    for(int j = 1;j<=9;j++){
      lev = i;
      dfs(j,1);
        
    }
    
  }
   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>a>>b;
    
    
    cout<<max(a+b,max(a-b,a*b))<<endl;
}



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

using namespace std;


int main (){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(y+r>h || x+r>w || x<0 ||y<0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
	return 0;
}



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

const int MAX = 1e6 + 6;
ll fact[MAX] , invfact[MAX];

//a^b % MOD
ll bigMod(ll a , ll b) {

    ll p ;
    if( b == 0) return 1;
    p = ( bigMod(a , b/2) % MOD );
    p = ( p * p) % MOD;
    if( b & 1 ) p = ( p * a) % MOD;
    return p;
}


// (1/a) % MOD == (a ^ MOD-2 )%MOD
ll modInverse( ll x ) {
    return bigMod(x, MOD-2);
}


//nCr % MOD
ll ncr(int n , int r) {
    if( n  < r || n < 0 || r < 0) return 0;
    ll up = fact[n];
    ll down = (invfact[r] * invfact[n-r])%MOD;
    return ( up * down )%MOD;
}


//nCr % MOD
ll npr(int n , int r) {
    if( n  < r || n < 0 || r < 0) return 0;
    ll up = fact[n];
    ll down = invfact[n-r];
    return ( up * down )%MOD;
}

void pre() {
    
    fact[0] =1 ;
    for(int i =1 ; i <  MAX ; i++) fact[i] = ( fact[i-1] * i )%MOD;
    
    invfact[MAX-1] = modInverse(fact[MAX-1]);
    for(int i = MAX-2 ; i >= 0 ; i--) invfact[i] = (invfact[i+1] * (i+1))%MOD;
}



int main()
{
    pre();
    ll n, m;
    cin>>n>>m;
    ll ans = 0, one = 1;
    for(int i = 0 ; i <= n ; i++ ) {
        
        ll tmp1 = (one * ncr(n, i) * npr(m,i))%MOD;
        ll tmp2 = (npr(m-i, n-i) * npr(m-i, n-i) ) %MOD;
        ll tmp = (tmp1 * tmp2) %MOD;
        ans = (ans + tmp) %MOD;
        one *= -1;
    }
    if(ans < 0) ans += MOD;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 19192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> ans(N+1);
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
                int p=x*x+y*y+z*z+x*y+y*z+z*x;
                if(p<=N)ans.at(p)++;
            }
        }
    }
    for(int i=1;i<=N;i++){
        cout<<ans.at(i)<<endl;
    }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class Main implements Runnable {
    // 定数

    public static void main(String[] args) throws Exception {
        Thread.setDefaultUncaughtExceptionHandler((t, e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        int result = 0;
        String N = "";

        // 入力
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            N = br.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (char c : N.toCharArray()) {
            if (c == '2') {
                result++;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 28500
cards = []
cards = ["%s %s" % (s, n) for s in ['S', 'H', 'C', 'D'] for n in range(1,14,1)]

input_cards = []
input_cards_num = int(raw_input())
for i in range(1, input_cards_num + 1, 1) :
    input_card = raw_input()
    cards.remove(input_card)

for card in cards:
    print(card)

Measured memory_bytes: 6436
A, B, Q = gets.split.map(&:to_i)
INF = 10**12

s=[-INF]
A.times do |i|
  s[i+1] = gets.to_i
end
s[A+1] = INF

t=[-INF]
B.times do |i|
  t[i+1] = gets.to_i
end
t[B+1] = INF

x=[]
Q.times do |i|
  x[i] = gets.to_i
end

Q.times do |i|
  j = s.bsearch_index{|y| x[i] < y}
  k = t.bsearch_index{|y| x[i] < y}

  ans =[
    (x[i]-s[j-1]).abs + [(s[j-1]-t[k-1]).abs, (s[j-1]-t[k]).abs].min,
    (x[i]-s[j]).abs + [(s[j]-t[k-1]).abs, (s[j]-t[k]).abs].min,
    (x[i]-t[k-1]).abs + [(t[k-1]-s[j-1]).abs, (t[k-1]-s[j]).abs].min,
    (x[i]-t[k]).abs + [(t[k]-s[j-1]).abs,(t[k]-s[j]).abs].min
  ].min

  puts ans
end


Measured memory_bytes: 5704
h=int(input())
w=int(input())
n=int(input())

if w>=h:
 if n%w==0:
  print(n//w)
 else:
  print(n//w+1)
else:
 if n%h==0:
  print(n//h)
 else:
  print(n//h+1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxm=1e6+5;
int a[maxm];
int n;
signed main(){
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    map<int,int>mark;
    for(int i=1;i<=n;i++){
        int x=a[i];
        for(int j=2;j*j<=x;j++){
            if(x%j==0){
                mark[j]++;
                while(x%j==0)x/=j;
            }
        }
        if(x!=1){
            mark[x]++;
        }
    }
    int ok=1;
    for(auto i:mark){
        if(i.second>=2){
            ok=0;break;
        }
    }
    if(ok){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    int g=0;
    for(int i=1;i<=n;i++){
        g=__gcd(g,a[i]);
    }
    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    return 0;
}
/*
1.称序列a"pairwise coprime"，当且仅当a中的数两两互质。
2.称序列a"setwise coprime"，
当且仅当a不为"pairwise coprime"，但是整个序列的gcd为1。
3.其他情况为"not coprime".

给定长度为n的序列a，要求判断该序列是上面哪种情况.

数据范围：n<=1e6，a(i)<=1e6

如果不是情况1,那么一定存在两个数,他们有公共质因子,
那么统计每个数质因子出现的情况,如果存在质因子出现两个以上,
那么就不是情况1,否则一定是情况1.

情况2直接gcd一遍看看是否为1即可.

如果不是情况1和2那就是3咯.
*/


Measured memory_bytes: 11064
#include<iostream>
using namespace std;
char b;
int main()
{
	ios::sync_with_stdio(false);
	cin>>b;
	if(b=='A')
	{
		cout<<"T";
	}
	else if(b=='T')
	{
		cout<<"A";
	}
	else if(b=='G')
	{
		cout<<"C";
	}
	else if(b=='C')
	{
		cout<<"G";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
 
using namespace __gnu_pbds;
using namespace std;
 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
// for pair comparison function(ascending order) use return (i1.ff < i2.ff);
 
/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/
 
const int M = (1<<20)+5;
const int md = 1e9+7;
 
priority_queue<ll,vector<ll >,greater<ll > > pq;
 
ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin >> x;
	cout << (!x) << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, K;
ll dp[50][50][50*50];

int main() {
    cin >> n >> K;
    if (K%2) {
        cout << 0 << endl;
        return 0;
    }
    K /= 2;
    dp[0][0][0] = 1;
    dp[0][1][1] = 1;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n*n; k++) {
                if (j > 0 && k >= j) dp[i][j][k] = (dp[i][j][k] + dp[i-1][j-1][k-j]) % MOD;
                if (k >= j) dp[i][j][k] = (dp[i][j][k] + (2*j+1)*dp[i-1][j][k-j]) % MOD;
                if (j+1 < n && k >= j) dp[i][j][k] = (dp[i][j][k] + (j+1)*(j+1)*dp[i-1][j+1][k-j]) % MOD;
            }
        }
    }
    cout << dp[n-1][0][K] << endl;
}


Measured memory_bytes: 48128
#include<stdio.h>
#define NILL -2000000001

int H;

void maxHeapify(int *A, int i){
  
  int l,r,max,k;
  
  l = i*2;
  r = i*2+1;
  
  if((l<=H)&&(A[l] > A[i]))
    max = l;
  else max = i;

  if((r<=H)&&(A[r] > A[max]))
    max = r;

  if(max != i){
    k = A[i];
    A[i] = A[max];
    A[max] = k;

    maxHeapify(A,max);
  }

}

void buildMaxHeap(int*A){
  int i;
  
  for(i = H/2 ;i >= 1;i--)
    maxHeapify(A,i);
  
}


int main(){

  int i,k;
  int A[500001];

  scanf("%d",&H);


  for(i=1;i<=H;i++){
    scanf("%d",&k);
    
    A[i] = k;
    
  }

  buildMaxHeap( A );
  
  for(i=1;i<=H;i++) printf(" %d",A[i]);

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3684
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

  int a = L, b = L + N - 1;
  int d;
  if (a > 0) {
    d = a;
  } else if (b < 0) {
    d = b;
  } else {
    d = 0;
  }

  cout << N * L + N * (N - 1) / 2 - d << endl;

  return 0;
}

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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	int sum = 0;
	for(int i=0;i<k;i++) sum = sum + a[i];
	cout<<sum<<endl;
}


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

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int translateChar(char ch){
    switch(ch){
    case 'A':
        return 1;
    case 'C':
        return 2;
    case 'G':
        return 3;
    case 'T':
        return 4;
    }
    return -1;	//must not reach here
}


int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += translateChar(buf[i])*mult;
        mult *= 4;
    }
    return sum;
}

int main(){

    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];

    char* check_table = new char[TABLE_SIZE];

    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}

Measured memory_bytes: 4532
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >>a >> b;
    string u;
    cin >> u;
    if (s == u) a--;
    else b--;
    cout << a << ' ' << b;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;

int main(){
    scanf("%ld", &n);
    printf("%ld\n", n*(n-1)/2);
}


Measured memory_bytes: 256
a, b = map(int, input().split())

def gcd(p, q):
    if p < q:
        p, q = q, p
    while q != 0:
        p, q = q, p % q
    return p

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

res = factorization(gcd(a, b))
if res[0][0] == 1:
    ans = 1
else:
    ans = len(res) + 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;

int main() {
 int N;
 string S;
 cin>>N>>S;int count=0;
 for(int i=0;i<N;i++){
   count++;
   if(S[i]==S[i+1]){
     while(i<N&&S[i]==S[i+1]){i++;}
   }
 }
  cout<<count<<endl;
return 0;}

Measured memory_bytes: 512
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 c = sc.nextInt();
    long k = sc.nextLong();
    int out = (k%2 == 0) ? a-b : b-a;
    System.out.println(out);
  }
}


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

int main()
{
	int N;
	long long solution = 0;
	cin >> N;
	char S[10000];
	cin >> S;
	int i;
	long long rcount = 0;
	long long gcount = 0;
	long long bcount = 0;
	for(i=0;i<N;i++)
	{
		if(S[i] == 'R') rcount += 1;
		if(S[i] == 'G') gcount += 1;
		if(S[i] == 'B') bcount += 1;
	}
	for(i=N;i<10000;i++)
	{
		S[i] = 'A';
	}
	int j;
	int count =0;
	for(i=1;i<2000;i++)
	{
		for(j=0;j<4000;j++)
		{
		if((S[j] == 'R')&&(S[j+i] == 'G')&&(S[j+2*i] == 'B'))
		{count += 1;}
		if((S[j] == 'R')&&(S[j+i] == 'B')&&(S[j+2*i] == 'G'))
		{count += 1;}
		if((S[j] == 'G')&&(S[j+i] == 'R')&&(S[j+2*i] == 'B'))
		{count += 1;}
		if((S[j] == 'G')&&(S[j+i] == 'B')&&(S[j+2*i] == 'R'))
		{count += 1;}
		if((S[j] == 'B')&&(S[j+i] == 'G')&&(S[j+2*i] == 'R'))
		{count += 1;}
		if((S[j] == 'B')&&(S[j+i] == 'R')&&(S[j+2*i] == 'G'))
		{count += 1;}
		}
	}
	solution = ((rcount)*(bcount)*(gcount)) - count;
	cout << solution;
}


Measured memory_bytes: 3644
_N = input()
a = map(int, input().split())

count = 0
for num in a:
    while True:
        if num % 1024 == 0:
            count += 10
            num /= 1024
        elif num % 2 == 0: 
            count += 1
            num /= 2
        else:
            break
print(count)

Measured memory_bytes: 3828
N,P=map(int,input().split(' '))
S =list(map(int,list(input()[::-1])))
ans = 0
cnt = [0]*P
cnt[0]=1
tmp = 0
for n,i in enumerate(S):
    d=i*pow(10,n,P)
    tmp =(tmp+d)%P
    cnt[tmp] += 1
if P in [2,5]:
    if P==2:
        check=[0,2,4,6,8]
    else:
        check=[0,5]
    for n,i in enumerate(S):
        if i in check:
            ans += N-n
else:
    for i in cnt:
        ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 6436
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var raw = ReadLine().Split().Select(int.Parse).ToArray();
            var N = raw[0];
            var D = raw[1];

            var ans =(float) N / (D * 2 + 1);
            WriteLine(Math.Ceiling(ans));
        }
    }
}


Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

//??°?????????????????°

void function()
{
	//??¢??°
}

int main()
{
	int n, x;
	while (cin >> n >> x)
	{
		if (n == 0 && x == 0)
		{
			return 0;
		}

		int cnt = 0;
		for (int i = 1; i <= n - 2; i++)
		{
			for (int j = i + 1; j <= n - 1; j++)
			{
				for (int k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#D
from collections import deque
h,w=map(int,input().split())
s=[]

for i in range(h):
    s.append(list(input()))
dx=[1,0,-1,0]#東南西北
dy=[0,-1,0,1]
ans=0
def search(i,j):
    if s[i][j]=="#":
        return 0
    max_step=0
    que=deque()
    que.append([i,j])#1現在地
    dist=[[-1 for _ in range(w)] for _ in range (h)]
    #(h,w)
    dist[i][j]=0#現在地は0
    while que:#行き先が無くなるまで
        y,x=que.popleft()#現在地を取り出す(y,x)
        for dir in range(4):
            nx=x+dx[dir]#行き先(nx,xy)
            ny=y+dy[dir]
            if ny<0 or ny>=h or nx<0 or nx>=w or s[ny][nx]=="#":#壁の中
                pass#何もしない
            elif dist[ny][nx]!=-1:#捜索済み
                pass
            elif s[ny][nx]==".":
            #未捜索地点"."
                dist[ny][nx]=dist[y][x]+1#1進む
                que.append([ny,nx])
    out=0
    for i in range(h):
        for j in range(w):
            if dist[i][j]==-1:
                pass
            out=max(out,dist[i][j])
    return out

for i in range(h):
    for j in range(w):
        step=search(i,j)#(j,i)の時の最大移動数を求める
        if ans<step:
            ans=step
print(ans)

Measured memory_bytes: 3436
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int N = 2002;

int n,m,q,s0[N][N],s1[N][N],s2[N][N];
char p[N][N];

inline int Calc1(int r1,int c1,int r2,int c2)
{
	return s0[r2][c2] - s0[r2][c1-1] - s0[r1-1][c2] + s0[r1-1][c1-1];
}

inline int Calc2(int r1,int c1,int r2,int c2)
{
	int A = s1[r2][c2] - s1[r2][c1] - s1[r1-1][c2] + s1[r1-1][c1];
	int B = s2[r2][c2] - s2[r2][c1-1] - s2[r1][c2] + s2[r1][c1-1];
	return A + B;
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++)
	{
		scanf("%s",p[i] + 1);
		for (int j = 1; j <= m; j++)
		{
			int now = p[i][j] - '0';
			s0[i][j] = s0[i][j-1] + s0[i-1][j] - s0[i-1][j-1] + now;
			s1[i][j] = s1[i][j-1] + s1[i-1][j] - s1[i-1][j-1] + ((now && p[i][j-1] == '1') ? 1 : 0);
			s2[i][j] = s2[i][j-1] + s2[i-1][j] - s2[i-1][j-1] + ((now && p[i-1][j] == '1') ? 1 : 0);
		}
	}
	while (q--)
	{
		int r1,c1,r2,c2; scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
		printf("%d\n",Calc1(r1,c1,r2,c2) - Calc2(r1,c1,r2,c2));
	}
	return 0;
}

Measured memory_bytes: 52736
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define mod 
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL)
int32_t main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int dp[k+1];
	dp[0]=1;
	for(int i=1;i<=k;i++){
		dp[i]=1;
	}
	sort(a,a+n);
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]>=0){
				if(dp[i-a[j]]==1){
					dp[i]=0;
					break;
				}
                
			}
		}
	}
	if(dp[k]==0){
		cout<<"First"<<endl;
	}
	else cout<<"Second"<<endl;
	
return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.next();
		String str2 = sc.next();
		for(int i = 0; i < str1.length(); i++){
			if(!str1.substring(i, i + 1).equals(str2.substring(2 - i, 3 - i))) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> c(m);
    rep(i, m) cin >> c[i];
    ll dp[100000];
    rep(i, 100000) dp[i] = INF;
    dp[0] = 0;
    rep(i, n+1) {
        rep(j, m) chmin(dp[i + c[j]], dp[i] + 1);
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 3868