akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    vector<int> v;
    int data;
    do{
        cin >> data;
        v.push_back(data);
    }while(data != 0);

    v.pop_back();
    for(int i = 0; i < v.size(); i++)
        cout << "Case " << i+1 << ": " << v[i] << endl;
}



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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int cnt = 0;
  rep(i,1000){
    int c[3] = {i/100, (i/10)%10, i%10};
    int f = 0;
    rep(j,N){
      if(S[j] == ('0' + c[f])) f++;
      if(f == 3){
        cnt++;
        break;
      }
    }
  }
  
  cout << cnt << endl;  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int sx,sy,tx,ty,i;
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	for(i=0;i<ty-sy;i++)printf("U");
	for(i=0;i<=tx-sx;i++)printf("R");
	for(i=0;i<=ty-sy;i++)printf("D");
	for(i=0;i<=tx-sx;i++)printf("L");
	printf("U");
	printf("L");
	for(i=0;i<=ty-sy;i++)printf("U");
	for(i=0;i<=tx-sx;i++)printf("R");
	for(i=0;i<=ty-sy;i++)printf("D");
	for(i=0;i<tx-sx;i++)printf("L");
	return 0;
}

Measured memory_bytes: 128
from sys import stdin
n = int(stdin.readline())
arr = sorted(list(map(int,stdin.readline().split())),reverse=True)
ans = arr[0]
peo = n-2
i = 1
while peo > 0:
    if peo == 1:
        ans += arr[i]
        peo -= 1
    else:
        ans += 2*arr[i]
        peo -= 2
        i += 1
print(ans)


Measured memory_bytes: 92208
N, K = map(int, input().split())
plist = [((num*(num+1))//2)/num for num in list(map(int, input().split()))]
# print(plist)
ans = 0
for i in range(K):
    ans += plist[i]
_ = ans
for i in range(N-K):
    temp = _
    temp -= plist[i]
    temp += plist[i+K]
    # print(i, i+K, ans, temp)
    ans = max(ans, temp)
    _ = temp
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>
#define all(n) n.begin(),n.end()
#define forr(i,a,b) for(i=a;i<b;i++)
#define forrr(i,a,b) for(i=b-1;i>=a;i--)

ll power(ll x,  ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll t;
    t=1;
    while(t--){
       ll n;
       cin>>n;
       ll ans=power(10,n,mod)-2*power(9,n,mod)+power(8,n,mod);
       while(ans<0) ans+=mod;
       cout<<ans<<endl;


            




    }
    
return 0;    
 }  

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out

vvi v(50,vi(50,-2));

bool dfs(int x,int y,int count,int h,int w){
    
    if(v[y][x]>=0)return false;
    v[y][x]=count;
    bool t=true;
    if(x+1<w&&v[y][x+1]==-1){
        t=dfs(x+1,y,count,h,w);
    }
    if(x-1>=0&&v[y][x-1]==-1){
        t=dfs(x-1,y,count,h,w);
    }
    if(y+1<h&&v[y+1][x]==-1){
        t=dfs(x,y+1,count,h,w);
    }
    if(y-1>=0&&v[y-1][x]==-1){
        t=dfs(x,y-1,count,h,w);
    }///////
    if(x+1<w&&y+1<h&&v[y+1][x+1]==-1){
        t=dfs(x+1,y+1,count,h,w);
    }
    if(x-1>=0&&y-1>=0&&v[y-1][x-1]==-1){
        t=dfs(x-1,y-1,count,h,w);
    }
    if(y+1<h&&x-1>=0&&v[y+1][x-1]==-1){
        t=dfs(x-1,y+1,count,h,w);
    }
    if(y-1>=0&&x+1<w&&v[y-1][x+1]==-1){
        t=dfs(x+1,y-1,count,h,w);
    }
    if(t) return true;
    else return false;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int w,h,i,j;
    while(1){
        cin>>w>>h;
        if(w==0&&h==0)break;
        int count=1,x,y;
        rep(i,50)rep(j,50)v[i][j]=-2;
        rep(i,h)rep(j,w){
            cin>>v[i][j];
            v[i][j]*=-1;
        }
        bool c;
        for(y=0;y<h;y++){
            for(x=0;x<w;x++){
                c=dfs(x,y,count,h,w);
                if(c)count++;
            }
        }
        set<int> s;
        for(y=0;y<h;y++){
            for(x=0;x<w;x++){
                if(v[y][x]>0)s.insert(v[y][x]);
            }
        }
        cout<<s.size()<<endl;
        /*
        for(y=0;y<h;y++){
            for(x=0;x<w;x++){
                cout<<v[y][x]<<" ";
            }
            cout<<endl;
        }*/
    }
    

//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 3388
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int d,r,a,b;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %.5lf",d,r,f);
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3236
#include <iostream>

int N = 100;

int main(){
  int A, B;
  std::cin >> A >> B;
  int Ba[N][N];

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i<N/2){
        Ba[i][j] = 0; //A
      }else{
        Ba[i][j] = 1; //B
      }
    }
  }

  for(int i=0;i<N/2-1;i+=2){
    for(int j=0;j<N-1;j+=2){
      if(B==1){
        i=N/2;
        j=N;
      }else{
        Ba[i][j]=1; //B
        B--;
      }
    }
  }

  for(int i=N/2+1;i<N;i+=2){
    for(int j=0;j<N-1;j+=2){
      if(A==1){
        i=N;
        j=N;
      }else{
        Ba[i][j]=0; //A
        A--;
      }
    }
  }

  std::cout << "100 100" << std::endl;

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(Ba[j][i] == 0){
        std::cout << ".";
      }else{
        std::cout << "#";
      }
    }
    std::cout << std::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 per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n-1) {
    if(s[i]!=s[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5)
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
a,b,c = li()
 
a,b,c = sorted([a,b,c])
 
cnt = 0
while a != b or b != c:
    if a != b:
        a += 2
        
    else:
        a += 1
        b += 1
        
    a,b,c = sorted([a,b,c])
        
    cnt += 1
    
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

ll n, ans = 0;

void dfs(ll x, ll y ) {
    if (x > n) return;
    if (y == 7) ans++;
    dfs(10 * x + 3, y | 1);
    dfs(10 * x + 5, y | 2);
    dfs(10 * x + 7, y | 4);
}

int main() {
    cin >> n;
    dfs(0, 0);
    cout << ans << endl;

}

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

int main()
{
	int a, b; cin >> a >> b;
	
	bool flag = false;

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

		if (i * a == b) flag = true;

	}

	int ans = b - a;

	if (flag) ans = a + b;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/*修正ver.*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll f(ll b,ll n){
  if(n<b){
    return n;
  }else{
    return f(b,n/b)+n%b;
  }
}
int main(void){
  ll n,s;
  cin>>n>>s;
  if(n<s){
    cout<<-1<<endl;
  }else if(n==s){
    cout<<n+1<<endl;
  }else{
    ll k=n-s;
    vector<ll> vec;
    for(ll i=1;i*i<=k;i++){
      if(k%i==0){
        if(k==i*i){
          vec.push_back(i+1);
        }else{
          vec.push_back(i+1);
          vec.push_back((k/i)+1);
        }
      }
    }
    sort(vec.begin(),vec.end());
    ll ans=-1;
    ll len=vec.size();
    for(int i=0;i<len;i++){
      ll num=vec[i];
      if(f(num,n)==s){
        ans=num;
        break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i+=2){
    cout << S[i];
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(void)
{
	int array [101][101];
	int r, c, i, j, rsum, csum;

	scanf("%d %d", &r, &c);
	for(i = 0;i < r + 1;i++)
	{
		rsum = 0;
		for(j = 0;j < c + 1;j++)
		{
			if((j < c) && (i < r))
			{
				scanf("%d", &array[i][j]);
				rsum += array[i][j];
			}
			else
				array[i][j] = rsum;
		}
	}
	for(i = 0;i < c + 1;i++)
	{
		csum = 0;
		for(j = 0;j < r + 1;j++)
		{
			if(j < r)
				csum += array[j][i];
			else
				array[j][i] = csum;
		}
	}
	for(i = 0;i < r + 1;i++)
	{
		for(j = 0;j < c + 1;j++)
		{
			if(j < c)
				printf("%d ", array[i][j]);
			else
				printf("%d\n", array[i][j]);
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005,p=1000000007;
struct node { int c,z; } a[N];
int W[N],G[N],s[N],c[N],fc[N],i,j,k,n,m,an,S,x,y,M,X,Y;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ char c; int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

bool cmp(node a,node b){ return a.c<b.c||a.c==b.c&&a.z<b.z; }
bool cmp1(int x,int y){ return a[x].z<a[y].z; }

int power(int z,int k)
{
	int d=1;
	for (;k;z=(LL)z*z%p,k>>=1) if (k&1) d=(LL)d*z%p;
	return d;
}

int main()
{
	n=read(),X=read(),Y=read();
	for (c[0]=i=1;i<=n;++i) c[i]=(LL)c[i-1]*i%p;
	for (fc[n]=power(c[n],p-2),i=n;i;--i) fc[i-1]=(LL)fc[i]*i%p;
	for (i=1;i<=n;++i) a[i]=(node){read(),read()};
	sort(a+1,a+n+1,cmp);
	for (i=1;i<=n;i=j)
		for (W[++W[0]]=i,G[a[i].c]=1,j=i+1;a[i].c==a[j].c;++j)
			if (a[i].z+a[j].z<=X)
				++G[a[i].c];
	sort(W+1,W+W[0]+1,cmp1);
	y=G[a[W[1]].c],an=1,
	M=a[W[1]].z;
	for (i=2;i<=W[0];++i)
		if (M+a[W[i]].z<=Y)
		{
			x=G[a[W[i]].c];
			for (j=W[i]+x;a[j].c==a[j-1].c;++j)
				if (M+a[j].z<=Y)
					++x;
			S+=x,an=(LL)an*fc[x]%p;
		}
		else
			break;
	--i;
	if (i>=2)
	{
		M=a[W[2]].z;
		for (j=W[1]+y;a[j].c==a[j-1].c;++j)
			if (M+a[j].z<=Y)
				++y;
	}
	an=(LL)an*fc[y]%p*c[S+y]%p;
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =2e3+5;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if((a+b)%2)
    {
        cout<<"IMPOSSIBLE"<<'\n';
    }
    else
    {
        cout<<(a+b)/2<<'\n';
    }



}


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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> a(N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
		a[i]--;
	}
	int now = 0;
	for(i = 0; i < N; i++){
		if(a[i] == now){
			now++;
		}
	}
	if(now == 0){
		printf("-1\n");
	}
	else{
		printf("%d\n", N - now);
	}
	return 0;
}

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

int main()
{
  int N, K; cin >> N >> K;
  string S; cin >> S;

  int cnt = 0;
  for (int i = 0; i < N-1; i++)
  {
    if (S[i] != S[i + 1]) cnt++;
  }
  cnt -= 2*K;
  if (cnt <= 0) cout << N - 1 << endl;
  else cout << N - 1 - cnt << endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	char s[200001];
	scanf("%s", s);

	ll ans = 0;
	int c = 0;
	int cntA = 0;
	REP(i, strlen(s)) {
		if (c == 0) {
			if (s[i] == 'A') {
				cntA++;
			}
			else if ((s[i] == 'B')) {
				if (cntA) c = 1;
			}
			else if (s[i] == 'C') {
				cntA = 0;
			}
		}
		else {
			if (s[i] == 'C') {
				ans += cntA;
			}
			else {
				cntA = 0;
				if (s[i] == 'A')cntA++;
			}
			c = 0;
		}
	}
	PRINTL(ans);
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main {
	int a,b,x,y;
	double z = 0.0;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		x = a / b;
		y = a % b;
		z = a * 1.0 / b;
		System.out.printf("%d %d %7f\n",x,y,z);
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 17384
N, M, C = list(map(int, input().split()))
b_li = list(map(int, input().split()))
ct = 0
for i in range(N):
    a_li = list(map(int, input().split()))
    total = 0
    for a,b in zip(a_li, b_li):
        total += a * b
    if total + C > 0:
        ct += 1

print(ct)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=5e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,k;
      cin>>n>>k;
      string s;
      cin>>s;
      s[k-1]=tolower(s[k-1]);
      cout<<s; 
}     



Measured memory_bytes: 256
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int a[101010],n,k[101010];
int main()
{int p,o=0;
 cin>>n;
 fo(i,0,n)
 {cin>>a[i];
  k[i]=1;
 }
 p=1;
 while(k[p-1]){
     o++;
     k[p-1]=0;
     p=a[p-1];
     if(p==2){
         cout<<o<<endl;
         return 0;
     }
 }
 cout<<"-1"<<endl;
 return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 50000;
	
	public static long gcd(long x, long y){
		if(x == 0){
			return y;
		}else{
			return gcd(y % x, x);
		}
	}
	
	public static long lcm(long x, long y){
		return x / gcd(x, y) * y;
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int d = sc.nextInt();
			
			if(a == 0 && b == 0 && d == 0){
				break;
			}
			
			final long lcm = lcm(a, b);
			
			//System.out.println(lcm);
			
			long min_count = Integer.MAX_VALUE;
			long min_x = 0;
			long min_y = 0;
			
			//same
			for(long x = 0; ; x++){
				long rest = d - a * x;
				
				if(rest < 0){
					break;
				}else if(rest % b != 0){
					continue;
				}
				
				long y = rest / b;
				
				//System.out.println("=>1 " +  x + " " + y + " " + (a * x + b * y) + " " + d);
				
				if(min_count > x + y){
					min_count = x + y;
					min_x = x;
					min_y = y;
				}
			}
			
			//other(a = b + d)
			for(long x = 0; a * x < lcm; x++){
				long rest = a * x - d;
				
				if(rest < 0){
					continue;
				}else if(rest % b != 0){
					continue;
				}
				
				long y = rest / b;
				
				//System.out.println("=>2 " +  x + " " + y + " " + (a * x) + " " + (b * y + d));
				
				if(min_count > x + y){
					min_count = x + y;
					min_x = x;
					min_y = y;
				}
			}
			
			//other(a * x + d = b * y)
			for(long x = 0; a * x < lcm; x++){
				long rest = a * x + d;
				
				if(rest % b != 0){
					continue;
				}
				
				long y = rest / b;
				
				//System.out.println("=>3 " +  x + " " + y + " " + (a * x + d) + " " + (b * y));
				
				if(min_count > x + y){
					min_count = x + y;
					min_x = x;
					min_y = y;
				}
			}
			
			System.out.println(min_x + " " + min_y);
		}
		
	}

}

Measured memory_bytes: 20788
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = {
  parent = nil;
  left = nil;
  right = nil;
  depth = nil;
  height = nil
}

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1)
  in doit 0

let set_depth t n =
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).left <> nil then doit t.(i).left (d + 1);
    if t.(i).right <> nil then doit t.(i).right (d + 1);
  in doit (search_root t n) 0

let set_height t n =
  let rec doit i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).left <> nil then (doit t.(i).left; hl := t.(t.(i).left).height + 1);
    if t.(i).right <> nil then (doit t.(i).right; hr := t.(t.(i).right).height + 1);
    t.(i).height <- (max !hl !hr)
  in doit (search_root t n)

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil
  in
  let degree i = 0 + (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  let print_node i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).parent;
    print_string ", sibling = "; print_int (sibling i);
    print_string ", degree = "; print_int (degree i);
    print_string ", depth = "; print_int t.(i).depth;
    print_string ", height = "; print_int t.(i).height;
    print_string (if t.(i).parent = nil then ", root" else if t.(i).left = nil && t.(i).right = nil then ", leaf" else ", internal node");
    print_string "\n"
  in Array.iteri (fun i _ -> print_node i) t

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  Array.iter (fun _ ->
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id
  ) t;
  set_depth t n;
  set_height t n;
  print t

Measured memory_bytes: 2236
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
    int a, x;
    cin >> a >> x;
    int sum = a+x;
    cout << 6 - sum << '\n';
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}



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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



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

    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;



    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n, m;
    cin >> n >> m;
    vector<int> food(m, 0);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int a;
            cin >> a;
            a--;
            food[a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(food[i] == n) ans++; 
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

vector<int>& bfs(vector<bool> &visited, vector<int> edges[], vector<int> &distance, int source)
{
	distance[source] = 0;
	queue<int> q;
	q.push(source);
	visited[source]=true;
	while(!q.empty())
	{
		int top = q.front();
		q.pop();
		for(int i = 0; i < edges[top].size(); i++)
		{
			if(visited[edges[top][i]]==false)
			{
				distance[edges[top][i]] = distance[top] + 1;
				visited[edges[top][i]]=true;
				q.push(edges[top][i]);
			}
		}
	}
	return distance;
}
int main()
{
	int n, x, y;
	cin>>n>>x>>y;
	x--;
	y--;
	vector<int> edges[n];
	for(int i = 0; i < n-1; i++)
	{
		edges[i].push_back(i+1);
		edges[i+1].push_back(i);
	}
	edges[x].push_back(y);
	edges[y].push_back(x);

	// for(int i = 0; i < n; i++)
	// {
	// 	for(int j = 0; j < edges[i].size(); j++) 
	// 	{
	// 		cout<<edges[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// cout<<endl;
	vector<pair<int, int> > dist(n-1);
	for(int i = 0; i < n; i++)
	{
		vector<bool> visited(n, false);
		vector<int> distance(n, 0);
		distance = bfs(visited, edges, distance, i);
		// for(int i = 0; i < distance.size(); i++)
		// {
		// 	cout<<distance[i]<<" ";
		// }
		// cout<<endl;
		for(int i = 0; i < distance.size(); i++)
		{
			(dist[distance[i]].second)++;
		}
	}
	for(int i = 1; i<n; i++)
	{
		cout<<(dist[i].second)/2<<endl;
	}
	// for(int i = 0)
	
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  ll v[7];
  for (; cin >> v[0]; ) {
    for (int i : range(1, 7)) cin >> v[i];

    ll res = 0;

    {
      ll cand = 2 * ((v[0] / 2) + (v[3] / 2) + (v[4] / 2));
      res = max(res, cand);
    }
    if (v[0] >= 1 && v[3] >= 1 && v[4] >= 1) {
      ll cand = 3 + 2 * (((v[0] - 1) / 2)) + 2 * (((v[3] - 1) / 2) + ((v[4] - 1) / 2));
      res = max(res, cand);
    }

    res += v[1];

    cout << res << endl;
  }
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;
const int N = 1e6 + 5;
int sieve[N];

void init() {
	sieve[1] = 1;
	for (int p = 2; p < N; p++) {
		if (!sieve[p]) {
			sieve[p] = p;
			for (int q = p + p; q < N; q += p)
				sieve[q] = p;
		}
	}
}

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

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	init();

	int n; scanf("%d", &n);
	vi a(n);
	vector<map<int,int>> fact(n);
	map<int,int> lc;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		a[i] = x;
		for (int p = sieve[x]; p > 1; p = sieve[x]) {
			int t = 0;
			while (x % p == 0) {
				x /= p;
				++t;
			}
			fact[i][p] = t;
			lc[p] = max(lc[p], t);
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		ll b = 1;
		for (auto x : lc) {
			if (fact[i].count(x.first)) x.second -= fact[i][x.first];
			b = (b * powmod(x.first, x.second)) % MOD;
		}
		ans = (ans + b) % MOD;
	}
	*/
	ll lm = 1;
	for (auto x : lc)
		lm = (lm * powmod(x.first, x.second)) % MOD;
	ll ans = 0;
	for (int x : a) {
		ans += (lm * powmod(x, MOD - 2)) % MOD;
		ans %= MOD;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 7040
l=[[2**(2+i)-3,2**(1+i)-1] for i in range(51)]
N,X=map(int,input().split())
a=0
def k(n,x):
    global a
    if x==l[n][0]:
        return l[n][1]
    elif l[n-1][0]+1<x:
        return l[n-1][1]+k(n-1,x-l[n-1][0]-2)+1
    elif 1<=x:
        return k(n-1,x-1)
    else:
        return 0
print(k(N,X))

Measured memory_bytes: 3064
S = list(input())# 各桁をリストに分配
n = len(S)-1 #桁数
ans = 0
for i in range(2**n): #隙間に+が入るかどうかの全パターン
    box = []
    for j in range(n): #隙間に+が入る場合の数
        if (i>>j) & 1:
            box.append(S[j])
            box.append("+")
        else:
            box.append(S[j])
    box.append(S[n])

    sub = 0
    plus = 0

    for k in range(len(box)):
        if box[k] == "+":
            sub += plus
            plus = 0
        else:
            if plus == 0:
                plus = int(box[k])
            else:
                plus *= 10
                plus += int(box[k])
    sub += plus
    ans += sub

print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using Matrix=std::vector<std::vector<int>>;

void rotate(Matrix &a) {
  size_t r, c, size;
  int angle;
  scanf("%zu %zu %zu %d", &r, &c, &size, &angle);
  --r, --c;

  if (angle == 0 || angle == 360) return;  // ???
  Matrix b(size, std::vector<int>(size));
  for (size_t i=0; i<size; ++i)
    for (size_t j=0; j<size; ++j)
      b[i][j] = a[r+i][c+j];

  for (size_t i=0; i<size; ++i) {
    for (size_t j=0; j<size; ++j) {
      if (angle == 90) {
        a[r+i][c+j] = b[size-j-1][i];
      } else if (angle == 180) {
        a[r+i][c+j] = b[size-i-1][size-j-1];
      } else if (angle == 270) {
        a[r+i][c+j] = b[j][size-i-1];
      }
    }
  }
}

void reversal(Matrix &a) {
  size_t r, c, size;
  scanf("%zu %zu %zu", &r, &c, &size);
  --r, --c;

  for (size_t i=0; i<size; ++i)
    for (size_t j=0; j<size; ++j)
      a[r+i][c+j] ^= 1;
}

void left_shift(Matrix &a) {
  size_t r;
  scanf("%zu", &r);
  --r;

  int tmp=a[r][0];
  for (size_t j=1; j<a.size(); ++j) 
    a[r][j-1] = a[r][j];

  a[r].back() = tmp;
}

void right_shift(Matrix &a) {
  size_t r;
  scanf("%zu", &r);
  --r;

  int tmp=a[r].back();
  for (size_t j=a.size()-1; j>=1; --j)
    a[r][j] = a[r][j-1];

  a[r][0] = tmp;
}

const size_t di[]={size_t(-1), 0, 1, 0};
const size_t dj[]={0, size_t(-1), 0, 1};

void island_reversal(Matrix &a) {
  size_t r, c;
  scanf("%zu %zu", &r, &c);
  --r, --c;

  int par=a[r][c];
  std::queue<std::pair<size_t, size_t>> q;
  q.emplace(r, c);
  while (!q.empty()) {
    size_t i=q.front().first, j=q.front().second;
    q.pop();
    if (a[i][j] != par) continue;
    a[i][j] ^= 1;

    for (int k=0; k<4; ++k) {
      size_t ni=i+di[k], nj=j+dj[k];
      if (!(ni < a.size() && nj < a.size())) continue;
      if (a[ni][nj] != par) continue;
      q.emplace(ni, nj);
    }
  }
}
        

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::vector<std::vector<int>> a(n, std::vector<int>(n));
  for (size_t i=0; i<n; ++i) {
    for (size_t j=0; j<n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }

  for (size_t i=0; i<m; ++i) {
    int op;
    scanf("%d", &op);

    switch (op) {
    case 0:
      rotate(a);
      break;

    case 1:
      reversal(a);
      break;

    case 2:
      left_shift(a);
      break;

    case 3:
      right_shift(a);
      break;

    case 4:
      island_reversal(a);
      break;
    }

  // for (size_t i=0; i<n; ++i)
  //   for (size_t j=0; j<n; ++j)
  //     fprintf(stderr, "%d%c", a[i][j], j+1<n? ' ':'\n');
  }

  for (size_t i=0; i<n; ++i)
    for (size_t j=0; j<n; ++j)
      printf("%d%c", a[i][j], j+1<n? ' ':'\n');
}



Measured memory_bytes: 2812
#include <stdio.h>
#define MAX 10000

struct node{
  int p, l, r; //????????????
};
struct node T[MAX];
int n, D[MAX], H[MAX]; //??????, depth

void setDepth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  setDepth(T[u].l, d + 1);
  setDepth(T[u].r, d + 1);
}
int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].l != -1)
    h1 = setHeight(T[u].l) + 1;
  if(T[u].r != -1)
    h2 = setHeight(T[u].r) + 1;
  if(h1 > h2)
    return H[u] = h1;
  else return H[u] = h2;
}

int getSibling(int u){
  if(T[u].p == -1) return -1;
  if(T[T[u].p].l != u && T[T[u].p].l != -1)
    return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != -1)
    return T[T[u].p].r;
  return -1;
}

void print(int u){
  int deg = 0;
  printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));
  if(T[u].l != -1) deg++;
  if(T[u].r != -1) deg++;
  printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);

  if(T[u].p == -1) printf("root\n");
  else if(T[u].l == -1 && T[u].r == -1) printf("leaf\n");
  else printf("internal node\n");

}

int main()
{
  int id, l, r, root = 0, i;

  scanf("%d", &n);
  for(i = 0; i < n; i++) T[i].p = -1;
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &id, &l, &r);
    T[id].l = l;
    T[id].r = r;
    if(l != -1) T[l].p = id;
    if(r != -1) T[r].p = id;
  }
  for(i = 0; i < n; i++){
    if(T[i].p == -1) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i = 0; i < n; i++) print(i);

  return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i,0,n) cin >> p[i];

    ll _max(LL_MAX);
    ll cnt(0);
    rep (i,0,n) 
    {
        if (_max > p[i])
            _max = p[i], cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	vint A(N);rep(i,N)cin>>A[i];

	int m=min_element(all(A))-A.begin();
	int M=max_element(all(A))-A.begin();

	vpint ans;
	if(A[M]<=0){
		rep(i,N){
			if(i==M)continue;
			ans.eb(A[M],A[i]);
			A[M]-=A[i];
		}
	}
	else if(A[m]>=0){
		int last=N-1;
		if(last==m)last--;
		rep(i,N){
			if(i==last){
				ans.eb(A[last],A[m]);
				A[last]-=A[m];
				continue;
			}
			if(i==m)continue;
			ans.eb(A[m],A[i]);
			A[m]-=A[i];
		}
	}
	else{
		rep(i,N){
			if(i==M||i==m)continue;
			if(A[i]>=0){
				ans.eb(A[m],A[i]);
				A[m]-=A[i];
			}
		}
		rep(i,N){
			if(i==M)continue;
			if(A[i]>=0)continue;
			ans.eb(A[M],A[i]);
			A[M]-=A[i];
		}
	}

	cout<<ans.back().fi-ans.back().se<<endl;
	rep(i,N-1)cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	return 0;
}

Measured memory_bytes: 4464
#include <stdio.h>
int main(void)
{
  int n;
  int s[100][5]={0};
  int w;
  int i,j;

  while(1)
    {

      scanf("%d",&n);
      if(n==0)
	break;
      int sum[100]={0};
      for(i=0;i<n;i++){
	scanf("%d %d %d %d %d",&s[i][0],&s[i][1],&s[i][2],&s[i][3],&s[i][4]);
	for(j=0;j<5;j++)
	  sum[i]+=s[i][j];
      }
      for(i=0;i<n-1;i++){
	for(j=n-1;j>i;j--){
	  if(sum[j-1]<sum[j]){
	    w=sum[j-1];
	    sum[j-1]=sum[j];
	    sum[j]=w;
	  }
	}
      }

      printf("%d %d\n",sum[0],sum[n-1]);
    }

  return 0;
}

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

using namespace std;

typedef struct b {
	int dis;
	int node1;
	int node2;
}b;

bool cmp(b n1, b n2) {
	return n1.dis < n2.dis;
}

int main() {
	int n;
	cin >> n; 
	int graph[101][101];
	b bs[10000];
	int bCount = 0;
	int ifs[101];
	for (int i = 0; i < n; ++i) {
		ifs[i] = 0;
		for (int j = 0; j < n; ++j) {
			cin >> graph[i][j];
			if (graph[i][j] == -1) {
				continue;
			}
			else if(i>j){
				bs[bCount].dis= graph[i][j];
				bs[bCount].node1 = i;
				bs[bCount++].node2 = j;
			}
		}
	}

	sort(bs, bs + bCount, cmp);

	long totalDis = 0;
	int k = 1;
	for (int i = 0; i < bCount; ++i) {
		b b1 = bs[i];
		if (ifs[b1.node1]>0 && ifs[b1.node2]==ifs[b1.node1]) {
			continue;
		}

		totalDis += b1.dis;
		if (ifs[b1.node1] == 0 && ifs[b1.node2] == 0) {
			ifs[b1.node1] = k;
			ifs[b1.node2] = k++;
		}
		else if (ifs[b1.node1] == 0) {
			ifs[b1.node1] = ifs[b1.node2];
		}
		else if (ifs[b1.node2] == 0) {
			ifs[b1.node2] = ifs[b1.node1];
		}
		else {
			for (int j = 0; j < n; ++j) {
				if (ifs[j] == ifs[b1.node2] && j != b1.node2) {
					ifs[j] = ifs[b1.node1];
				}
			}
			ifs[b1.node2] = ifs[b1.node1];
		}
	}

	cout << totalDis << endl;
	return 0;

}


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

#define n 100005 
void sieve();
vector<int> is_prime(n,true);
void find(int x) 
{ 
   //vector<int> is_prime(n,true);
   //sieve();
        is_prime.clear();
      
    is_prime[0] = is_prime[1] = false;
 
    for(int i=4;i<=n;i+=2) is_prime[i]=false;
    for (int i = 3; i * i <= n; i+=2) {
        if (is_prime[i]) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
   
    while (true) { 
        if (is_prime[x]) { 
             cout << x<<endl; 
            break; 
        } 
        else
            x++; 
    } 
} 
int main() 
{ 
   int x;
   cin>>x;

   find(x);

    return 0; 
} 

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

int main() {
  string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s; cin >> s;
  for(int i = 0; i < 7; ++i) {
    bool f = true;
    for(int j = 0; j < 3; ++j) {
      if(days[i][j] != s[j]) {
        f = false;
      }
    }
    if(f) {
      cout << 7 - i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {

	long long int n, m, v, p;
	cin >> n >> m >> v >> p;
	long long int a[100000];

	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long int counter = 0;
	int left = -1, right = n - 1, mid, dis = right - left;
	if (v <= p) {

		counter = p - 1;
		for (i = p; i <= n; i++) {
			if (a[n - i] + m >= a[n - p]) {
				counter++;
			}
		}

		cout << counter << endl;
		return 0;
	}
	else {


		while (dis > 1) {
			dis = right - left;
			mid = left + (int)((dis - (dis % 2)) / 2);
			counter = 0;
			if (a[mid] + m < a[n - p]) {
				left = mid;
			}
			else {
				for (i = 0; i < n; i++) {

					if (i <= mid) {
						counter = counter + m;
					}
					else if (i > n - p) {
						counter = counter + m;
					}
					else {
						counter = counter + a[mid] + m - a[i];
					}
				}
				if (counter < m * v) {
					left = mid;
				}
				else {
					right = mid;
				}
			}
		}
		cout << n - left - 1 << endl;
		return 0;
	}

	

}

Measured memory_bytes: 4408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

  int d, c;
  cin >> d >> c;
  cout << d*c << endl;


	return 0;
}

Measured memory_bytes: 1200
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()
C = input()

print(chr(ord(C)+1))

Measured memory_bytes: 21396
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, m, u, v, s, t;
    cin >> n >> m;
    map<int, vector<int>> edges;
    int state[n] = {};
    int visited[n][3] = {};
    for(int i=0;i<m;++i)
    {
        cin >> u >> v;
        --u;
        --v;
        edges[u].push_back(v);
    }
    cin >> s >> t;
    --s;
    --t;
    queue<pair<int,pair<int,int>>> q;
    q.push(MP(s, MP(0, 0)));
    visited[s][0] = 1;
    ll res = -1;
    while(!q.empty()) {
        auto front = q.front();
        int cur = front.first;
        int mod = front.second.first;
        int depth = front.second.second;
        q.pop();
        int next_mod = (mod + 1) % 3;
        for(auto nxt : edges[cur]) {
            if(visited[nxt][next_mod] != 0) continue;
            if(nxt == t && next_mod == 0) {
                assert((depth + 1) % 3 == 0);
                cout << (depth + 1) / 3 << endl;
                return 0;
            }
            q.push(MP(nxt, MP(next_mod, depth + 1)));
            visited[nxt][next_mod] = true;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;

    ll l[n], a[n], num[n]={};
    ll ans = 0, size = 0;

    for(ll i=0; i<n; i++){
        cin >> l[i];
    }

    sort(l, l+n);

    a[0] = l[0];
    num[0] = 1;

    for(ll i=1; i<n; i++){
        if(a[size] != l[i]){
            size++;
            a[size] = l[i];
            num[size]++;
        }
        else{
            num[size]++;
        }
        //cout << a[size] << " " << size << endl;
    }

    for(ll i=0; i<size-1; i++){
        for(ll j=i+1; j<size; j++){
            for(ll k=j+1; k<size+1; k++){
                if(a[i]+a[j] > a[k]){
                    ans += num[i]*num[j]*num[k];
                    
                }
                    
            }
        }
    }
    

    cout << ans << endl;

}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "Draw";
	else if (a == 1) cout << "Alice";
	else if (b == 1) cout << "Bob";
	else if (a > b) cout << "Alice";
	else cout << "Bob";
}

Measured memory_bytes: 256
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]
ans = 0

for i in range(2**h):
    for j in range(2**w):
        black = 0
        
        for a in range(h):
            if (i>>a)&1:
                for b in range(w):
                    if (j>>b)&1:
                        if c[a][b] == "#":
                            black += 1
                            
        if black == k:
            ans += 1
            
print(ans)

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

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


int main(){
string S;
cin>>S;
int a=S.size()-1;
if(S.at(a)=='s'){
    cout<<S<<"es"<<endl; 
}else{
cout<<S<<'s'<<endl;
}


    
}
  

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());

		int[] B = new int[M];
		for (int i = 0; i < M; i++) {
			B[i] = Integer.parseInt(sc.next());
		}
		int[][] A = new int[N][M];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				A[i][j] = Integer.parseInt(sc.next());
			}
		}

		long ans = solve(N, M, C, B, A);
		System.out.println(ans);
	}

	private static long solve(int n, int m, int c, int[] b, int[][] a) {
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int tmp = c;
			for (int j = 0; j < m; j++) {
				tmp += a[i][j] * b[j];
			}

			// System.err.printf("A%s SUM%s\n", i,tmp);
			if (tmp > 0) {
				ans++;
			}
		}
		return ans;
	}
}


Measured memory_bytes: 23124
#include<iostream>

using namespace std;

int main() {
	int A, B;

	//入力
	cin >> A >> B;

	//13より1が強いため、1を14として考える
	if (A == 1) {
		A = 14;
	}
	if (B == 1) {
		B = 14;
	}

	//勝敗判定
	if (A > B) {
		cout << "Alice" << endl;
	}
	else if (A < B) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
	

}

Measured memory_bytes: 256
n=int(input())
s=input()
left=0
right=len(s)-1
ans=0
while left<right:
    if s[left]!="W":
        left+=1
    if s[right]!="R":
        right-=1
    if s[left]=="W" and s[right]=="R":
        ans+=1
        left+=1
        right-=1
print(ans)

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S.find("RRR") != string::npos)
    {
        cout << 3 << endl;
    }
    else if (S.find("RR") != string::npos)
    {
        cout << 2 << endl;
    }
    else if (S.find("R") != string::npos)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3584
import java.util.HashMap;
import java.util.Scanner;

// 16
class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
        for(int i = 1; i <= N; i++)
            hm.put(sc.nextInt(), i);

            for(int i = 1; i <= N; i++)
                System.out.print(hm.get(i) + " ");
    }

}


Measured memory_bytes: 68468
#include <stdio.h>

char* LCS(int n1, int n2, char s1[], char s2[])
{
	int i, j, dp[3001][3001] = {}, prev[3001][3001][2] = {};
	for (i = 1; i <= n1; i++) {
		for (j = 1; j <= n2; j++) {
			if (dp[i-1][j] > dp[i][j]) {
				dp[i][j] = dp[i-1][j];
				prev[i][j][0] = i - 1;
				prev[i][j][1] = j;
			}
			if (dp[i][j-1] > dp[i][j]) {
				dp[i][j] = dp[i][j-1];
				prev[i][j][0] = i;
				prev[i][j][1] = j - 1;
			}
			if (s1[i-1] == s2[j-1] && dp[i-1][j-1] >= dp[i][j]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				prev[i][j][0] = i - 1;
				prev[i][j][1] = j - 1;
			}
		}
	}
	
	int k;
	static char ans[3001];
	for (i = n1, j = n2, k = dp[n1][n2] - 1; k >= 0; ) {
		if (prev[i][j][0] == i - 1 && prev[i][j][1] == j - 1) {
			ans[k--] = s1[i-1];
			i--;
			j--;
		} else if (prev[i][j][0] == i - 1) i--;
		else j--;
	}
	ans[dp[n1][n2]] = 0;
	return ans;
}

int main()
{
	int a, b;
	char s[3001], t[3001];
	scanf("%s", s);
	scanf("%s", t);
	for (a = 0; s[a] != 0; a++);
	for (b = 0; t[b] != 0; b++);
	printf("%s\n", LCS(a, b, s, t));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 107188