akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> a(n + 1);
    map<ll, vector<ll> > d;
    for (ll i = 1; i <= n; ++i) {
        cin >> a.at(i);
        (--a.at(i) += a.at(i - 1)) %= k;
    }
    for (ll i = 0; i <= n; ++i) d[a.at(i)].push_back(i);
    for (auto i = d.begin(); i != d.end(); ++i) for (auto j = (*i).second.begin(); j != (*i).second.end(); ++j) ans += lower_bound((*i).second.begin(), (*i).second.end(), *j + k) - j - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23680
#include<stdio.h>
#include<stdlib.h>


int main(){
    int n,k,h,sum=0;

    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&h);
        if(h>=k){
            sum++;
        }
    }
    printf("%d\n",sum);

    return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

li a, b, c, d;

bool read () {
	if (scanf("%lld%lld%lld%lld", &a, &b, &c, &d) != 4)
		return false;
	return true;
}

void solve() {
	a -= b;
	
	if (a < 0 || d < b){
		puts("No");
		return;
	}
	
	a -= (a - c + b - 1) / b * b;
	
	if (a < 0){
		puts("No");
		return;
	}
	
	if (b <= c){
		puts("Yes");
		return;
	}
	
	if (b > c + __gcd(d, b)){
		puts("No");
		return;
	}
	
	puts("Yes");
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	int tc;
	scanf("%d", &tc);
	forn(_, tc){
		read();
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,k;
    cin >> a >>b >>k;
    int cnt=0;
    for(int i=max(a,b);i>0;i--){
        if(a%i==0&&b%i==0){
            cnt++;
        }
        if(cnt==k){
            cout << i;
            return 0;
        }
    }

    return 0;
}

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

int W,h,ans=0;
bool a[100+2][100+2],b[100+2][100+2];

bool ch(bool s,bool t){
	if(s&&!t)return true;
	if(!s&&t)return true;
	return false;
}

void w(int x,int y){
	a[x][y]=false;
	b[x][y]=true;
	if(x==0){
		if(x!=101)if(a[x+1][y])w(x+1,y);
		if(y!=101)if(a[x][y+1])w(x,y+1);
		if(y!=0){
			if(a[x][y-1])w(x,y-1);
			if(y%2==1){
				if(x!=101)if(a[x+1][y-1])w(x+1,y-1);
				if(x!=101&&y!=101)if(a[x+1][y+1])w(x+1,y+1);
			}
		}
	}
	else {
		if(a[x-1][y])w(x-1,y);
		if(x!=101)if(a[x+1][y])w(x+1,y);
		if(y!=101)if(a[x][y+1])w(x,y+1);
		if(y%2==0){
			if(a[x-1][y+1])w(x-1,y+1);
			if(y!=0){
				if(a[x-1][y-1])w(x-1,y-1);
				if(a[x][y-1])w(x,y-1);
			}
		}
		else {
			if(a[x][y-1])w(x,y-1);
			if(x!=101)if(a[x+1][y-1])w(x+1,y-1);
			if(x!=101&&y!=101)if(a[x+1][y+1])w(x+1,y+1);
		}
	}
}		

int main(){
	int c;
	scanf("%d%d",&W,&h);
	for(int i=0;i<102;i++){
		for(int j=0;j<102;j++){
			b[j][i]=false;
			if(1<=i&&i<=h&&1<=j&&j<=W){
				scanf("%d",&c);
				if(c==0)a[j][i]=true;
				else a[j][i]=false;
			}
			else a[j][i]=true;
		}
	}
	w(0,0);
	for(int i=1;i<=W;i++){
		for(int j=1;j<=h;j++){
			if(j%2==0){
				if(ch(b[i-1][j-1],b[i][j])){ans++; if(i==1||j==1)ans++;}
				if(ch(b[i-1][j+1],b[i][j])){ans++; if(i==1||j==h)ans++;}
			}
			else {
				if(ch(b[i+1][j-1],b[i][j])){ans++; if(i==W||j==1)ans++;}
				if(ch(b[i+1][j+1],b[i][j])){ans++; if(i==W||j==h)ans++;}
			}
			if(ch(b[i][j+1],b[i][j])){ans++; if(j==h)ans++;}
			if(ch(b[i][j-1],b[i][j])){ans++; if(j==1)ans++;}
			if(ch(b[i+1][j],b[i][j])){ans++; if(i==W)ans++;}
			if(ch(b[i-1][j],b[i][j])){ans++; if(i==1)ans++;}
		}
	}
	printf("%d\n",ans/2);
}

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

int main()
{
  int x, y;
  while (cin>>x>>y) {
    if (x==0 && y==0) continue;
    if (x > y) {
      cout << y << ' ' << x << endl;
    } else {
      cout << x << ' ' << y << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 2976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt();
		boolean check;
		int count = 0;
		for(int i=a;i<b+1;i++){
			if(i == 0){
				System.out.println("Zero");
				return ;
			}
			if(i < 0){
				count++;
			}
		}
		if(count % 2 == 0){
			System.out.println("Positive");
		}else{
			System.out.println("Negative");
		}
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
	ios::sync_with_stdio(0);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	vector<int>L(n+1),R(n+1);
  	for(int i=0;i<n;i++)
  		cin>>L[i]>>R[i];
  	sort(L.rbegin(),L.rend());
  	sort(R.begin(),R.end());
  	LL ans=0;
  	for(int i=0;i<=n;i++){
  		//cout<<L[i]<<" "<<R[i]<<endl;
  		if(L[i]<R[i])break;
	  	ans+=L[i]-R[i];
	}
	cout<<ans*2<<endl;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll pow(ll x, ll ntimes) {
    ll ret = 1;
    while (ntimes > 0) {
        if ((ntimes & 1) == 1) {
            ret = ret * x;
        }
        x = x * x;
        ntimes >>= 1;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    int l = (int)s.size();
    REP(i,l){
        ll now = (ll)(s[i]-'0');
        for(int j = l-i-1;j>=0;--j){
            ans += now * pow(10,l-i-1-j) * pow(2,max(0,j-1)) * pow(2,i);
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;


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

	string S;
	cin >> S;

	ll ans = 0;

	
	for (ll i = 0; i < S.size(); ++i)
	{
		for (ll j = i; j < S.size(); ++j)
		{
			bool f = true;
			for (ll k = i; k <= j; ++k)
			{
				if (S[k] != 'A' &&S[k] != 'T' &&S[k] != 'C' &&S[k] != 'G')
				{
					f = false;
					break;
				}
			}

			if (f)
			{
				chmax(ans, j - i + 1);
			}
		}
	}

	cout << ans << endl;

	//system("pause");
}


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int n;
    vector<long long int>v; 
    cin>>n;
    while(n)
    {
      v.push_back(n%10);
      n=n/10;

    }
    bool found=false;
    for(int i=0;i<v.size();i++)
    {
      if(v[i]==7)
      {
        found=true;
        break;
      }
    }
    if(found)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	string s;
	stack<int> S;
	stack<pair<int, int> > W;
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++) {
		if (ch == '\\') {
			S.push(i);
		}
		else if (ch == '/' && S.size() > 0) {
			int j = S.top(); S.pop();
			sum += i - j;
			int a = i - j;
			while (W.size() > 0 && W.top().first > j) {
				a += W.top().second; W.pop();
			}

			W.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (W.size() != 0) { ans.push_back(W.top().second); W.pop(); }

	cout << sum << endl;
	cout << ans.size();
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << " " << ans[i];
	}
	cout << endl;
}



Measured memory_bytes: 3192
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Channels;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        //var N = long.Parse(Console.ReadLine());
        var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var D = inp[0];
        var T = inp[1];
        var S = inp[2];

        Console.WriteLine(((D-1)/T+1) <= S ? "Yes":"No");
    }
}




Measured memory_bytes: 28228
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  int x=0;
  int y=0;
  int z=0;
  
  
  if(S[0]=='A'){
    x=1;
  }
  
  for(int i=2;i<=S.size()-2;i++){
    if(S[i]=='C'){
      y++;
    }
  }
  
  for(int i=0;i<S.size();i++){
    if(islower(S[i])){
      z++;
    }
  }
  
  if(x==1&&y==1&&z==S.size()-2){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}

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



int main(void){
    string s;
    cin>>s;
    int judge=0;
    int count=0;
    if(s[0]=='A') judge++;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C') count++;
    }
    if(count==1) judge++;
    int count2=0;
    for(int i=0;i<s.size();i++){
        if('a'<=s[i]&&s[i]<='z') count2++;
    }
    if(count2==s.size()-2) judge++;
    if(judge==3){
        cout<<"AC"<<endl;
    }else{
        cout<<"WA"<<endl;
    }
    return 0;
}



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

int main()
{
    int64_t n, col;
    cin >> n >> col;
    int64_t d[col][col], c[n][n];
    for (int i = 0; i < col; i++)
    {
        for (int j = 0; j < col; j++)
        {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    int64_t ans = (1ll << 60), a[3], b[3][col];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < col; j++)
        {
            b[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            b[(i + j) % 3][c[i][j]]++;
        }
    }
    for (a[0] = 0; a[0] < col; a[0]++)
    {
        for (a[1] = 0; a[1] < col; a[1]++)
        {
            if (a[0] == a[1])
            {
                continue;
            }
            for (a[2] = 0; a[2] < col; a[2]++)
            {
                if (a[0] == a[2] || a[1] == a[2])
                {
                    continue;
                }
                int64_t tmp = 0;
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < col; j++)
                    {
                        tmp += b[i][j] * d[j][a[i]];
                    }
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
s=input().split('T')
p=list(map(int,input().split()))
mv=[len(i) for i in s]
d=[[],[]]
for i in range(len(mv)):
    d[i&1].append(mv[i])
x=d[0].copy()
y=d[1].copy()
t=[x.pop(0),0]
x.sort()
y.sort()
while x!=[]:
    if t[0]>p[0]:t[0]-=x.pop()
    else:t[0]+=x.pop()
while y!=[]:
    if t[1] > p[1]:t[1] -= y.pop()
    else:t[1] += y.pop()
print(['No','Yes'][p==t])

Measured memory_bytes: 3316
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;

int main()
{
   int h,w,n;
   cin>>h>>w>>n;
   if(h<w)
   h=w;
   int t=n/h;
   if(h*t<n)
   t++;
   cout<<t<<endl;
    return 0;
}








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

int main(){
	int n,temp;
	cin>>n;
	int f[n],c[n][11];
	for(int i=0;i<n;i++){
		f[i]=0;
		for(int j=0;j<10;j++){
			cin>>temp;
			if(temp) f[i]|=(1<<j);
		}
	}
	
	for(int i=0;i<n;i++)
		for(int j=0;j<11;j++)
			cin>>c[i][j];
	
	int maxProfit=INT_MIN;
	for(int i=(1<<10)-1;i>0;i--){
		int profit=0;
		for(int j=0;j<n;j++){
			profit+=c[j][__builtin_popcount(f[j]&i)];
		}
		maxProfit=max(maxProfit,profit);
	}
  	cout<<maxProfit<<endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int A = s.nextInt();
		int B = s.nextInt();

		if (N * A < B) {
			System.out.println(N * A);
		} else {
			System.out.println(B);
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n, x[1010], y[1010];
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d%d", y + i, x + i);
    int tag = !!((x[1] + y[1]) % 2);
    for(int i = 1; i <= n; i++) if(tag != !!((x[i] + y[i]) % 2)) return puts("-1"), 0;
    int m = tag ? 32 : 31;
    puts("32");
    if(tag == 0) printf("1 ");
    for(int i = 0; i < m; i++) printf("%lld ", 1ll << i);
    puts("");
    for(int i = 1; i <= n; i++) {
        int dx = x[i], dy = y[i];
        if(tag == 0) dx--, putchar('U');
        for(int i = 1; i < m; i++) {
            assert((dx + dy) % 2);
            long long tt = ((dx + dy) % 4 + 4) % 4;
            if(dx % 2) {
                if(tt == 3) putchar('U'), dx--, dx /= 2, dy /= 2;
                else putchar('D'), dx++, dx /= 2, dy /= 2;
            }
            else {
                if(tt == 3) putchar('R'), dy--, dx /= 2, dy /= 2;
                else putchar('L'), dy++, dx /= 2, dy /= 2;
            }
            // cerr << dx << ' ' << dy << endl;
        }
        assert(abs(dx) + abs(dy) == 1);
        if(dx == 1) puts("U");
        else if(dx == -1) puts("D");
        else if(dy == 1) puts("R");
        else puts("L");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

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

	int n = min(a, b);
	vector<int> ans;
	for (int i = 1; i <= n; i++) {
		if (a % i == 0 and b % i == 0)
			ans.push_back(i);
	}
	sort(rall(ans));
	cout << ans[k - 1] << endl;
}


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

cnt = 0
G = [[] for i in range(N + 1)]
for i in range(1, N + 1):
    for j in range(i, N + 1):
        if N % 2 == 1:
            if i + j != N and i != j:
                G[i].append(j)
                cnt += 1
        else:
            if i + j != N + 1 and i != j:
                G[i].append(j)
                cnt += 1

print(cnt)

for i in range(1, N + 1):
    for g in G[i]:
        print(i, g)

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    multimap<int, int> mp;
    int N, A, ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A;
        mp.insert(make_pair(A, i+1));
    }
    for(auto it = mp.begin(); it != mp.end(); it++){
        cout << it->second << " ";
    }
    return 0;
}


Measured memory_bytes: 5504
s = [int(i) for i in list(input())]
a = []
b = []
for i in range(len(s)):
    if i % 2 == 0:
        a.append(0)
    else:
        a.append(1)
for i in range(len(s)):
    if i % 2 == 1:
        b.append(0)
    else:
        b.append(1)
count_a = 0
count_b = 0
for i, j in zip(s, a):
    if i != j:
        count_a += 1
for i, j in zip(s, b):
    if i != j:
        count_b += 1
print(min(count_a, count_b))


Measured memory_bytes: 5404
use std::io::*;
use std::str::FromStr;

fn main() {
    let ai: i64 = read();
    let ao: i64 = read();
    let _at: i64 = read();
    let aj: i64 = read();
    let al: i64 = read();
    let _as: i64 = read();
    let _az: i64 = read();

    println!(
        "{}",
        ao + (ai / 2 + aj / 2 + al / 2) * 2 + if ai % 2 == 1 && aj % 2 == 1 && al % 2 == 1 {
            3
        } else if ai % 2 == 1 && aj % 2 == 1 && al >= 2 {
            1
        } else if ai % 2 == 1 && al % 2 == 1 && aj >= 2 {
            1
        } else if aj % 2 == 1 && al % 2 == 1 && ai >= 2 {
            1
        } else {
            0
        }
    );
}

fn read<T: FromStr>() -> 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().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code

int main()
{
  int x, y, z;
  cin>>x>>y>>z;
  int ans = (x - z) / (y + z);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        char[][] map = new char[n][n];
        for(int i = 0; i < n; i++){
            map[i] = sc.next().toCharArray();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            boolean flg = true;
            for(int h = 0; h < n; h++){
                for(int w = 0; w < n; w++){
                    char c1 = map[h][(w+i)%n];
                    char c2 = map[w][(h+i)%n];
                    if(c1 != c2){
                        flg = false;
                        break;
                    }
                }
                if(!flg) break;
            }
            if(flg) ans++;
        }
        pw.println(ans * n);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 29604
#include<cstdio>
int main(){
    int n,pmax=0,psum=0,ptmp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&ptmp);
        if(ptmp>pmax)pmax=ptmp;
        psum+=ptmp;
    }
    printf("%d",psum-pmax/2);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    ll n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for (int i = 1; i < n; i++)
    {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

 double n,d;
 cin >> n >> d;
 double x,y;
 double count=0;
 while(n-->0)
 {
	 cin >> x >>y;
	 if((x*x+y*y)<=d*d)
	 {
		 count++;
	 }
 }

  cout << count << endl;

	return 0;
}











Measured memory_bytes: 3164
N=int(input())
S=list(map(int,input().split()))
s=list(set(S))
s.sort()
x=len(s)
Z=0
for i in range(x-1):
  a=s[i]
  A=S.count(a)
  for j in range(x-i-1):
    b=s[i+1+j]
    B=S.count(b)
    t=[i for i in S if i>b and i<a+b]
    T=len(t)
    Z+=A*B*T
print(Z)

Measured memory_bytes: 9216
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
const int dlu=10;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszkol[nax][nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if ((a/dlu)==(b/dlu) && !jeszkol[x][a/dlu])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if ((a/dlu)==(b/dlu) && !jeszkol[y][a/dlu])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszkol[j][i/dlu]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
		for (int j=0; j<nax; j++)
			if (dlu*j<n)
				jeszkol[i][j]=pyt(dlu*j, min(dlu*j+dlu-1, n-1), i, i);
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 724
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
		static int CARD_MAX=200;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<String> str =new ArrayList<String>();


		for(int i=0;;i++){
			 str.add(scan.next());
			 if(str.get(i).equals("-")) {
				 str.remove(i);
				 break;
			 }

			 int m = scan.nextInt();
				 while(scan.hasNextInt()){
					 int h =  scan.nextInt();
							str.set(i,shutffleString(str.get(i),h));
				 }

		}

		for (String st : str){
			System.out.println(st);
		}

	}



public static String shutffleString(String str,int h){
		String before = new String();
		String after = new String();

		for(int i = 0 ; i<h ; i++){
			before = before + str.charAt(i);
		}
		for(int i=h ; i < str.length() ;i++){
			after = after + str.charAt(i);
		}
			str = after + before;

	return str;
}

}

Measured memory_bytes: 44736
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

// 個数制限なしナップサック問題
vector<long long> KnapsackProblem(vector<long long> &v, vector<long long> &w, long long W) {
  size_t n = v.size();
  vector<vector<long long>> dp(n + 1, vector<long long> (W + 1, 0));
  for(size_t i = 0; i < n; i++) {
    for(size_t j = 0; j <= W; j++) {
      if(j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  return dp[n];
}


int main(){
  
  lint n, W; cin >> n >> W;
  vector<lint> v(n);
  vector<lint> w(n);
  REP(i, n) cin >> v[i] >> w[i];
  
  auto hoge = KnapsackProblem(v, w, W);
  cout << hoge[W] << endl;
  return 0;
}



Measured memory_bytes: 10776
using System;

namespace B_81
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for (var i = 1; i < 10; i++)
            {
                for (var j = 1; j < 10; j++)
                {
                    if (i * j == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }
    }
}

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

public class Main {

	Scanner sc = new Scanner(System.in);
	final static long LNF = 1L << 60;
	final static double EPS = 1e-9;

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

	void run() {

		int n = ni();
		long[][] a = new long[110000][3];
		long[][] dp = new long[110000][3];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = ni();
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if(j==k) continue;
					dp[i+1][k] = Util.max(dp[i+1][k], dp[i][j] + a[i][k]);
				}
			}
		}

		long result = 0;
		for (int i = 0; i < 3; i++) {
			result = Util.max(result, dp[n][i]);
		}
		System.out.println(result);

	}

	int ni() {
		return Integer.parseInt(sc.next());
	}

	long nl() {
		return sc.nextLong();
	}

	double nd() {
		return Double.parseDouble(sc.next());
	}

	void debug(Object... os) {
		System.out.println(Arrays.deepToString(os));
	}

	static class Util {
		static <T extends Comparable<T>> T max(T a, T b) {
			if (a.compareTo(b) > 0) {
				return a;
			} else {
				return b;
			}
		}

		static <T extends Comparable<T>> T min(T a, T b) {
			if (a.compareTo(b) < 0) {
				return a;
			} else {
				return b;
			}
		}
	}

}


Measured memory_bytes: 74480
#include "bits/stdc++.h"
using namespace std;
vector<int>to[100005];
const int INF = 1001001001;
int dist[100005][3];

int main() {
	int N, M;
	cin >> N >> M;
	for (int n = 0; n < M; ++n) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
	}
	int sv, tv;
	cin >> sv >> tv;
	--sv;
	--tv;
	for (int i = 0;i<N;++i) {
		for (int j = 0;j<3;++j) {
			dist[i][j] = INF;
		}
	}
	dist[sv][0] = 0;
	queue<pair<int, int>>q;
	q.push(make_pair(sv,0));
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (int e : to[v]) {
			int nl = (1+l) % 3;
			if (INF != dist[e][nl]) {
				continue;
			}
			dist[e][nl] = dist[v][l] + 1;
			q.push(make_pair(e, nl));
		}
	}
	int ans = dist[tv][0];
	if (INF == ans) {
		cout << -1 <<endl;
	}
	else {
		cout << ans/3<<endl;
	}
	return 0;
}

Measured memory_bytes: 10224
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
LL ans,n,a,b,c,d;
map<LL,LL> mp;
LL dg(LL x){
//	cout<<x<<" "<<o<<" "<<ans<<"   mdzz\n";
//	system("pause");
	if (mp.count(x)) return mp[x];
	if (x==0) return 0;
	if (x==1) return d;
	LL res=1e18; 
	if (x<res/d) res=x*d;
	if (x%5==0) res=min(res,c+dg(x/5));
	if (x%2==0) res=min(res,a+dg(x/2));
	if (x%3==0) res=min(res, b+dg(x/3));
	if (x&1) res=min(res, a+d+min(dg(x/2),dg(x/2+1)));
	if (x%3!=0){
		int k=x%3;
		res=min(res, min(dg(x/3)+b+d*k,dg(x/3+1)+b+d*(3ll-k)));
	}
	if (x%5!=0) {
		int k=x%5;
		res=min(res, min(dg(x/5)+c+d*k,dg(x/5+1)+c+d*(5ll-k)));
	}
	return mp[x]=res;
}
int main(){
	int T=read();
	while (T--){
		cin>>n>>a>>b>>c>>d;
//		ans=1e18;
//		dg(n);
mp.clear();
		cout<<dg(n)<<"\n";
	}
    return 0;
}



Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ar[3];
    for(int i = 0; i<3; i++){
        cin >> ar[i];
    }
    int ret = 10000000;
    for(int m = 0; m<2; m++){
        int a[3];
        int ans = 0;
        for(int i = 0; i<3; i++){
            a[i] = ar[i];
            if(a[i]%2!=m){
                a[i]--;
                ans++;
            }
        }
        int mm = max(a[0],max(a[1],a[2]));
        for(int i = 0; i<3; i++){
            ans += (mm-a[i])/2;
        }
        ret = min(ret,ans);
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 109;

int n;
vector<int> b;

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        int b_tmp;
        cin >> b_tmp;
        b.push_back(b_tmp);
    }

    vector<int> ans;
    while(!b.empty()) {
        int del = -1;
        for(int i = 1; i <= b.size(); i++) {
            if(b[i-1] == i)
                del = i-1;
        }
        if(del != -1) {
            ans.push_back(b[del]);
            b.erase(b.begin() + del);
        }
        else
            b.clear();

    }

    if(ans.size() == n) {
        reverse(ans.begin(), ans.end());
        for(auto x : ans)
            cout << x << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int left = A + B;
  int right = C + D;
  if (left > right) cout << "Left";
  else if (left == right) cout << "Balanced";
  else if (left < right) cout << "Right";
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)
#define N 200010
using namespace std;
ll n,nn[2],md[N][2];
string s;
ll f(ll v,ll nd,ll sd,ll sx){
	ll ret=1,x=(nn[nd]+sd+sx*md[v][nd])%sd;
	while(x!=0)
	{
		x=x%__builtin_popcount(x);
		ret++;
	}
	return ret;
}
int main(){
	ll i,bb=0;
	fast;itt;now;
	cin>>n>>s;
	for(i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			bb++;
		}
	}
	md[0][0]=1%(bb+1);
	if(bb>1)
	{
		md[0][1]=1%(bb-1);
	}
	for(i=1;i<=n;i++)
	{
		md[i][0]=(md[i-1][0]*2)%(bb+1);
		if(bb>1)
		{
			md[i][1]=(md[i-1][1]*2)%(bb-1);
		}
	}
	nn[0]=nn[1]=0;
	for(i=0;i<n;i++)
	{
		nn[0]=(nn[0]*2+(s[i]-'0'))%(bb+1);
		if(bb>1)
		{
			nn[1]=(nn[1]*2+(s[i]-'0'))%(bb-1);
		}
	}
	for(i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			cout<<f(n-i-1,0,bb+1,1)<<endl;
		}
		else if(bb>1)
		{
			cout<<f(n-i-1,1,bb-1,-1)<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6904
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int n;
  cin >> n;
  int iti = n%10;
  if(iti==2||iti==4||iti==5||iti==7||iti==9)cout << "hon" << endl;
  else if(iti==0||iti==1||iti==6||iti==8)cout << "pon" << endl;
  else cout << "bon" << endl;
}


Measured memory_bytes: 3624
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    string s,t;
    cin>>s>>t;
    ll n = s.length();
    ll m = t.length();
    ll dp[n+1][m+1];
    FILL(dp,0);
    
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }

    string ans = "";

    ll i = n,j = m;

    while(dp[i][j]!=0){
        if(dp[i][j]!=dp[i-1][j] && dp[i][j]!=dp[i][j-1]){
            ans += s[i-1];
            i--;j--;
        }
        else if(dp[i][j]==dp[i-1][j-1]){
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}






Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    string str;
    cin >> str;
    int r = 0;
    int sum = 0;
    vector<int> j;
    for (int i = 0; i < str.size();i++) {
        if(str[i] == 'R') {
            r++;
        } else {
            sum=max(sum,r);
            r = 0;
        }
    }
    sum = max(sum,r);
    cout << sum;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int tl[N+2],tr[N+2],v[N+2];
  tl[0] = 0;
  tr[0] = 0;
  int endt = 0;
  for(int i=1;i<=N;i++){
    int tmp;
    cin >> tmp ;
    tl[i] = tr[i-1];
    tr[i] = tl[i] + tmp;
    endt += tmp;
  }
  tl[N+1] = tr[N];
  tr[N+1] = tl[N+1];
  for(int i=1;i<=N;i++){
    cin >> v[i];
  }
  v[0] = 0;
  v[N+1] = 0;
 
  double spd[2*endt+1];
  for(int i=0;i<=2*endt;i++){
    spd[i] = 1000000000;
    for(int j=0;j<N+2;j++){
      double tmp;
      double tnow = double(i)/2;
      //cout << "tnow" << tnow << endl;
      //cout << tl[j] << tr[j] << endl;
      if(tnow < tl[j]){
        tmp = v[j] + tl[j] - tnow;
      } else if (tr[j] < tnow){
        tmp = v[j] + tnow - tr[j];
      } else if(tl[j] <= tnow && tnow <= tr[j]) {
        tmp = v[j];
      }
      spd[i] = min(spd[i],tmp);
    }
    //cout << "i=" << i << " " << spd[i] << endl;
  }
 
  /*for(int i=0;i<N+2;i++){
    cout << tl[i] << " " << tr[i] << " " << v[i] << endl;
  }*/
 
  double sum = 0;
  for(int i=1;i<=2*endt;i++){
    sum += (spd[i]+spd[i-1]) * 0.5 / 2;
  }
 
  printf("%.15lf\n",sum);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int dp[n+1][m+1];
    string res="";
    repA(i,0,n)
    {
        repA(j,0,m)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    int i=n,j=m;
    while(i>=1 && j>=1)
    {
        if(s[i-1]==t[j-1])
        {
            res+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 35456
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

deque< int > d;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++ i) {
        int x;
        cin >> x;

        if (i % 2) {
            d.push_back( x );
        } else {
            d.push_front( x );
        }
    }

    if (n % 2 == 0) {
        while (!d.empty()) {
            cout << d.front() << " ";
            d.pop_front();
        }
    } else {
        while (!d.empty()) {
            cout << d.back() << " ";
            d.pop_back();
        }
    }

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

struct Node{
	vector<int> to,from;
};

void DFS(const int n,const vector<Node> &nodes,bool is_done[]){
	is_done[n]=true;
	REP(i,0,nodes[n].to.size()) if(!is_done[nodes[n].to[i]]) DFS(nodes[n].to[i],nodes,is_done);
	REP(i,0,nodes[n].from.size()) if(!is_done[nodes[n].from[i]]) DFS(nodes[n].from[i],nodes,is_done);
}

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N;
    while(cin >> N&&N){
	    vector<Node> nodes('z'+1);
	    REP(i,0,N){
			string str;
			cin >> str;
			char initial=str[0],terminal=str[str.size()-1];
			nodes[initial].to.push_back(terminal);
			nodes[terminal].from.push_back(initial);
		}
		int cnt=0;
		REP(i,'a','z'+1) if(nodes[i].to.size()+nodes[i].from.size()!=0) ++cnt;
		bool flag=true,is_done['z'+1];
		memset(is_done,0,sizeof(is_done));
		REP(i,'a','z'+1) if(nodes[i].to.size()+nodes[i].from.size()!=0){
			DFS(i,nodes,is_done);
			break;
		}
		int cnt_=0;
		REP(i,'a','z'+1) if(is_done[i]) ++cnt_;
		if(cnt!=cnt_) flag=false;
		if(flag){
			REP(i,'a','z'+1) if(nodes[i].to.size()!=nodes[i].from.size()){
				flag=false;
				break;
			}
		}
		if(flag) cout << "OK";
		else cout << "NG";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1352
import java.util.Scanner;
 class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int result[] = new int[1000000],i = 0;
		while(true){
			result[i] = sc.nextInt();
			if(result[i] == 0) break;
			i++;
		}
		for(int j = 0; j < i; j++){
			System.out.println("Case "+(j+1)+": "+result[j]);
		}
	}
 }
 

Measured memory_bytes: 47696