akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n; cin >> n;
	int y; cin >> y;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n - i; ++j) {
				if(n - i - j >= 0) {
					int k = n - i - j;
					int sum = (i * 10000) + (5000 * j) + (1000 * k);
					if (sum == y && ((i + j + k == n))) {
						cout << i << " " << j << " " << k << endl;
						return;
					}
				}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
    return;
}

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



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

int main(){
  int n; long long x; cin >> n >> x;
  long long prev = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long k; cin >> k;
    if (prev + k > x) {
      ans += prev + k - x;
      k -= prev + k - x;
    }
    prev = k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTravelingSalesmanAroundLake solver = new CTravelingSalesmanAroundLake();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTravelingSalesmanAroundLake {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int k = ni();
            int n = ni();
            int[] arr = new int[n];
            int i = 0;
            int mx1 = 0;
            for (i = 0; i < n; i++) {
                arr[i] = ni();
                if (i > 0)
                    mx1 = Math.max(mx1, arr[i] - arr[i - 1]);
            }
            int mx = arr[n - 1] - arr[0];
            mx = Math.min(mx, k - mx1);
            pn(mx);
        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 43644
(defmacro inner-input []
  '(Integer/parseInt (read-line)))

(defn input []
  (list (inner-input) (inner-input)))

(defn AdditionAndMultiplication [[N K]]
  (let [As (->> 1 (iterate (partial * 2)) (take-while (partial >= K)))]
    (if (<= N (count As))
      (int (Math/pow 2 N))
      (+ (* 2(last As))
        (* K (- N (count As)))))))


(-> (input)
  AdditionAndMultiplication
  println)

Measured memory_bytes: 66988
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            long t = 1, a = 1;

            for (var i = 0; i < n; i++)
            {
                var inputs = Console.ReadLine().Split(" ");
                var tn = long.Parse(inputs[0]);
                var an = long.Parse(inputs[1]);

                var tc = (t / tn) + ((t % tn != 0) ? 1L : 0L);
                var ac = (a / an) + ((a % an != 0) ? 1L : 0L);
                var count = Math.Max(tc, ac);

                t = tn * count;
                a = an * count;
            }

            Console.WriteLine(t + a);
        }
    }
}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    int cnt=0;
    string s,t;
    cin>>s>>t;
    REP(i,0,s.size()){
      if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
 
int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}
 
int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}
 
int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;

signed main(){
	cin>>s;
	rep(i,(int)s.size()){
		if(i<(int)s.size()-2){
			if(s[i]==s[i+2]){
				cout<<i+1<<" "<<i+3<<endl;
				return 0;
			}
		}
		if(i<(int)s.size()-1){
			if(s[i]==s[i+1]){
				cout<<i+1<<" "<<i+2<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
    long n;
    cin >> n;
    vector<long> vec(n);
    for (long i = 0; i < n; i++)
    {
        cin >> vec.at(i);
    }
    if (n < 3)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<long> vec2(3);
    long counter = 0;
    for (long i = 0; i < n; i++)
    {
        vec2.at(0) = vec.at(i);
        for (long j = i + 1; j < n; j++)
        {
            vec2.at(1) = vec.at(j);

            for (long k = j + 1; k < n; k++)
            {

                vec2.at(2) = vec.at(k);
                vector<long> vec3 = vector<long>(vec2);
                sort(vec3.begin(), vec3.end());
                // cout << vec2.at(0) << " " << vec2.at(1) << " " << vec2.at(2) << endl;
                // cout << vec3.at(0) << " " << vec3.at(1) << " " << vec3.at(2) << endl;
                if (vec3.at(2) < vec3.at(1) + vec3.at(0))
                {
                    if (vec3.at(2) != vec3.at(1) && vec3.at(1) != vec3.at(0) && vec3.at(2) != vec3.at(0))
                    {
                        // cout << i + 1 << " " << j + 1 << " " << k + 1 << endl;
                        counter++;
                    }
                }
            }
        }
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
    #pragma gcc optimize("ofast")
    using namespace std;

    #define ll long long
    #define ull unsigned long long
    #define ui unsigned int
    #define mod 1000000007
    #define us unsigned short
    #define IOS ios_base::sync_with_stdio(0);
    #define INF LONG_MAX
    #define PI 3.1415926535897932384626
    #define mp make_pair
    #define fi first
    #define se second
    #define pb push_back
    #define rep(x,j,n)for(int x=j;x<n;x++)
    typedef vector<pair<ll,ll>> vpi;
    typedef vector<ll> vi;
    typedef vector<vi> vvi;

    ll modexp(ll a,ll b,ll m)
    {
    	ll r=1;
    	a=a%m;
    	while(b>0)
    	{
    	if(b&1)
    		r=(r*a)%m;
    	b=b/2;
    	a=(a*a)%m;
    	}
    	return r%m;
    }


    int main()
    {
        IOS
        ll n;
        cin>>n;
        vi a(n);
        rep(i,0,n)
            cin>>a[i];
        vi b(n),c(n-1);
        rep(i,0,n)cin>>b[i];
        rep(i,0,n-1)cin>>c[i];
        ll last=-1;
        ll sum=0;
        rep(i,0,n)
        {
            sum+=b[a[i]-1];
            if( i!=0)
            {
                if( a[i] == last+1)
                {
                    sum+=c[last-1];
                }
            }
            last=a[i];
        }
        cout<<sum<<'\n';

        return 0;
    }


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;
const int MAX_V=10000;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	int cnta=1,cntb=1;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			if(j<50){
				if(i%2==0)cout<<"#";
				else if(j%2==0 || j==49 || cnta==a)cout<<"#";
				else{
					cout<<".";
					cnta++;
				}
			}else{
				if(i%2==0)cout<<".";
				else if(j%2==0 || cntb==b)cout<<".";
				else{
					cout<<"#";
					cntb++;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
ll dp[1001][1001],n,m;
char  a[1001][1001];
ll mod=1e9+7;
void func()
{
  dp[n-1][m-1]=1;
//  cout<<"a";
  for(int i=n-1;i>=0;i--)
  {
    for(int j=m-1;j>=0;j--)
    {
    if(i+1<n && a[i+1][j]=='.'){dp[i][j]+=dp[i+1][j];}
    if(j+1<m && a[i][j+1]=='.'){dp[i][j]+=dp[i][j+1];}
    dp[i][j]%=mod;
    //cout<<dp[i][j]<<endl;
    }
  }
  
}
void solve()
{
  cin>>n>>m;
  rep(i,n){rep(j,m){cin>>a[i][j];}}
  func();
  cout<<dp[0][0];
}
int main()
{
  fastio;
 // fopen();
  //int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const ll maxn=2*1e5;
ll bin(ll a, ll b) {
	//a%=m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a; //mod
        a = a * a; //mod
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll fact(ll x)
{
  ll res=1;
  for(ll i=1;i<=x;i++)
    res=(res*i)%mod;

  return res;
}

ll bcof(ll x,ll y) //x choose y
{
  return fact(x)*bin(fact(x-y)*fact(y)%mod,mod-2)%mod;
}

ll lmod(string n,ll x)
{
	
	ll res=0;
	for(ll i=0;i<n.length();++i)
	{
		res=(res*10+(int)n[i]-'0')%x;
	}
	return res;
}
bool ispal(string s,int l,int r)
{
	string t=s;
	for(int i=l,j=r;i<=r;++i)
	{
		if(s[i]!=s[j])
			return false;
		else
			{
				--j;
			}
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n,i,j,k,b=0;
	cin>>n;
	ll a[n];
	ll freq[maxn+3];
	
	memset(freq,0,sizeof(freq));
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		
		++freq[a[i]];
	}
	ll ans=0;
	for(i=1;i<maxn+3;i++)
	{
		if(freq[i]!=0)
		ans+=freq[i]*(freq[i]-1)/2;
	}
	for(i=0;i<n;i++)
	{
		ll ff=freq[a[i]];
		ll tans=ans-ff*(ff-1)/2+max(b,(ff-1)*(ff-2)/2);
		cout<<tans<<"\n";
	}
		
}

Measured memory_bytes: 5760
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 = int.Parse(Console.ReadLine());
            var hi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 1;
            var max = hi[0];
            for (var i = 1; i < hi.Length; i++)
            {
                if (max <= hi[i]) count++;
                max = Math.Max(max, hi[i]);
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
package main

import (
	"fmt"
)

func check(ruiseki *[21]int) bool {
	for bit_num := uint(0); bit_num < 21; bit_num++ {
		if ruiseki[bit_num] > 1 {
			return false;
		}
	}
	return true;
}
func add(ruiseki *[21]int, val int ,is_add bool) {
	for bit_num := uint(0); bit_num < 21; bit_num++ {
		x := (val >> bit_num) & 1
		if x > 0 {
			if is_add {
				ruiseki[bit_num]++
			}else{
				ruiseki[bit_num]--
			}
		}
	}
}


func main() {
	f := func() (a int) {
		fmt.Scan(&a)
		return
	}
	N := f()
	var ruiseki [21]int
	ans :=0
	ruiseki_length := 0
	var A []int
	for i := 0; i < N; i++ {
		tmp_input := f()
		A = append(A, tmp_input)
		add(&ruiseki,tmp_input,true)
		for ; !check(&ruiseki); ruiseki_length-- {
			add(&ruiseki, A[i - ruiseki_length],false)
		}
		ruiseki_length++
		//fmt.Println(i,ruiseki_length)
		//fmt.Println(ruiseki)
		ans += ruiseki_length
	}
	fmt.Println(ans)
	//fmt.Println(A)

}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
int n,m,in[maxn];
bool alive[maxn];
vector<int> g[maxn];
void Yes() {
	printf("Yes\n"); exit(0);
}
void No() {
	printf("No\n"); exit(0);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	int x,y;
	for (int i=1;i<=m;i++) {
		read(x); read(y);
		in[x]++; in[y]++;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (int i=1;i<=n;i++)
		if (in[i]&1) No();
	for (int i=1;i<=n;i++)
		if (in[i]>=6) Yes();
	bool flag=1;
	for (int i=1;i<=n;i++)
		if (in[i]!=2) { flag=0; break; }
	if (flag) No();
	memset(alive,1,sizeof(alive));
	flag=0;
	for (int i=1;i<=n;i++) {
		if (in[i]==4) continue;
		alive[i]=0;
		// in[i]=2
		x=y=0;
		for (int j=0,v;j<g[i].size();j++) {
			v=g[i][j];
			if (alive[v]) {
				if (!x) x=v; else y=v;
			}
		}
		g[x].push_back(y);
		g[y].push_back(x);
		if (x==y) flag=1;
	}
	/*for (int i=1;i<=n;i++) {
		for (int j=0,v;j<g[i].size();j++) {
			v=g[i][j];
			if (alive[i]&&alive[v]) printf("%d %d\n",i,v);
		}
	}*/
	int N=0;
	for (int i=1;i<=n;i++) N+=alive[i];
	if (N==1) No();
	if (N>=3) Yes();
	if (flag) Yes();
	No();
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 7552
#include <iostream>
#include <cassert>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <map>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <limits>
#include <typeinfo>
 
#include <stdio.h>
#include <string.h>
 
 
using namespace std;
 
int main(int argc, char* argv[])
{
	int A,B,C;
 
	cin >> A >> B >> C;
	 
	cout << (C >= A && C<=B ? "Yes" : "No") << endl;
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
////////////////////

char s[41];
string ans;
int v;

void rec(int p){
	if(p == 4){
		if(v == 7){
			ans.pb('=');
			ans.pb('7');
			printf("%s\n",ans.c_str());
			exit(0);
		}
	}else{
		if(p == 0){
			ans.pb(s[0]);
			v += s[0] - '0';
			rec(1);	
		}else{
			ans.pb('+');
			ans.pb(s[p]);
			v += s[p] - '0';
			rec(p+1);
			ans.pop_back();
			ans.pop_back();
			v -= s[p] - '0';
			
			ans.pb('-');
			ans.pb(s[p]);
			v -= s[p] - '0';
			rec(p+1);
			ans.pop_back();
			ans.pop_back();
			v += s[p] - '0';
		}
	}
}

void solve(){
	rec(0);	
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%s",s);

	solve();

	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int>songs(n);
	map<string,int>mp;
	for(int i=0;i<n;i++){
		string s; cin>>s;
		mp[s]=i;
		cin>>songs[i];
	}
	string x; cin>>x;
	int ans=0;
	for(int i=mp[x]+1;i<n;i++)
		ans+=songs[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<long long int> H(N);
  rep(i, N)
  {
    cin >> H[i];
  }
  reverse(H.begin(), H.end());
  int val = 0;
  int ans = 0;
  for (int i = 1; i < N; i++)
  {
    if (H[i - 1] <= H[i])
    {
      val++;
    }
    else
    {
      val = 0;
    }
    ans = max(ans, val);
  }
  cout << ans << endl;
}

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

int main() {
    int N;          //都市の個数
    int M;          //道路の総本数
    cin >> N >> M;
    int a[2*M];     //どの都市から道路が伸びているか
    int c[N+1];     //都市iから何本道路が伸びているか

    for(int i = 0; i < 2*M; i += 2) {
        cin >> a[i] >> a[i+1];
    }

    for(int i = 0; i <= N; i++) {
        c[i] = 0;
    }

    sort(a, a + 2*M);

    int t = a[0];

    for(int i = 0; i < 2*M; i++) {
        if( t == a[i] ) {
            c[a[i]]++;    
        }
        if( t < a[i] ) {
            t = a[i];
            c[a[i]]++;
        }
    }

    for(int i = 1; i <= N; i++) {
        cout << c[i] <<"\n";
    }
    
    cout << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    string n;
    cin>>n;
    long long int ans=0;
    for(int i=0;i<n.size();i++){
        ans+=int(n[i]-'0');
        ans%=9;
    }
    if(ans==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
int main()
{
  // std::string a;
  int n, i, count = 0, flag = 0, tmp;
  int a[200];

  std::cin >> n;
  for (i = 0; i < n; i++)
  {
    std::cin >> a[i];
  }

  while (flag == 0)
  {
    for (i = 0; i < n; i++)
    {
      tmp = a[i];
      a[i] = a[i] / 2;
      if (tmp % 2 == 1)
      {
        flag = 1;
        break;
      }
      if (i == n - 1)
      {
        count++;
      }
    }
  }
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define mp make_pair
typedef pair<int,int>P;

int main(){
	int N,M;
	while(cin>>N>>M,N){
		map<string,P>data;
		string name[1001];
		
		string tmp;
		
		for(int i=0,a,b;i<N;i++){
			cin>>name[i]>>a>>b;
			data[name[i]]=mp(b-a+1,b);
		}
		
		for(int i=0,a,f,j;i<M;i++){
			cin>>a;
			for(f=1,j=0;j<N;j++){
				if(data[name[j]].first<=a&&a<=data[name[j]].second&&f){
					f=0;
					cout<<name[j]<<" "<<a-data[name[j]].first+1<<endl;
				}
			}
			if(f)cout<<"Unknown"<<endl;
		}
		
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1348
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		final int p1 = 1;
		final int p2 = 2;
		final int p3 = 3;
		final int pinf = 0;

		int n;
		Scanner stdIn = new Scanner(System.in);

		n = stdIn.nextInt();

		int[] x = new int[n];
		int[] y = new int[n];

		inputLine(n, x, stdIn);
		inputLine(n, y, stdIn);

		System.out.format("%.6f\n", distance(x,y,p1));
		System.out.format("%.6f\n", distance(x,y,p2));
		System.out.format("%.6f\n", distance(x,y,p3));
		System.out.format("%.6f\n", distance(x,y,pinf));
	}

	public static void inputLine(int n, int[] array, Scanner stdIn) {
		for (int i = 0; i < n; i++) {
			array[i] = stdIn.nextInt();
		}
	}

	public static double distance(int[] x, int[] y, int p) {
		double d = 0.0;
		double pinf = 0.0;

		for (int i = 0; i < x.length; i++) {
			int temp = 0;

			temp += Math.abs(x[i] - y[i]);
			d += Math.pow(temp, p);

			if(pinf < temp) {
				pinf = temp;
			}
		}
		switch (p) {
		case 2:
			return Math.sqrt(d);

		case 3:
			return Math.cbrt(d);

		case 0:
			return pinf;

		default:
			return d;

		}
	}
}

Measured memory_bytes: 26736
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pii pair<int,int>
using namespace std;
void boost(){
 ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a,b,c;
main(){
boost();
cin>>a>>b>>c;
int t=a,ans=0;
while(t<=c){
    ans+=b;
    t+=a;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
A=[]
for i in range(3):
    a=list(map(int,input().split()))
    A.append(a)
V=[[0]*3 for i in range(3)]
n=int(input())
for i in range(n):
    t=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==t:
                V[j][k]=1
if V[0][0]==V[1][0]==V[2][0]==1:
    print('Yes')
    exit()
elif V[0][1]==V[1][1]==V[2][1]==1:
    print('Yes')
    exit()
elif V[0][2]==V[1][2]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][0]==V[0][1]==V[0][2]==1:
    print('Yes')
    exit()
elif V[1][0]==V[1][1]==V[1][2]==1:
    print('Yes')
    exit()
elif V[2][0]==V[2][1]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][0]==V[1][1]==V[2][2]==1:
    print('Yes')
    exit()
elif V[0][2]==V[1][1]==V[2][0]==1:
    print('Yes')
    exit()
else:
    print('No')

Measured memory_bytes: 3188
def do(a, d, n, l):
    return (n*(a+l) // 2)

n, k = map(int, input().split())
maxnum = n + 1
res = 0
mod = 10**9 + 7

for i in range(k, n+2):
    #print("---")
    #print(i)
    l = do(0      , 1, i, i - 1)
    #print((0      , 1, i, i - 1))

    r = do(n+1 - i, 1, i,     n)
    #print((n+1 - i, 1, i,     n))

    #print(i, l, r, r-l+1)
    res += r-l+1
    res %= mod
print(res)

Measured memory_bytes: 65024
N = int(input())
def DFS(s, mx):
    if len(s) == N:
        print(s)
        return
    c = 'a'
    while c <= chr(ord(mx)+1):
        t = s + c
        DFS(t, chr(max(ord(c), ord(mx))))
        c = chr(ord(c) + 1)
DFS("", chr(ord('a')-1))


Measured memory_bytes: 4412
while True:
    a, op, b = raw_input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print a + b
    elif op == "-":
        print a - b
    elif op == "*":
        print a * b
    elif op == "/":
        print a / b

Measured memory_bytes: 4208
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int x,int y,int H,int W){return (0<=x&&x<H)&&(0<=y&&y<W);}

struct Graph{
	int V,E,t;
	vector<int>cost;
	vector<int>d;
	vector<int>f;
	vector<bool>vzt;
	vector<vector<int>>adj;
	void init(int dflt){//dflt!=0
		t=1;
		adj=vector<vector<int>>(V+1);
		cost = vector<int>(V + 1, dflt);
		d = vector<int>(V + 1, dflt);
		f = vector<int>(V + 1, dflt);
		vzt=vector<bool>(V+1,false);
	}

	void bfs(int s, int scost){
		queue<pair<int,int>>q;
		q.push({scost,s});
		vzt[s]=true;
		cost[s]=0;
		while(!q.empty()){
			auto top=q.front();
			q.pop();
			int cst=top.first,now=top.second;
			for(int i=0;i<adj[now].size();i++){
				if(!vzt[adj[now][i]]){
					vzt[adj[now][i]]=true;
					cost[adj[now][i]]=cost[now]+1;
					q.push({cost[adj[now][i]],adj[now][i]});
				}
			}
		}
	}

	void dfs(int now){
		if(d[now]==-1){d[now]=t;t++;}
		else return;
		for(int i=0;i<adj[now].size();i++)dfs(adj[now][i]);
		if(f[now]==-1){f[now]=t;t++;}
		return;
	}
};

int n;
Graph G;

int main() {
	cin>>n;
	G.V=n;
	G.init(-1);
	for(int i=0;i<n;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int v;
			cin>>v;
			G.adj[u].push_back(v);
		}
	}
	for(int i=1;i<=n;i++)G.dfs(i);
	for(int i=1;i<=G.V;i++)cout<<i<<" "<<G.d[i]<<" "<<G.f[i]<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

string N;

int a[5]={2,4,5,7,9},b[4]={0,1,6,8},c[1]={3};

int main(){
    cin>>N;
    for(int i=0;i<5;++i){
        if(N[N.size()-1]-'0'==a[i]){
            cout<<"hon"<<endl;
            return 0;
        }
    }
    for(int i=0;i<4;++i){
        if(N[N.size()-1]-'0'==b[i]){
            cout<<"pon"<<endl;
            return 0;
        }
    }
    for(int i=0;i<1;++i){
        if(N[N.size()-1]-'0'==c[i]){
            cout<<"bon"<<endl;
            return 0;
        }
    }

}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	
	ll a,b; cin >>a>>b;
	if((a+b)%2==0) cout <<(a+b)/2 <<endl;
	else cout <<(a+b+1)/2 <<endl;
	
   return 0;
}

Measured memory_bytes: 256
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAX = 2005;
int ar[MAX][MAX] , br[MAX][MAX] , cr[MAX][MAX], dr[MAX][MAX];
string grid[MAX];

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

    int n , m;
    cin >> n >> m;
    for(int i=0;i<n;i++)cin >> grid[i];
    for(int i=0;i<n;i++){
        int counter = 0;
        for(int j=0;j<m;j++){
            if(grid[i][j]=='#')counter = 0;
            else counter++;
            ar[i][j] = counter;
        }
    }
    for(int i=0;i<n;i++){
        int counter = 0;
        for(int j=m-1;j>=0;j--){
            if(grid[i][j]=='#')counter = 0;
            else counter++;
            br[i][j] = counter;
        }
    }
    for(int j=0;j<m;j++){
        int counter = 0;
        for(int i=0;i<n;i++){
            if(grid[i][j]=='#')counter = 0;
            else counter++;
            cr[i][j] = counter;
        }
    }
    for(int j=0;j<m;j++){
        int counter = 0;
        for(int i=n-1;i>=0;i--){
            if(grid[i][j]=='#')counter = 0;
            else counter++;
            dr[i][j] = counter;
        }
    }
    int mx = 0;
    for(int i=0;i<n;i++){
        int counter = 0;
        for(int j=0;j<m;j++){
            mx = max(mx , ar[i][j]+br[i][j]+cr[i][j]+dr[i][j]-3);
        }
    }
    cout << mx << endl;
    return 0;
}


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

void solve(int D, vector<int> c, vector<vector<int>> s, vector<int> t)
{
    vector<int> last(26, -1);
    int res = 0;
    for (int d = 0; d < D; d++)
    {
        last.at(t.at(d)) = d;
        res += s.at(d).at(t.at(d));
        for (int i = 0; i < 26; i++)
        {
            if (i == t.at(d))
                continue;
            res -= c.at(i) * (d - last.at(i));
        }
        cout << res << endl;
    }
}

int main()
{
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++)
    {
        cin >> c.at(i);
    }
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s.at(i).at(j);
        }
    }
    vector<int> t(D);
    for (int i = 0; i < D; i++)
    {
        cin >> t.at(i);
        t.at(i)--;
    }
    solve(D, move(c), move(s), move(t));
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}


Measured memory_bytes: 3636
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
x, y = map(int, input().split())
print(x+int(y/2))


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>>v(n);
	for(ll i = 0; i < n; i++){
		pair<ll, ll>p;
		cin >> p.first >> p.second;
		v[i] = p;
	}
	sort(v.begin(), v.end());
	
	ll check = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		check += v[i].second;
		if(check >= k){
			ans = v[i].first;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: String = read();
    let sum: u32 = N.chars().map(|x| x.to_digit(10).unwrap()).sum();
    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2324
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
vector<int> v[100005],v1[100005];
int vis[100005]; int cc=1;
void dfs(int node){
  vis[node]=cc;
  rr(v[node]){
    if(!vis[val])dfs(val);
  }
}
  int32_t main(){
  fastIO
   int n,m,k; cin>>n>>m>>k;
    rep(i,0,m){
      int a,b; cin>>a>>b;
      v[a].pub(b);
      v[b].pub(a);
    }
    rep(i,0,k){
      int a,b; cin>>a>>b;
      v1[a].pub(b);
      v1[b].pub(a);
    }
    rep(i,1,n+1)if(!vis[i])dfs(i),cc++;
    map<int,int> mp;
    rep(i,1,n+1)mp[vis[i]]++;
    rep(i,1,n+1){
      int ans=mp[vis[i]];
      rr(v1[i]){
        if(vis[i]==vis[val])ans--;
      }
     ans-=v[i].sz;
      cout<<ans-1<<" ";
    }
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 20512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

const ll mod = 1e9 + 7;
vector<bool> visited;
queue<ll> q;
ll ans;
void bfs(Mat &G, ll k)
{
    while(!q.empty())
    {
        ll now = q.front(); q.pop();
        if(visited[now]) continue;
        visited[now] = true;
        ll cur = k - 2;
        for(ll v : G[now]) 
        {
            if(!visited[v]) q.push(v), (ans *= (cur--)) %= mod;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    visited = vector<bool>(n + 1);
    Mat G(n + 1);
    forn(i, n - 1)
    {
        ll u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans = k;
    visited[1] = true;
    for(ll v : G[1])
    {
        static ll cur = k - 1;
        (ans *= (cur--)) %= mod;
        q.push(v);
    }
    bfs(G, k);
    cout << (ans % mod);
    return 0;
}

Measured memory_bytes: 7412
#include<stdio.h>

int main(){
	int a;
	int f = 0;
	int s = 0;
	for(int i = 0; i < 3; i++){
		scanf("%d",&a);
		if(a == 5) f++;
		if(a == 7) s++;
	}
	if(f == 2 && s == 1) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>


using namespace std;


int main() 
{
	string input;
	int sum;
	for (;;)
	{
		cin >> input;
		if (input == "0")
			return 0;

		sum = 0;
		
		for (auto a : input)
		{
			if (a == '0')
				continue;
			sum += a - 48;
		}
		
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
N, T = map(int, input().split())

# c_list = []
# t_list = []

answer = 10000

for i in range(N):
    c,t = map(int, input().split() )
    if t <= T and c < answer:
        answer = c

if answer == 10000:
    print("TLE")
else:
    print(answer)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
    string s,p;
    cin>>s;
    cin>>p;
    if(s.size()>p.size()){
        cout<<"GREATER"<<endl;
    }
    else
    if(s.size()<p.size()){
        cout<<"LESS"<<endl;
    }
    else
    {
        int greater=-1;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]>p[i]){
                greater=1;
                break;
            }
            else
            if(s[i]<p[i]){
                greater=0;
                break;
            }
        }
        if(greater==-1){
            cout<<"EQUAL"<<endl;
        }
        else
        if(greater==1){
            cout<<"GREATER"<<endl;
        }
        else{
            cout<<"LESS"<<endl;
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <regex>

using namespace std;

int main(){

  int a, b;
  string s, former, latter;
  cin >> a >> b;
  cin >> s;
  former = "";
  latter = "";

  for(int i = 0; i < a; i++){
    former += s[i];
  }
  for(int i = a+1; i < a+b+1; i++){
    latter += s[i];
  }


  if(regex_search(former,regex("[0-9]")) && regex_search(latter,regex("[0-9]")) && s[a] == '-')
    printf("Yes");
  else
    printf("No");
  return 0;
}


Measured memory_bytes: 256
use std::collections::BTreeMap;

fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let info: Vec<usize> = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
    if info[0] % 3 == 0 || info[1] % 3 == 0 || (info[0] + info[1]) % 3 == 0 {
        println!("{}", "Possible");
    } else {
        println!("{}", "Impossible");
    }
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define siz(temp) temp.size()
#define len(temp) temp.length()
#define timepass 1073741824
#define int ll

signed main()
{
    int n,w;
    cin >> n >> w;
    vector<pair<int , int > > arr(n);
    rep(i , 0 , n)
        cin >> arr[i].ff >> arr[i].ss;
    ll dp[n + 1][w + 1];
    ms(dp , 0);
    for (int i = 1 ; i <= n ; i++)
    {
        for (int j = 1 ; j <= w ; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= arr[i - 1].ff)
                dp[i][j] = max(dp[i][j] , dp[i - 1][j - arr[i - 1].ff] + arr[i - 1].ss);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 79104
#include<stdio.h>
#define MAX 100005
#define NIL -1

/*
 p: parent
 l: left-child
 r: right sibling
 */
struct Node{ int p, l, r;};
struct Node T[MAX]; // Tree
int *Child[MAX];

char type[3][20] = {
	"root",
	"internal node",
	"leaf"
};

void print(int u, int n){
	int p = T[u].p;
	int d = 0;
	int t = T[u].p;
	int i, j, z;
	int child[MAX];
	char *mes;
	int isfound;
	while(t != NIL) {
		t = T[t].p;
		d++;
	}
	
	if(p==NIL) {
		mes = type[0];
	} else if(T[u].l == NIL) {
		mes = type[2];
	} else {
		mes = type[1];
	}

	printf("node %d: parent = %d, depth = %d, %s, [", u, p, d, mes);
	for(i=0;i<Child[u][0];i++) {
		if(i==0) {
			printf("%d", Child[u][i+1]);
		} else {
			printf(", %d", Child[u][i+1]);
		}
	}

	printf("]\n");
}

int main(void){
    int i, j, d, v, c, n, old;

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for ( i = 0; i < n; i++ ){
        scanf("%d %d", &v, &d);
        Child[v] = (int*)malloc(sizeof(int)*(d+1));
        Child[v][0] = d;
        for ( j = 0; j < d; j++ ){
            scanf("%d", &c);
            Child[v][j+1] = c;
            if(j==0) {
            	T[v].l = c;
            }
            T[c].p = v;
            if(j > 0) {
            	T[c].r = old;
            }
            old = c;
        }
    }
    
    for ( i = 0; i < n; i++ ) print(i, n);
    return 0;
}

Measured memory_bytes: 6080
import java.io.*;
import java.util.*;
 
public class Main{
	
 
	public void solve(){
		while(true){
			int x = nextInt();
			int y = nextInt();
			int s = nextInt();
			if(x == 0) break;
			int max = 0;
			for(int i = 1; i < s; i++){
				for(int j = 1; j < s; j++){
					if((i + i * x / 100) + (j + j * x / 100) == s){
						max = Math.max(max, (i + i * y / 100) + (j + j * y / 100));
					}
				}
			}
			out.println(max);
		}
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24920
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n;
  cin >> n;
  pair<int, int> a[110000];
  for(int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i+1;
  }
  sort(a,a+n);

  for(int i = 0; i < n; i++) {
    if(i != n-1) cout << a[i].second << " ";
    else cout << a[i].second;
  }
  cout << endl;
}

Measured memory_bytes: 4432
#include<iostream>

using namespace std;

int main(void){
	int a,b;
	
	cin >> a;
	if(a/100==9){
		if((a%100)/10==9){
			if(a%10==9){
				cout << 111 << endl;
			}
			else
			cout << 119 << endl;
		}
		else if(a%10==9){
		cout << 191 << endl;
		}
		else 
		cout << 199 << endl;
	}else if((a%100)/10==9){
		if(a%10==9){
			cout << 911 << endl;
		}else 
			cout << 919 << endl;
	}else if(a%10==9){
		cout << 991 << endl;
	}else
		cout << 999 << endl;
		
return 0;
}


Measured memory_bytes: 256
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

// 次の駅まで最短で何秒でいけるかを計算する
fn next_time(start_t: u64, from: usize, csf: &Vec<Vec<u64>>) -> u64 {
    let c = csf[from][0];
    let s = csf[from][1];
    let f = csf[from][2];

    if start_t <= s {
        s - start_t + c
    } else if (start_t - s) % f == 0 {
        c
    } else {
        (f - ((start_t - s) % f)) + c
    }
}

// 駅 from から 駅 n まで何秒で行けるかを計算する
fn to_n_time(from: usize, n: usize, csf: &Vec<Vec<u64>>) -> u64 {
    let mut time = 0;
    for from in from..(n-1) {
        time += next_time(time, from, csf);
    }
    time
}

fn main() {
    input!{
        n: usize,
        csf: [[u64; 3]; n-1],
    }

    for station in 0..n {
        println!("{}", to_n_time(station, n, &csf));
    }
}


Measured memory_bytes: 4352