akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b, c;
  //  double  c;
//  long long  A[1000001]={};
 int  A[1000001][2]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
  long long   d, X, Y;
  long long JPY;
  double BTC;
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  long long min=10000000001;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
  scanf("%s", &s);
  for(i=0;i<a;i++){
    if(s[i]=='R') cnt++;
  }
  if(cnt>(a/2))  printf("Yes\n");
  else     printf("No\n");
/*    
    for(j=0;j<b;j++){
      if( i==A[j][0])
        ans[j]=-sum[i];
      else if(i==A[j][1])
        ans[j]=ans[j]+sum[i];
      printf("%d\n",ans[j]);
    }
    */

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 256
na=int(input())

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

aha=digitSum(na)

if aha%9==0:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 11188
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<set>
using namespace std;
using ll = long long;

unsigned egcd(unsigned a, unsigned b) {
  if(a < b) return egcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int n,k,agcd;
    cin >> n >> k;
    vector<int> l(n);
    for (auto &p:l) cin >>p;
    sort(l.begin(),l.end());

    ll overallgcd = l[0];
    for (int i=1;i<n;i++) {
        overallgcd = egcd(overallgcd,l[i]);
        if (overallgcd == 1) break;
    }

    bool pos = false;
    if (k <= l.back()) {
        if (overallgcd ==1) pos = true;
        else {
            if (k%overallgcd==0) pos = true;
        }
    }
    cout << (pos ? "POSSIBLE" : "IMPOSSIBLE")<< endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  char S[3];
  char T[3];
  int count=0;
  
  scanf("%s",S);
  scanf("%s",T);
  
  for(int i=0;i<3;i++){
    if(S[i]==T[i]) count++;
  }
  
  printf("%d\n",count);
  
return 0;
}

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

using namespace std;

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

    bool seven = false;
    for (char c : s) {
        if (c == '7') {
            seven = true;
            break;
        }
    }

    if (seven) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string s;
#define regi register int
//bool ss[100005]={false};
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s;
	int n=s.size();
	for (regi i=0;i<=n-1;i++)
	{
		
		int j=n-1-i;
		if ((s[i]=='b'&&s[j]=='d')||(s[i]=='d'&&s[j]=='b')||(s[i]=='q'&&s[j]=='p')||(s[i]=='p'&&s[j]=='q'))
			continue;
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

		int a[]=new int[20000];
		int b[]=new int[20000];
		String op1;
		int val[]=new int[20000];

		int i=0;
		while(true){
			a[i]=sc.nextInt();
			op1=sc.next();
			b[i]=sc.nextInt();

			char op2=op1.charAt(0);

			if(op2=='?')	break;
			else{
				switch(op2){
				case '+':
					val[i]=a[i]+b[i];
					break;

				case '-':
					val[i]=a[i]-b[i];
					break;

				case '*':
					val[i]=a[i]*b[i];
					break;

				case '/':
					val[i]=a[i]/b[i];
					break;
				}
			i++;
			}
		}

		for(int j=0;j<i;j++)	System.out.println(val[j]);
	}
}

Measured memory_bytes: 26588
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int X[1010], Y[1010];
signed main() {
    int N; cin >> N;
    
    int evencnt = 0, oddcnt = 0;
    for(int i=0; i<N; i++) {
        cin >> X[i] >> Y[i];
        int sum = abs(X[i]) + abs(Y[i]);
        if(sum % 2 == 0) evencnt++;
        else oddcnt++;
    }

    if(evencnt and oddcnt) cout << -1 << endl;
    else {
        const int MAXB = 32;
        string pat = "LUDR";

        vector<int> arms;
        if(evencnt) arms.push_back(1);
        for(int i=0; i<MAXB; i++) {
            arms.push_back(1LL << i);
        }

        cout << arms.size() << endl;
        for(int i=0; i<(int)arms.size(); i++) {
            cout << arms[i] << " \n"[i+1 == arms.size()];
        }

        for(int i=0; i<N; i++) {
            int offset = (evencnt > 0);
            int NX = X[i] + Y[i], NY = X[i] - Y[i];

            vector<char> dirs(arms.size());
            if(offset) {
                dirs[0] = pat[0];
                NX++; NY++;
            }

            int full = -((1LL << MAXB) - 1);
            int subX = full, subY = full;
            for(int j=(int)dirs.size()-1; j>=offset; j--) {
                int x = 0, y = 0;
                if(subX + 2 * arms[j] <= NX) {
                    x = 1;
                    subX += 2 * arms[j];
                }
                if(subY + 2 * arms[j] <= NY) {
                    y = 1;
                    subY += 2 * arms[j];
                }
                dirs[j] = pat[2*y + x];
            }

            for(size_t j=0; j<dirs.size(); j++) {
                cout << dirs[j];
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ld long double
#define MOD 1000000007
#define u128 __int128
#define ff first
#define ss second
#define INTMAX 1000000009
#define N 100050

ll bmexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x,a;
	cin >> x >> a;
	if(x < a)
		cout << 0;
	else
		cout << 10;

	return 0;	
}

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

using namespace std;

int main(void)

{
    long long int n, i, ans = 1, a;
    cin>>n;
    long long int ara[n];
    for(i = 0; i < n; i++)
        cin>>ara[i];
    sort(ara, ara+n);
    for(i = 0; i < n; i++){
        if(ara[i] == 0){
            ans = 0;
            break;
        }
        else{
            a = (1000000000000000000/ans);
            if(ara[i] <= a){
                ans = ans*ara[i];
            }
            else{
                ans = -1;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int count=0;
  while(B>=A){
    B-=A;
    count++;
    if(count==C)break;
  }
  cout<<count<<endl;
  return 0;
}

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

using namespace std;

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

	int h, w, n;
	cin >> h >> w >> n;

	map<pair<int, int>, int> cnt;
	while (n--) {
		int a, b;
		cin >> a >> b;

		for (int i = -1; i <= 1; i++)
			for (int j = -1; j <= 1; j++)
				if (a + i - 1 > 0 && a + i + 1 <= h && b + j - 1 > 0 && b + j + 1 <= w)
					cnt[make_pair(a + i, b + j)]++;
	}

	long long ans[10] = {(long long)(h - 2) * (w - 2)};
	for (auto& elem : cnt) {
		ans[0]--;
		ans[elem.second]++;
	}

	for (int i = 0; i < 10; i++)
		cout << ans[i] << endl;

	return 0;
}


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

//Binomial Coefficients
const long long c_max = 1000003;
const long long mod = 1e9+7;
long long fac[c_max], finv[c_max], inv[c_max];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < c_max; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
long long COM(long long comn, long long comk){
    if (comn < comk) return 0;
    if (comn < 0 || comk < 0) return 0;
    return fac[comn] * (finv[comk] * finv[comn - comk] % mod) % mod;
}

void solve_A(){
	int r;
    cin >> r;
    cout << r*r << endl;
}

void solve_B(){
	int n,i;
    char c[505];
    bool ans=true;
    cin >> n >> c;
    if(n%2==1){
        cout << "No" << endl;
        ans=false;
    } else {
        for(i=0;i<n/2;i++){
            if(c[i]!=c[n/2+i]){
                cout << "No" << endl;
                ans=false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
}

void solve_C(){
	int n,i,f=1;
    double x[15],y[15],ans=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i] >> y[i];
        f*=(i+1);
    }
    vector<int> p;
    for(i=0;i<n;i++) p.push_back(i);
    do{
        double memo;
        for(i=1;i<n;i++){
            memo=(x[p[i-1]]-x[p[i]])*(x[p[i-1]]-x[p[i]])+(y[p[i-1]]-y[p[i]])*(y[p[i-1]]-y[p[i]]);
            memo=sqrt(memo);
            ans+=memo;
        }
    }while(next_permutation(p.begin(),p.end()));
    ans=ans/(double)f;
    printf("%.13lf\n",ans);
}

void solve_D(){
	long long x,y,n,i;
    bool t=true;
    cin >> x >> y;
    if((x+y)%3!=0){
        cout << "0" << endl;
    } else {
        n=(x+y)/3;
        if(x-n<0||2*n-x<0){
            cout << "0" << endl;
        } else {
            COMinit();
            cout << COM(n,x-n) << endl;
        }
    }
}

int main() {
	// your code goes here
	//solve_A();
    //solve_B();
    solve_C();
    //solve_D();
	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()

    ans = 0
    for i in range(len(s)):
        cur = 0
        for j in range(i,len(s)):
            if s[j] in {"A", "C", "G", "T"}:
                cur += 1

            else:
                break

            ans = max(cur, ans)


    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
GETA=12
#import sys,os,multiprocessing
#print(3)
###############################################################################
#FINDING THE MEDIAN OF N CONS
#CHOIANS
s=input()
if s.isupper():
    print("A")
else:
    print("a")


Measured memory_bytes: 61696
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> A){
  multiset<long long> s;
  s.insert(A[0]);
  for (int i = 1; i < N; i++) {
    auto it = s.lower_bound(A[i]);
    if (it == s.begin()) {
      s.insert(A[i]);
    } else {
      s.erase(--it);
      s.insert(A[i]);
    }
  }
  std::cout << s.size() << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 5760
#!/usr/bin/env python3
import math
import sys
from itertools import permutations

readlines = sys.stdin.buffer.readlines

N = int(input())
patterns = [tuple(map(int, input().split())) for _ in range(N)]

total = 0
n = 0

for pattern in permutations(patterns):

    for i in range(len(pattern) - 1):
        town_a = pattern[i]
        town_b = pattern[i + 1]

        distance = math.sqrt((town_a[0] - town_b[0])**2 +
                             (town_a[1] - town_b[1])**2)
        total += distance

    n += 1

print(total / n)


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
ll find(ll x, ll y, ll p)
{ll res = 1; x = x % p;
while (y > 0)
{if(y & 1) res = (res*x) % p;
y = y>>1;x = (x*x) % p;
}return res;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,a,b;
cin>>n>>a>>b;
int mod=pow(10,9)+7;
int ans=find(2,n,mod);
ans-=1;
if(ans<0)
    ans+=mod;
    int mx=200005;
int dp[mx]={};
dp[1]=n;
int res=1;
int prev=n;

for(int i=2;i<mx;i++)
{
    prev*=(n-i+1);
    prev%=mod;
    res*=i;
    res%=mod;
    dp[i]=prev;

    dp[i]*=find(res,mod-2,mod);

    dp[i]%=mod;
}
ans-=dp[a];
if(ans<0)
    ans+=mod;
   
ans-=dp[b];
if(ans<0)
    ans+=mod;
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
n,k=map(int,input().split())
s=input()
g=[]
t=1
for i in range(1,n):
    if s[i]==s[i-1]:
        t+=1
    else:
        g.append(t)
        t=1
g.append(t)
for i in range(1,len(g)):
    g[i]+=g[i-1]
g=[0]+g+[g[-1]]
a=0
for i in range(s[0]=='1',len(g),2):
    a=max(a,g[i]-g[max(0,i-2*k-1)])
print(a)


Measured memory_bytes: 8700
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)>=c)
    {
        cout<<"Yes"<<NL;
    }
    else
    {
        cout<<"No"<<NL;
    }
    return 0;
}


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

int main(){
while(1){
	int n,m,s;
	static int dp[2][2002][3002];
	for(int i=0;i<2;i++)for(int j=0;j<2002;j++)for(int k=0;k<3002;k++)dp[i][j][k]=0;
	scanf("%d%d%d",&n,&m,&s);
	if(n==0&&m==0&&s==0)break;
	for(int j=0;j<=m;j++)dp[0][j][0]=1;
	for(int i=1;i<=n*n;i++){
		for(int j=i;j<=m;j++){
			for(int k=1;k<=s;k++){
				if(k-j>=0){
					dp[1][j][k]=dp[0][j-1][k-j];
				}
				dp[1][j][k]+=dp[1][j-1][k];
				dp[1][j][k]%=100000;
			}
		}
		for(int j=0;j<=m;j++)for(int k=0;k<=s;k++){dp[0][j][k]=dp[1][j][k]; dp[1][j][k]=0;}
	}
	printf("%d\n",dp[0][m][s]);
}
}

Measured memory_bytes: 48120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T> 
map<T,int> factorize(T x){
    map<T,int> mp;
    for (T i = 2; i*i <= x; i++){
        while (x%i == 0) {
            x /= i;
            mp[i]++;
        }
        if (x == 1) break;
    }
    if (x != 1) mp[x]++;
    return mp;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    int ans = 0;
    rep1(i, N+1){
        auto mp = factorize(i);
        ll cnt = 1;
        for(auto p: mp){
            cnt *= (1+p.second);
        }
        if(cnt == 8&&i&1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();

		String B = String.valueOf(A);

		char[] C = B.toCharArray();

		if (C[0] == '7' || C[1] == '7' || C[2] == '7') {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}

	return;

	}
}


Measured memory_bytes: 27080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		int inputX = Integer.parseInt((new BufferedReader(new InputStreamReader(System.in))).readLine());
		String result = (inputX >= 30) ? "Yes" : "No";
		System.out.println(result);
	}
}


Measured memory_bytes: 32640
# coding: utf-8
w = int(input())
ans = [i + 1 for i in range(w)]
loop = int(input())

# swap
for _ in range(loop):
    left, right = map(int, input().split(","))
    ans[left-1], ans[right-1] = ans[right-1], ans[left-1]

# result
for i in ans:
    print(i)


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

namespace atcoder_Begginer_Contest88_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                c[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
                c[i] = c[i].Select(x => x - c[i].Min()).ToArray();
            }
            Console.WriteLine((c[0].SequenceEqual(c[1]) && c[0].SequenceEqual(c[2])) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  map<int,int> memo;
  rep(i,N){
    int a;
    cin >> a;
    int b = a/400;
    if(b>8) b=8;
    memo[b]++;
  }

  int ret = 0;
  rep(i,8){
    ret += (memo[i]>0?1:0);
  }

  int mn = 0;
  if(ret > 0){
    mn = ret;
  }else{
    mn = (memo[8]>0?1:0);
  }
  int mx = ret + memo[8];
  
  cout << mn << " " << mx << endl;
  
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	S := nextLine()
	T := "CODEFESTIVAL2016"
	ans := 0
	for i := 0; i < len(S); i++ {
		if S[i] != T[i] {
			ans++
		}
	}
	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> Pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

    int n,k;
    cin >> n >> k;
    
    vector<ll> a(n+1,0);
    
    for(int i= 1;i<=n;i++) cin >> a[i];
    
    for(int i =1;i<=n;i++) a[i]+=a[i-1];
    
    //for(int i =1;i<=n;i++) a[i] = (a[i] - i)%k; 
    
    map<ll,ll> m;
    
    ll ans = 0;
    m[0] = 1;
    
    for(int i =1;i<=n;i++){
		
		if( i >= k) m[(a[i-k]-(i-k))%k]--;
		
		ans += m[(a[i]-i)%k];
		m[(a[i]-i)%k]++;	
		 
		}
     
   cout << ans << endl;

}




Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	s[1] ^= ('B'^'R');
	cout << s << endl;
	return 0;
}

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

int main(){
	int64_t n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	for(int64_t k = 0; k < n; k++) if(k * c - (n - 1 - k) * d <= b - a && b - a <= k * d - (n - 1 - k) * c){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}

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

long long su[200005];
map<long long, long long> suu;

int main(){
    int n;
    scanf("%d",&n);
    suu[0] += 1;
    for(int i=1;i<=n;i++){
        scanf("%lld",&su[i]);
        su[i] += su[i-1];
        suu[su[i]] += 1;
    }
    long long ans = 0;
    for(auto &pp: suu){
        ans += pp.second * (pp.second - 1) / 2;
    }
    printf("%lld\n", ans);
}


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

bool isOk(ll index,ll key){
    if(index>=key)return true;
    else return false;
}

ll bs(ll key){
    ll ng = -1;
    ll ok = 1e11;
    while(abs(ok-ng)){
        ll mid = (ok+ng)/2;
        if(isOk(mid,key))ok=mid;
        else ng = mid;
    }
    return ok;
}
int main(){
    ll b;
    while(cin>>b){
        if(b==0)break;
        ll ans=b,ans2=1;
        //ll j=b/2,n=1e6;
        for(ll n=1e5;n>0;n--){
//           ll t = (n*(2*j+(n-1)))/2;
            if((n-n*n+2*b)%(2*n)!=0)continue;
            ll j = (n-n*n+2*b)/(2*n);
//            ll j = 
//            ll j = n*(n+1); 
            if(j<=0)continue;
            //cout<<"tes:"<<(n-n*n+2*b)<<" tess:"<<2*n<<endl;
            //cout<<"j:"<<j<<" n:"<<n<<endl;
            //ans = bs(j);
            /*if ((n * n + n - j * j - j) / 2 == b)
            {
                if ((n - j + 1) > (ans2))
                {
                    ans = j;
                    ans2 = n - j + 1;
                }
                break;
            }*/
            if(n>ans2){
                ans = j;
                ans2 = n;
            }
        }
        /*        while(1){
            n--;
            bool flag= false;
            ll cnt=0;
            if(cnt>20){
                ll t = (n*(2*j+(n-1)))/2;
                cnt++;
                if(b==t){
                    flag=true;
                    break;
                }else if(b<t){
                    j/=2;
                    if(j==0)break;
                }else if(b>t){
                    j+=t/2;
                }
            }
            if(flag)break;
        }*/
        cout<<ans<<" "<<ans2<<endl;
    }
}


Measured memory_bytes: 3080
import sys
from collections import defaultdict, deque

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    f_inf = float('inf')
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    MAX_N = 110000
    dp = [0] * (W + 1)


    for _ in range(N):
        w, v = map(int, input().split())
        for sum_w in range(W, w-1, -1):
            tv = dp[sum_w - w] + v
            if tv > dp[sum_w]:
                dp[sum_w] = tv
    print(dp[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 10100
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;
const int N = 100000 + 10;
typedef long long LL;
int n, m;

int nod[2][N<<2], C, s, t;
vector< pair<int,int> > g[1300000 + 10];
void build(int id, int l, int r,int rt) {
    nod[id][rt] = ++ C;
    //printf("id = %d, l = %d, r = %d, rt = %d, C = %d\n", id, l, r, rt, C);
    if (l == r) {
        if (id == 0 && l == 1) s = nod[id][rt];
        if (id == 1 && l == n) t = nod[id][rt];
        if (id == 1) {
            g[ nod[id][rt] ].push_back( make_pair(nod[0][rt], 0) );
        }
        return;
    }
    int mid = (l + r) >> 1;
    build(id, l, mid, rt<<1);
    build(id, mid+1, r, rt<<1|1);
    if (id == 0) {
        g[nod[id][rt<<1]].push_back( make_pair(nod[id][rt], 0));
        g[nod[id][rt<<1|1]].push_back( make_pair(nod[id][rt], 0));
    } else {
        g[nod[id][rt]].push_back( make_pair(nod[id][rt<<1], 0));
        g[nod[id][rt]].push_back( make_pair(nod[id][rt<<1|1], 0));
    }
}
void split(int id, int to, int l, int r, int rt, int L, int R) {
    if (L <= l && r <= R) {
        if (id == 0){
            //printf("[%d, %d], id = %d, rt = %d\n", l, r, id, rt);
            //printf("link %d -> %d\n", nod[id][rt], to);
            g[ nod[id][rt] ].push_back(make_pair(to, 0));
        } else {
            //printf("@ [%d, %d], id = %d, rt = %d\n", l, r, id, rt);
            //printf("link %d -> %d\n", to, nod[id][rt]);
            g[to].push_back( make_pair(nod[id][rt], 0) );
        }
        return;
    }
    int mid = (l + r) >> 1;
    if (L <= mid) split(id, to, l, mid, rt<<1, L, R);
    if (R  > mid) split(id, to, mid+1, r, rt<<1|1, L, R);
}

struct Nod
{
    LL dis;int u;
    bool operator<(const Nod&o)const{
        return dis>o.dis;
    }
};
LL dis[1300000 + 10];
void dijkstra() {
    priority_queue<Nod> q;
    q.push((Nod){0, s}); 
    memset(dis,-1,sizeof(dis)); dis[s]=0;
    while (q.size()) {
        Nod tmp = q.top(); q.pop();
        int u = tmp.u;
        //printf("u = %d, %d\n", u, tmp.dis);
        if (dis[u] < tmp.dis) continue;
        for (auto e: g[u]) {
            int v = e.first;
            if (dis[v] == -1 || dis[v] > dis[u] + e.second) {
                dis[v] = dis[u] + e.second;
                q.push((Nod){dis[v], v});
            }
        }
    }
    printf("%lld\n", dis[t]);
}

int main() {
    scanf("%d%d",&n,&m);
    build(0,1,n,1); build(1,1,n,1);
    for(int i=1;i<=m;i++){
        int l,r,c; scanf("%d%d%d", &l,&r,&c);
        {
            int x=++C, y=++C;
            split(0, x, 1, n, 1, l, r);
            g[x].push_back(make_pair(y, c));
            split(1, y, 1, n, 1, l, r);
        }
        {
            int x=++C, y=++C;
            split(0, y, 1, n, 1, l, r);
            g[y].push_back(make_pair(x, c));
            split(1, x, 1, n, 1, l, r);
        }
    }
    //printf("s = %d, t = %d\n", s, t);
    dijkstra();
}

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

int main() {
	int ans[100000] = {};
	int n;
	cin >> n;
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int val = x*x + y*y + z*z + x*y + y*z + z*x;
				ans[val]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3476
N = int(input())
h = [int(x) for x in input().split()]

cost = [0] * N
cost[0] = 0
cost[1] = abs(h[1] - h[0])
for i in range(2, N):
    cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]))

print(cost[N - 1])

Measured memory_bytes: 20472
#include<iostream>
using namespace std;
int main(){
	int n,temp,cnt,minj;
	while(cin >> n){
		int k=0;
		int a[n];

		while(k!=n){
			cin >> a[k];
			k++;
		}
		cnt=0;
		for(int i=0;i<n;i++){
			minj =i;
			for(int j=i;j<n;j++){
				if(a[minj]>a[j]) minj =j;
			}
			if(minj!=i){
				temp=a[minj];
				a[minj]=a[i];
				a[i]=temp;
				cnt++;
			}
		}

	
		int l=0;
		while(l!=n-1){
			cout << a[l] << " ";
		l++;
		}
		cout << a[n-1]<< endl;
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

long long inv[1000002];

int C(int m, int n, int P) {
    long long res = 1;
    for (int i = 0; i < m; ++i) {
        res = res * (n - i) % P;
    }
    for (int i = 2; i <= m; ++i) {
        res = res * inv[i] % P;
    }
    return (int)res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    const int P = 1e9 + 7;
    inv[1] = 1;
    for (int i = 2; i <= 1000001; ++i) {
        inv[i] = (P - (P / i)) * inv[P % i] % P;
    }
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    int ans = (C(r2 + 1, r2 + 1 + c2 + 1, P) + C(r1, r1 + c1, P)) % P;
    ans = (ans + P - C(r2 + 1, r2 + 1 + c1, P)) % P;
    ans = (ans + P - C(r1, r1 + c2 + 1, P)) % P;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8064
n=int(input())
ll=[6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp=[i for i in range(100010)]

for l in ll:
    for x in range(l,n+1):
        dp[x]=min(dp[x],dp[x-l]+1)
print(dp[n])
    
    




Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,a;
    cin>>n>>m;
    long long int sum=0;
    for (long long int i=0;i<m;i++) {
        cin>>a;
        sum+=a;
    }
    if (n-sum<0) {
        cout<<-1<<endl;
    } else {
        cout<<n-sum<<endl;
    }
}


Measured memory_bytes: 3620
import numpy as np

N = int(input())
X = input()[::-1]
mod = X.count('1')
listX = np.array(list(X), int)

def simulate(num):
    counter = 0
    while num > 0:
        num %= bin(num).count('1')
        counter += 1
    return counter

if mod == 1:
    coefP = np.array([pow(2,i,mod+1) for i in range(N)])
    posi = np.dot(coefP, listX) % (mod+1)

    ans = []
    for i,x in enumerate(X):
        if x == '0':
            num = (posi + coefP[i]) % (mod+1)
            ans.append(simulate(num) + 1)
        else:
            ans.append(0)
    print(*ans[::-1], sep='\n')

else:
    coefP = np.array([pow(2,i,mod+1) for i in range(N)])
    coefN = np.array([pow(2,i,mod-1) for i in range(N)])
    posi = np.dot(coefP, listX) % (mod+1)
    nega = np.dot(coefN, listX) % (mod-1)

    ans = []
    for i,x in enumerate(X):
        if x == '0':
            num = (posi + coefP[i]) % (mod+1)
            ans.append(simulate(num) + 1)
        else:
            num = (nega - coefN[i]) % (mod-1)
            ans.append(simulate(num) + 1)
    print(*ans[::-1], sep='\n')

Measured memory_bytes: 39804
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
string s; 
int main(){
	cin>>s;
	if(s[1]==s[2]&&(s[0]==s[1]||s[3]==s[2])) cout<<"Yes";
	else cout<<"No";
    return 0;
}

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

struct status{
  vector<int> ans;
  vector<long long> last;
};

bool operator< (pair<long long, status> l, pair<long long, status> r){
  if(l.first != r.first) return l.first < r.first;
  return l.first < r.first;
}

int main() {
  int d;
  cin >> d;
  vector<long long> c(26);
  for(int i = 0; i < 26; i++) cin >> c.at(i);
  vector<vector<long long>> s(d, vector<long long> (26));
  for(int i = 0; i < d; i++){
    for(int j = 0; j < 26; j++) cin >> s.at(i).at(j);
  }
  
  priority_queue<pair<long long, status>> beam;
  vector<int> an(0);
  vector<long long> la(26, 0);
  status sta = {an, la};
  beam.push({(long long)0, sta});
  for(int day = 0; day < d; day++){
    priority_queue<pair<long long, status>> now;
    
    while(beam.size() > 0){
      long long score = beam.top().first;
      auto state = beam.top().second;
      beam.pop();
      state.ans.push_back(0);
      
      for(int i = 0; i < 26; i++){
        long long sum = score;
        auto n = state;
        n.last.at(i) = day;
        n.ans.at(day) = i + 1;
        
        sum += s.at(day).at(i);
        for(int j = 0; j < 26; j++){
          sum -= c.at(j) * (day - n.last.at(j));
        }
        
        now.push({sum, n});
      }
    }
    for(int i = 0; i < 120; i++){
      if(now.size() <= 0) break;
      beam.push(now.top());
      now.pop();
    }
  }
  
  auto res = beam.top().second.ans;
  for(auto now : res) cout << now << endl;
}


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// vector print(debug or stdout)
template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    REP(i,K) {
        vector<int> imos(N+1);
        REP(j,N) {
            int u = max(0,j-A[j]);
            int d = min(N,j+A[j]+1);
            imos[u] += 1;
            imos[d] -= 1;
            // cerr << u << " " << d << endl;
        }
        int cnt = 0;
        int all = A[0];
        int stop = true;
        REP(i,N) {
            cnt += imos[i];
            A[i] = cnt;
            if (A[i] != all) stop = false;
        }
        if (stop) break;
    }
    vout(ALL(A),cout);


    return 0;
}

Measured memory_bytes: 4984
# -*- coding: utf-8 -*-

import sys
import numpy as np
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, T = MAP()
AB = []
for i in range(N):
    a, b = MAP()
    AB.append((a, b))

# 各料理を時間の昇順でソート
AB.sort(key=itemgetter(0))

# 後は普通のナップザック
TMAX = 6007
dp = np.zeros((N+1, TMAX), dtype=np.int64)
for i in range(N):
    a, b = AB[i]
    dp[i+1] = dp[i]
    dp[i+1,a:a+T] = np.maximum(dp[i+1,a:a+T], dp[i,:T] + b)
print(dp[N].max())


Measured memory_bytes: 153184
import java.util.Scanner;
import java.util.Arrays;
import java.lang.Math;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                int W = scan.nextInt();
                int[] v = new int[N+1];
                int[] w = new int[N+1];
                for(int i=0; i<N; i++){
                        v[i] = scan.nextInt();
                        w[i] = scan.nextInt();
                }

                int[][] T = new int[N+1][W+1];
                // (1) ?????????
                for(int i=0; i<=W; i++){
                        T[0][i] = 0;
                }
                for(int i=0; i<=N; i++){
                        T[i][0] = 0;
                }

                // (2) ????????????????????´??°?????????
                // T[i][j] = Math.min(T[i-1][j], T[i][j-c[i]]+1)
                for(int i=1; i<=N; i++){
                        for(int j=1; j<=W; j++){
                                if (j-w[i-1] < 0)
                                {
                                        T[i][j] = T[i-1][j];
                                }else{
                                        T[i][j] = Math.max(T[i-1][j], T[i-1][j-w[i-1]]+v[i-1]);
                                }
                        }
                }

                System.out.println(T[N][W]);
        }
}

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


struct P
{
    //string r;
    long long x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
              return y>a.y;
    }
};


vector<int> v[1555];
//bitset<4001000> b;
int a,c,i,b,k,n,d,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[111222];

int o[113555];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,-1,1,-1,1},dz[10]={0,0,0,0,1,-1};

long long x,y,mod=1000000007;
long long z;
int j[200];
P u[110000];
//stack<int> s;
//queue<long long> q;
queue<int> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;
//string r;
char r[1310][1222];
//deque<int> de;

bool as(P a,P b)
{
    return (long long)a.x*b.y<(long long)b.x*a.y;
//    return 0;
}


int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=100;t++)
        for(int w=1;w<=100;w++)
        if(w<=t) r[t][w]='.';
        else r[t][w]='#';
    swap(a,b);
    a--;
    b--;
    for(int h=6;a;h+=3)
    for(int t=h-2,w=2;t<100&&a;t++,w++)
    {
        a--;
        r[t][w]='#';
    }
    for(int h=7;b;h+=3)
    for(int t=2,w=h-t;w<100&&b;t++,w++)
    {
        b--;
        r[t][w]='.';
    }
    printf("100 100\n");
    for(int t=1;t<=100;t++,puts(""))
        for(int w=1;w<=100;w++)
        printf("%c",r[t][w]);
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main(){
  ll n;
  cin >> n;
  map<ll,ll> ans;
  for(ll x=1; x*x+2*x+3<=n; x++){
    for(ll y=1; x*x+y*y+x*y+x+y+1<=n; y++){
      for(ll z=1; x*x+y*y+z*z+x*y+y*z+z*x<=n; z++){
        ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(ll i=1; i<=n; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 4156
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, K;
    cin >> N >> K;
    int a[N];
    REP(i, N) cin >> a[i];
    bool dp[K + 1];
    REP(i, a[0]) dp[i] = false;
    FOR(i, a[0], K + 1) {
        bool f = false;
        REP(j, N) {
            if (i - a[j] < 0) break;
            f = f | (!(dp[i - a[j]]));
        }
        dp[i] = f;
    }
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a;
		int b;
		while(true){
			if(!sc.hasNext())break;
			a = sc.nextInt();
			b = sc.nextInt();
			System.out.println(a + b);
		}
	}
}

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

int n;
vector<string> ans;
void dfs(string s, int used) {//aのみが使われた状態をused=1とする
	if (s.size() == n) {
		ans.push_back(s);
		return;
	}
	for (int i = 0; i < used; ++i) {
		string t(s);
		t.push_back('a' + i);
		dfs(t, used);
	}
	s.push_back('a' + used);
	dfs(s, used + 1);
}

signed main() {
	cin >> n;
	dfs("a", 1);
	sort(ans.begin(), ans.end());
	for (string x : ans) {
		cout << x << endl;
	}
}


Measured memory_bytes: 7796
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        int a;
        cin >> a;
        a--;
        A[i] = a;
    }

    int swap_num = 0;
    FOR(i, 0, N){
        if(i==N-1 && i==A[i]){
            swap_num++;
        }
        else if(i==A[i]){
            swap(A[i], A[i+1]);
            swap_num++;
        }
    }

    p(swap_num);
    
    return 0;
}

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

int main() {

	ll n; cin >> n;
	vector<pair<ll, ll>> pa;
	for (ll i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		pa.push_back({ b,a });
	}
	sort(pa.begin(), pa.end());
	ll time = 0;
	bool can = true;
	for (ll i = 0; i < n; i++) {
		time += pa[i].second;
		if (pa[i].first < time) can = false;
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 7436
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int32_t main() {
    fast_io();
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    int i = n, num = 0;
    vector <int> l, r;
    while (i >= 1)
    {
        if (s[i - 1] == 'o')
        {
            num++;
            r.pb(i);
            i -= c;
        }
        i--;
    }
    if (num != k)
        return 0;
    i = 1;
    reverse(r.begin(), r.end());
    while (i <= n)
    {
        if (s[i - 1] == 'o')
        {
            l.pb(i);
            i += c;
        }
        i++;
    }
    for (int i = 0; i < (int)l.size(); i++)
    {
        if (l[i] == r[i])
            cout << l[i] << " ";
    }
    return 0;
}

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

int main()
{ 
  int h, w ;
  cin >> h >> w ;
  vector< vector<string> > data(h, vector<string>(w)) ;
  for(int i = 0 ; i < h ; i++)
  {
    for(int j = 0 ; j < w ; j++)
    {
      cin >> data.at(i).at(j) ;
    }
  }

  int ans_i = 0 ;
  int ans_j = 65 ;
  for(int i = 0 ; i < h ; i++)
  {
    for(int j = 0 ; j < w ; j++)
    {
      if(data.at(i).at(j) == "snuke")
      {
        ans_i = i ;
        ans_j += j ;
        //cout << i << " " << j << endl ;
      }
    }
  }

  cout << (char)ans_j << ans_i + 1 << endl ; 
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var args = chunk.split(' ').map(Number);
    var length = args[0];
    var width = args[1];
    var area = length * width;
    var perimeter = 2 * (length + width);
    console.log(area, perimeter);
});

Measured memory_bytes: 7644