akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=105;
int mp[MAXN][MAXN],n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)mp[i][j]=1;
	int cnt=n*(n-1)/2;
	if(!(n&1))for(int i=1;2*i<=n;i++)mp[i][n-i+1]=0,cnt--;
	else for(int i=1;2*i<n;i++)mp[i][n-i]=0,cnt--;
	pr2(cnt);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)if(mp[i][j])pr1(i),pr2(j);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        String[] strArray = s.split("");
        String strK = strArray[k-1];
        
        for( int i=0 ; i<n ; i++ ) {
            if( !(strArray[i].equals(strK)) ) strArray[i] = "*";
        }

        System.out.println(String.join("", strArray));
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;

const ull INF = 1e18;
const ll MOD = 1e9 + 7;

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

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

int main() {
  ll a; long double b;
  cin >> a >> b;

  ll ans = floor((long double)a * b);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int dfs(int v,int N,bool visited[10],int gp[10][10]){
  bool all_visited=true;

  for(int i=0;i<N;++i){
    if(visited[i]==false){
      all_visited=false;
    }
  }

  if(all_visited){
    return 1;
  }

  int ret=0;

  for(int i=0;i<N;++i){
    if(gp[v][i]==0 || visited[i]){
      continue;
    }
    visited[i]=true;
    ret+=dfs(i,N,visited,gp);
    visited[i]=false;
  }
  return ret;
}

int main(){
  int N,M,a,b;
  cin>>N>>M;
  int gp[10][10]={};
  //グラフを設定
  for(int i=0;i<M;++i){
    cin>>a>>b;
    gp[a-1][b-1]=1;
    gp[b-1][a-1]=1;
  }
  bool visited[10];
  for(int i=0;i<N;++i){
    visited[i]=false;
  }
  visited[0]=true;
  cout<<dfs(0,N,visited,gp)<<"\n";
return 0;
}


Measured memory_bytes: 256
import sys,math,collections,itertools,copy,bisect
import numpy as np
input = sys.stdin.readline

N=int(input())
L=sorted(list(map(int,input().split())))

ans = 0
for a in range(N):
    for b in range(a+1,N):
        cmax = L[a]+L[b]
        ci = bisect.bisect_left(L,cmax)
        ans += ci-b-1
print(ans)
        

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

int main(){
  int c = 0, n; cin>>n;
  for(int i=1;i<=n;i++) if((int)log10(i)%2==0) c++;
  // for(int i=1;i<=n;i++) if(to_string(i).size()%2) c++;
  cout<< c <<endl;
}

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

void solve(vector<vector<char>>& paper) {
    // + 変換
    for (int j = 1; j < paper[0].size(); j++) {
        for (int i = 0; i < paper.size(); i++) {
            if (paper[i][j - 1] == '.' && paper[i][j] != '.') {
                paper[i][j - 1] = '+';
            }
        }
    }

    // // | 変換
    for (int i = 0; i < paper[0].size(); i++) {
        for (int left = 0; left < paper.size() - 1; left++) {
            if (paper[left][i] != '+') continue;
            int right = left + 1;
            while (right < paper.size() - 1 && paper[right][i] == '.') {
                right++;
            }
            if (paper[right][i] != '+') continue;
            for (int j = left + 1; j < right; j++) {
                paper[j][i] = '|';
            }
        }
    }

    // 残りのドットをスペースにする。
    for (int i = 0; i < paper.size(); i++) {
        for (int j = 0; j < paper[i].size(); j++) {
            if (paper[i][j] == '.') {
                paper[i][j] = ' ';
            }
        }
    }
}

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

    while (1) {
        int N;
        cin >> N;
        if (!N) break;
        vector<vector<char>> paper(N, vector<char>(1100, '#'));
        string tmp;
        for (int i = 0; i < N; i++) {
            cin >> tmp;
            for (int j = 0; j < tmp.size(); j++) {
                paper[i][j] = tmp[j];
            }
        }
        solve(paper);
        for (auto i : paper) {
            for (auto j : i) {
                if (j == '#') break;
                cout << j;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 4140
#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, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#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 <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, k;
    cin >> m >> k;
    if (m == 0) {
        if (k == 0) cout << "0 0\n";
        else cout << "-1\n";
    } else if (m == 1) {
        if (k == 0) cout << "0 1 1 0\n";
        else cout << "-1\n";
    } else {
        if (k < (1 << m)) {
            rep (i, (1 << m)) if (i != k) cout << i << " ";
            cout << k << " ";
            reprev (i, (1 << m)) if (i != k) cout << i << " ";
            cout << k << "\n";
        } else {
            cout << "-1\n";
        }
    }
    return 0;
}

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

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T resL = def;
        T resR = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ resL = operate(resL, mVal[offset+l-1]); l++; }
            if(r&1){ resR = operate(mVal[offset+r-2], resR); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return operate(resL, resR);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return max(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
};

int main(){
    int N, K; cin >> N >> K;
    SegTree<int> seg(300001, 0);
    for(int i=0;i<N;i++){
        int A; cin >> A;
        int cur = seg.get(A-K, A+K+1);
        seg.update(A, cur+1);
    }
    cout << seg.get(0, 300001) << endl;
}

Measured memory_bytes: 7480
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    n = I()
    if n == 1:
        print("Hello World")
    else:
        a,b = IR(2)
        print(a+b)
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                if h > 0:
                    H = abs(x-cx)+abs(y-cy)+h
                    break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    def factorize(n):
        if n == 1:
            return [1]
        if n<4:
            return [1,n]
        l = [1,n]
        m = n
        z = 2
        while z**2 <= n:
            if m%z == 0:
                l.append(z)
                if m//z != z:
                    l.append(m//z)
            z += 1
        l = list(set(l))
        l.sort()
        return l

    n,m = LI()
    l = factorize(m)
    for i in l[::-1]:
        if n*i <= m:
            print(i)
            quit()

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38640
using System;

namespace _0626
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			long[,] joi = new long[n + 1, 3];
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < 3; j++) joi[i + 1, j] = joi[i, j];
				switch (s[i])
				{
					case 'J': { joi[i + 1, 0]++; break; }
					case 'O': { joi[i + 1, 1]++; break; }
					case 'I': { joi[i + 1, 2]++; break; }
				}
			}
			long ret = 0; long max = 0; long jcount = 0; long icount = 0;
			for (int i = 0; i < n; i++)
			{
				long x = joi[i + 1, 0] * (joi[n, 2] - joi[i + 1, 2]);
				if (s[i] == 'O')
				{
					jcount += joi[i + 1, 0]; icount += joi[n, 2] - joi[i + 1, 2];
					ret += x;
				}
				max = Math.Max(max, x);
			}
			Console.WriteLine(ret + Math.Max(max, Math.Max(jcount, icount)));
		}
	}
}


Measured memory_bytes: 20168
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 typedef struct
 {
   double x,y;        
 }Point;
 
 Point A1,A2,B1,B2;
 Point A1B1,B2B1,A2A1,B2A1;
 
 double xx(Point &s,Point &t)
 {
   return (s.x*t.y+s.y*t.x);       
 }
 
 int kua()
 {
   A1B1.x=A1.x-B1.x;
   A1B1.y=A1.y-B1.y;
   B2B1.x=B2.x-B1.x;
   B2B1.y=B2.y-B1.y;
   A2A1.x=A2.x-A1.x;
   A2A1.y=A2.y-A1.y;
   B2A1.x=B2.x-A1.x;
   B2A1.y=B2.y-A1.y;
   if(xx(A1B1,B2B1)*xx(B2B1,A2A1)>=0)
   {
     A1B1.y=-A1B1.y;
     A1B1.x=-A1B1.x;
     if(xx(A1B1,A2A1)*xx(A2A1,B2A1)>=0) return 1;
     else return 0;                                  
   }    
   else return 0;
 }

 int main()
 {
   Point A1,A2,B1,B2;
   while(cin>>A1.x>>A1.y>>A2.x>>A2.y>>B1.x>>B1.y>>B2.x>>B2.y)
   {
     if(min(A1.x,A2.x)<=max(B1.x,B2.x)&&
        min(B1.x,B2.x)<=max(A1.x,A2.x)&&
        min(A1.y,A2.y)<=max(B1.y,B2.y)&&
        min(B1.y,B2.y)<=max(A1.y,A2.y))
      {
        //if(kua()) cout<<"YES"<<endl;
        cout<<"YES"<<endl;                                 
      }                       
      else cout<<"NO"<<endl;                                   
   }   
   //while(1);
   return 0;
 }

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  string S;
  char s[3];
  cin >> S;
  for(int i=0; i < S.length(); ++i){
    s[i] = S[i];
  }
  sort(s, s+3);
  S = s;
  if(S.find("abc") != string::npos){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	int ans = N / 2;
	if (N % 2 == 0)--ans;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int r = N % 10;
        if (r == 3) System.out.print("bon");
        else if (r <= 1 || r == 6 || r == 8) System.out.print("pon");
        else System.out.print("hon");
    }
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define X real()
#define Y imag()
#define PB push_back 
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef complex<int> cld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut,pr> ppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef vector<ppr> Vppr;
const int SIZE=101;
const LL p=7+1e+9;
int able[SIZE];
int size[SIZE];
int main(){
	int N,M,x,p;
	cin >>N >> M;
	REP(i,M){
		cin >> x >> p;
		able[x]=max(able[x],p);
	}
	REP(x,N)
		able[(x+1)%N]=max(able[x]-1,able[(x+1)%N]);
	REP(x,N)
		able[(x+1)%N]=max(able[x]-1,able[(x+1)%N]);
	int ans=0,now=0;
	bool first=true;
	REP(i,N*2){
		if(able[i%N]){
			if(first&&i<N) continue;
			now++;	
		} 
		else{
			first=false;
			size[now]++;
			now=0;
			if(i>=N) break;
		} 
	}
	if(first)
		cout << N << " " << 1 << endl;
	REP(i,N){
		int k=N-i;
		if(size[k]){
			cout << k <<" " << size[k] << endl;
		}
	}

}


Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp(i, m)        for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rpp(i ,m)       for(int i = 1; i <= m; ++i)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())

#define fi              first
#define se              second
#define u_map           unordered_map
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             2000000000
#define ool             2000000000000000000
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define vll             vector<ll>
#define vpll            vector<pll>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1e5 + 10;



int n, k, m, query;

void Solve(){
    cin >> n >> m;
    n = (1 << n) - 1;
    vector<int> f(n + 1);
    f.assign(n + 1, ooi); f[0] = 0;
    Rpp(i, m){
        int cost, bitmask = 0, index;
        cin >> cost >> k;
        while(k--){
            cin >> index;
            bitmask = bitmask | (1 << (index - 1));
        }
        Rp(i, n){
            f[bitmask | i] = min(f[bitmask | i], f[i] + cost);
        }
    }
    if(f[n] < ooi) cout << f[n];
    else cout << -1;
}

int main(){
    speed;
    cout << fixed << setprecision(10);
    Solve();
}

















Measured memory_bytes: 256
import types

_atcoder_code = """
# Python port of AtCoder Library.

__version__ = '0.0.1'
"""

atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)

_atcoder_dsu_code = """
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
"""

atcoder.dsu = types.ModuleType('atcoder.dsu')
exec(_atcoder_dsu_code, atcoder.dsu.__dict__)
DSU = atcoder.dsu.DSU

# https://atcoder.jp/contests/practice2/tasks/practice2_a

# from atcoder.dsu import DSU


def main() -> None:
    import sys

    n, q = map(int, sys.stdin.readline().split())
    dsu = DSU(n)

    for _ in range(q):
        t, u, v = map(int, sys.stdin.readline().split())
        if t == 0:
            dsu.merge(u, v)
        if t == 1:
            if dsu.same(u, v):
                print(1)
            else:
                print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13148
W, H, N = (int(i) for i in input().split())
points = [[int(i) for i in input().split()] for i in range(N)]
low_left_x = 0
low_left_y = 0
s = 0
j = 0

for j in range(N):
    if(points[j][2] == 1): #blanking left
        if(points[j][0] > low_left_x):
            low_left_x = points[j][0]
    elif(points[j][2] == 2): #blanking right
        if(points[j][0] < W):
            W = points[j][0]
    elif(points[j][2] == 3): #blanking low
        if(points[j][1] > low_left_y):
            low_left_y = points[j][1]
    elif(points[j][2] == 4): #blanking high
        if(points[j][1] < H):
            H = points[j][1]
    
    if(W < low_left_x):
        W = low_left_x
    if(H < low_left_y):
        H = low_left_y

s = (W - low_left_x) * (H - low_left_y)
print(s)

Measured memory_bytes: 3064
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = input()
    A = [int(i) for i in input().split()]
    even = list(filter(lambda x: x % 2 == 0, A))
    print('APPROVED' if len(even) == len(list(filter(lambda x: x % 3 == 0 or x % 5 == 0, even))) else 'DENIED')

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n;

int ketawa(int x){
    int ret = 0;
    while(x){
        ret += x%10;
        x /= 10;
    }
    return ret;
}

int main(){
    I(n);
    int ret = INT_MAX;
    FOR(i,1,n/2+1){
        int j = n-i;
        int temp = ketawa(i) + ketawa(j);
        ret = min(ret,temp);
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n;
        double tmp;
        n = input.nextInt();
        double[] x = new double[n];
        double[] y = new double[n];
        for (int i = 0; i < n; i++){
            x[i] = input.nextDouble();
        }
        for (int i = 0; i < n; i++){
            y[i] = input.nextDouble();
        }
        for (int i = 0; i < 3; i++){
            tmp = 0;
            for (int j = 0; j < n; j++){
                tmp += Math.pow(Math.abs(x[j] - y[j]),(i+1));
            }
            tmp = Math.pow(tmp,(double)1/(i+1));
            System.out.println(tmp);
        }
        tmp = 0;
        for (int i = 0; i < n; i++){
            tmp = Math.max(tmp,Math.abs(x[i]-y[i]));
        }
        System.out.println(tmp);
    }
}


Measured memory_bytes: 29024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[110];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	ll ans=0;
	ll temp=0;
	rep(i,0,n){
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
			temp++;
			ans=max(ans,temp);
		}else temp=0;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
using System;

namespace Myatcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string ans = "Yes";
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            T = T + T;
            if (!T.Contains(S)) ans = "No";
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  int a = num / 100; 
  int b = num / 10 - (a * 10);
  int c = num - (a * 100) - (b * 10);
  cout << a + b + c << endl;
}

Measured memory_bytes: 3604
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

bool sorted(vector<int> &a) {
  for (size_t i = 0; i < a.size() - 1; ++i) {
    if (a[i] > a[i + 1]) return false;
  }
  return true;
}

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  rep(i, n) {
    rep(j, n) {
      swap(a[i], a[j]);
      if (sorted(a)) {
        print("YES"); return 0;
      }
      swap(a[i], a[j]);
    }
  }
  print("NO");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define BR "\n"
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	long r = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		r += i;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
int main(void) {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  while (a > 0 && c > 0) {
    c -= b;
    if (c <= 0) break;
    a -= d;
  }
  if (a <= 0)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}

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

int main()
{
    int n;
    std::cin>>n;
    double ans = n / 1.08;
    int res = std::ceil(ans);
    int ans2 = res*1.08;
    if(n==ans2)std::cout<<res<<std::endl;
    else std::cout<<":("<<std::endl;
}

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

using namespace std;
typedef long long ll;

const int N=3005,P=1e9+7;

int fac[N],ifac[N];
int fpow(int a,int t){static int r;for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;return r;}
int C(int n,int m){if(n<m)return 0;return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}

int n,m,f[N],L,R,sum[N];
char str[N];

int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",str+1);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(str[i]&1);
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[n]=fpow(fac[n],P-2);
	for(int i=n;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	f[0]=1;
	for(int i=1,l,r;i<=m;i++){
		scanf("%d%d",&l,&r);
		if(r<=R)continue;
		if(R<l){
			int t=0;
			for(int i=0;i<=n;i++)if(f[i])t=(t+(ll)C(R-L+1,i)*f[i])%P,f[i]=0;
			L=l,R=r,f[sum[R]-sum[L-1]]=t;
		}else{
			while(L<l){
				for(int i=1;i<=n;i++)if(f[i])(f[i-1]+=f[i])%=P;
				L++;
			}
			for(int i=R-L+2;i<=n;i++)f[i]=0;
			int t=sum[r]-sum[R];
			for(int i=n,x;i>=0;i--)if(f[i])x=f[i],f[i]=0,f[i+t]=x;
			R=r;
		}
	}
	int t=0;
	for(int i=0;i<=n;i++)if(f[i])t=(t+(ll)f[i]*C(R-L+1,i))%P;
	printf("%d\n",t);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int amount, first, second;
	int mark = 0;
	
	scanf("%d", &amount);
	scanf("%d %d", &first, &second);
	
	for(int i = first; i <= second; i++){
		if(i % amount == 0){
			mark = 1;
		}
	}
	
	if(mark == 1){
		printf("OK\n");
	}else{
		printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 3172
mod = 1000000007


def fexp(x, y):
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = ans * x % mod
        x = x * x % mod
        y //= 2
    return ans


n = int(input())
ans = fexp(10, n) - 2 * fexp(9, n) + fexp(8, n)
ans %= mod
if ans < 0:
    ans += mod
print(ans)

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define SCAN_INT(n) scanf("%i",&n)
#define SCAN_P_INT(n,m) scanf("%i %i",&n,&m)
#define PRINT_P_INT(n,m) printf("%i %i\n",n,m);
#define PRINT_INT(n) printf("%i\n",n)


#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 1000000007


#define MAXSIZE 

int n;
int main(){
   
   SCAN_INT(n);
   VI znaki;
   while(n){
		znaki.PB(n%10);
		n/=10;
   }
    int dlugosc = 1;
	for(int i=1;i<SIZE(znaki);i++){
		if(dlugosc !=3){
			if(znaki[i]==znaki[i-1])
				dlugosc++;
			else 
				dlugosc =1;
		}
	}
   
   if(dlugosc==3)
		printf("Yes\n");
	else 
		printf("No\n");
   return 0;
}


Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::cmp;
use std::collections::VecDeque;

fn main() {
    input!(n: usize, k: usize, a: [usize1; n]);
    let mut ans = 0;
    let mut a = a;
    if a[0] != 0 {
        ans += 1;
        a[0] = 0;
    }
    let mut tree = vec![vec![]; n];
    for child in 0..n {
        let parent = a[child];
        tree[parent].push(child);
    }

    let mut dist_from_leaf = vec![0; n];
    let mut finished_count = vec![0; n];
    let mut q = VecDeque::new();
    for i in 0..n {
        if tree[i].is_empty() {
            q.push_back(i);
        }
    }

    while let Some(v) = q.pop_front() {
        let parent = a[v];
        finished_count[parent] += 1;
        if dist_from_leaf[v] == k - 1 {
            if parent != 0 {
                ans += 1;
            }
        } else {
            dist_from_leaf[parent] = cmp::max(dist_from_leaf[parent], dist_from_leaf[v] + 1);
        };

        if finished_count[parent] == tree[parent].len() {
            q.push_back(parent);
        }
    }

    println!("{}", ans);
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 550000

ll n,m;
vector<vector<int>> edges(MAXN, vector<int>());
ll dp1[MAXN];
ll dp2[MAXN];

ll dfs1(int n, int p=-1){
  ll r=1;
  for(auto c: edges[n]){
    if(c==p)continue;
    r *= dfs1(c, n);
    r %= m;
  }
  dp1[n] = r+1;
  return dp1[n];
}

void dfs2(int now, int p=-1){
  if(p==-1)dp2[now]=1;

  int ec = edges[now].size();
  ll pr=1;
  vector<ll> lprod;
  rep(i, ec){
    ll c = edges[now][i];
    if(c==p){
      lprod.push_back(pr);
      continue;
    }
    pr *= dp1[c];
    pr %= m;
    lprod.push_back(pr);
  }

  pr=1;
  vector<ll> rprod;
  rrep(i, ec){
    ll c = edges[now][i];
    
    if(c==p){
      rprod.insert(rprod.begin(), pr);
      continue;
    }
    pr *= dp1[c];
    pr %= m;
    rprod.insert(rprod.begin(), pr);
  }

  rep(i, ec){
    ll c = edges[now][i];
    if(p==c)continue;
    dp2[c] = dp2[now];
    if(i)dp2[c] *= lprod[i-1];
    dp2[c] %= m;
    if(i<ec-1)dp2[c] *= rprod[i+1];
    dp2[c] %= m;
    dp2[c]++;
    dp2[c] %= m;
    dfs2(c, now);

  }
}

vector<ll>ans(MAXN);
void dfs3(int now, int p=-1){
  ans[now] = dp2[now];
  for(auto c:edges[now]){
    if(c==p)continue;

    ans[now] = ans[now]*dp1[c]%m;
    dfs3(c, now);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    int x,y;cin>>x>>y;x--;y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1(0);
  dfs2(0);
  dfs3(0);

  rep(i, n){
    cout<<ans[i]<<endl;
  }

  return 0;

  rep(i, n)cout<<dp1[i]<<' ';cout<<endl;
  rep(i, n)cout<<dp2[i]<<' ';cout<<endl;

  return 0;
}


Measured memory_bytes: 42216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

bool contains(const string &a, const string &b){
	if( a.find( b ) != string::npos ){
		return true;
	}else
		return false;
}

bool mystrcmp(const string &a, const string &b){
	return a.compare(b) < 0;
}

bool strless(const string &a, const string &b){
	if( a.length() < b.length() )
		return true;
	else if( a.length() == b.length() && mystrcmp( a, b ) )
		return true;
	else
		return false;
}

string overwrap( const string &a, const string &b ){
	unsigned int len = 0;
	unsigned int min_len = min( a.length(), b.length() );
	string ret = a;
	
	for(unsigned int i = min_len; i >= 1; --i){
		bool bOk = true;
		for(unsigned int j = 0; j < i; ++j){
			if( a[ a.length() - i + j ] != b[ j ] ){
				bOk = false;
			}
		}
		if( bOk ){
			len = i;
			break;
		}
	}

	ret += b.c_str() + len;

	return ret;
}

void solve( vector< string > &vs, string &ans ){
	sort( vs.begin(), vs.end(), mystrcmp );
	
	for(unsigned int i = 0; i < vs.size(); ++i){
		for(unsigned int j = 0; j < vs.size(); ++j){
			if( i != j ){
				if( contains( vs[i], vs[j] ) ){
					vs.erase( vs.begin() + j );
					i = -1;
					break;
				}
			}
		}
	}

	for(unsigned int i = 0; i < vs.size(); ++i){
		for(unsigned int j = 0; j < vs.size(); ++j){
			if( i != j ){
				int diff = (vs[i]+vs[j]).length() - (overwrap(vs[i],vs[j])).length();
				if( diff > 0 ){
					vector<string> tvs(vs.begin(),vs.end());
					
					tvs[i]=overwrap(tvs[i],tvs[j]);
					tvs.erase( tvs.begin() + j );
					solve( tvs, ans );
				}
			}
		}
	}		
	
	for(unsigned int i = 1; i < vs.size(); ++i){
		vs[0] += vs[i];
	}

	if( strless( vs[0], ans ) )
		ans = vs[0];
}

int main(){
	while(true){
		int n;
		string ans;
		vector<string> vs;
		
		scanf("%d", &n);

		if( n == 0 )
			break;

		for(int i = 0; i < n; ++i){
			string s;
			cin>>s;
			vs.push_back(s);
			ans+=s;
		}

		solve( vs, ans );

		cout << ans << endl;
	}
	return 0;
}

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

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

  int k;
  string s;
  cin >> k >> s;

  if (k >= s.size())
  {
    cout << s << endl;
    return 0;
  }

  cout << s.substr(0, k) << "..." << endl;
  
  return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	bool flag = (n%2 ? false : true);
	for(int i = 0; i < n/2; i++){
		if(s[i] != s[n/2+i]) flag = false;
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

#define MIN(X,Y) ((X<Y)?(X):(Y))

int main(void) {
    while(true) {
        int n,m,dis[11]={};
        scanf("%d%d",&n,&m);
        if(!n) break;
        for(int i=0; i<n; i++) {
            int d,p;
            scanf("%d%d",&d,&p);
            dis[p] += d;
        }

        for(int i=10; i; i--) {
            int k = MIN(dis[i], m);
            dis[i] -= k;
            m -= k;
        }

        int res=0;
        for(int i=0; i<=10; i++) {
            res += dis[i] * i;
        }

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

    return 0;
}

Measured memory_bytes: 1032
n, m, l = gets.chop.split(' ').map(&:to_i)

a = Array.new(n).map{Array.new(m, 0)}
b = Array.new(m).map{Array.new(l, 0)}
c = Array.new(n).map{Array.new(l, 0)}

0.step n-1 do |ni|
  row = gets.chop.split(' ').map(&:to_i)
  0.step m-1 do |mi|
    a[ni][mi] = row[mi]
  end
end

0.step m-1 do |mi|
  row = gets.chop.split(' ').map(&:to_i)
  0.step l-1 do |li|
    b[mi][li] = row[li]
  end
end

0.step n-1 do |i|
  0.step l-1 do |j|
    0.step m - 1 do |k|
      c[i][j] += a[i][k] * b[k][j]
    end
  end
end

c.each do |row|
  row.each_with_index do |num,index|
    print num
    if index != l-1
      print ' '
    end
  end
  puts ''
end



Measured memory_bytes: 7424
a, b, c = list(map(int, input().split()))
l = [a, b, c]


time_of_exchange = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
	
	if a == b == c:
		time_of_exchange = -1
		break
	
	a = (l[1] + l[2]) / 2
	b = (l[0] + l[2]) / 2
	c = (l[0] + l[1]) / 2
	l = [a, b, c]
	
	time_of_exchange += 1
	
print(time_of_exchange)



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

using namespace std;
long long N,k,GCD,mmax,QAQ;
int main(){
	cin >> N >> k >> GCD;
	mmax=GCD;
	for(int i=1;i<N;i++){
		cin >> QAQ;
		mmax=max(mmax,QAQ);
		GCD=__gcd(GCD,QAQ);
	}
	if(!(k%GCD) && k<=mmax)
		cout << "POSSIBLE" << endl;
	else 
		cout << "IMPOSSIBLE" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

uint64_t base = 1000000007;

template<typename T>
T power(T a, int b){
    T ret = 1;
    for(int i=0; i<b; i++){
        ret*=a;
    }
    return ret;
}

vector<uint64_t> make_hash(string &S, int N){
    vector<uint64_t> hash_((int)S.size(),0);
    for(int i=0; i<N; i++){
        hash_[0]*=base;
        hash_[0]+=(uint64_t) S[i]-'a';
    }
    uint64_t baseN=power(base, N);
    for(int i=1; i+N-1<(int)S.size(); i++){
        hash_[i]=hash_[i-1]*base-(S[i-1]-'a')*baseN+(S[i+N-1]-'a');
    }
    return hash_;
}

int RK(vector<uint64_t> &thash, int N){
    map<uint64_t, int> mp;
    for(int i=0; i<(int)thash.size(); i++){
        if(i+N-1>thash.size()){
            break;
        }
        if(mp.count(thash[i])==0){
            mp[thash[i]]=i;
        }else if(mp[thash[i]]+N<=i){
            return i;
        }
    }
    return -1;
}

int bin_search(int l, int r, string &S){
    int mid=(l+r)/2;

    if(mid==l){
        return l;
    }

    vector<uint64_t> thash = make_hash(S, mid);
    if(RK(thash, mid)==-1){
        return bin_search(l, mid, S);
    }else{
        return bin_search(mid, r, S);
    }
}

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

    cout << bin_search(0, (int)S.size(), S) << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long ans = 0L;
		long[] cnt = new long[100001];
		for(int i = 0; i < n; i++) {
			int cur = in.nextInt();
			cnt[cur] += 1;
			ans += cur;
		}
		int q = in.nextInt();
		for(int i = 0; i < q; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			long cnt_rem = cnt[a];
			if(cnt[a] >= 0) {
				long rem = cnt_rem * a;
				ans -= rem;
				ans += cnt_rem * b;
				cnt[b] += cnt[a];
				cnt[a] = 0;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 62076
class Field:

    def __init__(self, N):
        self.N = N
        self.row = [-1 for _ in range(N)]
        self.hold = []
        self.col = [0 for _ in range(N)]
        self.dpos = [0 for _ in range(2*N - 1)]
        self.dneg = [0 for _ in range(2*N - 1)]

    def putQueen(self, i):
        if i in self.hold:
            self.putQueen(i + 1)
            return 
        if i == self.N:
            self.printBoard()
            return
        for j in range(self.N):
            if self.col[j] or self.dpos[i+j] or self.dneg[i-j+self.N-1]:
                continue
            self.setQueen(i, j)
            self.putQueen(i + 1)
            self.col[j] = self.dpos[i+j] = self.dneg[i-j+self.N-1] = 0

    def setQueen(self, i, j):
        self.row[i] = j
        self.col[j] = self.dpos[i + j] = self.dneg[i - j + self.N - 1] = 1

    def printBoard(self):
        print('\n'.join("." * r + "Q" + "." * (self.N - r - 1) for r in self.row))


if __name__ == "__main__":
    field = Field(8)
    for _ in range(int(input())):
        i, j = (map(int, input().split()))
        field.setQueen(i, j)
        field.hold.append(i)
    field.putQueen(0)


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <queue>

int main() {
  unsigned int N, M;
  std::cin >> N >> M;

  std::priority_queue<unsigned int> A_que;
  for (unsigned int i = 0; i < N; ++i) {
    unsigned int A;
    std::cin >> A;
    A_que.push(A);
  }

  for (unsigned int i = 0; i < M; ++i) {
    unsigned int cost = A_que.top();
    A_que.pop();
    A_que.push(cost / 2);
  }

  unsigned long sum = 0;
  for (unsigned int i = 0; i < N; ++i) {
    sum += A_que.top();
    A_que.pop();
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 892
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	var sum int
	if a >= k {
		fmt.Println(k)
		return
	} else {
		sum += a
		k = k - a
	}
	if b >= k {
		fmt.Println(sum)
		return
	} else {
		k = k - b
	}
	fmt.Println(sum - k)
}


Measured memory_bytes: 1752
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
string s;
int main(){
    cin>>s;
    if( (s[0]==s[s.size()-1]) == (s.size()%2) ){
        cout<<"Second";
    }else{
        cout<<"First";
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int a[n+1];
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    a[0] = a[1];
    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        int ans = INT_MAX;
        for(int j = i - 1; j >= max((i - k),0); j--){
            ans = min(ans, dp[j] + abs(a[j] - a[i]));
        }
        dp[i] = ans;
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll tak = (c+b-1)/b, aok = (a+d-1)/d;
    Ans(tak <= aok);
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  
  int N,cal;
  vector<int> Ldata(100010);
  vector<int> Rdata(100010);
  int max1 = 0;
  int max2 = 0;
  int judge = 199999;
  
    cin >> N;
    //cin >> M;
    
    for(int g = 0; g<N ; g++){
      
    cin>>Ldata.at(g);
    //cin>>Rdata.at(g);
    
    }
  
 
  
  for (int T = 0; T < N-1 ; T++) {
    for (int f = 0; f < N; f++) {
      if(f <= T){
        max1 += Ldata.at(f);
      }
      else{
        max2 += Ldata.at(f);
      }
    
      
    }
    cal = max1-max2;
    cal = abs(cal);
    max1 = 0;
    max2 = 0;
  // cout << cal << endl;
    
    if(judge >= cal ){
      judge = cal;
    }
  }
  
  
  
 
  
  cout << judge << endl;
  
}
  
 

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Z, W, a[2009];
int main() {
	cin >> N >> Z >> W;
	for (int i = 0; i < N; i++) cin >> a[i];
	cout << max(abs(W - a[N - 1]), (N >= 2 ? abs(a[N - 2] - a[N - 1]) : 0)) << endl;
	return 0;
}

Measured memory_bytes: 256