akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll q, h, s, d, n; cin >> q >> h >> s >> d >> n;
	chmin(h, q * 2);
	chmin(s, h * 2);
	chmin(d, s * 2);
	cout << n / 2 * d + n % 2 * s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,a,b; cin >> n >> a >> b;
    if(a+b-1>n||a*b<n){
        cout << -1 << endl;
    }
    else {
        vector<int> ans;
        int cnt=(n-a)/(b-1);
        rep(i,a){
            ans.pb(n-a+1+i);
        }
        int mxm=n-a;
        rep(i,b-1){
            //b-1-i区間
            int len=min(a,mxm-(b-1-i)+1);
            rep(j,len){
                ans.pb(mxm-len+j+1);
            }
            mxm-=len;
        }
        for(auto u:ans) cout << u << " ";
    }
    
}


Measured memory_bytes: 5264
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	long long a,b=0,c=200010,e=0,f=0,g[200010],i;
	char d[200010];
	scanf("%lld",&a);
	scanf("%s",d);
	for(i=0;i<a;i++){
		if(d[i]=='.'){
			b++;
		}
	}
	g[0]=0;
	for(i=0;i<a;i++){
		if(d[i]=='.'){
			g[i+1]=g[i]+1;
		}else{
			g[i+1]=g[i];
		}
	}
	for(i=0;i<a+1;i++){
		e=i-g[i]+b-g[i];
		if(e<c) c=e;
	}
	printf("%lld",c);
	return 0;
}
		

Measured memory_bytes: 1920
N = int(input())
sp = {}

for i in range(N):
    S,P = input().split()
    if S not in sp:
        sp[S] = [[int(P),i+1]]
    else:
        sp[S].append([int(P),i+1])

#print(sp)
sp = sorted(sp.items(), key=lambda x:x[0])
#print(sp)

for key,v in sp:
    v.sort()
    v.reverse()
    for i in range(len(v)):
        print(v[i][1])

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(long i=0;i<(long)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int MOD;
static inline int MPow(long a,long b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
int main()
{
  long N=IN(),calc=0;int X=IN(),vis[100001];
  MOD=IN();int val[100001];
  if(N<=MOD){rep(i,N){calc+=X;X=MPow(X,2);}return OUT(calc),0;}
  else
  {
    rep(i,MOD+1)
    {
      val[i+1]=X;
      if(vis[X])
      {
        rep(j,vis[X]){calc+=val[j+1];}
        int k=vis[X]+1;while(k<=i+1){calc+=1l*(N-vis[X]+i+1-k)/(i+1-vis[X])*val[k];k++;}
        return OUT(calc),0;
      }
      vis[X]=i+1;X=MPow(X,2);
    }	
  }
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int m;
	cin >> m;
	cout << 48 - m << endl;
	return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
tmp = A[0]
A = [a - A[0] for a in A]
A.append(K)
# print(A)
s = 0
mx = -1
for i in range(N):
    s += A[i+1] - A[i]
    mx = max(mx, A[i+1] - A[i])

print(s - mx)


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

typedef struct List {
	struct List *prev, *next;
	char c;
} list;

int main()
{
	int i, Q, T[200001], F[200001];
	char S[100001] = {}, C[200001] = {};
	scanf("%s", S);
	scanf("%d", &Q);
	for (i = 1; i <= Q; i++) {
		scanf("%d", &(T[i]));
		if (T[i] == 2) scanf("%d %c", &(F[i]), &(C[i]));
	}
	
	int l, flip = 0;
	list data[300001] = {}, *head = &(data[0]), *tail, *p;
	data[0].prev = NULL;
	data[0].c = S[0];
	for (l = 1; S[l] != 0; l++) {
		data[l].prev = &(data[l-1]);
		data[l-1].next = &(data[l]);
		data[l].c = S[l];
	}
	data[l-1].next = NULL;
	data[l-1].c = S[l-1];
	tail = &(data[l-1]);
	
	for (i = 1; i <= Q; i++) {
		if (T[i] == 1) flip ^= 1;
		else {
			data[l+i].c = C[i];
			if ((F[i] + flip) % 2 == 1) {
				data[l+i].prev = NULL;
				data[l+i].next = head;
				head->prev = &(data[l+i]);
				head = &(data[l+i]);
			} else {
				data[l+i].prev = tail;
				data[l+i].next = NULL;
				tail->next = &(data[l+i]);
				tail = &(data[l+i]);
			}
		}
	}
	
	if (flip == 0) {
		for (p = head; p != NULL; p = p->next) printf("%c", p->c);
	} else {
		for (p = tail; p != NULL; p = p->prev) printf("%c", p->c);
	}
	printf("\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 9344
def examD():
    N = I();  S = SI()
    dp = [[0]*10 for _ in range(N+1)]
    for i in range(N):
        for j in range(10):
            dp[i+1][j] = dp[i][j]
        dp[i+1][int(S[i])] +=1
    left = [-1]*10; right = [-1]*10
    for i in range(N):
        if left[int(S[i])]==-1:
            left[int(S[i])] = i
    for i in range(N-1,-1,-1):
        if right[int(S[i])]==-1:
            right[int(S[i])] = i
    ans = 0
#    print(left)
#    print(right)
    for i in left:
        if i>=0:
            for j in right:
                if j>=0:
                    for k in range(10):
                        if dp[j][k]>0 and dp[j][k] - dp[i+1][k] > 0:
                            ans += 1
#                            print(S[i],k,S[j])
    print(ans)
    return
def examE(mod):
    N = I()
    A = LI()
    a =[0,0,0]
    cur = 1
    for i in A:
        if a[0]==i:
            if a[0]==a[1]:
                if a[1]==a[2]:
                    cur *= 3
                else:
                    cur *=2
            a[0]+=1
        elif a[1]==i:
            if a[1] == a[2]:
                cur *= 2
            a[1] +=1
        elif a[2]==i:
            a[2]+=1
        else:
            cur *=0
        a.sort(reverse=True)
        cur %=mod
    print(cur)
    return

def examF():
    T = LI()
    A = LI()
    B = LI()
    loop1 = T[0]*(A[0]-B[0])
    loop2 = T[1]*(A[1]-B[1])
    if loop1>0 and loop2>0:
        ans = 0
    elif loop1<0 and loop2<0:
        ans = 0
    else:
        now = loop1
        cur = loop1+loop2
#        print(now,cur)
        if cur!=0:
            ans = abs(now)//abs(cur)*2
            if abs(now)%abs(cur)!=0:
                judge = now + cur*ans//2
                if (now>0 and judge+loop1>0) or (now<0 and judge+loop1<0):
                    ans +=1
        else:
            ans = "infinity"
    print(ans)
    return

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


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

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            read.Sort();
            Console.WriteLine(read.GetRange(0, 2).Sum());
        }
    }
}


Measured memory_bytes: 13396
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    b=[0]*n




    zouka=0


    for i in range(1,n):
        if a[i-1]<a[i]:
            if zouka!=1:
                zouka=1
                b[i-1]=1
        if a[i-1]>a[i]:
            if zouka!=-1:
                zouka=-1
                b[i-1]=-1
        if i==n-1 and zouka!=0:
            b[n-1]=zouka*(-1)

    kab=0
    temo=1000
    for i in range(n):
        if b[i]==1:
            kab += temo // a[i]
            temo -= a[i] * kab
        elif b[i]==-1:
            temo += kab * a[i]
            kab = 0
        if i==n-1 and kab!=0:
            temo += kab * a[i]
            kab = 0

    print(temo)
resolve()

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

const int max_n = 1e5 + 10;

int main()
{
    int n, q, a[max_n];
    string s;
    pair<int, int> lr[max_n];

    cin >> n >> q;
    cin >> s;

    for (int i = 0; i < q; ++i)
    {
        cin >> lr[i].first >> lr[i].second;
        --lr[i].first, --lr[i].second;
    }

    int total = 0;
    a[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
            ++total;
        }
        a[i] = total;
    }

    for (int i = 0; i < q; ++i)
    {
        cout << a[lr[i].second] - a[lr[i].first] << endl;
    }
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		int i = 1;
		//??°?????????
		while(true){
			//????????????
			int x = sc.nextInt();
			if(x == 0){
				break;
			}else{
				//??¨???
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}
}

Measured memory_bytes: 42744
import sys

n, m = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()
lr = zip(*[map(int, sys.stdin.read().split())] * 2)

def main():
    cnt = [0] * n
    for i in range(n - 1):
        cnt[i+1] = s[i:i+2] == 'AC'
    for i in range(n - 1): cnt[i+1] += cnt[i]
    for l, r in lr:
        print(cnt[r-1] - cnt[l-1])

if __name__ ==  '__main__':
    main()

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

int main() {
        int n;
        scanf("%d", &n);
        vector<long long> all;
        vector<long long> x(n);
        for (int i = 0; i < n; i ++) {
                long long s;
                scanf("%lld%lld", &x[i], &s);
                if (i == 0) all.push_back(s);
                else {
                        all.push_back(-(x[i] - x[i - 1]));
                        all.push_back(s);
                }
        }
        n = all.size();
        for (int i = 1; i < n; i ++) all[i] += all[i - 1];
        vector<long long> ma(n); //max of [l, n)
        ma[n - 1] = all[n - 1];
        for (int i = n - 2; i >= 0; i --) ma[i] = max(ma[i + 1], all[i]);
        long long ans = 0;
        ans = max(ans, ma[0]);
        for (int l = 0; l < n - 1; l ++) ans = max(ans, ma[l + 1] - all[l]);
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 9068
#include <stdio.h>

int main(void)
{
  int n, d, a;
  
  scanf("%d%d", &n, &d);
  
  a = n / (2*d+1);
  if (n%(2*d+1)>0) a++;
  
  printf("%d\n", a);
  
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)
def dfs(v):
    if(dp[v]==-1):
        dp[v]=0
        for nv in G[v]:
            dp[v]=max(dp[v],dfs(nv)+1)
    return dp[v]
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)
dp=[-1]*N
res=-1
for v in range(N):
    res=max(res,dfs(v))
print(res)

Measured memory_bytes: 159820
#include<bits/stdc++.h>
using namespace std;
double dp[301][301][301];
double solve(int x,int y,int z,int &n){
	if(x < 0 || y < 0 || z < 0)
    	return 0;
    if(x ==0 && y == 0 && z == 0)
    	return 0;
    if(dp[x][y][z] > -0.9)
    	return dp[x][y][z];
    double e = n + x*solve(x-1,y,z,n) + y*solve(x+1,y-1,z,n) + z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = e/(x+y+z);
}
int main(){
	cout.precision(10);
    cout << fixed;
	int n,i;
	memset(dp,-1,sizeof(dp));
    cin>>n;
    int a[n];
    int one = 0,two = 0,three = 0;
    for(i=0;i<n;++i){
    	cin>>a[i];
        if(a[i] == 1)
        	one ++;
        else if(a[i] == 2)
        	two ++;
        else
        	three++;
    }
    cout<<solve(one,two,three,n)<<"\n";
}


Measured memory_bytes: 213376
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll h1, m1, h2, m2, k, t;
  scanf("%lld%lld%lld%lld%lld", &h1, &m1, &h2, &m2, &k);
  t = (h2 - h1) * 60 + m2 - m1;
  printf("%lld", t - k);
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int cnt=1;
  int q=euclidean_gcd(a,b);
  int z=0;
  rep(i,q){
    int y=q-i;
    if(q%y==0){
      z++;
      if(z==k)cout << y << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

template<class A, class B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<class A, class B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

int n;
ll a[100000], b[100000];

int main() {
	cin >> n;
	
	REP(i, n) scanf("%lld %lld", a + i, b + i);
	reverse(a, a + n);
	reverse(b, b + n);
	
	ll ans = 0;
	REP(i, n) {
		a[i] += ans;
		if (a[i] % b[i] == 0) continue;
		
		ll t = (a[i] / b[i] + 1) * b[i];
		ans += t - a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import math
nxy=list(map(int, input().split()))
n=nxy[0]
x=nxy[1]-1
y=nxy[2]-1
ans=[0]*(n-1)
for i in range(0,n):
    for j in range(i+1,n):
        mindis=min(j-i, abs(i-x)+abs(j-y)+1, abs(j-x)+abs(i-y)+1)
        #print(i, j, mindis)
        ans[mindis-1]+=1
for k in range(n-1):
    print(ans[k])

Measured memory_bytes: 47964
#より高速に
def pow(x, n ,p):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (x*K) % p
        x = (x*x) % p
        n //= 2

    return (K * x) % p




def cmb3(n,r,q):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)    
    s = 1
    for x in range(n,n-r,-1):
        s = (s*x) % q
    t = 1
    for x in range(1,r+1):
        t = (t*x) % q

    #割る数の剰余をどうするかが問題
    u = pow(t,q-2,q)
    return (u * s) % q
  
n,a,b = map(int,input().split())
A = pow(2,n,10**9+7)

if a <= n:
  B = cmb3(n,a,10**9+7)
else:
  B = 0
if b <= n:
  C = cmb3(n,b,10**9+7)
else:
  C = 0

print((A-B-C-1)%(10**9+7))

  

Measured memory_bytes: 9212
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    long[] cums;
    int[long] cnt;
    long ret;
    cums.length = N;
    foreach (i, a; AS) {
        if (i == 0) {
            cums[i] = a;
        } else {
            cums[i] = cums[i-1] + a;
        }
        if (cums[i] in cnt) {
            ++cnt[cums[i]];
        } else {
            cnt[cums[i]] = 0;
        }
        if (!cums[i]) ++ret;
    }

    foreach (c; cums) {
        if (c in cnt) {
            ret += cnt[c];
            --cnt[c];
        }
    }

    writeln(ret);
}

Measured memory_bytes: 30092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var dict = new Dictionary<char, char>();
		dict['A'] = 'T';
		dict['T'] = 'A';
		dict['C'] = 'G';
		dict['G'] = 'C';
		WriteLine(dict[GetChar()]);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
    using namespace std;
    const int maxn = 1e6 + 100;
    char s[maxn]; bool mark[maxn];
    int main(){
    int n; cin >> n; int c = 0;
    for(int i = 0 ; i < n ; i++){
        cin >> s[i];
        if(!(int)mark[s[i]]) c++;
        mark[(int)s[i]] = 1; 
    }if(c == 3) cout << "Three";
    else cout << "Four"; return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int m, d, anser = 0;
  cin >> m >> d;
  FOR(i, 1, m + 1) {
    FOR(j, 1, d + 1) {
      int d1 = j % 10, d10 = j / 10 % 10;
      if (d1 >= 2 && d10 >= 2 && d1 * d10 == i ) {
        anser++;
      }
    }
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
def C_BFS(R, C, sy, sx, gy, gx, c):
    """
    R:行数
    C:列数
    sy,sx:スタートの座標(sy行sx列)
    gy,gx:ゴールの座標(gy行gx列)
    c:迷路の形状(.:通路,#:壁)
    """
    INF = float('inf')
    sy -= 1
    sx -= 1
    gy -= 1
    gx -= 1

    def bfs(maze, row, column, sy, sx, gy, gx):
        # 原点は(0,0)とする(問題の制約によっては原点をずらす必要がある)
        queue = []
        queue.insert(0, (sy, sx))
        dist = [[INF for _ in range(column)] for _ in range(row)]
        dist[sy][sx] = 0  # yが行数、xが列数を意味するときはこの順に書く
        # （追記）距離の最大値を持っておく
        dist_max = 0
        while len(queue):
            y, x = queue.pop()
#             if x == gx and y == gy:
#                 # ゴール座標と一致するなら
#                 break
            for i in range(4):
                nx, ny = x + [1, 0, -1, 0][i], y + \
                    [0, 1, 0, -1][i]  # (x,y)の右、上、左、下
                if 0 <= nx and nx < column and 0 <= ny and ny < row \
                        and maze[ny][nx] != '#' and dist[ny][nx] == INF:
                    #(nx,ny)が迷路内であり、壁でなく、まだ距離が確定していないとき
                    queue.insert(0, (ny, nx))  # 次に探索する座標
                    dist[ny][nx] = dist[y][x] + 1
                    # （追記）距離の最大値を更新する
                    if dist_max < dist[ny][nx]:
                        dist_max = dist[ny][nx]
        return dist_max
#         return dist[gy][gx]

    maze = [['' for _ in range(C)] for _ in range(R)]
    for i, tmp in enumerate(c):
        for j in range(C):
            maze[i][j] = tmp[j]

    ans = bfs(maze, R, C, sy, sx, gy, gx)
    return ans

R , C = [int(i) for i in input().split()]
c = [input() for _ in range(R)]

# スタート地点は全て試す
dist_ans = 0
for sy in range(1, R+1):
    for sx in range(1, C+1):
        if c[sy-1][sx-1] != '#':
            dist_tmp = C_BFS(R, C, sy, sx, 1, 1, c) # 今回、 gy, gx は不要
            if dist_ans < dist_tmp:
                dist_ans = dist_tmp
print(dist_ans)

Measured memory_bytes: 3192
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner (System.in);
		//??°?????????????????????
		int n = sc.nextInt();
		//n????????°?????°?????????
		for(int i = 1; i<= n; i++){

			//??????????????°???
			if(i % 3 == 0 || Integer.toString(i).contains("3")){
				System.out.print(" " + i);
			}
		}
		System.out.println();
	}
}

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

int len = 0;
priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> pq;

int ask(string s) {
    cout << "? " << s << endl;
    int ret; cin >> ret; return ret;
}

string repeat(char c, int t) {
    string s = "";
    for (int i = 0; i < t; i++) {
        s += c;
    }
    return s;
}

string merge(string s, string t) {
    string ans = "";
    while (!s.empty() && !t.empty()) {
        string tmp = ans + t[0] + s;
        if (ask(tmp) != len - (int)tmp.size()) {
            ans += s[0];
            s.erase(0, 1);
        } else {
            ans += t[0];
            t.erase(0, 1);
        }
    }
    return ans + s + t;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for (char c = 'a'; c <= 'z'; c++) {
        string s = repeat(c, 128 - ask(repeat(c, 128)));
        len += s.size();
        pq.push({s.size(), s});
    }
    for (char c = 'A'; c <= 'Z'; c++) {
        string s = repeat(c, 128 - ask(repeat(c, 128)));
        len += s.size();
        pq.push({s.size(), s});
    }
    for (char c = '0'; c <= '9'; c++) {
        string s = repeat(c, 128 - ask(repeat(c, 128)));
        len += s.size();
        pq.push({s.size(), s});
    }
    while (pq.size() > 1) {
        string s = pq.top().second; pq.pop();
        string t = pq.top().second; pq.pop();
        string me = merge(s, t);
        pq.push({me.size(), me});
    }
    cout << "! " << pq.top().second << endl;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    if((a == 1 and b == 2) || (a == 2 and b == 1))cout<<3<<endl;
    else if((a == 2 and b == 3) || (a == 3 and b == 2))cout<<1<<endl;
    else cout<<2<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int a = Integer.parseInt(br.readLine());
        br.readLine(); br.readLine(); br.readLine();
        int e = Integer.parseInt(br.readLine());
        int k= Integer.parseInt(br.readLine());
        if(e-a<=k) bw.write("Yay!");
        else bw.write(":(");
        bw.close();

    }
}


Measured memory_bytes: 21332
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(N):
    par[i]=i
    num[i]=0
def find(x):
  if par[x]==x:
    return x
  else:
    return find(par[x])
def unite(x,y):
  if (y<x):
    par[x]=y
  else:
    par[y]=x
def same(x,y):
  return find(x)==find(y)
def cnt(x):
  if par[x]==x:
    res = num[x]
    return res
  else:
    if used[par[x]] == True:
      res = num[x] + ans[par[x]]
      return res
    else:
      return

N,Q = IL()
ab = [IL() for i in range(N-1)]
px = [IL() for i in range(Q)]

par=[0 for i in range(N+1)]
num=[0 for i in range(N+1)]

init(N)

for a,b in ab:
  unite(a,b)

for p,x in px:
  num[p] += x

ans = [0 for i in range(N+1)]
used = [False for i in range(N+1)]
for i in range(1,N+1):
  ans[i] = cnt(i)
  used[i] = True

print(" ".join(map(str,ans[1:])))

Measured memory_bytes: 141532
#include <stdio.h>

int main(void){
  int N;
  char S[100002];
  scanf("%d",&N);
  for(int i=0;i<=N;i++){
    scanf("%c",&S[i]);
  }
  int sum=N;
  for (int i=0;i<N;i++){
    if(S[i]==S[i+1]){
      --sum;
    }
  }

  printf("%d",sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include <cmath>
#include<vector>
using namespace std;
#define pb push_back
#define pf push_front
#define M 1000000007
#define ll long long int
int main()
 {
 	 
     double n;
     cin>>n;
     double ans;
    ans=2*3.1415*n;
    printf("%.20lf",ans);
     return 0;
 }


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

int a[200],b[200];
int c[200],d[200];

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

using i64 = long long;


struct Graph
{
    struct edge
    {
        int to;
        i64 cap;
        i64 rev;
    };

    int n;
    vector<vector<edge>> edges;

    Graph(int N)
    {
        n = N;
        edges.resize(n,vector<edge>());
    }

    int size() const
    {
        return n;
    }

    vector<edge>& operator[](int v)
    {
        return edges[v];
    }
};




struct Dinic
{
    int N;
    vector<int> level;
    vector<int> itr;
    Graph G;

    Dinic(int n) : G(n)
    {
        N = n;
    }

    void add_edge(int from,int to,int cap,int rev_cap)
    {
        G[from].push_back({to,cap,(int)G[to].size()});
        G[to].push_back({from,rev_cap,(int)G[from].size() - 1});
    }

    bool g_level(int s,int t)
    {
        level.assign(N,-1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while(!que.empty())
        {
            int v = que.front();
            que.pop();
            for(auto& e : G[v])
            {
                if(e.cap > 0 && level[e.to] == -1)
                {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
        return level[t] >= 0;
    }

    i64 dfs(int v,int t,i64 f)
    {
        if(v == t) return f;

        for(int& i = itr[v];i < G[v].size();i++)
        {
            auto& e = G[v][i];
            if(e.cap > 0 && level[e.to] > level[v])
            {
                i64 mi_f = dfs(e.to,t,min(f,e.cap));
                if(mi_f > 0)
                {
                    e.cap -= mi_f;
                    G[e.to][e.rev].cap += mi_f;
                    return mi_f;
                }
            }
        }
        return 0;
    }

    i64 max_flow(int s,int t)
    {
        i64 result = 0;
        i64 flow;
        while(g_level(s,t))
        {
            itr.assign(N,0);
            while((flow = dfs(s,t,1e9)) > 0) result += flow;
        }
        return result;
    }
};


/*

checked
    http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2723921#1
*/
int main(){
    cin>> n;
    rep(i,1,n) cin >> a[i] >> b[i];
    rep(i,1,n) cin >> c[i] >> d[i];

    Dinic dinic = Dinic(2 * n + 2);

    int s = 0;
    int t = 2 * n + 1;

    rep(i,1,n){
        dinic.add_edge(s,i,1,0);
    }

    rep(i,1,n){
        dinic.add_edge(i + n,t,1,0);
    }

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

    cout << dinic.max_flow(s,t) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

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

    bool win = false;
    for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 1) {
            win = true;
            break;
        }
    }

    if (win) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    ll N;
    cin >> N;

    ll resh, resn, resw;
    bool good = false;
    reps(h, 1, 3500){
        reps(n, 1, 3500){
            if(4*h*n - n*N - h*N > 0){
                if(h*n*N % (4*h*n - n*N - h*N) == 0){
                    ll w = h*n*N / (4*h*n - n*N - h*N); 
                    if(w > 3500) continue;
                    if(N*(h*n+n*w+w*h) == 4*h*n*w){
                        resw = w;
                        resh = h;
                        resn = n;
                        good = true;
                        break;
                    }
                }
            }
        }
        if(good) break;
    }

    cout << resh sp resn sp resw << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j - i
        if k < n:
            """
            if s[i] == s[j]:
                continue
            if s[j] == s[k]:
                continue
            if s[k] == s[i]:
                continue
            """
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1
print(ans)

Measured memory_bytes: 9152
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
#include<cassert>
using namespace std;
typedef pair<int,int> pii;

struct FenwickTree{
  int n;
  vector<int> bit;
  FenwickTree(int x = 0):n(x){bit = vector<int>(x+1,0);}

  inline void add(int i, int x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }

  inline int sum(int i){
    int res = 0;
    while(i > 0){
      res += bit[i];
      i -= i & -i;
    }
    return res;
  }

  inline int partial_sum(int l, int r){ return sum(r) - sum(l-1); }
};

int main(){
  int d;
  scanf("%d", &d);
  vector<int> x(d+1);
  for(int i=1;i<=d;i++){
    scanf("%d", &x[i]);
  }

  int q;
  scanf("%d", &q);
  vector<int> l(q), r(q), e(q);
  for(int i=0;i<q;i++){
    scanf("%d%d%d", &l[i], &r[i], &e[i]);
  }

  vector<pii> query(d + 2*q);
  for(int i=1;i<=d;i++){
    query[i-1] = pii(x[i],-i);
  }
  for(int i=0;i<q;i++){
    int L = min(x[l[i]], x[r[i]]) - e[i]-1;
    int U = max(x[l[i]], x[r[i]]) + e[i];

    query[d+2*i] = pii(L,i);
    query[d+2*i+1] = pii(U,i);
  }

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

  vector<int> ans(q,0);
  FenwickTree bit(d);
  for(pii p : query){
    if(p.second<0){
      bit.add(-p.second,1);
    }else{
      assert(0<=p.second && p.second<=q);
      int lq = l[p.second], rq = r[p.second];
      int num = bit.partial_sum(lq,rq);
      
      if( p.first == max(x[lq], x[rq]) + e[p.second] ){
	ans[p.second] += num;
      }else{
	ans[p.second] -= num;
      }
    }
  }

  for(int i=0;i<q;i++){
    printf("%d\n",r[i]-l[i]+1 - ans[i]);
  }

  return 0;
}

Measured memory_bytes: 5680
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define INF (1<<30)

template <class X>
vector<X> dijkstra(int n, int s, const vector<vector<pair<X, int>>> &G) {
    priority_queue<pair<X, int>, vector<pair<X, int>>, greater<pair<X, int>>>
        que;
    vector<X> d(n, INF);
    d[s] = 0;
    que.push(pair<X, int>(0, s));
    while (!que.empty()) {
        pair<X, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            pair<X, int> e = G[v][i];
            if (d[e.second] > d[v] + e.first) {
                d[e.second] = d[v] + e.first;
                que.push(pair<X, int>(d[e.second], e.second));
            }
        }
    }
    return d;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> pqc(M);
    vector<set<int>> v(N);
    map<pair<int, int>, int> mp;
    for(int i=0; i<M; i++){
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        pqc[i] = make_tuple(p, q, c);

        v[p].insert(c);
        v[q].insert(c);

        if(mp.find(make_pair(p, 0)) == mp.end())
            mp[make_pair(p, 0)] = mp.size()-1;

        if(mp.find(make_pair(q, 0)) == mp.end())
            mp[make_pair(q, 0)] = mp.size()-1;

        if(mp.find(make_pair(p, c)) == mp.end())
            mp[make_pair(p, c)] = mp.size()-1;

        if(mp.find(make_pair(q, c)) == mp.end())
            mp[make_pair(q, c)] = mp.size()-1;
    }
    if(mp.find(make_pair(0, 0)) == mp.end() || mp.find(make_pair(N-1, 0)) == mp.end()){
        cout << -1 << endl;
        return 0;
    }
    vector<vector<pair<int, int>>> G(mp.size());

    for(int i=0; i<N-1; i++){
        for(auto c : v[i]){
            G[mp[make_pair(i, 0)]].push_back(make_pair(1, mp[make_pair(i, c)]));
            G[mp[make_pair(i, c)]].push_back(make_pair(0, mp[make_pair(i, 0)]));
        }
    }
    for(auto c : v[N-1])
        G[mp[make_pair(N-1, c)]].push_back(make_pair(0, mp[make_pair(N-1, 0)]));

    int s = mp[make_pair(0, 0)];
    int g = mp[make_pair(N-1, 0)];

    for(int i=0; i<M; i++){
        int p, q, c;
        tie(p, q, c) = pqc[i];
        G[mp[make_pair(p, c)]].push_back(make_pair(0, mp[make_pair(q, c)]));
        G[mp[make_pair(q, c)]].push_back(make_pair(0, mp[make_pair(p, c)]));
    }

    auto d = dijkstra(G.size(), s, G);
    cout << (d[g] != INF ? d[g] : -1) << endl;
	return 0;
}

Measured memory_bytes: 90996
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for (int i = 1; i < int(s.size()); i++) {
    string t = s.substr(i);
    if (t.size() % 2 != 0) continue;
    if (t.substr(0, t.size() / 2) == t.substr(t.size() / 2)) {
      cout << t.size() << endl;
      return 0;
    }
  }
}


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

int A[1000], L[500], R[500];

void merge(int A[], int n, int left, int right, int mid){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = -1;
    R[n2] = -1;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        if(L[i] >= R[j]) A[k] = L[i++];
        else             A[k] = R[j++];
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, right, mid);
    }
}

int main(void){
    int n, m;
    cin >> n >> m;
    int A[n], sum;
    float check_num;
    sum = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        sum += A[i];
    }
    check_num = (float)sum / (4 * m);
    mergeSort(A, n, 0, n);
    
    //cout << check_num << endl;
    //for(int i = 0; i < n; i++) cout << A[i] << " ";
    //cout << endl;
    
    
    bool flag = true;
    for(int i = 0; i < m; i++){
        if(A[i] < check_num){
            flag = false;
            break;
        }
    }
    
    if(flag == true) 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 ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  cin >> n;
  vector<int> v(n+2,0);
  REP(i,n)cin >> v[i+1];
  ll sum = 0;
  REP(i,n+1)sum += abs(v[i]-v[i+1]);
  for(ll i = 1;i <= n;i++){
    ll res = sum;
    res -= abs(v[i]-v[i-1]);
    res -= abs(v[i+1]-v[i]);
    res += abs(v[i+1]-v[i-1]);
    cout << res << endl;
  }

  

  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

vector<string> search(ll N){
  vector<string> ans;
  if(N==1){
    ans.pb("a");
    return ans;
  }else{
    vector<string> ans_tmp = search(N-1);
    ll L = ans_tmp.size();
    set<string> st;
    REP(i,L){
      string tmp_str = ans_tmp[i];
      REP(j,N-1){
        string tmptmp = tmp_str + tmp_str[j];
        if(st.find(tmptmp)==st.end()) st.emplace(tmptmp);
      }
      REP(j,10){
        string tmptmp = tmp_str + (char)('a'+j);
        if(st.find(tmptmp)==st.end()){
          st.emplace(tmptmp);
          break;
        }
      }
    }
    for(auto itr : st){
      ans.pb(itr);
    }
    return ans;
  }
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vector<string> ans = search(N);
  REP(i,ans.size()){
    OUT(ans[i]);
  }

  return 0;
}

Measured memory_bytes: 16588
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Map<Integer, Integer> m = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            m.putIfAbsent(a, 0);
            m.put(a, m.get(a) + 1);
        }

        int ans = 0;
        for (int a : m.keySet()) {
            if (m.get(a) > a) {
                ans += m.get(a) - a;
            } else if (m.get(a) < a) {
                ans += m.get(a);
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 64304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

int n,m;
// {n of digits,first digit}
pi mem[N];
bool vis[N];
int a[10];
int cost[] = {0,2,5,5,4,5,6,3,7,6};

pi dp(int n)
{
    if (n < 0) return {-OO,-OO};
    pi &ret = mem[n];
    if (vis[n]) return ret;
    vis[n] = 1;
    if (n == 0) return {0,0};

    ret = {0,-1};
    int idx = 0;
    REP(i,0,m-1)
    {
        pi p = dp(n-cost[a[i]]);
        //if (n == 20 && i == 1) cout << p.F << ' ' << p.S << endl;
        if (p.F > ret.F || ret.S == -1) {ret = p;idx = i;}
    }
    if (ret.S != -1){
    ret.F++;
    ret.S = a[idx];}
    //cout << n << ' ' << ret.F << ' ' << ret.S << endl;
    return ret;
}

void findsol(int n)
{
    pi p = dp(n);
    if (p.F == 0) return;

    cout << p.S;
    findsol(n-cost[p.S]);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    cin >> n >> m;
    REP(i,0,m-1) cin >> a[i];
    sort(a,a+m,greater<int>());
    //cout << a[0] << endl;
    findsol(n);
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
int  main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long int  n;
	cin>>n;
	vector <long long int > ele(n);
	for(long long int  j = 0 ; j < n; j++)
	{
		cin>>ele[j];
	}
	long long int  zeroes = 0;
	for(long long int  j = 0 ; j < n; j++)
	{
		if(ele[j] == 0)
		{
			zeroes += 1;
		}
	}
	if(zeroes > 0)
	{
		cout<<"0"<<"\n";
	}
	else
	{
		long long int  ans = 1;
		for(long long int  j = 0 ; j < n; j++)
		{
			if(ele[j] <= 1000000000000000000/ans)
			{
				ans *= ele[j];
			}
			else
			{
				cout<<"-1"<<"\n";
				return 0;
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  int len[N];

  for(int i = 0; i < N; i++){
    int j = 0;
    while(true){
      if(S[i+j] == 'A' || S[i+j] == 'C' || S[i+j] == 'G' || S[i+j] == 'T'){
	j++;
	continue;
      }
      break;
    }
    len[i] = j;
  }

  sort(len, &len[N]);

  cout << len[N-1] << "\n";

  return 0;
}


Measured memory_bytes: 256