akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std;

void trace(int A[], int N) {
    for (int i = 0; i < N; i++){
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    int v;
    for (int i = 1; i < N; i++){
        v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int A[100];
    int N;
    cin >> N;
    for (int k = 0; k < N; k++){
        cin >> A[k];
    }
    trace(A, N);
    insertionSort(A, N);
    return 0;
}


Measured memory_bytes: 3092
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b) = readIntegerList()
    val hList = LongArray(n) { readLong() }

    val diff = a - b
    fun canDefeatAllBy(count: Long) = hList.map { it - count * b }
        .filter { it > 0L }
        .fold(0L) { acc, v -> acc + (v + (diff - 1)) / diff }
        .let { it <= count }

    var left = -1L
    var right = hList.fold(0L) { acc, v -> acc + (v + (b - 1)) / b } + 1
    while (right - left > 1L) {
        val mid = (right + left) / 2
        if (canDefeatAllBy(mid)) right = mid else left = mid
    }

    println(right)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 86668
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ss second
const ll mod = (ll)1e9 + 7;
ll power(ll x, ll a)
{
    if(a==0)return(1);
    ll z  = power(x, a/2);
    z = (z * z)%mod;
    if(a%2)z = (z * x)%mod;
    return(z);
}
int main()
{
    int s;
    cin>>s;
    vll dp(2001, 1);
    dp[0]=0;
    dp[1]=0;
    dp[2]=0;    
    for(int no = 4; no<=s; no++)
    {
        for(int x = 3; x<=no-3; x++)
        {
            dp[no]+=dp[x];
            dp[no]%=mod;
        }
    }
    cout<<dp[s]<<endl; 

}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
char f2[500];
string st1,st2;
int l;
int main()
{
	cin>>st1;
	f2['b']='d';
	f2['d']='b';
	f2['p']='q';
	f2['q']='p';
	l=st1.size();
	st2=st1;
	reverse(st1.begin(),st1.end());
	for (int i=0;i<l;i++)
		if (st2[i]!=f2[st1[i]])
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;

const int dx[4] = { -1,  0 };
const int dy[4] = {  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

using namespace std;

typedef pair<int, int> pii;

class C {
	int n;
	int ans{ 0 };
	vector<pii> red;
	vector<pii> queries;
	vector<bool> matched;

public:
	C()
	{
		cin >> n;
		red.reserve(n);
		queries.reserve(n);
		matched.resize(n, false);

		int y, x;
		REP(i, n)
		{
			cin >> y >> x;
			red.emplace_back(MP(y, x));
		}
		REP(i, n)
		{
			cin >> y >> x;
			queries.emplace_back(MP(y, x));
		}
	}

	void search(const int& sy, const int& sx)
	{
		if (!sx || !sy)
			return;

		REP(i, n)
		{

			if (red[i].second < sx && red[i].first < sy && !matched[i])
			{
				ans++;
				matched[i] = true;
				return;
			}

		}

	}


	void solve()
	{
		sort(ALL(queries));
		sort(ALL(red), [](const pii& left, const pii& right) { return (left.second > right.second); });

		REP(i, n)
			search(queries[i].first, queries[i].second);

		cout << ans << endl;

	}
};

int main()
{

	C solution;
	solution.solve();

	return 0;
}

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

int main(){
  ll n,k;
  cin >> n;
  vector<ll> a(n,0),b(n,0),c(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  ll dp[n][2][2][2];
  dp[0][1][0][0]=a[0];dp[0][0][1][0]=b[0];dp[0][0][0][1]=c[0];
  for(int i=1;i<n;i++){
    dp[i][1][0][0] = max(dp[i-1][0][1][0],dp[i-1][0][0][1]) + a[i];
    dp[i][0][1][0] = max(dp[i-1][1][0][0],dp[i-1][0][0][1]) + b[i];
    dp[i][0][0][1] = max(dp[i-1][0][1][0],dp[i-1][1][0][0]) + c[i];
  }
  cout << max(dp[n-1][1][0][0],max(dp[n-1][0][1][0],dp[n-1][0][0][1])) << endl;
}


Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[100001];
int odd(int n)
{
    int cnt=0;
    while(n!=0)
    {
        n/=10;
        cnt++;
    }
    
    return cnt%2!=0;
}


int main()
{
   int n; cin>>n;
   int cnt=0;
   for(int i=1;i<=n;i++)
   {
        if(odd(i))
        {
        cnt++;
        }
    }
    cout<<cnt;

}

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

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cout << setprecision(15) << fixed;
 
    char c; cin >> c;
    cout << (islower(c) ? 'a' : 'A') << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct hopcroft{
	vector<int> dist, pair_l, pair_r;
	vector<bool> seen;
	vector<vector<int>> to;
	int n1, n2;
	hopcroft(int n1, int n2) : n1(n1), n2(n2){
		to.resize(n1);
		pair_l.assign(n1, -1);
		pair_r.assign(n2, -1);
		dist.resize(n1);
		seen.resize(n1);
	}
	void add_edge(int u, int v){
		to[u].push_back(v);
	}
	bool bfs(){
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int i = 0; i < n1; i++){
			if (pair_l[i] == -1){
				dist[i] = 0;
				q.push(i);
			}
		}
		bool reach_minus = false;
		while (!q.empty()){
			int u = q.front();
			q.pop();
			for (int adj : to[u]){
				int radj = pair_r[adj];
				if (radj == -1){
					reach_minus = true;
				} else if (dist[radj] == -1){
					dist[radj] = dist[u] + 1;
					q.push(radj);
				}
			}
		}
		return reach_minus;
	}
	bool dfs(int u){
		seen[u] = true;
		for (int adj : to[u]){
			int radj = pair_r[adj];
			if (radj == -1 || (!seen[radj] && dist[radj] == dist[u] + 1 && dfs(radj))){
				pair_l[u] = adj;
				pair_r[adj] = u;
				return true;
			}
		}
		return false;
	}
	int max_matching(){
		int res = 0;
		while (bfs()){
			fill(seen.begin(), seen.end(), false);
			for (int i = 0; i < n1; i++)
				if (pair_l[i] == -1 && dfs(i))
					res++;
		}
		return res;
	}
};
const int lim = 10000002;
bool prime[lim];
void init(){
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i < lim; i++){
		if(prime[i]){
			for(int j = i + i; j < lim; j += i)
				prime[j] = false;
		}	
	}
}
int main(){
	init();
	int n; cin >> n;
	bitset<lim> b;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		b[x] = 1;
	}
	vector<int> p[2];
	for(int i = 1; i < lim; i++){
		if(b[i] != b[i - 1]){
			p[i%2].push_back(i);
		}
	}
	int l0 = p[0].size(), l1 = p[1].size();
	hopcroft ho(l0, l1);
	assert((l0 + l1) % 2 == 0);
	for(int i = 0; i < l0; i++){
		for(int j = 0; j < l1; j++){
			if(prime[abs(p[0][i] - p[1][j])]){
				ho.add_edge(i, j);
			}
		}
	}
	int fl = ho.max_matching();
	int ans = fl + ((l0 - fl) / 2) * 2 + ((l1 - fl)/2) * 2 + ((((l0 - fl) % 2) + ((l1 - fl) % 2))/2) * 3;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>

long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}

int main()
{
	long long a, b, n; scanf ("%lld %lld %lld", &a, &b, &n);

	long long g = gcd(a, b);
	long long r = b - g;
	if (r > n) r = n;

	printf ("%lld\n", (a * r) / b);

	return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;
import java.util.Arrays;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int c = scanner.nextInt();
		int[][] numbers = new int[r+1][c+1];

		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				numbers[i][j] = scanner.nextInt();
			}
		}

		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				numbers[i][c] += numbers[i][j];
			}
		}

		for(int i = 0; i <= c; i++){
			for(int j = 0; j < r; j++){
				numbers[r][i] += numbers[j][i];
			}
		}

		for(int i = 0; i <= r; i++){
			for(int j = 0; j < c; j++){
				System.out.print(numbers[i][j] + " ");
			}
			System.out.println(numbers[i][c]);
		}
		
	}
}

Measured memory_bytes: 41844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    bool N = false,W = false,S = false,E = false;
    REP(i,s.length()){
        if(s[i] == 'N') N = true;
        else if(s[i] == 'W') W = true;
        else if(s[i] == 'S') S = true;
        else if(s[i] == 'E') E = true;
    }
    if((N == true && W == true && S == true && E == true) || (N == true && W == false && S == true && E == false) || (N == false && W == true && S == false && E == true)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int IsPrime(int);

main(){
  int n, x, i, count=0;

  scanf("%d", &n);

  for( i = 0; i< n; i++){
    scanf("%d", &x);

    count += IsPrime(x);

  }

  printf("%d\n", count);

  return 0;

}

int IsPrime(int x){

  int i;

  if( x == 2 ) return 1;

  else if( x < 2 || x % 2 == 0 ) return 0;

    i = 3;
    while( i <= sqrt(x) ){
      if( x % i == 0 ) return 0;
      i = i + 2;
    }

    return 1;

}

Measured memory_bytes: 596
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node {
        int key;
      struct   Node *prev, *next;
};
struct Node *nil;
void printList(){
  struct Node *cur = nil->next;
  int isf =0;
  while(1){
    if(cur==nil){
      break;
    }
    if(isf++>0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void init(){
        nil=(struct Node *)malloc(sizeof(struct Node));
        nil->next=nil;
        nil->prev=nil;
}
void insert(int key){
        struct Node *x=(struct Node *)malloc(sizeof(struct Node));
        x->key=key;
        x->next=nil->next;
        nil->next->prev=x;
        nil->next=x;
        x->prev=nil;
}
struct Node* listsearch(int key){
        struct Node *cur=nil->next;
        while(cur!=nil&&cur->key !=key) {
                cur=cur->next;
        }
        return cur;
}
void deleteNode(struct Node *t){
        if(t==nil) {
                return;
        }
        t->prev->next=t->next;
        t->next->prev=t->prev;
        free(t);

}
void deleteFirst(){
        deleteNode(nil->next);
}
void deleteLast(){
        deleteNode(nil->prev);
}
void deletekey(int key){
        deleteNode(listsearch(key));
}
int main(){
        int key,n,i;
        int size=0;
        char com[20];
        int np=0,nd=0;
        scanf("%d",&n);
        init();
        for(i=0; i<n; i++) {
                scanf("%s%d",com,&key);
                if(com[0]=='i') {
                        insert( key);
                        np++;
                        size++;
                }
                else if(com[0]=='d') {
                        if(strlen(com)>6) {
                                if(com[6]=='F') {
                                        deleteFirst();
                                }
                                else if(com[6]=='L') {
                                        deleteLast();
                                }

                        }

                        else{
                                deletekey(key);
                                nd;
                        }
                        size--;

                }
        }
        printList();
        return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  int matrix[100][100]={{0}};
  int vector[100]={0};
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>matrix[i][j];
    }
  }
  for(int j=0;j<m;j++){
    cin>>vector[j];
  }
  
  for(int i=0;i<n;i++){
    int result = 0;
    for(int j=0;j<m;j++){
      result += matrix[i][j]*vector[j];
    }
    cout<<result<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define int long long

int32_t main()
{
    int n; cin>>n;
    vector<int> a(n+2),b(n+1);
    a[0]=0;
    int sum=0;
    for(int i=1;i<=n+1;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
        if(b[i]<=a[i]) sum+=b[i];
        else
        {
            sum+=a[i]; b[i]-=a[i];
            //cout<<b[i]<<" "<<a[i+1]<<endl;
            if(a[i+1]>=b[i])
            {
                sum+=b[i];
                a[i+1]-=b[i];
            }
            else
            {
               // cout<<a[i+1]<<endl;
                sum+=a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int in;
    int ans;
    for (int i = 0; i < 5; i++)
    {
        cin >> in;
        if (in == 0) ans = i + 1;
    }

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

Measured memory_bytes: 3576
#include<iostream>
#include<queue>
using namespace std;
int H,W;
string s[30],v;
struct state{
	int x,y,t,f,id;
};
int dp[30][30][7][7][7];
int rgt[7][7];
string col=" rmbygc";
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
main()
{
	rgt[1][2]=3;
	rgt[1][3]=5;
	rgt[1][4]=2;
	rgt[1][5]=4;
	rgt[2][1]=4;
	rgt[2][3]=1;
	rgt[2][4]=6;
	rgt[2][6]=3;
	rgt[3][1]=2;
	rgt[3][2]=6;
	rgt[3][5]=1;
	rgt[3][6]=5;
	rgt[4][1]=5;
	rgt[4][2]=1;
	rgt[4][5]=6;
	rgt[4][6]=2;
	rgt[5][1]=3;
	rgt[5][3]=6;
	rgt[5][4]=1;
	rgt[5][6]=4;
	rgt[6][2]=4;
	rgt[6][3]=2;
	rgt[6][4]=5;
	rgt[6][5]=3;
	while(cin>>W>>H,H)
	{
		for(int i=0;i<H;i++)for(int j=0;j<W;j++)
		{
			for(int k=0;k<7;k++)for(int l=0;l<7;l++)for(int m=0;m<7;m++)
			{
				dp[i][j][k][l][m]=1e9;
			}
		}
		queue<state>P;
		for(int i=0;i<H;i++)
		{
			cin>>s[i];
			for(int j=0;j<W;j++)
			{
				if(s[i][j]=='#')
				{
					P.push((state){i,j,1,2,0});
					dp[i][j][1][2][0]=0;
				}
			}
		}
		cin>>v;
		int ans=-1;
		while(!P.empty())
		{
			state now=P.front();P.pop();
			int cost=dp[now.x][now.y][now.t][now.f][now.id];
			if(now.id==6)
			{
				ans=cost;
				break;
			}
			for(int r=0;r<4;r++)
			{
				state nxt;
				nxt.x=now.x+dx[r];nxt.y=now.y+dy[r];
				if(nxt.x<0||nxt.y<0||nxt.x>=H||nxt.y>=W||s[nxt.x][nxt.y]=='k')continue;
				if(r==0)
				{
					nxt.t=7-rgt[now.t][now.f];
					nxt.f=now.f;
				}
				else if(r==1)
				{
					nxt.t=7-now.f;
					nxt.f=now.t;
				}
				else if(r==2)
				{
					nxt.t=rgt[now.t][now.f];
					nxt.f=now.f;
				}
				else if(r==3)
				{
					nxt.t=now.f;
					nxt.f=7-now.t;
				}
				nxt.id=now.id;
				char sc=s[nxt.x][nxt.y];
				if(sc!='w'&&sc!='#')
				{
					if(sc!=col[nxt.t]||v[nxt.id]!=sc)continue;
					nxt.id++;
				}
				if(dp[nxt.x][nxt.y][nxt.t][nxt.f][nxt.id]>cost+1)
				{
					dp[nxt.x][nxt.y][nxt.t][nxt.f][nxt.id]=cost+1;
					P.push(nxt);
				}
			}
		}
		if(ans<0)cout<<"unreachable"<<endl;
		else cout<<ans<<endl;
	}
}



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

int main() {
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){cin >> A[i];}
  int miss = 0;
  int ans = 0;
  while(miss==0){
    for(int i=0;i<N;i++){
      if(A[i]%2==0){
        A[i] /= 2;
      }else{
        miss++;
      }
    }
    if(miss==0){ans++;}
  }
 cout << ans << endl;
  
  
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int r;
  cin >> r;

  cout << 2 * 3.1415926535 * r << endl;

  return 0;
}


Measured memory_bytes: 3804
#include<iostream>
using namespace std;
int n;
int main()
{
	cin>>n;
	int a,b;
	a=n%10;
	b=n/10;
	if(a==9) {cout<<"Yes"<<endl;return 0;}
	if(b==9){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
alst = list(map(int, input().split()))
minus = 0
for num in alst:
    if num < 0:
        minus += 1

blst = [abs(num) for num in alst]
blst.sort()

if 0 in alst:
    print(sum(blst))
elif minus % 2 == 0:
    print(sum(blst))
else:
    print(sum(blst[1:]) - blst[0])

Measured memory_bytes: 20020
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}
const ll inf = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int n = s.length()-1;
    long long sum = 0;
 
    for(int bit = 0; bit < (1<<n);bit++){
        int start = 0;
        int stop = n+1;
        for(int i = 0;i < n;i++){
            if(1 & (bit>>i)){
                stop = i+1;
                sum += atoll(s.substr(start,stop-start).c_str());
                start = stop;
            }
        }
        sum += atoll(s.substr(start,n+1-start).c_str());
    }
    cout << sum << endl;
}

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

const int mod = 1e9 + 7;

// O(N * K^2)

void add_self(int& a, int b) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
}
void sub_self(int& a, int b) {
	a -= b;
	if(a < 0) {
		a += mod;
	}
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> dp(k + 1);
	// dp[i] - the number of ways such that we used i candies so far
	dp[0] = 1;
	for(int child = 0; child < n; ++child) {
		int up_to;
		scanf("%d", &up_to);
		vector<int> fake(k + 1);
		for (int used = k; used >= 0; --used) {
			int tmp = dp[used];
			int L = used + 1;
			int R = used + min(up_to, k - used);
			if(L <= R) {
				add_self(fake[L], tmp);
				if(R + 1 <= k) {
					sub_self(fake[R+1], tmp);
				}
			}
			//~ for(int i = L; i <= R; ++i) {
			//~ add_self(dp[i], tmp);
			//~ }
		}
		int prefix_sum = 0;
		for(int i = 0; i <= k; ++i) {
			add_self(prefix_sum, fake[i]);
			add_self(dp[i], prefix_sum);
		}
	}
	printf("%d\n", dp[k]);
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<int> v[100001];
struct UnionFind{
    int data[100001]; 
    void init(int n){memset(data,-1,sizeof(data));}
    int find(int x){return data[x]<0?x:data[x]=find(data[x]);}
    void unite(int x, int y){
        x=find(x);y=find(y);       
        if(x!=y){
            if(data[y]<data[x]) swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return;
    } 
    bool same(int x, int y){return (find(x) == find(y));}
    int size(int x){return -data[x];}
};
int main(){
    int n,m,k,li;
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k){
            cin>>li;
            v[li-1].pb(i);
        }
    }
    UnionFind uf;
    uf.init(n+1);
    rep(i,m){
        rep(j,(int)v[i].size()-1){
            uf.unite(v[i][j],v[i][j+1]);
        }
    }
    FOR(i,1,n){
        if(!uf.same(0,i)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	string s,t;
	ll i,j,k;
	cin>>s>>t;
	
	ll n1=s.size(),n2=t.size();
	
	ll c=0,min=INT_MAX;
	
	
	//cout<<c<<"\n";
	j=n2;
	i=0;
	min=INT_MAX;
	
	while(j<=n1)
	{
		c=0;
		for(k=i;k<j;k++)
			if(s[k]!=t[k-i])
				c++;
		if(c<min)
			min=c;
		i++;
		j++;
	}
	
	cout<<min;
	
	return 0;
}


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

using namespace std;
int main(){
    char s[102];
    int j = 0;
    cin >> s;
    for( int i = 0 ; i < strlen(s) ; i++){
        if( s[i]=='C'){
            for( int n = i+1 ; n < strlen(s) ; n++){
                if( s[n]=='F'){
                    j = 1;
                    break;
                }

            }
        }
    }
    if( j==1){
        cout <<"Yes";
    }
    else{
        cout <<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

long long i, j, q;

int main() {
	IO;
	//ifstream cin("In.txt");
	ll n,a, ans = 0;
	cin >> n;
	VEC vc(n);
	f0(i, n)
		cin >> vc[i];
	f0(i, n) {
		cin >> a;
		ans += max(vc[i] - a, (ll) 0);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt();
    val P, Q = Array.fill(N)(sc.nextInt())

    val ordering = Ordering.Iterable(Ordering.Int)
    val permutations =
      (1 to N).permutations.toIndexedSeq.sorted(ordering)
    def binarySearch(P: IndexedSeq[Int]): Int = {
      def loop(left: Int, right: Int): Int =
        if (right - left > 1) {
          val mid = left + (right - left) / 2
          if (ordering.gteq(permutations.apply(mid), P))
            loop(left, mid)
          else loop(mid, right)
        } else right
      loop(-1, permutations.size)
    }

    println((binarySearch(P) - binarySearch(Q)).abs)
  }

}


Measured memory_bytes: 51820
#include<stdio.h>

int main(void)
{
	int buf1, buf2, buffer;
	int array[3000][2];
	int i = 0;
	while (1)
	{
		scanf("%d %d", &buf1, &buf2);
		if (buf1 == 0 && buf2 == 0)break;
		if (buf1 > buf2)
		{
			buffer = buf1;
			buf1 = buf2;
			buf2 = buffer;
		}

		array[i][0] = buf1;
		array[i][1] = buf2;
		i++;
	}

	for (int k = 0; k < i; k++)
	{
		printf("%d %d\n", array[k][0], array[k][1]);
	}
	return 0;
}




Measured memory_bytes: 2076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;

  //辞書順で小さい≒先頭の数が小さい
  int digits, num;
  digits = max(a, b);
  num = min(a, b);
  int answer = 0;
  for(int i=0; i<digits; i++){
    answer *= 10; 
    answer += num;
  }
  
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
      int M = sc.nextInt();
      
      HashMap<Integer, ArrayList<Integer>> h = new HashMap<Integer, ArrayList<Integer>>();
      HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
      
      for(int i = 0; i < M; i++) {
         int P = sc.nextInt();
         int Y = sc.nextInt();
         
         if(!h.containsKey(P)) {
            h.put(P, new ArrayList<Integer>());
         }
         h.get(P).add(Y);
         hm.put(Y, i);
      }
      
      for(int key : h.keySet()) {
         Collections.sort(h.get(key));
      }
      
      String[] ans = new String[M];
      for(int key : h.keySet()) {
         String first = key+"";
         for(int i = 0; i < 6 - (key+"").length(); i++) {
            first = "0" + first;
         }
         for(int i = 0; i < h.get(key).size(); i++) {
            int ind = hm.get(h.get(key).get(i));
            String second = (i+1)+"";
            for(int j = 0; j < 6 - ((i+1)+"").length(); j++) {
               second = "0" + second;
            }
            ans[ind] = first + second;
         }
      }
      
      for(String an : ans) {
         System.out.println(an);
      }
   }
}

Measured memory_bytes: 172216
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int extraX = n % 2 + 1;
    vector<vector<ll>> dp(n + 1, vector<ll>(extraX + 2, -LINF));
    dp[0][0] = 0;
    rep(i, n){
        rep(j, extraX + 1){
            //最初はi % 2 = 0だが、extraXが入るたびに読み枠が1つずれる。
            if (i % 2 == j % 2) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i]);
            else dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            //j(extraX)をインクリメントするなら、そこの枠を足さない
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
        }
    }
    cout << dp[n][extraX] << endl;
}


Measured memory_bytes: 17664
#include<stdio.h>
#include<math.h>
int main()
{
    int n,x,y,o,e,i;
    scanf("%d",&n);
    for(i=sqrt(n); i>=1; i--)
    {
        if(n%i==0)
        {
            x=i;
            y=n/i;
            if(x>9||y>9)
            {
                printf("No\n");
                break;
            }
            else
            {
                printf("Yes\n");
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
/**
*    author:  yuya1234
*    created: 13.07.2020 16:54:10
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  list<string> s;
  string tmp;
  cin>>tmp;
  s.push_back(tmp);

  bool rev=false;
  int n;
  cin>>n;
  REP(i,n){
    int q;
    cin>>q;
    if(q==1){
      rev=!rev;
    }
    else{
      int f;
      string c;
      cin>>f>>c;
      if((!rev && f==1) || (rev && f==2)){
        s.emplace_front(c);
      }
      else{
        s.emplace_back(c);
      }
    }
  }

  if(rev){
    for(auto itr = s.rbegin(); itr != s.rend(); ++itr) {
      reverse((*itr).begin(),(*itr).end());
      cout<<*itr;
    }
  }
  else{
    for(auto itr = s.begin(); itr != s.end(); ++itr) {
      cout<<*itr;
    }
  }
  
  cout<<endl;
  

  return 0;
}

Measured memory_bytes: 16284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    int n;cin>>n;
    double v[n];
    rep(i,n){
        cin>>v[i];
    }
    sort(v,v+n);
    double ans=(v[0]+v[1])/2;
    if (n==2)
    {
        /* code */
        cout<<ans<<endl;
    }
    else{
    for (int i = 2; i < n; i++)
    {
        /* code */
        
        ans=(v[i]+ans)/2;
    }
    cout<<ans<<endl;
    }
    
  
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
LL read(){
    LL nm=0,fh=1; char cw=getchar();
    for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
    for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
    return nm*fh;
}
LL ans,sum0,sum1,sig;
LL n,m,fs[M],nt[M<<1],to[M<<1],col[M],f[M],sz[M],tmp;
LL fd(LL x){return x==f[x]?x:f[x]=fd(f[x]);}
void link(LL x,LL y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void merge(LL x,LL y){x=fd(x),y=fd(y);if(x!=y) f[x]=y,sz[y]+=sz[x];}
bool check(LL x,LL now){
    if(col[x]) return col[x]==now; col[x]=now;
    for(LL i=fs[x];i!=-1;i=nt[i])
        if(!check(to[i],3-now)) return false;
    return true;
}
int main(){
    n=read(),m=read(),memset(fs,-1,sizeof(fs));
    for(LL i=1;i<=n;i++) f[i]=i,sz[i]=1;
    for(LL i=1;i<=m;i++){
        LL x=read(),y=read();
        link(x,y),link(y,x),merge(x,y);
    }
    for(LL i=1;i<=n;i++) if(fd(i)==i&&sz[i]==1) sig++;
    for(LL i=1;i<=n;i++){
        if(fd(i)!=i||sz[i]==1) continue;
        if(check(i,1)) ans+=2,sum0++;
        else ans++,sum1++;
    }
    ans+=sig*((n<<1)-1)-sig*(sig-1);
    ans+=((sum0*(sum0-1))<<1);
    ans+=sum1*(sum0<<1)+sum1*sum1-sum1;
    printf("%lld\n",ans);
    return 0;
}

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

void show(int a[])
{
//	for (int i = 0; i < 10; i++)
//		printf("%d ", a[i]);
//	printf("\n");
}

void quicksort(int a[], int left, int right)
{

	int p;	//中央値
	int L = left, R = right;		//ループ中で変化するleft、right
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
	}

	show(a);

	if (left < L - 1) quicksort(a, left, L - 1); if (right > R + 1)
		quicksort(a, R + 1, right); 
	
}

int main(void)
{
	int a,b,c[100010],i,d[100010];
	long long x=0;
	scanf("%d %d",&a,&b);
//	if(a>=b){
//		a=3;
//	}
	for(i=0;i<b;i++){
		scanf("%d",&c[i]);
	}
	quicksort(c,0,b-1);
	for(i=0;i<b-1;i++){
		d[i]=c[b-i-1]-c[b-i-2];
	}
	quicksort(d,0,b-2);
	for(i=0;i<b-a;i++){
		x=x+d[i];
	}
//	if(a>=b){
//		printf("%d\n",0);
//	}else{
		printf("%lld\n",x);
//	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string s[3];
int cnt[26];

int main(void){
    scanf("%d",&n);
    for(int i=0;i<3;i++){
        cin >> s[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        memset(cnt,0,sizeof(cnt));
        for(int j=0;j<3;j++){
            cnt[s[j][i]-'a']++;
        }
        int ma=0;
        for(int j=0;j<26;j++){
            ma=max(ma,cnt[j]);
        }
        ans+=3-ma;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

main = do
    [n, t] <- map (read::String->Int) . words <$> getLine
    ct <- replicateM n $ map read . words <$> getLine
    putStrLn $ f t ct

f t ct
 | null p = "TLE"
 | otherwise = show $ minimum p
 where p = map head $ filter ((<=t) . last) ct     

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

void Output(int a[],int n){

  cout << a[0];
  for(int i=1; i<n; i++)
    cout << ' ' << a[i];

  cout << endl;

}

int main(){

  int a[100];
  int n;
  int v;
  int j;

  cin >> n;
  for(int i=0; i<n; i++)
    cin >> a[i];


  for(int i=1; i<n; i++){

    Output(a,n);

    v=a[i];
    j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1]=v;
  }

  Output(a,n);


  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    int n, h, w, ans = 0;
    cin >> n >> h >> w;

    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        ans += min(a/h, b/w);
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,i,x[7];
	for(a=1;a<=4;a++){
		x[a] = 0;
	}
	for(a=0;a<6;a++){
		scanf("%d",&i);
		x[i]++;
	}
	if(x[1]<=2 && x[2]<=2 && x[3]<=2 && x[4]<=2){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long			long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

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

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a													  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a]												 -= size(b);
	p[b]												  = a;
  }
};

int main(){
  string s;cin>>s;
  int ans=INF;
  REP(SZ(s)-2){
	int n=(s[i]-'0')*100;
	n+=(s[i+1]-'0')*10;
	n+=(s[i+2]-'0');
	chmin(ans,abs(753-n));
	DEBUG(i);
	DEBUG(n);
	DEBUG(ans);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    ll n, q; cin >> n;
    vector<ll> seq_s(n);
    for(int i = 0; i < n; i++) { cin >> seq_s.at(i); }
    cin >> q; 
    vector<ll> seq_t(q);
    for(int i = 0; i < q; i++) { cin >> seq_t.at(i); }

    ll sum = 0;
    for(ll i = 0; i < q; i++) {
        ll l = 0, r = n;
        while( l < r) {
            ll mid = (r + l) / 2;
            if( seq_s.at(mid) == seq_t.at(i) ) {
                sum++; break;
            } else if( seq_s.at(mid) < seq_t.at(i) ) {
                l = mid + 1;
            } else {
                r = mid;
            }
        }
    }
    cout << sum << endl;

    return 0;
}





Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n,m;
    cin >> n >> m;
    long long mod = 1000000007;

    if(abs(n-m) >= 2){
        cout << 0 << endl;
        return 0;
    }
    else{
        if(abs(n-m) == 1){
            long long ans = 1;
            for(int i=1; i <= n; i++){
                ans *= i;
                ans %= mod;
            }
            for(int i=1; i <= m; i++){
                ans *= i;
                ans %= mod;
            }

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

        else{
            long long ans = 2;
            for(int i=1; i <= n; i++){
                ans *= i;
                ans %= mod;
            }
            for(int i=1; i <= m; i++){
                ans *= i;
                ans %= mod;
            }

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
//bool fff[100000][100000];
//vector<vector<bool>> graph(100000,vector<bool>(10000,true));
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  int a,b,c;
  bool flag;
  cin>>a>>b>>c;
  if(a==b&&(b!=c||a!=c))cout<<"Yes"<<endl;
  else if(b==c&&(b!=a||c!=a))cout<<"Yes"<<endl;
  else if(a==c&&(a!=b||b!=a))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b;
cin >> a>> b;
a -= 2;
b -= 2;
cout << abs(a * b) << endl;
}

Measured memory_bytes: 3620
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int cnt = 0;
	for (int i = 0; i*r <= n; i++) {
		for (int j = 0; i*r + j * g <= n; j++) {
			int rest = n - i * r - j * g;
			if (rest % b == 0)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().ToInt();
            Console.WriteLine(r * r);
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 13140
using System;
using System.Collections.Generic;

namespace Sample
{
  class Sample
  {
    static void Main()
    {
      int tate = int.Parse(Console.ReadLine());
      int yoko = int.Parse(Console.ReadLine());
      int block = int.Parse(Console.ReadLine());
      int i = 0;
      int count = 0;
   		if(tate > yoko){
         for(i=0;i<10000;i++){
        count++;
           
           if(tate*i >= block){
         break; 
        }
         
         }
          
        
        }else{
          
          
           for(i=0;i<10000;i++){
        count++;
           
           if(yoko*i >= block){
         break; 
        }
         
         }
          
          
          
        }

      Console.WriteLine(count-1);
      
    }
  }
}


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

int main() {
    string s;cin>>s;
    if(s[1]=='B')cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

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

		int v = sc.nextInt();
		String out = "hon";

		switch(v % 10)
		{
		case 0:
			out = "pon";
			break;
		case 1:
			out = "pon";
			break;
		case 6:
			out = "pon";
			break;
		case 8:
			out = "pon";
			break;
		case 3:
			out = "bon";
			break;
		}

		System.out.println(out);
	}
}



Measured memory_bytes: 35756
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        long total = 0;
        for (int i = 0; i < n; i++) {
            char x = 'a';
            if (i - k >= 0) {
                x = arr[i - k];
            }
            if (arr[i] == 'r') {
                if (x != 'r') {
                    total += p;
                } else {
                    arr[i] = 'x';
                }
            } else if (arr[i] == 's') {
                if (x != 's') {
                    total += r;
                } else {
                    arr[i] = 'x';
                }
            } else {
                if (x != 'p') {
                    total += s;
                } else {
                    arr[i] = 'x';
                }
            }
        }
        System.out.println(total);
    }
}


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

int main() {
    map<int, string> hon;
    hon.insert(make_pair(0, "pon"));
    hon.insert(make_pair(1, "pon"));
    hon.insert(make_pair(2, "hon"));
    hon.insert(make_pair(3, "bon"));
    hon.insert(make_pair(4, "hon"));
    hon.insert(make_pair(5, "hon"));
    hon.insert(make_pair(6, "pon"));
    hon.insert(make_pair(7, "hon"));
    hon.insert(make_pair(8, "pon"));
    hon.insert(make_pair(9, "hon"));

    int n;
    cin >> n;
    cout << hon[n % 10] << '\n';
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
#include <cmath>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
Int f(Int b, Int n)
{
    Int ans = 0;
    while (n >= b) {
        ans += n % b;
        n /= b;
    }
    return ans + n;
}
Int solve(Int n, Int s)
{
    if (s > n) return -1;
    if (s == n) return s + 1;
    int m = sqrt(n);
    for (int b = 2; b <= m; b++) {
        if (f(b, n) == s) {
            return b;
        } 
    }
    // n == b*p + s-p  <=>  b == (n - s) / p + 1
    Int bmin = numeric_limits<Int>::max();
    for (int p = 1; p <= m; p++) {
        Int b = (n - s) / p + 1;
        if ((n - s) % p == 0 && f(b, n) == s) {
            bmin = min(bmin, b);
        }
    }
    if (bmin == numeric_limits<Int>::max()) return -1;
    return bmin;
}
int main()
{
    Int n, s; cin >> n >> s;
    cout << solve(n, s) << endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L[202020],R[202020];
int S[2][402020];

int ok1(int v,int tar) {
	int C[3]={};
	int i;
	FOR(i,N) {
		if(R[i]<v) C[0]++;
		else if(v<L[i]) C[2]++;
		else C[1]++;
	}
	
	return C[0]<tar;
}

int ok2(int v,int tar) {
	int C[3]={};
	int i;
	FOR(i,N) {
		if(R[i]<v) C[0]++;
		else if(v<L[i]) C[2]++;
		else C[1]++;
	}
	
	return C[2]<tar;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<int> V;
	FOR(i,N) {
		cin>>L[i]>>R[i];
		V.push_back(L[i]);
		V.push_back(R[i]+1);
	}
	
	int ma[2]={};
	int mi[2]={1<<30,1<<30};
	FOR(i,2) {
		int tar;
		if(N%2==0) {
			tar=N/2+i;
		}
		else {
			tar=(N+1)/2;
		}
		
		for(j=29;j>=0;j--) {
			if(ok1(ma[i]+(1<<j),tar)) ma[i]+=1<<j;
			if(ok2(mi[i]-(1<<j),tar)) mi[i]-=1<<j;
		}
	}
	
	//cout<<mi[0]<<" "<<mi[1]<<" "<<ma[0]<<" "<<ma[1]<<endl;
	if(N%2==0) {
		cout<<(ma[1]+ma[0]-mi[0]-mi[1])+1<<endl;
	}
	else {
		cout<<ma[0]-mi[0]+1<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6616
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll n;
  cin >> n;
  vector<string> ss(n);
  vll ts(n);
  vll acc(n, 0);
  ll ans = 0;
  rep(i, n) {
    cin >> ss[i];
    cin >> ts[i];
    ans += ts[i];
    acc[i] += ts[i];
    if(i > 0) acc[i] += acc[i - 1];
  }
  string x;
  cin >> x;
  ll idx = -1;
  rep(i, n) {
    if (ss[i] == x) {
      idx = i;
      break;
    }
  }

  cout << ans - acc[idx] << endl;

  return 0;
}


Measured memory_bytes: 256