akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll m = min({A, B, C, D, E});
    cout << (N + m - 1) / m + 4 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int R,G,B,N,i,t,ans;
  ans=0;
  scanf("%d %d %d %d",&R,&G,&B,&N);
  for(i=0;i<=N/R;i++){
    for(t=0;t<=(N-R*i)/G;t++){
      if((N-R*i-G*t)%B==0){ans=ans+1;}
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
vector<Int> children[108000];
Int parent[108000][20];
Int dep[108000];
Int u, v, w, n, k, c, q;
void dfs_dep(Int x){
  for(auto c:children[x]){
    dep[c] = dep[x]+1;
    dfs_dep(c);
  }
}

int lca(int u, int v, int check = 19){
  while(check >= 0 && parent[u][check] == parent[v][check])check--;
  if(check == -1)return parent[u][0];
  return lca(parent[u][check], parent[v][check]);
}

int ancestor(int u, int height){
  for(int check = 19;check >= 0;check--){
    if((1<<check) > height)continue;
    u = parent[u][check];
    height -= (1<<check);
  }
  return u;
}

int main(){
  cin >> n;
  for(Int i = 0;i < n;i++){
    cin >> k;
    for(Int j = 0;j < k;j++){
      cin >> c;
      children[i].push_back(c);
      parent[c][0] = i;
    }
  }
  dfs_dep(0);
  for(int i = 1;i < 20;i++){
    for(int j = 0;j < n;j++){
      parent[j][i] = parent[parent[j][i-1]][i-1];
    }
  }
  cin >> q;
  while(q--){
    cin >> u >> v;
    if(dep[u] < dep[v])swap(u, v);
    if(dep[u] != dep[v])u = ancestor(u, dep[u] - dep[v]);
    if(u == v)cout << u << endl;
    else cout << lca(u, v) << endl;
  }  
  return 0;
}


Measured memory_bytes: 28196
#include <iostream>
using namespace std;
int LCM(int a, int b);
int GCD(int a, int b, int ans1);

int main(){
    int a,b;
    while(cin >> a >> b){
        int ans1 = LCM(a,b);
        int ans2 = GCD(a,b,ans1);
        cout << ans1 << " " << ans2 << endl;
    }
}

int LCM(int a, int b){
    int r;
    if(a < b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    while(1){
        r = a % b;
        if(r == 0) break;
        a = b;
        b = r;
    }
    
    return b;
}

int GCD(int a, int b, int ans1){
    int ans = b / ans1 * a;
    return ans;
}


Measured memory_bytes: 3004
#include<iostream>
#include<string>

using namespace std;
struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root=NULL, *NIL=NULL;

void Preorder(Node *root) {
    if ( root != NIL ) {
    cout << " " << root->key;
    Preorder(root->left);
    Preorder(root->right);
   }
}

void Inorder(Node *root) {
    if ( root != NIL ) {
       Inorder( root->left);
      cout << " " << root->key;
       Inorder( root->right);
     }
}

void Postorder(Node *root) {
    if ( root != NIL ) {
       Postorder( root->left);
       Postorder( root->right);
       cout << " " << root->key;
     }
}
void insert(int key) {
	Node *p=new Node;
	p->key=key;
	p->left=NIL;
	p->right=NIL;

	Node *x = root;
	Node *y = NIL;

	while(x != NIL ){
		y=x;
		if ( p->key > x->key ) x = x->right;
		else x = x->left;

	}
    
    p->parent = y;
    if( y == NIL ) root = p;
    else {
    	if ( p->key > y->key ) y->right = p;
    	else y->left = p;
    }

	//delete p;

}
int main() {
    int n;
    string op;
    int key;

    cin >> n;
    while ( n-- ) {
    	cin >> op;
    	if ( op == "insert" ) {
    		cin >> key;
    		insert(key);
    	} else if ( op == "print" ){
    		Inorder(root);
    		cout << endl;
    		Preorder(root);
    		cout << endl;
    	}
    }
	return 0;
}


Measured memory_bytes: 26636
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;

void change(string &s){
    rep(i, s.size()){
	if(s[i]=='?')s[i]='a';
    }
}

bool checkbox(vector<bool>&c){
    rep(i, c.size()){
	if(!c[i])return false;
    }
    return true;
}

int main(){
    /*input*/
    string s;
    string t;
    cin >> s >> t;
    /*calculatoin*/
    bool ok=false;  //false:UNRESTORABLE
    if(s.size() >= t.size()){
	for(int i = s.size()-1; i >= t.size()-1 && !ok; i--){
	    vector<bool>c(t.size(), false);
	    for(int j = t.size()-1; j >= 0; j--){
		int sptr = i-(t.size()-j-1);
		if(t[j]==s[sptr] || s[sptr] == '?')c[j]=true;
	    }
	    if(checkbox(c)){
		ok=true;
		for(int j = t.size()-1; j >= 0; j--){
		    int sptr = i-(t.size()-j-1);
		    s[sptr]=t[j];
		}
	    }
	}
    }
    change(s);
    /*output*/
    if(ok){
	cout << s << endl;
    }else{
	cout << "UNRESTORABLE" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    int a,b,c; cin >> a >> b >> c;
    int ans = c-(a-b);
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
button = input().split()
a_button = int(button[0])
b_button = int(button[1])
sum = 0

for i in range(0, 2):
    if(a_button >= b_button):
        sum += a_button
        a_button -= 1

    elif(b_button > a_button):
        sum += b_button
        b_button -= 1

print(sum)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

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

   int N;
   cin >> N;
   vector<int> A(N);
   rep(i,N) cin >> A[i];
   sort(ALL(A));
   deque<int> deq;
   // 先頭に小さい数、前と後ろに大きい数 前と後ろに小さい数って感じでいていく
   int mncnt = 0, mxcnt = 0;
   deq.push_back(A[mncnt]);
   mncnt++;
   while(mncnt + mxcnt < N){
      deq.push_front(A[N-1-mxcnt]);
      mxcnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_back(A[N-1-mxcnt]);
      mxcnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_front(A[mncnt]);
      mncnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_back(A[mncnt]);
      mncnt++;
      if(mncnt + mxcnt >= N)break;
   }
   ll ans = 0;
   rep(i,N-1)ans += abs(deq[i]-deq[i+1]);
   deq.resize(0);
   mncnt = 0;
   mxcnt = 0;
   deq.push_back(A[N-1-mxcnt]);
   mxcnt++;
   while( (mncnt + mxcnt) < N){
      deq.push_front(A[mncnt]);
      mncnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_back(A[mncnt]);
      mncnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_front(A[N-1-mxcnt]);
      mxcnt++;
      if(mncnt + mxcnt >= N)break;
      deq.push_back(A[N-1-mxcnt]);
      mxcnt++;
      if(mncnt + mxcnt >= N)break;
   }
   ll t = 0;
   rep(i,N-1)t+=abs(deq[i]-deq[i+1]);
   cout << max(t,ans) << endl;
}

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

int N, K;
void solve()
{
	int ans = K;
	for(int i = 1; i < N; i++){
		ans *= (K-1);
	}
	cout << ans << endl;
}
int main()
{
	cin >> N >> K;
	solve();
	return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll power(ll a, ll b)    //a is base, b is exponent
    {
        if(b==0)
            return 1;
        if(b==1)
            return a;
        if(b%2 == 1)
            return (power(a,b-1)*a)%mod;
        ll q = power(a,b/2);
        return (q*q)%mod;
    }

    ll sum[100001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,k,i,j;
            cin>>n>>k;
            ll ans=0,zz;
            for(i=k;i>=1;--i)
            {
                zz=k/i;
                sum[i]=power(zz,n);
                for(j=2*i;j<=k;j=j+i)
                {
                    sum[i]=(sum[i]-sum[j]+mod)%mod;
                }
                ans=(ans+sum[i]*i)%mod;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 4388
#include <stdio.h>

int main(void)
{
	int w, n;
	int a[30], b[30];
	int r[30];
	int i;
	
	scanf("%d\n", &w);
	scanf("%d\n", &n);
	
	for(i = 0; i < 30; i++)
		r[i] = i+1;
		
	for(i = 0; i < n; i++) {
		int temp;
		
		scanf("%d,%d", &a[i], &b[i]);
		temp = r[a[i] - 1];
		r[a[i] - 1] = r[b[i] - 1];
		r[b[i] - 1] = temp;
	}
	
	for(i = 0; i < w; i++)
		printf("%d\n", r[i]);
	
	return 0;
}


Measured memory_bytes: 596
#include <stdio.h>

int main(void){

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a<=b && b<=c){
        printf("%d %d %d\n",a,b,c);        
    }else if(a<=c && c<=b){
        printf("%d %d %d\n",a,c,b);
    }else if(b<=a && a<=c){
        printf("%d %d %d\n",b,a,c);
    }else if(b<=c && c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if(c<=a && a<=b){
        printf("%d %d %d\n",c,a,b);
    }else{
        printf("%d %d %d\n",c,b,a);
    }
}


Measured memory_bytes: 2060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<ll>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    vi sum(n+1);
    rep(i, n) {
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }

    sort(sum.begin(), sum.end());
    ll ans = 0LL;
    map<ll, int> mp;
    rep(i, n+1) {
        mp[sum[i]]++;
    }

    for(pair<ll, int> x:mp) {
        if(x.second&1) {
            ans += (x.second-1)/2*(ll)x.second;
        } else {
            ans += x.second/2*((ll)x.second-1);
        }
        
    }

    cout << ans << endl; 
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n, k;
  cin >> n >> k;
  vector< ll > a(n);
  for (ll i=0; i<n; ++i) cin >> a[i];
  ll asum = 0;
  for (ll i=0; i<n; ++i) asum += a[i];
  vector< ll > p;
  for (ll i=1; i*i<=asum; ++i) {
    if (asum%i==0) {
      p.push_back(i);
      if (i*i<asum) p.push_back(asum/i);
    }
  }
  sort(p.rbegin(), p.rend());
  for (ll idx=0; idx < p.size(); ++idx) {
    ll pi = p[idx];
    vector< ll > diff(n);
    for (ll i=0; i<n; ++i) diff[i] = a[i]-a[i]/pi*pi;
    //for (ll i=0; i<n; ++i) cerr << diff[i] << " ";
    //cerr << endl;
    sort(diff.rbegin(), diff.rend());
    ll kadd=0, ksub=0;
    ll aidx=0, sidx=n-1;
    while (aidx <= sidx) {
      if (kadd <= ksub) {
	kadd += pi-diff[aidx];
	aidx++;
      } else {
	ksub += diff[sidx];
	sidx--;
      }
    }
    // cerr << kadd << endl;
    if (kadd <= k) {
      cout << pi << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
n, a, b = map(int, input().split())

def comb(n, k):
    x, y = 1, 1
    for i in range(n, n-k, -1):
        x = x * i % MOD
    for i in range(1, k+1):
        y = y * i % MOD
    return x*pow(y, MOD-2, MOD) % MOD

ans = (pow(2, n, MOD)-1-comb(n,a)-comb(n,b)) % MOD

print(ans)

Measured memory_bytes: 62680
import java.util.*;

class Main{

    public static int gyo,retu;
    //yÂÂªÂÃ´ÂÂÂÂ©ÂÃ¯ÂÂÂÂ©ÂÃÂÃ¦ÂÃÂÃdx,dyÂÃÂÃÂÃ­ÂÃ©
    //(1,1)ÂÃÂÂyÂÃÂÃ¯ÂÂÂÃÂÃÂÃdx[1][],dy[1][]ÂÃ°ÂgÂÂ¤
    //ÂÂ±ÂÃÂÃÂÂ«ÂÃdx[0][],dy[0][]ÂÃ°ÂgÂÃÂÃÂÂµÂÃÂÂ¤ÂÃ(2,2)ÂÃ°ÂÃÂÃÂÂ¢ÂÃ(0,2)ÂÃ°ÂÃÂÃÂÂµÂÃÂÂ¤
  
    public static int[][] dx={{1,0,-1,0,-1,-1},{1,0,-1,0,1,1}};
    public static int[][] dy={{0,1,0,-1,1,-1},{0,1,0,-1,-1,1}};
    public static int[][] map = new int[105][105]; 

    public static void main(String[] args){

	Scanner in = new Scanner(System.in);

	retu = in.nextInt();
	gyo = in.nextInt();

	for(int i=0;i<=gyo+1;i++){
	    for(int j=0;j<=retu+1;j++)map[i][j]=0;
	}
	
	//System.out.println("Hello, World!");
	for(int i=1;i<=gyo;i++){
	    for(int j=1;j<=retu;j++)map[i][j]=in.nextInt();
	}		

	System.out.println(dfs(0,0));

    }

    public static int dfs(int x,int y){
	map[y][x]=9; //ÂfÂoÂbÂOÂÃÂÂ©ÂÃ¢ÂÂ·ÂÂ¢ÂÃ¦ÂÂ¤ÂÃ9ÂÃÂÂµÂÂ½
	int nx,ny,ans=0;
	/*
	for(int f=0;f<10;f++){
	    for(int g=0;g<10;g++)System.out.print(map[f][g] + " ");
	    System.out.printf("\n");
	}
	*/

	for(int i=0;i<6;i++){
	    nx = x + dx[y%2][i];
	    ny = y + dy[y%2][i];
	    if(nx > retu+1 || ny > gyo+1 || nx<0 || ny<0)continue;

	    if(map[ny][nx] == 1)ans++;
	    else if(map[ny][nx] == 0)ans += dfs(nx,ny);

	}

	return ans;
    }



}


























/*ÂYÂÃªÂÂ½ÂÂÂpÂÂÂÂ

Q:ÂÃÂÂ¤ÂÂ¢ÂÃÂÂ½ÂÂ´ÂÂ¶ÂÃÂvÂÂÂOÂÂÂÂÂÃÂÂ­ÂÃªÂÃÂÂ¢ÂÂ¢ÂÃÂH
A:6ÂÃ»ÂÃ¼ÂÂ©ÂÃ1ÂÃÂÃ§ÂJÂEÂÂÂgÂA0ÂÃÂÃ§ÂÂ»ÂÂ±ÂÃÂÃ²ÂÃÂÃ°ÂJÂÃ¨ÂÃÂÂ¹ÂÃÂÃ¦ÂÂ¢
Q:ÂÃÂÂºÂÃ6ÂÃ»ÂÃ¼ÂH8ÂÃ»ÂÃ¼ÂÂ¶ÂÃ¡ÂÃÂÂ¢ÂÃÂH
A:ÂÃ¦ÂÂ­ÂlÂÂ¦ÂÃÂÃÂÃ¦ÂÂ¤Â@8ÂÃ»ÂÃ¼ÂÂ¾ÂÃÂÃÂÃÂÃªÂÃÂÃ©0ÂÃÂÃ ÂÃ²ÂÃ±ÂÃÂÂµÂÃÂÂµÂÃÂÂ¤
Q:0ÂÃÂÃ²ÂÃÂÃÂÂ¢ÂÂ½ÂÃÂÃÂÃÂÂ¢ÂÂ¤ÂÃÂÃÂÃ­ÂÂ©ÂÃÂÂ½ÂÂ¯ÂÃÂAÂÃÂÂºÂÃÂUÂÃ»ÂÃ¼ÂH8ÂÃ»ÂÃ¼ÂÂ¶ÂÃ¡ÂH
A:ÂÂ«ÂZÂpÂ`ÂÃÂÃÂÂ©ÂÂ¢ÂÃÂÃ©ÂÃÂÂµÂÃ¥ÂÂ¤ÂÃÂWÂÃÂÃÂÂ ÂÃÂÃ2ÂÃ»ÂÃ¼ÂÃÂÃÂÂ±ÂÃÂÃÂÃ©ÂÃ±ÂÃÂÂµÂÃ¥ÂÂ¤ÂÂ©ÂÂ±ÂÃÂÂ¿ÂÂªÂÂ·ÂÂ«ÂÂ½ÂÂ¢ÂÃÂÂ·ÂÃ
Q:ÂÃÂÃ±ÂÃdx,dyÂÂª2ÂÃ­ÂÃÂÂ ÂÃ©ÂÃÂH
A:ÂOÂÃÂÃ ÂÂÂÂ¢ÂÂ½ÂÂµÂÃÂÃÂÃÂÃ£ÂÃ¼ÂÂµÂÃÂÂ³6ÂpÂ`ÂÃÂOÂÂÂtÂÃÂmÂFÂÂµÂÃÂÃÂÃÂÂ³ÂÂ¢
  ÂÃÂÂ¦ÂÃÂÂ¢ÂÃÂÂ³ÂÂµÂÂ¢ÂÃÂÂ±ÂÃ«ÂÃ°ÂÃÂÃÂÂ­ÂÃªÂÃÂÂ¹ÂÃ±
 */

Measured memory_bytes: 13000
import java.util.Scanner;

//Cubic Eight-Puzzle
public class Main{

	int[] top = {0, 0, 1, 1, 2, 2, 3};
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	int[][] adj = {
			{2, 5, 2, 5},
			{4, 3, 4, 3},
			{0, 4, 0, 4},
			{5, 1, 5, 1},
			{1, 2, 1, 2},
			{3, 0, 3, 0}
	};

	int[][] goal, state;
	boolean dfs(int ei, int ej, int depth, int limit, int pre){
		int dif = 0;
		for(int i=0;i<3;i++)for(int j=0;j<3;j++)dif+=top[state[i][j]]!=goal[i][j]?1:0;
		if(dif==0)return true;
		if(limit<depth+dif-1)return false;
		for(int k=0;k<4;k++){
			if(pre==(k+2)%4)continue;
			int ni = ei+d[k][0], nj = ej+d[k][1];
			if(0<=ni&&ni<3&&0<=nj&&nj<3){
				state[ei][ej] = adj[state[ni][nj]][k]; state[ni][nj] = 6;
				if(dfs(ni, nj, depth+1, limit, k))return true;
				state[ni][nj] = adj[state[ei][ej]][k]; state[ei][ej] = 6;
			}
		}
		return false;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int x = sc.nextInt(), y = sc.nextInt();
			if((x|y)==0)break;
			goal = new int[3][3];
			for(int i=0;i<3;i++)for(int j=0;j<3;j++){
				char c = sc.next().charAt(0);
				goal[i][j] = c=='W'?0:c=='R'?1:c=='B'?2:3;
			}
			state = new int[3][3];
			state[y-1][x-1] = 6;
			int res = -1;
			for(int L=0;L<=30;L++){
				if(dfs(y-1, x-1, 0, L, -1)){
					res = L; break;
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#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>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    map<ll, ll> cnt;
    ll sum = 0;
    cnt[0]++;
    for(int i=0; i<n; i++){
        ll a; cin>>a;
        sum += a;
        cnt[sum]++;
    }

    ll ans = 0;
    for(auto i : cnt){
        ans += (i.second * (i.second - 1)) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> c;
        if(c == 'Y') { cout << "Four" << '\n'; return 0; }
    }
    cout << "Three" << '\n';
    return 0;
}

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

const ll MOD = 1000000007;

ll dp[2][303][303];

int main()
{
    ll n, m;
    cin >> n >> m;
    dp[0][1][1] = 1;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k < j; k++){
                dp[i % 2][j][k] = (dp[(i + 1) % 2][j][k] * (j - k) + dp[(i + 1) % 2][j - 1][k] * (n - j + 1)) % MOD;
            }
            dp[i % 2][j][j] = dp[(i + 1) % 2][j][j] * j % MOD;
            for(int k = 1; k < j; k++) dp[i % 2][j][j] = (dp[i % 2][j][j] + dp[(i + 1) % 2][j][k] * k) % MOD;
        }
    }
    cout << dp[m % 2][n][n] << endl;
}


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

int main() {
  int n, i;
  cin >> n >> i;
  cout << n-i+1 << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(){
	
	int N,M;
	cin >> N >> M;
	int ans=0;

	std::vector<int> X(M);
	for (int i = 0; i < M; i++){
		cin >> X[i];
	}

	if (N < M){
		sort(X.begin(),X.end());
		std::vector<int> dist;

		for (int i = 0; i < M-1; i++){
			dist.push_back(X[i+1]-X[i]);
		}
		int sum=0;
		sort(dist.begin(),dist.end(),greater<int>());
		for (int i = 0; i < N-1; i++){
			sum += dist[i];
		}

		ans = X[M-1]-X[0]-sum;
	}
	
	cout << ans << endl;

	return 0;
}

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

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

  int ans = 0;
  for (int i=1; i<S.size(); i++) {
    string t = S.substr(0, S.size()-i);

    if (t.size() % 2 == 0) {
      string first = t.substr(0, t.size() / 2);
      string second = t.substr(t.size() / 2, t.size() / 2);
      if (first == second) {
        ans = t.size();
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
      int n;
      cin>>n;
      int a[n];
      set<int>s;
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
          s.insert(a[i]);
      }
      int x=s.size();
      if(x%2==0)
      x--;
      cout<<x;
    }
}
// 🍪 🍪 🍪


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

char str[10001];
int vis[2][16001];

bool solve(int s,vector<int> arr,int t) {
    s+=8000;t+=8000;
    memset(vis,-1,sizeof(vis));
    vis[0][s]=0;
    
    int cur=1,pr=0;
    queue<int> que;
    que.push(s);
    for(int i=0;i<(int)arr.size();i++) {
        int s=(int)que.size();
        while(s--) {
            int p=que.front();que.pop();
            if(p+arr[i]<=16000 && vis[cur][p+arr[i]]!=i+1) {
                vis[cur][p+arr[i]]=i+1;
                que.push(p+arr[i]);
            }
            if(p-arr[i]>=0 && vis[cur][p-arr[i]]!=i+1) {
                vis[cur][p-arr[i]]=i+1;
                que.push(p-arr[i]);
            }
        }
        swap(cur,pr);
    }
    return vis[pr][t]==(int)arr.size();
}
int main() {
    int x,y;
    scanf("%s%d%d",str,&x,&y);
    vector<int> arr[2];
    int idx=0,n=strlen(str);
    int cnt=0;
    for(int i=0;i<n;i++) {
        if(str[i]=='F') cnt++;
        else{
            arr[idx].push_back(cnt);
            cnt=0;
            idx^=1;
        }
    }
    arr[idx].push_back(cnt);

    puts(solve(arr[0][0],vector<int>(arr[0].begin()+1,arr[0].end()),x) && solve(0,arr[1],y) ? "Yes" : "No");
    
    return 0;
}


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

char hoge(string s,int d){
  if(s[d] == 'a'){
    return 'a';
  }
  else if(s[d] == 'b'){
    return 'b';
  }
  else{
    return 'c';
  }
}

int main(){
  string A,B,C;
  char tem;
  int a,b,c,x=0,y=0,z=0;
  cin>>A>>B>>C;
  a = A.length();
  b = B.length();
  c = C.length();
  tem = 'a';
  while(1){
      if(tem == 'a'){
        if(x==a) {cout<<'A'<<endl; break;}
        tem=hoge(A,x);
        x++;
      }
      else if(tem == 'b'){
        if(y==b) {cout<<'B'<<endl; break;}
        tem=hoge(B,y);
        y++;
      }
      else{
        if(z==c) {cout<<'C'<<endl; break;}
        tem=hoge(C,z);
        z++;
      }
    }
    return 0;
}


Measured memory_bytes: 256
// 問題文ちゃんと読んで！！！＞＜
import java.util.Scanner;

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

        int n = sc.nextInt();
        long y = sc.nextLong();

        long a = -1;
        long b = -1;
        long c = -1;

        label: for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n-i; j++) {
                long tmp = (y - i*10000 - j*5000) / 1000;

                if (tmp < 0)
                    break;
                
                if (i+j+tmp == n) {
                    a = i; b = j; c = tmp;
                }
            }
        }

        System.out.println(a + " " + b + " " + c);
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int paint(int u, int v) {
    int diff = abs(u - v);
    for(int i = 0; i < 10; i++) {
        if(diff & (1 << i)) {
            return (i + 1);
        }
    }
    return 1 << 10;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        for(int j = i + 1; j < n; j++) {
            cout << paint(i, j) << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin >> n;
	ll a = 1; ll b = 1; ll c = 1;
	rep(i,0,n){
		a = (a * 10) % MOD;
		b = (b * 9) % MOD;
		c = (c * 8) % MOD;
	}
	ll ans = (((a - 2 * b + c) % MOD) + MOD) % MOD;
	cout << ans <<  endl;
	
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-12;
const double PI = acos(-1);
const LL INFF = (LL)1e18;
const int INF = (int)1e9;
const int mod = 998244353;
const int MAX = (int)6e5+7;
LL val[MAX], re_val[MAX];
LL mypow(LL v, LL t){
	LL res = 1;
	while(t){
		if(t & 1) res = res*v%mod;
		t >>= 1;
		v = v*v%mod;
	}
	return res;
}	
void build(){
	val[0] = 1;
	rep1(i, 1, MAX) val[i] = val[i-1]*i%mod;
	rep(i, MAX) re_val[i] = mypow(val[i], mod-2);
	return ;
}
int n;
LL vv(int p){
	return (val[n]*re_val[p]%mod)*re_val[n-p]%mod;
}
int main(void){
	build();
	LL a, b, k;
	scanf("%d %lld %lld %lld", &n, &a, &b, &k);
	LL ans = 0;
	rep(i, n+1){
		LL v = a*i;
		if(v > k) break;
		LL v2 = k - v;
		if(v2 % b) continue;
		LL t = v2 / b;
		if(t > n) continue;
		LL res = vv(i)*vv(t)%mod;
		ans = (ans + res) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll n, p;
ll b(ll a, ll x)
{
	ll r = 1;
	for(;x>0;x /= 2)
	{
		if(x & 1)
		{
			if(a > p || a <= 0)
				return -1;
			r *= a;
		}
		a *= a;
		if(r > p||r<=0)
			return -1;
	}
	if(r <= 0)
		return -1;
	return r;
}
int main()
{
	cin >> n >> p;
	ll ans = 1;
	for(ll i = 1; i * i <= p; i ++)
	{
		if(p % i != 0)
			continue;
		ll j = p / i;
		ll q = b(i, n);
		if(q > 0)
			if(p % q== 0)
				umax(ans, i);
		q = b(j, n);
		if(q <= 0)
			continue;
		if(p % q == 0)
			umax(ans, j);
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string s; cin >> s;
    ll k; cin >> k;

    set<char> se;

    for (ll i = 0; i < s.size(); ++i) {
        se.insert(s[i]);
    }

    if (se.size() == 1) {
        cout << s.size() * k / 2 << endl;
        return 0;
    }

    string t = s + s;

    ll cnt1 = 0;

    for (int i = 0; i < s.size()-1; ++i) {
        if (s[i] == s[i+1]) {
            s[i+1] = 'A';
            ++cnt1;
        }
    }

    ll cnt2 = 0;

    for (int i = 0; i < t.size()-1; ++i) {
        if (t[i] == t[i+1]) {
            t[i+1] = 'A';
            ++cnt2;
        }
    }

    cout << cnt1 + (cnt2 - cnt1) * (k - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  if((A+B)%2==0) {
cout<<(A+B)/2<<endl;
  }
  else {
cout<<"IMPOSSIBLE"<<endl;
  }
}

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

int main() {
  int n, k, x, y;
  cin >> n;
  cin >> k;
  cin >> x;
  cin >> y;

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= k) {
      ans += x;
    }
    else {
      ans += y;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
ll NUM = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define zer ll(0)

void solve()
{
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<ln;
}
 
int  main()
{
  fast_cin();
  ll t=1;
  //cin>>t;
  while(t--)solve();
  return 0;
} 

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Mint{
    public:
    int v;
    const long long MOD = 1000000007;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD; if(v<0)v+=MOD;}

    Mint pow(long long k){
        Mint res(1), tmp(v);
        while(k){
            if(k&1)res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }
    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v; if(v>=MOD)v-=MOD; return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD; return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-(){return v ? MOD-v : v;}
    bool operator==(Mint a)const{return v==a.v;}
    bool operator!=(Mint a)const{return v!=a.v;}

    Mint operator=(Mint a) {v=a.v;return a;}

    friend ostream& operator<<(ostream& os, const Mint& mint){
        os << mint.v;
        return os;
    }
};

class cmbs{
    public:
    vector<Mint> fact, finv, inv;
    cmbs(){
        fact.clear(); finv.clear(); inv.clear();
    }
    void init(int n){
        if(n+1 <= (signed)fact.size())return;
        fact.assign(n+1,1);
        finv.assign(n+1,1);
        inv.assign(n+1,1);

        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*Mint(i);
        finv[n] = Mint(1)/fact[n];
        for(int i=n; i>=1;i--) finv[i-1] = finv[i]*Mint(i);
        for(int i=1; i<=n; i++) inv[i] = finv[i]*fact[i-1];
    }
    Mint comb(long long n, int k){
        if(n<k||k<0)return Mint(0);
        Mint res(1);
        for(int i=0; i<k; i++){
            res *= Mint(n-i);
            res /= Mint(i+1);
        }
        return res;
    }
    Mint C(int n,int k){
        if(n<k||k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k]*finv[k];
    }
    Mint P(int n, int k){
        if(n<k || k<0)return Mint(0);
        init(n);
        return fact[n]*finv[n-k];
    }
    Mint H(int n, int k){
        if(n<0||k<0)return Mint(0);
        if(!n&&!k)return Mint(1);
        init(n+k-1);
        return C(n+k-1,k);
    }
};

int main(){
    ll n,k;
    cin>>n>>k;
    cmbs cmb;
    Mint v = cmb.P(k,n);
    cout<<v<<endl;
    return 0;
}


Measured memory_bytes: 3144
N = input()
for loop in range(N):
    s, d = map(int, raw_input().split())
    if s <= 0 <= d:
        print bin(s).count('1') + bin(d).count('1')
        continue
    if d <= 0:
        d, s = -s, -d
    ans = 0
    num = 2
    while s < d:
        if s % num != 0:
            s += num / 2
            ans += 1
        num *= 2
    ans -= 1
    s -= num / 4
    print ans + bin(d - s).count('1')



Measured memory_bytes: 4664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define Rep(i,s,f) for(int i=(int)s;i<(int)f;i++)
using ll=long long;
using namespace std;


int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	rep(i,N) cin>>A[i];
	vector<int> dist(N+1);
	dist[0]=abs(A[0]);
	dist[N]=abs(A[N-1]);
	ll sum=dist[0]+dist[N];
	rep(i,N-1)
	{
		dist[i+1]=abs(A[i]-A[i+1]);
		sum+=dist[i+1];
	}
	rep(i,N)
	{
		int a1,a2;
		if(i==0)
		{
			a1=0;
			a2=A[1];
		}
		else if(i==N-1)
		{
			a1=A[N-2];
			a2=0;
		}
		else
		{
			a1=A[i-1];
			a2=A[i+1];
		}
		cout<<sum-(dist[i]+dist[i+1])+abs(a1-a2)<<endl;
	}	
	return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Console.ReadLine();
            var n = int.Parse(N);
            var h = N.Sum(x => x - '0');
            Console.WriteLine(n % h == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27836
S = list(map(int,list(input())))
K = int(input())
from itertools import groupby, accumulate, product, permutations, combinations
def solve(S,K):
    ans = 0
    n = len(S)
    dp1 = [[0]*5 for _ in range(n)]
    dp0 = [[0]*5 for _ in range(n)]
    dp0[0][1] = 1
    dp1[0][0] = 1
    dp1[0][1] = S[0]-1
    for i in range(1,n):
        for j in range(4):
            dp1[i][j] = dp1[i-1][j]+dp1[i-1][j-1]*9
            if S[i]==0:
                dp0[i][j] = dp0[i-1][j]
            else:
                dp0[i][j] = dp0[i-1][j-1]
                dp1[i][j] += dp0[i-1][j-1]*(S[i]-1)+dp0[i-1][j]
    ans = dp1[n-1][K]+dp0[n-1][K]
    return ans
print(solve(S,K))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
using ll = long long;
int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	if((c - a - b) * (c - a - b) > 4 * a * b and c > a + b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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


int main(){
	
	int n, w, i, j;
	scanf("%d %d", &n, &w);
	vector <long long> arr(n), weight(n);
	for(int i = 0; i < n; i++){
		scanf("%lld %lld", &weight[i], &arr[i]);
	}

	long long dp[n+1][w+1];
	for(i = 0; i <= n; i++){
		for(j = 0; j <= w; j++){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
			}
			else if(weight[i-1] <= j){
				dp[i][j] = max(dp[i-1][j], arr[i-1] + dp[i-1][j-weight[i-1]]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][w];
}

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

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

	int tmp = N % 10;

	if (tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9) {
		cout << "hon" << endl;
	}
	else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "bon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
res = 0

for i in range(K, N+2):
    mini = (i-1)*(i)//2 
    maxi = (N-i+1) * i + (i-1)*(i)//2
    
    tmp = maxi - mini + 1
    res = (res+tmp) % MOD

print(res)

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

int main() {
  ll N;
  cin >> N;
  ll sum;
  vector<ll> X(N);
  for(ll i=0;i<N;i++){
    cin >> X.at(i);
    sum += X.at(i);
  }
  ll ave1,ave2;
  ave1=sum/N;
  ave2=sum/N+1;
  ll V1=0;
  ll V2=0;
  for(ll i=0;i<N;i++){
    V1 = V1 + (X.at(i)-ave1)*(X.at(i)-ave1);
    V2 = V2 + (X.at(i)-ave2)*(X.at(i)-ave2);
  }
  cout << min(V1,V2) << endl;
}


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

int A[10001];
vector<int> ans;

int main(void) {
    int n, a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        A[a]++;
    }
    for (int i = 0; i < 10001; i++) {
        for (int j = 0; j < A[i]; j++) {
            ans.push_back(i);
        }
    }
    for (int i = 0; i < (int)ans.size(); i++) {
        if (i < (int)ans.size() - 1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10264
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007

int main(){
	int H,W;
	cin >> H >> W;
	vector<vector<char>> maze(H,vector<char>(W));
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> maze[i][j];
		}
	}

	vector<vector<int>> dp(H+1,vector<int>(W+1));
	for(int i=1; i<=H; i++){
		for(int j=1; j<=W; j++){
			if(i==1 && j==1){ dp[i][j] = 1; continue; } 
			if(maze[i-1][j-1] == '.'){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % INF;
			}
		}
	}

	cout << dp[H][W] << endl;
}



Measured memory_bytes: 8476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k;cin>>n>>k;
    vl a(n);rep(i,n)cin>>a[i];
    vl dp(k+1);
    for(int i=1;i<=k;i++){
        rep(j,n){
            if(i-a[j]>=0){
                if(dp[i-a[j]]==0)dp[i]=1;
            }
        }
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

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

int solve(){
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if(n == 0) return 1;
    vector<vector<int> > cnt(m, vector<int>(n,1));
    for(;t>0;t--){
        int d, c;
        cin >> d >> c;
        if(d==2){
            vector<vector<int> > tmp(n, vector<int>(m));
            for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    tmp[j][i] = cnt[i][j];
                }
            }
            cnt = tmp;
            swap(m,n);
        }
        for(int i=0;i<m;i++){
            cnt[i].resize(max(n,c*2));
            for(int j=0;j<c;j++){
                cnt[i][c+j] += cnt[i][c-1-j];
            }
            cnt[i].erase(cnt[i].begin(), cnt[i].begin()+c);
        }
        n = cnt[0].size();
        if(d==2){
            vector<vector<int> > tmp(n, vector<int>(m));
            for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
                    tmp[j][i] = cnt[i][j];
                }
            }
            cnt = tmp;
            swap(m,n);
        }
    }
    for(;p>0;p--){
        int x, y;
        cin >> x >> y;
        cout << cnt[y][x] << endl;
    }

    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}



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

int cnt = 0;

void InsertionSort(vector<int> &V, int N, int g)
{
    for (int i = g; i < N; i++)
    {
        int v = V[i];
        int j = i - g;
        while (j >= 0 && V[j] > v)
        {
            V[j + g] = V[j];
            j -= g;
            cnt++;
        }
        V[j + g] = v;
    }
}

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

    int x;
    if (N <= 3)
    {
        x = 1;
    }
    else
    {
        x = (N - 1) / 3;
    }

    vector<int> G;
    for (int i = x; i >= 1; i = (i - 1) / 3)
    {
        G.push_back(i);
        InsertionSort(A, N, i);
        if (i == 2 || i == 3)
        {
            i = 4;
        }
    }

    cout << G.size() << endl;
    for (int i = 0; i < G.size(); i++)
    {
        cout << G[i];
        if (i < G.size() - 1)
        {
            cout << " ";
        }
    }
    cout << endl;
    cout << cnt << endl;
    for (auto a : A)
    {
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 6784
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

print("Yes" if S[2]==S[3] and S[4]==S[5] else "No")

Measured memory_bytes: 5148
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;

const int MOD = 1000000007;
const int INF = 1000000000;

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;
}



struct edge{
    int to, cost;
    edge(int To, int Cost) : to(To), cost(Cost){};
};


int V; //頂点数
vector<vector<edge>> G(10, vector<edge>());
vector<int> d(10); //sからの距離

void dijkstra(int s){
    //Pii first: 距離　second: 頂点
    priority_queue<PII, vector<PII>, greater<PII>> que;
    fill(ALL(d), INF);
    d[s] = 0;
    que.push(MP(0, s));

    while(!que.empty()){
        PII p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(MP(d[e.to], e.to));
            }
        }
    }
}

int main(){
    int h, w; cin >> h >> w;
    REP(i, 10) REP(j, 10){
        int c; cin >> c;
        G[j].PB(edge(i, c));
    }
    dijkstra(1);
    int ans = 0;
    REP(i, h) REP(j, w){
        int a; cin >> a;
        if(a == -1) continue;
        ans += d[a];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	for (int i = 1; i <= n; ++i)
	{
		if(i%3==0 || i%5==0)
		{}
		else ans+=i;
	}
	cout<<ans<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

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

Measured memory_bytes: 1024