akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<long long>::max()
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
int zrOne(char c){
    if(c=='#') return 0;
    else return 1;
}
void solve(){
    int h,w;
    cin>>h>>w;
    vector<string> v(h);
    rep(i,0,h) cin>>v[i];
    // 0 white, 1 black
    vector<vector<pair<int,int> > > dp(h,vector<pair<int,int> >(w,{inf,0}));
    dp[0][0] = {1-zrOne(v[0][0]),zrOne(v[0][0])};
    rep(i,0,h){
        rep(j,(i==0?1:0),w){
            dp[i][j].sc = zrOne(v[i][j]);
            if(j-1>=0){
                dp[i][j].fr = min(dp[i][j].fr,dp[i][j-1].fr+((dp[i][j-1].sc==1 && dp[i][j].sc==0)?1:0));
            }
            if(i-1>=0){
                dp[i][j].fr = min(dp[i][j].fr,dp[i-1][j].fr+((dp[i-1][j].sc==1 && dp[i][j].sc==0)?1:0));
            }            
        }
    }
    cout<<dp[h-1][w-1].fr<<endl;

}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 384
import sys
N, M = (int(i) for i in input().split())
X = [int(i) for i in input().split()]
X.sort()

L = []

for i in range(1, M):
    L.append(X[i]-X[i-1])

L = sorted(L, reverse=True)

print(X[M-1]-X[0]-sum(L[:N-1]))


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 ) a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 ) return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 ) return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
   return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
   if ( x == 1 )
	   return 0;
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
		   return 0;
	return 1;
}

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

int n, m;
int mat[ MAXN ][ MAXN ];
int vis[ MAXN ][ MAXN ];

int bfs( int x, int y )
{
	queue < pair < ii, int > > Q;
	Q.push( mp( mp( x, y ), 0 ) );
	int ret = 0;
	vis[ x ][ y ] = 1;
	while ( !Q.empty() )
	{
		pair < ii, int > state = Q.front();Q.pop();
		int x = state.X.X, y = state.X.Y, d = state.Y;
		ret = max( ret, d );
		
		FOR( i, 0, 4 )
		{
			int xi = x + dx[ i ];
			int yi = y + dy[ i ];
			if ( xi < 0 || xi >= n || yi < 0 || yi >= m )
				continue;
			if ( mat[ xi ][ yi ] )
				continue;
			if ( vis[ xi ][ yi ] )
				continue;
			
			vis[ xi ][ yi ] = 1;
			Q.push( mp( mp( xi, yi ), d + 1 ) );
		}
	}
	
	return ret;
}

int main()
{
   ios_base::sync_with_stdio( false );
   cin.tie( 0 );
   
	cin >> n >> m;
	FOR( i, 0, n )
	{
		string s;cin >> s;
		FOR( j, 0, m )
		{
			if ( s[ j ] == '#' )
				mat[ i ][ j ] = 1;
		}
	}
	
	int ans = 0;
	FOR( i, 0, n )
	{
		FOR( j, 0, m )
		{
			if ( mat[ i ][ j ] )
				continue;
			memset( vis, 0, sizeof vis );
			ans = max( ans, bfs( i, j ) );
		}
	}

	cout << ans << "\n";
   return 0;
}


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

using namespace std;

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

	int total = 0;
	for (int i = 0; i < n; i++) {
		total += (i + 1);
	}

	cout << total << endl;
	
}






Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
 
using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string hands="rsp";
  int n,k,r,s,p;
  cin>>n>>k>>r>>s>>p;
  vecint pt = {r, s, p};
  string t;
  cin>>t;
  vector<vecint> dp(n, vecint(3, 0));
  for(int i:irange(0,n)) {
    int h=boost::find(hands,t[i])-begin(hands);
    int win=(h+2)%3;
    if(i<k) {
      dp[i][win] = pt[win];
    } else {
      for(int j:irange(0,3)) {
        for(int l:irange(0,3)) {
          if (j==l) continue;
          if (l == win) {
            dp[i][l] = max(dp[i][l], dp[i-k][j] + pt[win]);
          } else {
            dp[i][l] = max(dp[i][l], dp[i-k][j]);
          }
        }
      }
    }
  }
  int sum = 0;
  for(int i:irange(n-k,n)) sum += *boost::max_element(dp[i]);
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 5840
/**
 *    author:  Mohamad Milhem
 *    created: 2020-02-19-12.06.24
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


int main(){

    FAST;

    int n;
    cin >> n;
    vector<string> s;
    map<string, int> mp;
    int maxx = 0;


    for (int i = 0 ; i < n ; i++){
        string in;
        cin >> in;
        if (mp[in] == 0)s.push_back(in);
        mp[in]++;
        maxx = max(maxx, mp[in]);
    }


    sort(s.begin(), s.end());
    for (int i = 0 ; i < s.size() ; i++){
        if (mp[s[i]] == maxx)cout << s[i] <<endl;
    }



    return 0;
}


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

int main(){
  int N =0;
  cin >> N;
vector<int64_t> veca(N+2);
  if(N == 1){
   cout << 1 << endl;
  }else{
  veca[0] = 2;
  veca[1] = 1;
  for(int i=0; i<N-1; i++ ){
    veca[i+2] = veca[i]+veca[i+1];
  }
  
  cout << veca[N] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Max=3e3;
const long long Mod=1e9+7;
#define int long long
int n,m,f[Max+10][Max+10]={},c[Max+10][Max+10]={},b[Max+10]={},l[Max+10]={},r[Max+10]={};
struct kk{
    int l,r,v;
} e[Max+10]={};
char a[Max+10]={};
main(){
 // freopen("a.in","r",stdin);
//  freopen("a.out","w",stdout);
    scanf("%lld%lld",&n,&m);
    scanf("%s",a+1);
    for(int i=1;i<=n;i++)
     b[i]=b[i-1]+(a[i]=='1');
    c[0][0]=c[0][1]=c[1][1]=1;
    for(int i=2;i<=Max;i++){
        c[0][i]=c[i][i]=1;
        for(int j=1;j<i;j++)
         c[j][i]=(c[j-1][i-1]+c[j][i-1])%Mod;
    }
    int Max=0;
    for(int i=1;i<=m;i++) {
        scanf("%d%d",&e[i].l,&e[i].r);
    }
    for(int i=1;i<=m;i++)
     for(int j=1;j<=m;j++)
      if(i!=j&&e[j].l>=e[i].l&&e[j].r<=e[i].r&&!e[i].v) e[j].v=1;
    int s=0;
    for(int i=1;i<=m;i++)
     if(!e[i].v) ++s,l[s]=e[i].l,r[s]=e[i].r;
    m=s;
    f[0][0]=1;
    for(int i=1;i<m;i++){
        if(l[i+1]>r[i]){
            for(int j=0;j<=n;j++)
             f[i][0]+=f[i-1][j]*c[j+b[r[i]]-b[max(r[i-1],l[i]-1)]][r[i]-l[i]+1]%Mod,f[i][0]%=Mod;
        }else{
            for(int j=0;j<=r[i]-l[i+1]+1;j++)
             for(int k=0;k<=n;k++)
              if(k+b[r[i]]-b[max(r[i-1],l[i]-1)]-j>=0){
                f[i][j]+=f[i-1][k]*c[k+b[r[i]]-b[max(r[i-1],l[i]-1)]-j][l[i+1]-l[i]]%Mod,f[i][j]%=Mod;
              }
        }
    }    
    int ans=0; 
     for(int i=0;i<=n;i++)
      ans+=f[m-1][i]*c[i+b[r[m]]-b[max(r[m-1],l[m]-1)]][r[m]-l[m]+1]%Mod,ans%=Mod;
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
	vector<int>a(5);
	for (int i = 0; i < 5; i++)cin >> a.at(i);
	int k; cin >> k;
	if (a.at(4) - a.at(0) > k)cout << ":(" << endl;
	else cout << "Yay!" << endl;
}

Measured memory_bytes: 3568
def main():
    s = list(input())
    left = int(s[0] + s[1])
    right = int(s[2] + s[3])

    if 1 <= left and left <= 12:
        if 1 <= right and right <= 12:
            return "AMBIGUOUS"
        else:
            return "MMYY"
    else:
        if 1 <= right and right <= 12:
            return "YYMM"
        else:
            return "NA"

print(main())


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
gra=[[] for _ in range(n)]
for i in range(m):
    a,b=mii()
    a-=1
    b-=1
    gra[a].append(b)
    gra[b].append(a)

ans=0
for i in permutations(range(1,n)):
    i=[0]+list(i)
    cnt=1
    for j in range(n-1):
        
        if i[j+1] in gra[i[j]]:
            cnt+=1

    if cnt==n:
        ans+=1

print(ans)



Measured memory_bytes: 65644
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 4010
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
const ll mod=1e9+7;
int num[30];
char str[105][105];
int g(char tmp){
    return tmp-'a';
}
int main() {
#ifdef ONLINE_JUDGE
#else
   // FREI;
    // FREO;
#endif
    //FAST;
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++) {
        scanf("%s",str[i]);
    }
    for(int i=1;i<=n;i++)
        for(int j=0;j<m;j++)
        num[g(str[i][j])]++;
    int cnt=0;
    for(int i=0;i<26;i++)
    {
        cnt+=num[i]/4;
        num[i]%=4;
    }
    int tmp=(n/2)*(m/2);
    if(cnt<tmp){
        cout<<"No"<<endl;
        return 0;
    }
    bool ans=(n*m)%2;
    int tt=0;
    for(int i=0;i<26;i++)
        if(num[i]%2)tt++;
    if(ans&&tt>1)cout<<"No"<<endl;
    else if(!ans&&tt)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")

import math
import collections


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(X: int):

    for i in range(X, 2*(10**5)):
        c = factorial(i)
        if len(c) == 1 and list(c.values())[0] == 1:
            print(i)
            break
    else:
        raise Error

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
h, w = map(int , input().split())

ahw = []
for i in range(h):
  aw = [a for a in input()]
  ahw.append(aw)

row = [False] * h
column = [False] * w
for i in range(h):
  for j in range(w):
    if ahw[i][j] == "#" :
      row[i] = True
      column[j] = True

for i in range(h):
  if row[i] :
    for j in range(w):
      if column[j]:
        print(ahw[i][j],end = "")
    print()
    

  

Measured memory_bytes: 9256
import java.io.*;
import java.util.*;
import java.lang.String;
import java.util.Arrays;

import static java.lang.Integer.min;
import static java.lang.Integer.parseInt;

public class Main extends PrintWriter {
    Main() { super(System.out, true); }
    Scanner sc = new Scanner(System.in);
    public static void main(String[] $) {
        Main o = new Main(); o.main(); o.flush();
    }

    void main(){

        char []A = new char[3];
        String B = sc.next();
        for(int i = 0; i < 3; i++){
            A[i] = B.charAt(i);

        }
        if(A[0] == A[1] && A[1] == A[2]){
            print("No");
        }
        else
        {
            print("Yes");
        }


    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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


string numToChar(int num){
    if(num == 0) return "A";
    else if(num == 1) return "B";
    else return "C";
}

int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];

    vector<char> ans;
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0){
            cout << "No" << endl;
            return 0;
        }
        if(num[0]+num[1]+num[2] == 1){
            // 0の方に足す
            int small = (num[c1] > num[c2])? c2: c1;
            int large = (num[c1] > num[c2])? c1: c2;
            ans.push_back(char(small+'A'));
            ++num[small];
            --num[large];
        }else{
            bool flag = true;
            for(auto c: s[i]){
                int idx = c-'A';
                if(num[idx] == 0){
                    ans.push_back(c);
                    ++num[idx];
                    --num[(idx == c1)? c2: c1];
                    flag = false;
                    break;
                }
                if(i+1 < N and num[idx] == 1 and num[c3] == 0 and (s[i+1] == numToChar(idx)+numToChar(c3) or s[i+1] == numToChar(c3)+numToChar(idx))){
                    ans.push_back(c);
                    ++num[idx];
                    --num[(idx == c1)? c2: c1];
                    flag = false;
                    break;
                }
            }
            if(flag){
                ans.push_back(s[i][0]);
                ++num[c1];
                --num[c2];
            }
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

Measured memory_bytes: 5480
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>



using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

long double a, b ,x;
long double w;
long double r;
long double pi = 3.14159265359 ;

int main(){
    cin >> a >> b >> x;
    if(x == a*b*a/2){
        long double h = 2*x/(b*a);
        w = atan(h/b);
    }
    else if(x > a*b*a/2){
        w = atan(-2/a*((x/(a*a))-b));
    }
    else{
        w = atan((a*b*b)/(2*x));
    }

    cout << setprecision(7) << w*180.0/pi << endl;

return 0;
}

Measured memory_bytes: 3844
while True:
    n, m = map(int, input().split())
    if n == 0:break
    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))
    l.sort(key=lambda x:x[1])
    l.reverse()
    for i in range(n):
        if m >= l[i][0]:
            m -= l[i][0]
            l[i][0] = 0
        elif m != 0:
            l[i][0] -= m
            m = 0
        else:
            break
    ans = 0
    for s in l:
        ans += s[0] * s[1]
    print(ans)


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

int main()
{
    int n;
    cin >> n;
    int a[n],c[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        c[i]=a[i];
    }
    int q;
    cin >> q;
    int b[q][2];
    for(int i=0;i<q;i++)
        cin >> b[i][0] >> b[i][1];
    sort(c,c+n);
    int m=0;
    for(int i=0;i<n;i++)
        if(a[i]!=c[i]) m++;
    if(m==0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<q;i++){
        int x=0,y=0;
        if(a[b[i][0]-1]==c[b[i][0]-1]) x++;
        if(a[b[i][1]-1]==c[b[i][1]-1]) y++;
        swap(a[b[i][0]-1],a[b[i][1]-1]);
        if(a[b[i][0]-1]==c[b[i][0]-1]) m--;
        if(a[b[i][1]-1]==c[b[i][1]-1]) m--;
        if(a[b[i][0]-1]!=c[b[i][0]-1]&&x>0) m++;
        if(a[b[i][1]-1]!=c[b[i][1]-1]&&y>0) m++;
        if(m==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 7840
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

int main(){
	int n;
	int sum=2;
	long long l[1000]={l[0]=2,l[1]=1};
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		l[i+2]=l[i]+l[i+1];
	}
	printf("%lld\n",l[n]);
}

Measured memory_bytes: 256
#include<stdio.h>
main(void)
{
	int m=0,f=0,r=0;
	while(EOF !=scanf("%d %d %d",&m,&f,&r)){
		
		if(m==-1 && f==-1 && r==-1){
		break;
		}
		
		if(m==-1 || f==-1)			printf("F\n");
		
		else if(m+f>=80)			printf("A\n");
		
		else if(65<=m+f && m+f<80)	printf("B\n");
		
		else if(50<=m+f && m+f<65)	printf("C\n");
		
		else if(m+f>=30 && m+f<50){
			if(r>=50)				printf("C\n");
			else 					printf("D\n");
		}
		
		else 						printf("F\n");
	}
	return 0;
}

Measured memory_bytes: 584
#方針: 連続するk本に点火するパターンを全部調べる
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

p (0..n-k).map{|i| [x[i].abs, x[i+k-1].abs].min + x[i+k-1] - x[i]}.min

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

long long gcd(long long x, long long y){
    if(y == 0) return x;
    return gcd(y, x % y);
}


int main(void){
    long long A, B;
    cin >> A >> B;
    long long g = gcd(A, B);
    vector<long long> prime;
    prime.reserve(1000000);
    prime.push_back(2);
    for(long long n = 3; n <= 1000000; n++){
        int i;
        for(i = 0; prime[i] * prime[i] <= n; i++){
            if(n % prime[i] == 0) break;
        }
        if(prime[i] * prime[i] > n){
            prime.push_back(n);
            //cout << n << endl;
        }
    }
    int ans = 1;
    for(int i = 0; prime[i] * prime[i] <= g; i++){
        if(g % prime[i] == 0){
            ans++;
            while(g % prime[i] == 0) g /= prime[i];
        }
    }
    if(g > 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <utility>
#include <map>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  std::multimap<long, int> sorted_map;
  long long result = 0;
  for (int i = 0; i < N; i++)
  {
    long a = 0;
    int b = 0;
	cin >> a;
    cin >> b;
    sorted_map.insert(std::make_pair(a, b));
  }
  for (auto const& entry: sorted_map)
    {
      if (M - entry.second <= 0)
      {
        result += entry.first * M;
        break;
      }
      result += entry.first * entry.second;
      M -= entry.second;
    }
  cout << result << endl;
}

Measured memory_bytes: 6528
fun main(args: Array<String>) {
    val (n, x) = readLine()!!.split(" ").map(String::toInt)
    val l = readLine()!!.split(" ").map(String::toInt)
    val result = l.fold(mutableListOf(0)) { acc, i ->
        acc.add(acc.last() + i)
        acc
    }
    println(result.count { it <= x })
}

Measured memory_bytes: 37816
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<ll> arr(n);
    ll minn=INT_MAX;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    for(int i=0;i+k<=n;i++){
        minn=min(minn,arr[i+k-1]-arr[i]);
    }
    cout<<minn;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int d, ans=0;
	vector<int> c, t, ld;
	vector< vector<int> >s;

	cin>> d;

	c.resize(26);
	rep(i, 26) cin>> c[i];
	s.resize(d);
	rep(i, d){
		s[i].resize(26);
		rep(j, 26) cin>> s[i][j];
	}
	t.resize(d);
	rep(i, d){
		cin>> t[i];
		t[i]--;
	}
	ld.resize(26);

	rep(i, d){
		ans+=s[i][t[i]];
		ld[t[i]]=i+1;
		rep(j, 26) ans-=(i-ld[j]+1)*c[j];
		cout<< ans << endl;
	}
 
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include <iostream> 
#include<math.h>
#include<string.h>
#include <algorithm>
#include<stdio.h>
#include<limits.h>
using namespace std; 
#define pb push_back 
#define lli long long int

int frog(int h[],int st,int n,int dp[])
{
    if(st==n-1)
    return dp[n-1]=0;
    if(st==n-2)
    return dp[n-2]=abs(h[n-2]-h[n-1]);
    if(dp[st]!=-1)
    return dp[st];
    for(int i=n-3;i>=0;--i)
    dp[i]=min( frog(h,i+1,n,dp)+abs(h[i]-h[i+1]) , frog(h,i+2,n,dp)+abs(h[i]-h[i+2]) );
    return dp[0];
}

int main() 
{   int n;
    cin>>n;
    int h[n],dp[n]={-1};
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
       //dp[i]=-1;
    }
    int fro = frog(h,0,n,dp);
    cout<<dp[0];
    
        
    
    return EXIT_SUCCESS; 
} 

  

Measured memory_bytes: 4424
import java.util.Scanner;
import java.util.Vector;

public class Main {
    private int cnt = 0;
    private Vector<Integer> G;
    private int[] a;

    public Main() {
        G = new Vector<Integer>();
    }

    private void shellSort(int n) {
        for (int i = 1; ;){
            if (i > n) break;
            G.add(i) ;
            i = i * 3 + 1;
        }
        int m = G.size();
        for (int i=m-1; i>=0; i--) insertionSort(n, (int)G.elementAt(i));
    }
    private void insertionSort(int n, int g) {
        for (int i=g; i<n; i++){
            int v = a[i];
            int j = i-g;
            while (j >=0 && a[j] > v){
                a[j+g] = a[j];
                j -= g;
                cnt++;
            }
            a[j+g] = v;
        }
    }
    private void output(int n){
        System.out.println(G.size());
        for (int i=G.size()-1; i>=0; i--){
            System.out.print((int)G.elementAt(i));
            char c;
            System.out.printf("%s", c=(i == 0)?'\n':' ');
        }
        System.out.println(cnt);
        for (int i = 0; i < n; i++){
            System.out.println(a[i]);
        }
    }
    public static void main(String[] args) {
        Main shellSort = new Main();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        shellSort.a = new int[n];
        for (int i=0; i<n; i++){
            shellSort.a[i] = scanner.nextInt();
        }
        shellSort.shellSort(n);
        shellSort.output(n);
    }
}



Measured memory_bytes: 301292
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
#define  fi0(i,n)  for(size_t i=0;i<n;i++)
#define   pb    push_back
#define   mk    make_pair
#define   fst      first
#define   scnd    second
#define   fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   endl     '\n';
using namespace std;
void f(){
    ll x,y,z,n;cin>>x>>y>>z>>n;
    ll a[x],b[y],c[z];vector<ll>xxx;
    fi0(i,x)cin>>a[i];fi0(i,y)cin>>b[i];fi0(i,z)cin>>c[i];
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            xxx.push_back((a[i]+b[j]));
        }
    }

    sort(xxx.begin(),xxx.end(),greater<int>());
   /// fi0(i,xxx.size())cout<<xxx[i]<<endl;
    sort(c,c+z,greater<int>());
    vector<ll>xx;
    for(int i=0;i<xxx.size();i++){
        for(int j=0;j<z;j++){
        xx.pb((xxx[i]+c[j]));
        }
    }
    sort(xx.rbegin(),xx.rend());
    for(int i=0;i<min(n,x*y*z);i++)cout<<xx[i]<<endl;
}
int main()
{
   /// int t;cin>>t;while(t--){
        int k;cin>>k;
        for(int i=0;i<k;i++)cout<<"ACL";
        
  ///  }
}


Measured memory_bytes: 3524
import math
N,D = map(int,input().split())
X = [list(map(int,input().split()))for _ in range(N)]

count = 0
a = 0
for i in range(N):
    for j in range(i + 1,N):
        for k in range(D):
            a += (X[i][k] - X[j][k])**2
        if math.sqrt(a) == int(math.sqrt(a)):
            count += 1
        a = 0

print(count)

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

int main() {
	//input
	int64_t N, K;
	cin >> N >> K;

	vector<int64_t> H(N);
	for (int64_t i = 0; i < N; i++) {
		cin >> H[i];
	}

	//calculation
	sort(H.begin(), H.end());
	int64_t sum = 0;
	for (int64_t i = 0; i < N - K; i++) {
		sum += H[i];
	}

	//output
	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    string str;
    int ans = 0;
    int n1, n2, n3;
    cin>>str;

    for (int i = 0; i < str.length(); ++i) {
        n1 = n2 = n3 = 0;
        while (str[i] == 'J') {
            n1++;
            i++;
        }
        while (str[i] == 'O') {
            n2++;
            i++;
        }
        while (str[i] == 'I') {
            n3++;
            i++;
        }
        if(n2 <= n1 && n2 <= n3) ans = max(ans, n2);
        i--;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


string nchar(char c, int n){
    string s = "";
    rep(i, n){
        s.push_back(c);
    }

    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    int d[n];
    int num = 0;
    int mn = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == '(') ++num;
        else --num;
        d[i] = num;
        mn = min(mn, num);
    }

    cout << nchar('(', -mn) << s << nchar(')', d[n-1]-mn) << endl;



    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

typedef pii P;
P f(int x) {
    int b = x%10;
    while (x > 9) x /= 10;
    int a = x;
    return P(a, b);
}

int main(){
    int n;
    cin >> n;
    map<P, int> cnt;
    rep1(i, n) cnt[f(i)]++;
    ll ans = 0;
    rep1(i, n) {
        P p = f(i);
        P q = { p.second, p.first };
        ans += cnt[q];
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

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

        vector<string> words(n);
        for(auto& w:words) cin >> w;
        for(auto it=words.begin(); it!=words.end();){
            if(![&]{
                for(auto it2=words.begin();it2!=words.end(); ++it2) if(it2!=it and it2->find(*it)!=string::npos){
                    it=words.erase(it);
                    return true;
                }
                return false;
            }()) ++it;
        }

        vector<vector<int>> graph(words.size(),vector<int>(words.size()));
        for(int i=0; i<words.size(); ++i) for(int j=0; j<words.size(); ++j){
            const string& w1=words[i],w2=words[j];
            int same=0;
            for(int len=0; len<=min(w1.size(),w2.size()); ++len) if(w1.substr(w1.size()-len,len)==w2.substr(0,len)) same=len;
            graph[i][j]=w2.size()-same;
        }

        const string infstr(101,'z');
        string dp[1<<10][10];
        fill_n((string*)dp,(1<<10)*10,infstr);
        for(int i=0; i<words.size(); ++i) dp[1<<i][i]=words[i];
        function<string(int,int)> rec=[&](int state,int v){
            string& res=dp[state][v];
            if(res!=infstr) return res;
            for(int u=0; u<words.size(); ++u) if(u!=v and (state>>u)&1){
                const string& tmp=rec(state&~(1<<v),u)+words[v].substr(words[v].size()-graph[u][v]);
                if(tmp.size()<res.size()) res=tmp;
                else if(tmp.size()==res.size()) res=min(res,tmp);
            }
            return res;
        };

        string ans=infstr;
        for(int i=0; i<words.size(); ++i){
            const string& tmp=rec((1<<words.size())-1,i);
            if(tmp.size()<ans.size()) ans=tmp;
            else if(tmp.size()==ans.size()) ans=min(ans,tmp);
        }
        cout << ans << endl;
    }
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3692
(defvar N (read))
(defparameter B+HB (make-hash-table :test #'equal))

(defun incf-hash (x ht)
  (if #1=(gethash x ht)
      (incf #1#)
      (setf #1# 1)))

(princ 
 (loop for A from 1 to N with HA
       do (setf HA (read))
       sum (or (gethash (- A HA) B+HB) 0)
       do (incf-hash (+ A HA) B+HB)))

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

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;
    for (int i = 0; i < A; i++) {
        if (!isdigit(S[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (S[A] != '-') {
        cout << "No" << endl;
        return 0;
    }
    for (int i = A + 1; i < A + 1 + B; i++) {
        if (!isdigit(S[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Two Abbreviations
https://atcoder.jp/contests/agc028/tasks/agc028_a

"""
import sys

from fractions import gcd

def solve(N, M, S, T):
    lcm = N * M // gcd(N, M)
    res = dict()
    for i, s in zip(range(0, lcm+1, lcm//N), S):
        res[i] = s
    for j, t in zip(range(0, lcm+1, lcm//M), T):
        if j in res and res[j] != t:
            return -1
    return lcm


def main(args):
    N, M = map(int, input().split())
    S = input()
    T = input()
    ans = solve(N, M, S, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 75500
#include <cstdio>

int main() {
	int n, h, w;
	scanf("%d%d%d", &n, &h, &w);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a >= h && b >= w) {
			cnt++;
		}
	}
	printf("%d", cnt);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char x,y;
	while(~scanf(" %c %c",&x,&y)){
		if(x<y) printf("<\n");
		else if(x>y) printf(">\n");
		else printf("=\n");
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Queue;
import java.util.ArrayDeque;



class Main {

    static class aaa {
        public int id;
        public int dis;
    }

    static int n;

    static int[][] graph;

    static int[] d,fin;
 
    static void bfs(int start){
        aaa a,b,c;
        c = new aaa();
        Queue<aaa> queue = new ArrayDeque<aaa>();
        c.id = start;c.dis = 0;
        queue.add(c);

        while(true){
            a = new aaa();
            a = queue.poll();
            //System.out.println(a.id + "  " + fin[a.id]);

            if(a == null)
                break;

            if(fin[a.id] == 1)
                continue;

            d[a.id] = a.dis;

            for(int i = 0;i < graph[a.id].length;i++){
                b = new aaa();
                b.id = graph[a.id][i];b.dis = a.dis + 1;
                if(fin[b.id] == 0){
                    queue.add(b);
                }
            }
            fin[a.id] = 1;
        }
    }

    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();

        graph = new int[n][];
        d = new int[n];
        fin = new int[n];
        for(int i = 0;i < n;i++){
            fin[i] = 0;
            d[i] = -1;
        }

        for(int i = 0;i < n;i++){
            int u = input.nextInt();
            int k = input.nextInt();
            graph[u - 1] = new int[k];
            for(int j = 0;j < k;j++){
                graph[u - 1][j] = input.nextInt() - 1;
            }
            Arrays.sort(graph[u - 1]);
        }

        bfs(0);

        for(int i = 0;i < n;i++){
            System.out.println((i + 1) + " " + d[i]);
        }
    }
}

Measured memory_bytes: 28132
S = list(input())
K = int(input())
check = 0

for i in range(len(S)):
    if S[i] != "1" :
        tmp = i+1
        check = 1
        break

if check == 0:
    ans = 1
else:
    if tmp > K :
        ans = 1
    else:
        ans = S[tmp-1]

print(ans)

Measured memory_bytes: 3064
input_line = input()
temp = input_line.split()
H, W = int(temp[0]), int(temp[1])
input_line = input()
temp = input_line.split()
h, w = int(temp[0]), int(temp[1])

field = H*W
colored = h*W + w*H - w*h

print(field - colored)

Measured memory_bytes: 3060
type SortDataType=Longint;
function SortCmp(const a,b:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
var
	x,d,id,v,w:Array[1..200000]of Longint;
	n,i,j,r:Longint;
function SortCmp(const a,b:SortDataType):Boolean;
begin
	SortCmp:=x[a]>x[b];
end;
begin
	read(n);
	for i:=1 to n do begin
		read(x[i],d[i]);
		id[i]:=i;
	end;
	sort(id,n);
	j:=1;
	v[1]:=2000000000;
	w[1]:=1;
	r:=1;
	for i:=1 to n do begin
		while v[j]<x[id[i]]+d[id[i]]do dec(j);
		r:=(r+w[j])mod 998244353;
		inc(j);
		v[j]:=x[id[i]];
		w[j]:=r;
	end;
	writeln(r);
end.


Measured memory_bytes: 3200
def main():
    N, K = (int(_) for _ in input().split())
    snuke = set(range(1, N+1))
    okashi = []
    for _ in range(K):
        d = int(input())
        okashi += [int(_) for _ in input().split()]
    snuke = snuke - set(okashi)
    print(len(snuke))
    return



if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
ans = [0] * 10000
N, X, Y = map(int, input().split())
for i in range(1, N):
    for j in range(i+1, N+1):
        l = min(j - i, abs(X-i) + abs(Y-j) + 1)
        ans[l] += 1
for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 47324
#include <stdio.h>
#include <string.h>
int main(){
  char moji[200000];
  int i=0,len;
  scanf("%s",moji);
  len=strlen(moji);
  while(moji[i]!='A')i++;
  while(moji[len]!='Z')len--;
  printf("%d",len-i+1);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int f (int n) {
    int ret = 0;
    while (n != 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << (n % f(n) ? "No\n" : "Yes\n");   
    return 0;
}

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

int main() {
    int K,X;
    cin >> K >> X;
    int min,max;
    min = X - (K - 1);
    max = X + (K - 1);
    for (int i = 0; i < max - min + 1; i++) {
        cout << min + i << " ";
    }
    
}

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

int main() {

	/* ----- 変数宣言 ----- */

	int n;
	cin >> n;

	vector<int> c(n - 1), s(n - 1), f(n - 1);
	int x;
	int next;
	int j;
	int i;
	int ans = 0;

	/* ----- 入力 ----- */
	for (i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	/* ----- 計算 ----- */
	for (i = 0; i < n; i++) {
		for (x = i; x < n-1; x++) {
			
			// 次に電車が来るのは
			next = s[x];

			for (j = 0; next < ans; j++) {
				next += f[x];
			}

			// 電車に乗る
			ans = next;

			// 電車でかかる時間
			ans += c[x];

		}
		cout << ans << endl;
		ans = 0;
	}

	
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;


int main(void){
    ll s,w;
    cin>>s>>w;
    if(w >= s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int b;

	cin >> b;

	cout << a[b - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    ll t=(h2-h1)*60+m2-m1;
    if(t<0)
    {
        t=60*24-t;
    }
    cout<<t-k<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15524
A, B = map(int, input().split())
count = 0
for num in range(A, B+1):
    num = str(num)
    search_range = len(num)//2+len(num)%2
    for num_i in range(search_range):
#         print(num[num_i], num[(-1)*num_i - 1])
        if num[num_i] != num[(-1)*num_i - 1]:
            break
        if num_i == search_range -1:
            count += 1
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,t,a[100005];
bool able[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>t;
		able[t+1]=1;
	}
	n++;
	a[1]=1;
	for(int i=2;i<=n;i++){
		if(able[i]){
			continue;
		}
		a[i]=((long long)(a[i-1])+a[i-2])%1000000007;
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 768
import math
N = int(input())

# 素数がどうか判定
flag = 0
for i in range(2, int(math.sqrt(N))+1, 1):
  if N % i == 0:
    flag = 1
    break
if flag == 0:
  print(N-1)
else:
  res = 0
  idx = int(math.sqrt(N))
  for i in range(idx, 0, -1):
    if N % i == 0:
      res = i + int(N/i) - 2
      print(res)
      break

Measured memory_bytes: 3064
s=0
R=[]
N,K=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
import collections
c=collections.Counter(A).most_common()
# for i in c.values():
#     R.append(i)
if len(c)>K:
    for i in range(K):
        s+=c[i][1]
    print(N-s)
else:
    print("0")

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

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  rep(i, N) {
    if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
      std::cout << "DENIED" << '\n';
      return 0;
    }
  }

  std::cout << "APPROVED" << '\n';
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	max, min := 0, 0
	if a > b {
		max, min = a, b
	} else {
		max, min = b, a
	}
	diff := max - min
	switch {
	case diff == 0:
		fmt.Println(2 * max)
	default:
		fmt.Println(max + (max - 1))
	}
}


Measured memory_bytes: 512