akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << n / 3 << endl;
	return 0;
}

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

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

  int a = N /1000;
  int b = N % 1000 / 100;
  int c = N % 100 / 10;
  int d = N % 10;
  
  if ((a == b && b == c) || (b == c && c == d)) {
	cout << "Yes" << endl; 
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  vector<int> v;
  int n = 3;
  while (n--) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  int five = 0;
  int seven = 0;
  for (auto el : v) {
    if (el == 5) {
     five++;
    }
    if (el == 7) {
      seven++;
    }
  }
  if (five == 2 && seven == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  ll ans=0;
  for(int i=1; i<=n; i++){
    int cnt=i/10000+i/1000%10+i/100%10+i/10%10+i%10;
    if(a<=cnt&&cnt<=b){ans+=i;}
  }

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


Measured memory_bytes: 256
a, b = list(map(int, input().split()))
s = list(input())
label = [str(i) for i in range(10)]

flag = True
for i in range(len(s)):
  if i < a and (not s[i] in label):
    flag = False
    break
  
  elif i - a == 0 and s[i] != "-":
    flag = False
    break
    
  elif 0 < i - a and i - a < b and (not s[i] in label):
    flag = False
    break
    
print("Yes" if flag else "No")

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin >> l.at(i);
  sort(l.begin(), l.end(), [&](int x, int y) {
    return x > y;
  });
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l.at(i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int> > Matrix;
const int inf=1e9;
int n,d,x;
int p[15][15];
int dp[15][100005];
void solve()
{
  for(int i=0;i<d-1;i++)
    {
      for(int j=0;j<=x;j++) dp[i][j]=j;
      for(int j=0;j<n;j++) for(int k=0;k<=x;k++) if(k-p[i][j]>=0) dp[i][k]=max(dp[i][k],dp[i][k-p[i][j]]+p[i+1][j]);
      int y=0;
      for(int j=0;j<=x;j++) y=max(y,dp[i][j]);
      x=y;
    }
}

int main()
{
  cin >> n >> d >> x;
  for(int i=0;i<d;i++)
    {
      for(int j=0;j<n;j++)
	{
	  cin >> p[i][j];
	}
    }
  solve();
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 3268
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) throws IOException{

    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] array=new int[n];
    for(int i=0;i<array.length;i++){
      array[i]=Integer.parseInt(scan.next());
    }

    for(int k=0;k<array.length;k++){
      if(k<array.length-1){
        System.out.print(array[k]);
        System.out.print(" ");
      }else{
        System.out.println(array[k]);
      }
    }

    //ソート
    for (int j = 1; j < array.length; j++) {
            int key = array[j];
            int i = j - 1;
            while (i >= 0 && array[i] > key) {
                array[i + 1] = array[i];
                i--;
            }
            array[i + 1] = key;
            for(int k=0;k<array.length;k++){
              if(k<array.length-1){
                System.out.print(array[k]);
                System.out.print(" ");
              }else{
                System.out.println(array[k]);
              }
            }
        }
  }
}



Measured memory_bytes: 34052
x=input().split()
h=int(x[0])
w=int(x[1])
s=['']*h*w
for i in range(h):
    row=input()
    for j in range(w):
        s[i*w+j]=row[j]
i=0
boo=True

while i<h*w:
    if i<w:
        if i==0:
            if s[i]=='#' and s[i+1]!='#' and s[i+w]!='#':
                boo=False
                break
        elif i==w-1:
            if s[i]=='#' and s[i-1]!='#' and s[i+w]!='#':
                boo=False
                break
        else:
            if s[i]=='#' and s[i+1]!='#' and s[i+w]!='#' and s[i-1]!='#':
                boo=False
                break
    elif i%w==0:
        if i==w*(h-1):
            if s[i]=='#' and s[i+1]!='#' and s[i-w]!='#':
                boo=False
                break
        else:
            if s[i]=='#' and s[i+1]!='#' and s[i+w]!='#' and s[i-w]!='#':
                boo=False
                break
    elif i%w==w-1:
        if i==h*w-1:
            if s[i]=='#' and s[i-1]!='#' and s[i-w]!='#':
                boo=False
                break
        else:
            if s[i]=='#' and s[i-1]!='#' and s[i+w]!='#' and s[i-w]!='#':
                boo=False
                break
    elif i>w*(h-1):
        if s[i]=='#' and s[i-1]!='#' and s[i+1]!='#' and s[i-w]!='#':
            boo=False
            break
    else:
        if s[i]=='#' and s[i-1]!='#' and s[i+1]!='#' and s[i-w]!='#' and s[i+w]!='#':
            boo=False
            break
    i+=1
if boo:
    print('Yes')
else:
    print('No')

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A;
  vector<pair<int, int> > P;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  for(int i=0; i<M; i++){
    int b, c; cin >> b >> c;
    P.push_back(make_pair(c, b));
  }
  sort(A.begin(), A.end());
  sort(P.begin(), P.end(), greater<pair<int, int> >());
  int idx=0;
  for(int j=0; j<P.size(); j++){
    while(A[idx]<P[j].first && P[j].second !=0){
      A[idx]=P[j].first;
      P[j].second--;
      idx++;
      if(idx==N) break;
    }
    if(idx==N) break;
  }
  long ans=0;
  for(int i=0; i<N; i++){
    ans += A[i];
  }
  cout << ans << endl;
  return 0;
}

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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        long H = cin.Long();
        long W = cin.Long();
        var a = new long[N];
        var b = new long[N];
        for(int i = 0; i < N; i++)
        {
            a[i] = cin.Long();
            b[i] = cin.Long();
        }

        int ans = 0;
        for(int i = 0; i < N; i++)
        {
            if (a[i] >= H && b[i] >= W) ans++;
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13244
/* **************************************************** */
/*                      Author : rakati                 */
/* **************************************************** */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define RP(i,a,b) for(int i = (a); i < (int)(b); i++)
#define RV(i,a,b) for(int i = (a); i > (int)(b); i--)
#define SHOW(v,d) {RP(i,0,v.size()) cout << v[i] << d;cout << '\n';}
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
const int INF = 1e9;
 
using ll    = long long;
using ull   = unsigned long long;
using vi    = vector<int>;
using vl    = vector<ll>;
using vb    = vector<bool> ;
using vc    = vector<char>;
using vii   = vector<vi>;
using vll   = vector<vl>;
using pii   = pair<int, int>;
using pll   = pair<ll, ll>;
using vpii  = vector<pii>;
using vpll  = vector<pll>;
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		for(i=0;i<n;i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		double ans = 0.0;
		for(i=0;i<n;i++) {
			ans += (double)1.0/a[i];
		}
		ans = (double)1.0/ans;
		out.println(ans);
	}
}


Measured memory_bytes: 21844
#!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] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,t = LI()
    k = t//a
    print(k*b)
    return

#B
def B():
    n = I()
    v = LI()
    c = LI()
    ans = 0
    for i in range(n):
        if v[i] > c[i]:
            ans += (v[i]-c[i])
    print(ans)
    return

#C
def C():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n = I()
    a = LI()
    m = math.ceil(n**0.5)
    f = [0 for i in range(m)]
    for i in range(m):
        b = a[m*i:min(n,m*(i+1))]
        if b:
            g = b[0]
            for j in b[1:]:
                g = gcd(g,j)
            f[i] = g
        else:
            f.pop(-1)
    ans = 1
    for i in range(n):
        j = i//m
        c = f[:j]+f[j+1:]+a[m*j:i]+a[i+1:min(n,m*(j+1))]
        g = c[0]
        for k in c[1:]:
            g = gcd(g, k)
        ans = max(ans,g)
    print(ans)
    return

#D
def D():
    n = I()
    a = LI()
    k = 0
    for i in a:
        if i < 0:
            k += 1
    ans = 0
    m = float("inf")
    for i in a:
        ans += abs(i)
        m = min(m,abs(i))
    if k%2:
        ans -= 2*m
    print(ans)
    return


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


Measured memory_bytes: 68332
N=int(input())

Axy={}

for i in range(N):
    a=int(input())
    xy=[]
    for j in range(a):
        xy.append(list(map(int,input().split())))
    Axy[i]=xy

ans=0
for i in range(2**N):
    bi=list(format(i,'b').zfill(N))
    flag=True
    for j in range(N):
        if bi[j]=='0': continue
        if bi[j]=='1':
            for v in Axy[j]:
                if int(bi[v[0]-1])!=v[1]:
                    flag=False
    if flag: ans=max(ans,bi.count('1'))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> h(N+K,0);
    vector<int> dp(N+K, INT_MAX);
    for(int i = 0;i < N; i++) cin >> h[i];
    dp[0] = 0;
    for(int i = 0;i < N; i++){
        for(int j = 1;j <= K; j++) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

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

int main(){
	int N,M;
	cin >>N>>M;
	if(abs(N-M)>=2){
		cout<<0<<endl;
	}
	else if(abs(N-M)==1){
		N=min(N,M);
		long long p=1;
		for(int i=1;i<=N;i++){
			p*=i;
			p=p%1000000007;
		}
		long long ans =(p*p)%1000000007;
		ans=(ans*(N+1))%1000000007;
		cout<<ans<<endl;
	}
	else if(abs(N-M)==0){
		N=min(N,M);
		long long p=1;
		for(int i=1;i<=N;i++){
			p*=i;
			p=p%1000000007;
		}
		long long ans =(p*p)%1000000007;
		ans=(ans*2)%1000000007;
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w,n;
int num[1000100];
int ans[101][101];
int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&num[i]);
	int numzz=1;
    for(int i=1;i<=h;i++)
    {
    	if(i%2==1)
    	{
    		for(int j=1;j<=w;j++)
    		{
    			if(num[numzz]==0)numzz++;
				ans[i][j]=numzz;
				num[numzz]--; 
			}
		}
		else
		{
			for(int j=w;j>=1;j--)
			{
				if(num[numzz]==0)numzz++;
				ans[i][j]=numzz;
				num[numzz]--;
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
from collections import Counter
import numpy as np
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)

# 2枚以上のところから-1, それ以外(2枚以上を優先しないなら1枚)のところから-1を繰り返す
# 3枚以上のところはそこから３枚とって２枚食べるということができるので偶数なら２、奇数なら１まで減らせる
values = np.array(sorted(list(c.values()), reverse=True))

values[(values % 2 != 0) & (values >= 3)] = 1
values[(values % 2 == 0) & (values >= 3)] = 2
values = values - 1
# print(values)
# print(values.sum())
if values.sum() % 2 == 0:
    print(len(values))
else:
    print(len(values) - 1)


Measured memory_bytes: 27324
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()

int main(){
	while(1){
		char buf[1100];
		scanf("%s",buf);
		if(buf[0]=='0') break;
		ll int ans = 0;
		for(int i=0;buf[i]!='\0';i++){
			ans += buf[i] - '0';
		}
		cout << ans << endl;
	}
		
	return 0;

}

Measured memory_bytes: 1148
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

void solve(int K, vector<int> AA) {

		bool ok = true;
		vector<int> A = AA;
		vector<int> a = A;
		rrep(i, 1, K) {
			A[i - 1] *= (AA[i] + A[i] - 1) / A[i - 1];
			if (A[i - 1] == 0) {
				ok = false; break;
			}
		}
		rrep(i, 1, K) {
			a[i - 1] *= a[i] / a[i - 1] + !!(a[i] % a[i - 1]);
		}
		dump(A);
		dump(a);
		rep(i, 1, K) {
			if (a[i - 1] >= a[i] * 2) {
				ok = false;
			}
		}

		int c = a[0];
		rep(i, 0, K) {
			c = (c / AA[i]) * AA[i];
		}
		if (c != 2)
			ok = false;

		if (AA.back() != 2)
			ok = false;
		if (ok)
			cout << a[0] << " " << A[0] + AA[0] - 1 << endl;
		else
			cout << -1 << endl;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int K; cin >> K&&K;) {
		vector<int> AA(K); rep(i, 0, K) {
			cin >> AA[i];
		}
		solve(K, AA);
	}
	return 0;
}

Measured memory_bytes: 3456
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c = li()

if a+b >= c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)

N = int(input())
a, b, c = [], [], []
dp = [[0] * 3 for _ in range(N+1)]

for i in range(N):
    v1, v2, v3 = map(int, input().split())
    a.append(v1)
    b.append(v2)
    c.append(v3)

def solve(idx, prev):
    if dp[idx][prev] > 0:
        return dp[idx][prev]

    if idx == N:
        dp[idx][prev] = 0
    elif idx == 0:
        v1 = solve(idx + 1, 0) + a[idx]
        v2 = solve(idx + 1, 1) + b[idx]
        v3 = solve(idx + 1, 2) + c[idx]
        dp[idx][prev] = max(v1, v2, v3)

    # Prev was A
    elif prev == 0:
        # Select B
        a1 = solve(idx + 1, 1) + b[idx]
        # Select C
        a2 = solve(idx + 1, 2) + c[idx]
        dp[idx][prev] = max(a1, a2)

    # Prev was B
    elif prev == 1:
        # Select A
        b1 = solve(idx + 1, 0) + a[idx]
        # Select C
        b2 = solve(idx + 1, 2) + c[idx]
        dp[idx][prev] = max(b1, b2)

    # Prev was B
    elif prev == 2:
        # Select A
        c1 = solve(idx + 1, 0) + a[idx]
        # Select B
        c2 = solve(idx + 1, 1) + b[idx]
        dp[idx][prev] = max(c1, c2)

    return dp[idx][prev]

print(solve(0, 0))

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

using namespace std;

//const int OO = 0x3f3f3f3f;
const long long OO = (long long) 1e18L+7;
//const unsigned long long UOO = (long long) 10e18+7;
#define lp(i,a,n) for(int i = a ; i < n ; ++i)
#define lpr(i,a,n) for(int i = a ; i >= n ; --i)
#define rep(i,vec) for(int i = 0 ; i < vec.size() ; ++i)
#define reprv(i,vec) for(int i = vec.size()-1; i >=0 ; --i)
#define eps (1e-5)
#define pb(i) push_back(i)
#define EPS 1e-9
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cout<<(#x)<<": \""<<x<<"\""<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl

typedef vector<int> vi ;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll ;
typedef pair<int,int> pii ;
typedef vector< pair<int,int> >  vpii;
typedef vector<pair<long long,long long>> vpll;
typedef vector<vector<int> > vvi ;
typedef complex<double> point;
typedef pair<ll,ll> pll;

ll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}
ll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p
ll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}
ll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }
ll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//int i=uniform_int_distribution<int>(1,n)(rng);
///-----------------------------------------------------------------------------

int n;
vll nms;

ll mem[3002][30002][2];


ll dp(int l , int r, int who){
    if(l > r) return 0LL;
    ll &ret = mem[l][r][who];
    if(ret!=OO) return ret;
    ll a = dp(l+1,r,!who);
    ll b = dp(l,r-1,!who);
    if(who){
        a += nms[l];
        b += nms[r];
        return ret = max(a,b);
    }
    a -= nms[l];
    b -= nms[r];
    return ret = min(a,b);
}


///-----------------------------------------------------------------------------
int main()
{
    #ifndef ONLINE_JUDGE
//       freopen( "output.txt" , "w" , stdout ) ;
    //   freopen( "input.txt" , "r" , stdin ) ;
    auto stTime = clock();
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
///-----------------------------------------------------------------------------------

    cin >> n ;
    nms.resize(n);
    lp(i,0,n+2)lp(j,0,n+2)lp(k,0,2) mem[i][j][k] = OO;
    lp(i,0,n) cin >> nms[i];
    cout << dp(0,n-1,1);

///------------------------------------------------------------------------------------
    #ifndef ONLINE_JUDGE
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif

    return 0;
}


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

int main(){
  long long N,X;
  cin >> N >> X;
  long long a,b,c,d,e,f,ans=0;
  a=d=N-X;b=e=0;c=f=X;
  ans += N;
  int type=0;//0は平行四辺形右下、1は台形左、2は台形右、3で完成
  while(type<3){
    if(type==0){
      if(a<c){
        ans+=a*2*((c-1)/a);
        type=0;
        c=f=(c-1)%a+1;
      }else if(a>c){
        ans+=c*2*((a-1)/c);
        type=0;
        a=d=(a-1)%c+1;
      }else{
        type=3;ans+=a;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int r;

signed main() {
	cin >> r;
    cout<<r*2*pie<<endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    int n,time=0;
    cin>>n;
    vector<string> s(n);
    vector<int>t(n);
    for(int i=0;i<n;i++)   cin>>s[i]>>t[i];
    string x;
    cin>>x;
    vector<string>::iterator itr = find(s.begin(),s.end(),x);
    int j=distance(s.begin(),itr);
    for(int k=j+1;k<n;k++) time+=t[k];
    cout<<time<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[100];
int main()
{
    scanf("%s" , s);
    int n = strlen(s);
    int i = 0;
    int an = 0 , luna = 0, zi = 0;
    while(s[i] != '/')
    {
        an = an * 10 + s[i] - '0';
        i ++;
    }
    i ++;
    while(s[i] != '/')
    {
        luna = luna *  10 + s[i] - '0';
        i ++;
    }
    i ++;
    while(i < n){
        zi = zi * 10 + s[i] - '0';
        i ++;
    }
    if(an <= 2019 && luna <= 4 && zi <= 30)
        printf("Heisei");
    else
        printf("TBD");
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
double X[10], Y[10];

double dist(int i, int j){
  double ans = (X[i] - X[j]) * (X[i] - X[j]);
  ans += (Y[i] - Y[j]) * (Y[i] - Y[j]);
  return sqrt(ans);
}

int main(){
  cin >> N;
  cout << N * N << endl;

  return 0;
}


Measured memory_bytes: 3540
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
 
using namespace std;
 
void Solution()
{
    int a, b, c;
    double h, s, l;
    
    cin>>a>>b>>c;
    
    double raid = c * 3.141592653 / 180.0 ; 
    
    h = b * sin(raid);
    s = h * a * 0.5;
    l = sqrt(a * a + b * b - 2 * a * b * cos(raid)) + a + b;
    
    cout<<fixed<<setprecision(4)<<s<<endl;
    cout<<fixed<<setprecision(4)<<l<<endl;
    cout<<fixed<<setprecision(4)<<h<<endl;

}
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>

using namespace std;

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

    string ret;
    while (n > 0) {
        n--;
        ret = string(1, ('a' + (n % 26))) + ret;
        n /= 26;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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

	if (abs(a - b) % 2 == 0) {
		cout << abs(a + b)/2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<string> a(N);
  string c="Yes";
  for(int i=0;i<N;i++)
    cin >> a.at(i);
  map<string,int> b;
  for(int i=0;i<N;i++)
    b[a.at(i)]++;
  for(int i=0;i<N;i++){
    if(b[a.at(i)]>1)
      c = "No";
  }
  for(int i=0;i<N-1;i++){
    if(a.at(i+1).at(0)!=a.at(i).at(a.at(i).size()-1))
      c = "No";
  }
  cout << c << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a_li = [input() for i in range(H)]
li = []
for i in range(H) :
    if "#" in a_li[i] :
        li.append(a_li[i])
del_nums = []
for i in range(W) :
    col_li = [row[i] for row in li]
    if not "#" in col_li :
        del_nums.append(i)
for l in li :
    for i in range(W) :
        if not i in del_nums :
            print(l[i],end="")
    print()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define int int64_t
#define rp(i, N) for(int i=0; i<N; i++);
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B;
	cin >> A >> B;

	int ct = 0;
	int pg = 1;
	if(B==1) ct = 0;
	else {
		while(B>pg) {
			pg = pg+A-1;
			ct += 1;
		}
	}

	cout << ct << endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(string, b);
    Cin(int, c);
    Cin(int, d);
    Cout((b == "+") ? a+c : a-c);
    //Cout(() ? "Yes" : "No");
    //Cout(() ? "YES" : "NO");
}

Measured memory_bytes: 256
def main():
    n,m,x = map(int,input().split())
    a = [[] for _ in range(n)]
    c = [0] * n

    INF = 10 ** 9
    ans = INF

    for i in range(n):
        ca = list(map(int,input().split()))
        c[i],a[i] = ca[0],ca[1:]

    for s in range(0,1<<n):
        smart = [0] * m
        cost = 0
        for i in range(n):
            if(s>>i) % 2 == 0:continue
            cost += c[i]
            for j in range(m):
                smart[j] += a[i][j]
        ok = True
        for i in range(m):
            if smart[i] < x:
                ok = False
        if ok:
            ans = min(ans,cost)
    if ans == INF:
        ans = -1
    
    print(ans)

if __name__ == "__main__":
    main()


               

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int v, e;
    string s;
    cin >> v >> e;
    rep(i, v)
    {
        char hoge;
        cin >> hoge;
        s.push_back(hoge);
    }
    map<int, set<int>> a;
    rep(i, e)
    {
        int x, y;
        cin >> x >> y;
        a[x].insert(y);
        a[y].insert(x);
    }
    rep(i, s.size())
    {
        set<char> hoge;
        rep(k, 26)
        {
            hoge.insert('a' + k);
        }
        if (s[i] != '?')
            continue;
        else
        {
            for (auto itr = a[i].begin(); itr != a[i].end(); itr++)
            {
                hoge.erase(s[*itr]);
            }
            s[i] = *hoge.begin();
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 31152
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

constexpr int inf = 1e9;
template<class T> struct edge { int to; T cap; int rev; edge(int t, T c, int r) : to(t), cap(c), rev(r) {} };

void add_edge(int from, int to, auto cap, auto& g) {
  g[from].emplace_back(to, cap, g[to].size());
  g[to].emplace_back(from, 0, g[from].size() - 1);
}

template<class T> T dinic(int s, int t, VV< edge<T> > g) {
  int n = g.size();
  V<> dist, i;

  auto bfs = [&]() {
    dist.assign(n, -1);
    queue<int> q;
    dist[s] = 0; q.push(s);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto&& e : g[v]) if (dist[e.to] == -1 and e.cap > 0) {
        dist[e.to] = dist[v] + 1; q.push(e.to);
      }
    }
  };

  function<T(int, T)> dfs = [&](int v, T f) {
    if (v == s) return f;
    for (; i[v] < g[v].size(); i[v]++) {
      edge<T>& e = g[v][i[v]];
      if (dist[e.to] < dist[v] and g[e.to][e.rev].cap > 0) {
        T d = dfs(e.to, min(f, g[e.to][e.rev].cap));
        if (d > 0) {
          g[e.to][e.rev].cap -= d;
          e.cap += d;
          return d;
        }
      }
    }
    return (T) 0;
  };

  T res = 0;
  while (true) {
    bfs();
    if (dist[t] == -1) return res;
    i.assign(n, 0);
    while (true) {
      T f = dfs(t, inf);
      if (f == 0) break;
      res += f; 
    }
  }
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> a(h); for (int i = 0; i < h; i++) cin >> a[i];
  int s, t;
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
    if (a[i][j] == 'S') s = 2 * (i * w + j) + 1;
    if (a[i][j] == 'T') t = 2 * (i * w + j);
  }
  VV< edge<int> > g(2 * h * w + h + w);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (a[i][j] != '.') {
    add_edge(2 * (i * w + j), 2 * (i * w + j) + 1, 1, g);
    add_edge(2 * (i * w + j) + 1, 2 * h * w + i, inf, g);
    add_edge(2 * h * w + i, 2 * (i * w + j), inf, g);
    add_edge(2 * (i * w + j) + 1, 2 * h * w + h + j, inf, g);
    add_edge(2 * h * w + h + j, 2 * (i * w + j), inf, g);
  }
  int res = dinic<int>(s, t, g);
  cout << (res >= inf ? -1 : res) << '\n';
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int dp[n-1][n+1];
	dp[0][0] = 0;
	dp[0][1] = (s[0]=='>');
	dp[0][2] = (s[0]=='<')+dp[0][1];
	int i,j;
	for(i=1;i<n-1;i++)
	{	
		dp[i][0] = 0;
		for(j=1;j<=i+2;j++)
		{
			if(s[i]=='<')
			{
				dp[i][j] = dp[i-1][j-1];
			}
			else
			{	
				dp[i][j] = (dp[i-1][i+1]-dp[i-1][j-1])%M;
				dp[i][j] = (dp[i][j]+M)%M;
			}
			dp[i][j] = (dp[i][j]+dp[i][j-1])%M;
		}
	}
	cout<<dp[n-2][n];
	return 0;

}


Measured memory_bytes: 31132
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();

    for(int i=0; i<c.length;i++){
      c[i] += n;
      if(c[i]>0x5a){
        c[i] -= 26;
      }
    }

      String ss = new String(c);

      System.out.println(ss);


  }

}

Measured memory_bytes: 22228
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, m; cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, m) {
        cin >> b[i];
    }

    for (int y = 0; y <= n - m; y++) {
        for (int x = 0; x <= n - m; x++) {
            bool ok = true;
            rep(i, m) rep(j, m) {
                if (a[y + i][x + j] != b[i][j]) ok = false;
            }

            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<int> cntACs;
  int cnt = 0;
  cntACs.push_back(cnt);
  for(int i = 1; i < n; i++) {
    if(s[i - 1] == 'A' && s[i] == 'C') cnt++;
    cntACs.push_back(cnt);
  }
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    cout << cntACs[r] - cntACs[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 1528
N, Y= gets.split(" ").map(&:to_i)

(0..N).each do |mi|
  (0..N-mi).each do |gi|
    si = N - mi - gi
    if Y == 10000*mi + 5000*gi + 1000*si
      puts "#{mi} #{gi} #{si}"
      exit
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,x;cin>>n>>x;
  vector<int> vec(n);
  int cnt=0,ans=0;
  rep(i,n){
    ans++;
    cin>>vec[i];
    cnt+=vec[i];
  }
  sort(all(vec));
  x-=cnt;
  while(x>0){
    if(vec[0]>x)break;
    x-=vec[0];
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(void){
    int line[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},{1,0,1,1,0,1,1},{1,0,0,1,1,1,1},{1,1,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,1,1,1,0,1},{0,1,0,0,1,1,1},{1,1,1,1,1,1,1},{1,1,0,1,1,1,1}};
    int num,i,kazu;
    while(1){
        int map[7]={0};
        scanf("%d",&num);
        if(num == -1)
            break;
        while(num){
            scanf("%d",&kazu);
            for(i=0;i<7;i++){
                if(map[i] == line[kazu][i])
                    printf("0");
                else
                    printf("1");
                map[i]=line[kazu][i];
            }
            printf("\n");
            num--;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int n, A, B, C;
vector<int> v;

int dfs(int trenutni, int a, int b, int c)
{
    if(trenutni == n)
    {
        if(min(a,min(b,c)) <= 0)
        {
            return 1e9;
        }
        else
        {
            return abs(a-A) + abs(b-B) + abs(c-C);
        }
    }

    int minimalno = 1e9;
    minimalno = min(minimalno, dfs(trenutni+1, a, b, c));
    minimalno = min(minimalno, dfs(trenutni+1, a+v[trenutni], b, c) + 10);
    minimalno = min(minimalno, dfs(trenutni+1, a, b + v[trenutni], c) + 10);
    minimalno = min(minimalno, dfs(trenutni+1, a, b, c + v[trenutni]) + 10);
    return minimalno;
}

int main()
{
    cin >> n >> A >> B >> C;

    v.resize(n);

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

    cout << dfs(0, 0, 0, 0)-30 << '\n';

    return 0;
}


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

ll square(ll x){
    return (x*x) % MOD;
}

ll mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll power(ll x, ll y){
    x = x % MOD;
    y = y % MOD;
    if( y == 0) return 1;
    else if( y == 1 ) return x % MOD;
    else if( y % 2 == 0) return square(power(x, y/2)) % MOD;
    else return mul(square(power(x, y/2)), x) % MOD;
}

ll Div(ll x, ll y){
    return mul(x, power(y, MOD-2));
}

void fact(void){
    F[0] = 1;
    F[1] = 1;
    for( ll i = 2; i < 100010; i++){
        F[i] = mul(F[i-1],i);
    }
}

ll Combi(ll x, ll y){
    if( x < y ) return 0;
    return Div(F[x], F[x-y]*F[y] % MOD);
}
 
int main(void)
{
    fact();
    int N;
    cin >> N;
    int a[N+1];
    int count[N+1];
    int b;
    for( int i = 0; i <= N; i++){
        count[i] = 0;
    }
    for( int i = 0; i <= N; i++){
        cin >> a[i];
        count[a[i]]++;
    }
    for( int i = 0; i <= N; i++ ){
        //printf("count[%d] = %d\n", i, count[i]);
        if(count[i] == 2){
            b = i; break;
        }
    }
    //printf("b = %d\n",b);
    int l = -1,m = -1;
    for( int i = 0; i <= N; i++){
        if(a[i] == b && l == -1) l = i;
        else if(a[i] == b && l != -1){
            m = i;
        }
    }
    //printf("l = %d, m = %d\n",l, m);
    for( int i = 0; i <= N; i++){
        /*
        printf("C(%d, %d) = %lld,C(%d, %d) = %lld, ans = %lld\n",
                N+1, i+1, Combi(N+1,i+1), l+N-m, i, Combi(l+N-m,i),
                Combi(N+1,i+1) - Combi(l+N-m,i));
        */
        cout << (Combi(N+1,i+1) - Combi(l+N-m,i)+MOD) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 3328
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
    	a:usize,
        s:chars
    }
    let ss = s.into_iter().collect::<String>();
    let sss = ss.trim();
       
    println!("{}", if a >= 3200 { sss } else { "red"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] and s[1]==s[2] or s[1]==s[2] and s[2]==s[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
#define int long long
const int N = 3e3 + 4;
int n;
int arr[N];
int mem[N][N];

int solve(int l , int r ){
    if(l>r){
        return 0;
    }

    if(~mem[l][r])
        return mem[l][r];
    int ret ;
    if(((l+r) % 2) != (n % 2)){
         ret = max(  arr[l] + solve(l+1 , r ) , arr[r] + solve(l , r-1) );
    }
    else{
        ret = min( solve(l+1 , r ) - arr[l] , solve(l , r-1) - arr[r] );
    }
    return mem[l][r] = ret;
}
 main()
{  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem , -1  , sizeof mem);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> arr[i];
    }
    cout << solve(1 , n) ;

}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  if(K<=A){
    cout << K;
  }
  else if(K>A&&K<=A+B){
    cout << A;
  }
  else{
    cout << 2*A+B-K;
  }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

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

        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < n;i++){
            list.add(sc.nextInt());
        }

        double diff = Double.MAX_VALUE;
        int ans = -1;
        for(int i = 0;i < n;i++){
            double temp = t - (double)list.get(i) * 0.006;
            if((Math.abs(a-temp)) < diff){
                diff = Math.abs(a-temp);
                ans = i+1;
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 23536
import heapq
N = int(input())
P = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    P[a-1].append((c, b-1))
    P[b-1].append((c, a-1))
Q, K = map(int, input().split())

C = [float("inf") for _ in range(N)]
V = [False for _ in range(N)]
C[K-1] = 0
H = [(0, K-1)] 
heapq.heapify(H)
while H:
    cost, node = heapq.heappop(H)
    V[node] = True
    for n in P[node]:
        if V[n[1]] == False:
            if n[0] + cost < C[n[1]]:
                C[n[1]] = n[0] + cost
                heapq.heappush(H, (n[0] + cost, n[1]))
Ans = []
for i in range(Q):
    x, y = map(int, input().split())
    Ans.append(C[x-1]+C[y-1])
for i in range(Q):
    print(Ans[i])

Measured memory_bytes: 52476
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
typedef  long long ll;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){
int N; cin >> N;
int x;
int sum = 0;
rep1(i,N){
    if((i * (i+1)) / 2 >= N){
        x = i;
        sum += i;
        break;
    }
    sum += i;
}
int d = sum - N;
rep1(i,x){
    if(i != d) cout << i << endl;
}
}

Measured memory_bytes: 256