akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9
 
int main(){
    ll n, ans = 0;
    cin >> n;
    n++;
 
    for(ll i = 1; i < n; i++){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
 
    return 0;
}

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

int main(){
  int n;
  int t[100010];
  int x[100010];
  int y[100010];

  cin >> n;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 0; i < n; ++i){
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }

  for(int i = 0; i < n; ++i){
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    int dt = t[i + 1] - t[i];
    if(dist > dt){
      cout << "No" << endl;
      return 0;
    }
    else{
      if(dist % 2 == dt % 2)continue;
      else{
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  ll N, M;
  cin >> N >> M;
  ll ans;
  if (N == 1 || M == 1) ans = max(N, M)-2;
  else ans = (N-2)*(M-2);
  if (ans == -1) ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <string>
using namespace std;
int n,a,b,x,y,i;
char s[100100];
int main() {
  scanf("%d%d%d",&n,&a,&b);
  scanf("%s",s);
  for (i=0; i<n; i++) if (s[i]=='a') {
    if (x+y<a+b) {
      puts("Yes");
      x++;
    } else puts("No");
  } else if (s[i]=='b') {
    if (x+y<a+b && y<b) {
      puts("Yes");
      y++;
    } else puts("No");
  } else puts("No");
  return 0;
}


Measured memory_bytes: 640
N, X = map(int, input().split())

a, p = [1 for i in range(N+1)], [1 for i in range(N+1)]
for i in range(1,N+1):
  a[i] = a[i-1] * 2 + 3
  p[i] = p[i-1] * 2 + 1

"""
B a[i-1] P a[i-1] B

"""
def solve(level, under):
  #print(level,under)
  if level == 0:
    return 1 if under > 0 else 0
  elif under == 0:
    return 0
  elif under <= a[level-1] + 1:
    return solve(level-1, under-1)
  elif under == a[level-1] + 2:
    return p[level-1] + 1
  elif under == a[level]:
    return p[level]
  else:
    return p[level-1]+1 + solve(level-1, under - (a[level-1]+2))
  
print(solve(N,X))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
a,b = map(int,input().split())

"""
if b < 10:
    number = 10 * a + b
if 10 <= b < 100:
    number = 100 * a + b
if b == 100:
    number = 1000 * a + b
"""

number = 10 ** len(str(b)) * a + b

ans = "No"
"""
for i in range(4, 101):
    if i ** 2 == number:
        ans = "Yes"
"""

if number ** 0.5 == int(number ** 0.5):
    ans = "Yes"

print(ans)


Measured memory_bytes: 3188
#include <cstdio>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

int main()
{
	long n, a, b;
	scanf("%ld", &n);
	scanf("%ld", &a);
	scanf("%ld", &b);
	vector<long> v;
	vector<long> w;
	v.resize(n);
	w.resize(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%ld", &v[i]);
	}
	sort(v.begin(), v.end(), greater<long>());

	long l = 0;
	long r = v[0];
	long m,count;
	bool flag = false;
	while (abs(l-r) > 1)
	{
		flag = false;
		m = (l + r) / 2;
		count = m;
		copy(v.begin(), v.end(), w.begin());
		for (int i = 0; i < n; i++)
		{
			w[i] -= b*m;
			if (w[i] <= 0)
			{
				flag = true;
				break;
			}
			count -= ceil((double)(w[i])/(a-b));
			if (count < 0) break;
			if (i == n - 1)
			{
				flag = true;
			}
		}
		if (flag)
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	printf("%ld\n", r);
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
namespace mp = boost::multiprecision;

ll valueMap[3000][3000];
ll dp[3000][3000][4];

struct item {
	int i;
	int j;
	ll v;
};

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

	int r, c, k;
	cin >> r >> c >> k;
	item* items = new item[k];
	rep(i, k) cin >> items[i].i >> items[i].j >> items[i].v;
	rep(i, k) valueMap[items[i].i - 1][items[i].j - 1] = items[i].v;
	delete[] items;

	rep(i, r) {
		rep(j, c) {
			if (i == 0 && j == 0)	dp[i][j][0] = 0;
			else if (i == 0)		dp[i][j][0] = dp[i][j - 1][0];
			else if (j == 0)		dp[i][j][0] = dp[i - 1][j][3];
			else					dp[i][j][0] = max(dp[i][j - 1][0], dp[i - 1][j][3]);

			REP(l, 1, 4) {
				dp[i][j][l] = dp[i][j][l - 1];

				if (i != 0) dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j][3] + valueMap[i][j]);
				if (j != 0) dp[i][j][l] = max(dp[i][j][l], max(dp[i][j - 1][l], dp[i][j - 1][l - 1] + valueMap[i][j]));

				if (i == 0 && j == 0) dp[i][j][l] = valueMap[0][0];
			}
		}
	}

	cout << dp[r - 1][c - 1][3] << "\n";

	return 0;
}


Measured memory_bytes: 355148
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

A,B,C = I()
m1 = A*B
m2 = B*C
m3 = A*C
t1 = abs(m1*(C//2)-m1*(C-C//2))
t2 = abs(m2*(A//2)-m2*(A-A//2))
t3 = abs(m3*(B//2)-m3*(B-B//2))
print(min(t1,t2,t3))


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

int main() {

    int N;
    string S;
    cin >> N >> S;
    if(N%2==1){
        cout << "No";
        return 0;
    }
    for(int i=0;i<N/2;i++){
        if(S.at(i) != S.at(i+N/2)){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[110];
int b[110];
long long pow10[17];
char to[110];
char rg[210]="1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162";
int main(){
	pow10[0]=1;
	for(int i=1;i<17;i++)pow10[i]=pow10[i-1]*10;
	while(1){
		scanf("%s",str);
		if(str[0]=='#')break;
		long long ret=9999999999999999LL;
		int n=strlen(str);
		bool OK=true;
		for(int i=0;i<n;i++)if(rg[i]!=str[i])OK=false;
		if(OK){
			printf("1\n");continue;
		}
		bool oz=true;
		for(int i=0;i<n;i++)if(str[i]!='0')oz=false;
		if(oz){
			long long at=2;
			for(int i=1;i<=n;i++)at+=(pow10[i]-pow10[i-1])*i;
			printf("%lld\n",at);continue;
		}
		for(int i=1;i<=n;i++){
			for(int j=0;j<i;j++){
				if(str[j]=='0')continue;
				long long fi=0;
				for(int k=0;k<i-j;k++){
					fi*=10;
					fi+=str[j+k]-'0';
				}
				long long la=0;
				for(int k=0;k<j;k++){
					la*=10;
					la+=str[k]-'0';
				}
				long long s=la+1;
				long long t=fi;
			//	printf("%lld %lld\n",s,t);
				while(s%10==0)s/=10;
				while(t%10==0)t/=10;
				long long f=fi*pow10[j]+la;
				if(s==1&&(j==0||la)){
					if(t==1){
						f=pow10[i]-1;
					}else{
						f=(fi-1)*pow10[j]+la;
					}
				}
				f++;
				long long F=f;
				bool ok=true;
				int at=j;
				while(at<n){
					sprintf(to,"%lld",f);
					int len=strlen(to);
					for(int k=0;k<len;k++){
						if(at>=n)break;
						if(to[k]!=str[at])ok=false;
						at++;
					}
					f++;
				}
				if(ok){
					long long at=-j;
					for(int k=1;k<i;k++){
						at+=(pow10[k]-pow10[k-1])*k;
					}
					at+=(F-pow10[i-1])*i;
					if(at<0)continue;
					ret=min(ret,at+1);
				}
			}
		}
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 984
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	ll  a;long double b; cin >> a >> b;
	ll ans = a * b;
	cout<< ans<< endl;
}


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

using namespace std;
vector<vector<long long> >grd;
vector<vector<vector<long long> > >dp;
long long ans=0ll;

int n,m,k;
long long slv(int x=0,int y=0,int tk=0){
    if(x==n-1&&y==m-1){
        return ((tk<3)?grd[x][y]:0ll);
    }
    long long &ret=dp[x][y][tk];
    if(ret!=-1ll)
        return ret;
    if(y<m-1){
        if(tk<3)
            ret=max(ret,slv(x,y+1,tk+1)+grd[x][y]);
        ret=max(ret,slv(x,y+1,tk));
    }
    if(x<n-1){
        ret=max(ret,slv(x+1,y,0)+((tk<3)?grd[x][y]:0ll));
    }
    return ret;
}

int main()
{///{}
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    cin>>n>>m>>k;
    grd=vector<vector<long long> >(n,vector<long long >(m));
    dp=vector<vector<vector<long long> > >(n,vector<vector<long long> >(m,vector<long long>(5,-1ll)));
    for(int i=0;i<k;i++){
        long long x,y,v;
        cin>>x>>y>>v;
        x--;  y--;
        grd[x][y]=v;
    }
    cout<<slv()<<'\n';
    return 0;
}


Measured memory_bytes: 707276
#include <stdio.h>
#define N 100000

int main(void){
  int a, b,i=0, j=0;
  int p[N], q[N];
  int k, l;

  while(scanf("%d %d", &a, &b), a!=0 && b!=0){
    p[i] = a;
    q[i] = b;
    i++;
  }

  while(j<i){
    for(k=1; k<=p[j];k++){
      if(k==1 || k==p[j]){
        for(l=1; l<=q[j]; l++) //各フレームの最初と最後の行の処理
          printf("#");
      }
      else{ //各フレームの上の行以外の行の処理
        printf("#");
        for(l=1; l<=(q[j]-2); l++)
          printf(".");
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    j++;
  }

    return 0;
}



Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
   string s,m;
   cin>>s;
   m=s;
   int a,e=0;
   long long qq,q;
   cin>>a;
   for(int i=1;i<s.length();i+=1){
        if(s[i]==s[i-1]){
                e+=1;
                if(i!=s.length()-1){
            if('a'!=s[i-1] && 'a'!=s[i+1]){s[i]='a';}
             else if('b'!=s[i-1] && 'b'!=s[i+1]){s[i]='b';}
             else{s[i]='c';}
        }
        else{
                if('a'!=s[i-1] && 'a'!=s[0]){s[i]='a';}
             else if('b'!=s[i-1] && 'b'!=s[0]){s[i]='b';}
             else{s[i]='c';}


        }

        }

   }
   bool aa=false;

        q=e;
        e=0;
        m+=m;
        for(int z=1;z<m.length();z+=1){


        if(m[z]==m[z-1]){
                e+=1;
                if(z!=m.length()-1){
            if('a'!=m[z-1] && 'a'!=m[z+1]){m[z]='a';}
             else if('b'!=m[z-1] && 'b'!=m[z+1]){m[z]='b';}
             else{m[z]='c';}
        }
        else{
                if('a'!=m[z-1] && 'a'!=m[0]){m[z]='a';}
             else if('b'!=m[z-1] && 'b'!=m[0]){m[z]='b';}
             else{m[z]='c';}


        }


        }

        }
           if(m[m.length()-1]==s[s.length()-1]){
     aa=true;
   }
        qq=e;
if(aa){
            long long f=(a-1)*(qq-q)+q;
            cout<<f;
}
else{

            if(a%2==0){
                long long f=(a/2)*qq;
            cout<<f;
        }
        else{
            long long f=((a/2)*qq)+q;
            cout<<f;
        }
}

        }









Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  if (n % 10 == 3)
  {
    printf("bon");
  }
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
  {
    printf("pon");
  }
  else
  {
    printf("hon");
  }
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200000




using namespace std;

int n,k,a[N+5];

int main()
{
    int i,j,x,y=0;

    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
        y=y>x?y:x;
    }
    sort(a,a+y+1);

    x=y-k+1;
    x=x>=0?x:0;

    for(i=x;i<=y;i++) n-=a[i];

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

    return 0;
}


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

const long long MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];

    vector<vector<long long> > dp(n + 1, vector<long long>(m + 1, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + MOD) % MOD;
            if (s[i] == t[j]) (dp[i + 1][j + 1] += dp[i][j] + 1) % MOD;
        }
    }

    cout << (dp[n][m] + 1) % MOD << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> L(N + 5);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; ++i) {
    L[i] = L[i - 1] + L[i - 2];
  }
  printf("%lld\n", L[N]);
  return 0;
}


Measured memory_bytes: 384
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

int n, m, len, sx, sy;
char S[MAX_N], T[MAX_N];

int main()
{
    scanf("%d%d%d%d%d%s%s", &n, &m, &len, &sx, &sy, S + 1, T + 1);
    // upper;
    bool ans = false;
    int x = sx, y = sy;
    for (int i = 1; i <= len; i++)
    {
        if (S[i] == 'U')
            x--;
        if (x < 1)
            ans = true;
        if (T[i] == 'D' && x < n)
            x++;
        if (x < 1)
            ans = true;
    }
    x = sx, y = sy;
    for (int i = 1; i <= len; i++)
    {
        if (S[i] == 'D')
            x++;
        if (x > n)
            ans = true;
        if (T[i] == 'U' && x > 1)
            x--;
        if (x > n)
            ans = true;
    }
    x = sx, y = sy;
    for (int i = 1; i <= len; i++)
    {
        if (S[i] == 'L')
            y--;
        if (y < 1)
            ans = true;
        if (T[i] == 'R' && y < m)
            y++;
        if (y < 1)
            ans = true;
    }
    x = sx, y = sy;
    for (int i = 1; i <= len; i++)
    {
        if (S[i] == 'R')
            y++;
        if (y > m)
            ans = true;
        if (T[i] == 'L' && y > 1)
            y--;
        if (y > m)
            ans = true;
    }
    puts(ans ? "NO" : "YES");
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

const int INF = 1001001001;

int main() {

  ll N,M,X,ans=INF;
  cin >> N >> M >> X;
  vector<vector<ll>> A(N,vector<ll>(M));
  vector<ll> C(N);
  bool ok = true;

  for(ll i=0;i<N;i++){
    cin >> C[i];
    for(ll j=0;j<M;j++){
      cin >> A[i][j];
    }
  }

  for(ll s=0;s<(1<<N);s++){
    ll cost=0;
    vector<ll> d(M);
    for(ll i=0;i<N;i++){
      if((s>>i) & 1){
        cost += C[i];

        for(ll j=0;j<M;j++){
          d[j] += A[i][j];
        }
      }
    }

    ok = true;
    for(ll j=0;j<M;j++){
      if(d[j] < X){
        ok = false;
        break;
      }
    }
    if(ok){
      ans=min(ans,cost);
    }

  }

  if(ans == INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }

}


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

using namespace std;

int main(){
    long long int n,k;
    long long int help;
    cin>>n>>k;
    int arr[n+1]={0},visited[n+1];
    for(int i=0;i<=n;i++){
        visited[i]=-1;
    }
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    int a=1;
    int b=0;
    visited[1]=0;
    long long int i;
    for( i=1;i<=k;i++){
        b=arr[a];
        a=b;
        if(visited[a]==-1){
            visited[a]=i;
        }else{
            help=i-visited[a];
            break;
        }
    }
    if(i==k+1){
        cout<<a;
    }else{
    long long int b=k-visited[a];
    long long int c=b%help;
    for(int j=0;j<c;j++){
        b=arr[a];
        a=b;
    }
    cout<<a;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto&& ai : a) cin >> ai;
	int mincost = INT_MAX;
	for (int i = -100; i <= 100; i++)
	{
		int cost = 0;
		for (int j = 0; j < n; j++)
		{
			cost += (i-a[j])*(i-a[j]);
		}
		mincost = min(mincost, cost);
	}
	cout << mincost << endl;
	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define eps 1e-8
#define MAXN 100000
#define INF 0x3f3f3f3f
#define Mod int(1e9+7)
int main(){
	int x=read();
	if(x==1)
		puts("Hello World");
	else printf("%d\n",read()+read());
	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++)

int main() {
    string s;
    cin>>s;
    int ans=0;
    if(s[0]==s[1] && s[1]==s[2] && s[0]=='R') ans=3;
    else if(s[0]==s[1] && s[0]=='R') ans=2;
    else if(s[1]==s[2] && s[1]=='R') ans=2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') ans=1;
    cout<<ans<<endl;
}

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

namespace ABC120B
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = temp[0];
            var B = temp[1];
            var K = temp[2];
            var answer = new List<int>();

            for (int i = Math.Max(A, B); i > 0; i--)
            {
                if (A % i == 0 && B % i == 0)
                {
                    answer.Add(i);

                    if (answer.Count == K)
                    {
                        Console.WriteLine(i);
                        break;
                    }
                }
            }
        }
    }
}


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

int main(){
    string N;
    cin >> N;
    rep(i, 3){
        if(N[i]=='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		List<Integer> list_kati=new ArrayList<Integer>();
		List<Integer> list_cost=new ArrayList<Integer>();
		int count=0;
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list_kati.add(a);
		}

		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list_cost.add(a);
		}

		for(int i=0;n>i;i++) {
			if(list_kati.get(i)>list_cost.get(i))
				count=count+list_kati.get(i)-list_cost.get(i);
		}

		System.out.println(count);

	}
}



Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++) { 
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		d[i] = v[i] - c[i];
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (d[i] > 0) {
			sum += d[i];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

int calc(v_Pii v){
    int n = SZ(v);
    int ans = 0;

    set<int> s;
    REP(i, n) s.insert(i);
    s.insert(-1);

    REP(i, n){
        int d = v[i].fi, k = v[i].se;
        auto it = s.upper_bound(k);
        it--;
        if(*it != -1){
            s.erase(it);
            ans += d;
        }
    }
    return ans;
}

signed main(){

    int T; cin >> T;
    REP(_, T){
        int N; cin >> N;
        vec K(N), L(N), R(N);
        int ans = 0;
        v_Pii vp, vm;
        REP(i, N){
            cin >> K[i] >> L[i] >> R[i];
            K[i]--;
            if(K[i] == N - 1){
                ans += L[i];
            }else if(L[i] >= R[i]){
                ans += R[i];
                vp.pb(Pii(L[i] - R[i], K[i]));
            }else{
                ans += L[i];
                vm.pb(Pii(R[i] - L[i], N - 2 - K[i]));
            }
        }

        Sort(vp); Reverse(vp);
        Sort(vm); Reverse(vm);
        ans += calc(vp) + calc(vm);
        Out(ans);
    }

    return 0;
}


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

int main(){
  int n;string s;cin>>n>>s;
  string x[4]={"SS","SW","WS","WW"};
  bool f=0;
  REP(i,4){
    string a=x[i];
    for(int k=2;k<n+1;k++){
      if((s[k-1]=='o'&&a[k-1]=='S')||(s[k-1]!='o'&&a[k-1]!='S')) a+=a[k-2];
      else a+=(a[k-2]=='S'?'W':'S');
    }
    if(a[0]==a[n]){
      if((a[0]=='S'&&s[0]=='o')||(a[0]=='W'&&s[0]=='x')){
        if(a[n-1]==a[1]) f=1;
      }else if(a[n-1]!=a[1]) f=1;
    }
    if(f){
      a.pop_back();
      cout<<a;
      return 0;
    }
  }
  cout<<("-1");
}

Measured memory_bytes: 776
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]



    N = int(input())
    S = input()
    lenstr = len(S)
    if lenstr % 2 == 1:
        print('No')
        return
    else:
        if S[:lenstr//2] == S[lenstr//2:]:
            print('Yes')
        else:
            print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
/*
 *  Author: mizo0203
 *  Problem: 2008
 *  Status:
 *  Submission Date:
 */
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int n;
int hx, hy, dx, dy;
int cx[20], cy[20];
double cdis[20];

// 初期化
void init() {
}

// 入力
bool input() {
  int i;

  scanf("%d %d %d %d %d", &n, &hx, &hy, &dx, &dy);
  if (!n && !hx && !hy && !dx && !dy)
    return false;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &cx[i], &cy[i]);
    cdis[i] = hypot(dx - cx[i], dy - cy[i]);
  }
  return true;
}

// 再帰関数
bool recursive(long bit, double sum, int x, int y) {
  int i;
  double minD, maxH;

  for (i = 0; i < n; i++)
    if (~bit & 1 << i)
      break;
  if (i == n)
    return true;
  minD = 2000000.0; // INF
  maxH = -2000000.0; // -INF
  for (i = 0; i < n; i++) {
    if (bit & 1 << i)
      continue;
    if (minD > cdis[i]) {
      minD = cdis[i];
      maxH = hypot(x - cx[i], y - cy[i]) + sum;
    }
  }
  //printf("%f >= %fn", maxH, minD);
  if (maxH >= minD)
    return false;

  for (i = 0; i < n; i++) {
    if (bit & 1 << i)
      continue;
    if (recursive(bit | 1 << i, sum + hypot(x - cx[i], y - cy[i]), cx[i], cy[i]))
      return true;
  }
  //printf("sum:%fn", sum);
  return false;
}

int main() {

  init(); // 初期化
  while (input()) { // 入力
    if (recursive(0, 0.0, hx, hy)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 740
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n*500>=m)puts("Yes");
	else puts("No");
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n;
   cin >> n;
vector<ll> ans(86);
   ans[0] = 2;
   ans[1] = 1;
   for(int i=2;i<=n;i++){
      ans[i] = ans[i-1] + ans[i-2];
   }
   cout << ans[n] << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,c;
vector<pair<int,int> > ap;
int main() {
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
    int t;
    for(int i=0;i<a;i++) {
        scanf("%d",&t);
        ap.push_back({t,-1});
    }
    for(int j=0;j<b;j++) {
        scanf("%d",&t);
        ap.push_back({t,1});
    }
    for(int i=0;i<c;i++) {
        scanf("%d",&t);
        ap.push_back({t,0});
    }
    sort(ap.begin(),ap.end());
    reverse(ap.begin(),ap.end());
    int tot=x+y;
    int ta=x;
    int tb=y;
    long long ans=0;
    for(int i=0;i<ap.size();i++) {
        if(tot==0) break;
        if(ap[i].second==-1) {
            if(ta!=0) {
                ans+=ap[i].first;
                ta--;
                tot--;
            }
        }
        else {
            if(ap[i].second==1) {
                if(tb!=0) {
                    ans+=ap[i].first;
                    tb--;
                    tot--;
                }
            }
            else {
                ans+=ap[i].first;
                tot--;
            }
        }
    }
    printf("%lld",ans);
    return 0;
}


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

void sortDecrease(vector<int> &array);

int main() {
  int A,B,C;
  cin >> A >> B >> C;

  int n = B / A;
  cout << min(n, C) << endl;
	

  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  for (int i = 0; i < max(a, b); ++i) {
    cout << min(a, b);
  }
  cout << endl;

  return 0;
}

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

#define ls val[k << 1]
#define rs val[k << 1 | 1]
#define mid ((s + t) >> 1)
#define lson k << 1, s, mid
#define rson k << 1 | 1, mid + 1, t
typedef long long ll;
typedef pair <ll, int> node;
typedef pair <int, int> pii;
typedef pair <ll, pii> edge;
const int maxn = 2e5 + 10;
int n, par[maxn]; ll k, a[maxn];
node dat[maxn]; vector <edge> e;
struct sgt {
  node val[maxn << 2];
  void build(int k, int s, int t) {
    if (s == t) {
      val[k] = node(1ll << 60, s); return;
    }
    build(lson), build(rson), val[k] = min(ls, rs);
  }
  void upd(int k, int s, int t, node x) {
    if (s == t) {
      val[k] = x; return;
    }
    if (x.second <= mid) {
      upd(lson, x);
    } else {
      upd(rson, x);
    }
    val[k] = min(ls, rs);
  }
  node query(int k, int s, int t, int l, int r) {
    if (l <= s && t <= r) {
      return val[k];
    }
    node res = node(1ll << 60, 0);
    if (l <= mid) res = query(lson, l, r);
    if (r > mid) res = min(res, query(rson, l, r));
    return res;
  }
} t1, t2;

int find(int x) {
  return par[x] == x ? x : par[x] = find(par[x]);
}

void unite(int x, int y) {
  par[find(x)] = find(y);
}

int main() {
  scanf("%d %lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i), dat[i] = node(a[i], i), par[i] = i;
  }
  sort(dat + 1, dat + n + 1);
  t1.build(1, 1, n), t2.build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int x = dat[i].second; node p;
    p = x < n ? t1.query(1, 1, n, x + 1, n) : node(1ll << 60, 0);
    if (p.first < 1ll << 60) {
      e.push_back(edge(p.first + a[x] - k * x, pii(x, p.second)));
    }
    t1.upd(1, 1, n, node(a[x] + k * x, x));
    p = x > 1 ? t2.query(1, 1, n, 1, x - 1) : node(1ll << 60, 0);
    if (p.first < 1ll << 60) {
      e.push_back(edge(p.first + a[x] - k * (n - x), pii(x, p.second)));
    }
    t2.upd(1, 1, n, node(a[x] + k * (n - x), x));
  }
  sort(e.begin(), e.end());
  ll ans = 0;
  for (edge p : e) {
    int u = p.second.first, v = p.second.second;
    if (find(u) != find(v)) {
      unite(u, v), ans += p.first;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 36844
n = int(input())
w = [input() for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        if w[i] == w[j]:
            print("No")
            exit()

for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 39024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a][b] = G[b][a] = true;
    }

    // 順列
    vector<int> ord(N);
    for (int i = 0; i < N; ++i) ord[i] = i;

    // 順列を全部試す
    int res = 0;
    do {
        if (ord[0] != 0) break;

        bool ok = true;
        for (int i = 0; i + 1 < N; ++i) {
            int from = ord[i];
            int to = ord[i+1];
            if (!G[from][to]) ok = false;
        }
        if (ok) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}


Measured memory_bytes: 256
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let lst = Array.fold_left (fun xs a -> a :: xs) [] as_ in
  match lst with
    [] -> print_newline()
   |first :: rest ->
    begin
      print_int first;
      List.iter (Printf.printf " %d") rest
    end ;
    print_newline() ;;


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

long long ans;
int n; 
string s;
int num[500005];

int main()
{
	cin >> s;
	n=s.length()+1;
	for(int i=0;i<s.length();i++) if(s[i]=='<') num[i+2]=max(num[i+1]+1,num[i+2]);
	for(int i=s.length()-1;i>=0;i--) if(s[i]=='>') num[i+1]=max(num[i+2]+1,num[i+1]);
	for(int i=1;i<=n;i++) ans+=num[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;

int main(){
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll c4=b*d;
    ll c1=a*c;
    ll c2=a*d;
    ll c3=b*c;
    cout<<max({c4,c1,c2,c3});

    


}
    


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;

	void doIt() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.max(c - (a - b), 0));
	}

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


Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl


int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int cntR = 0;
	rep(i, N) {
		if (S[i] == '(') {
			cntR++;
		}
		else if (S[i] == ')') {
			if (cntR > 0) {
				cntR--;
			}
		}
	}
	reverse(S);
	string SS = S;
	rep(i, N) {
		if (SS[i] == ')') {
			SS[i] = '(';
		}
		else {
			SS[i] = ')';
		}
	}
	//cout << S << endl;
	int cntL = 0;
	rep(i, N) {
		if (SS[i] == '(') {
			cntL++;
		}
		else if (SS[i] == ')') {
			if (cntL > 0) {
				cntL--;
			}
		}
	}
	reverse(S);
	rep(i, cntL) {
		cout << '(';
	}
	cout << S;
	rep(i, cntR) {
		cout << ')';
	}
	cout << endl;
	//cout << cntL << ' ' << cntR << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;

int main() {

	
	long long x;
	cin >> x;

	long p = ceil(pow(x, 0.2))*5;
	for (long i = p; i > -p;i--) {
		for (long q = p; q > -p; q--)
		{
			if (pow(i,5)-pow(q,5)==x)
			{
				cout << i << " " << q << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
//bool sa[100010][100010]={};



struct Edge{
    int to;
    bool same;
    Edge(int t,bool same):to(t),same(same){}
};

using Graph =vector<vector<Edge>>;
vector<int>g;


void dfs(const Graph &G,int now,int before,int color){

    if(g[now]!=-1)return;
    g[now]=color;
    for(auto next:G[now]){
        if(next.to==now)continue;

        int nc=color;
        if(!next.same){
        nc=color^1;
        }
        dfs(G,next.to,now,nc);
    }
    return;
}
int main(){
    int n;
    cin>>n;

    
    Graph G(n+1);
    rep(i,n-1){
        int x,y;
        long long w;
        cin>>x>>y>>w;
        x--,y--;
        bool same=false;
        if(w%2==0)same=true;
        
        G[x].emplace_back(Edge(y,same));
        G[y].emplace_back(Edge(x,same));
    }
    g.assign(n+1,-1);

    dfs(G,0,-1,1);

    rep(i,n){
        cout<<g[i]<<endl;
    }
    

    return 0;

}
/*
5
2 5 3
2 3 3
3 1 3
3 4 3


*/


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

ll term(int& i, const string& s) {
    ll ret = s[i] - '0';
    ++i;
    while (i < s.size() and s[i] == '*') {
        ++i;
        ret *= s[i] - '0';
        ++i;
    }
    return ret;
}

ll exp(int& i, const string& s) {
    ll ret = term(i, s);
    while (i < s.size() and s[i] == '+') {
        ++i;
        ret += term(i, s);
    }
    return ret;
}

int expleft(int& i, const string& s) {
    ll ret = s[i] - '0';
    ++i;
    while (i < s.size()) {
        if (s[i] == '+') {
            ++i;
            ret += s[i] - '0';
        }
        else if (s[i] == '*') {
            ++i;
            ret *= s[i] - '0';
        }
        ++i;
    }
    return ret;
}

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

    string s; cin >> s;

    int i = 0;
    ll mul = exp(i, s);
    i = 0;
    ll left = expleft(i, s);

    ll bob; cin >> bob;

    char ans;
    if (mul == bob and left == bob) ans = 'U';
    if (mul == bob and left != bob) ans = 'M';
    if (mul != bob and left == bob) ans = 'L';
    if (mul != bob and left != bob) ans = 'I';
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3240
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right,insort_left,insort_right
from heapq import heapify,heappop,heappush
from fractions import gcd
from copy import deepcopy
from itertools import accumulate,groupby,permutations,combinations
from math import ceil,sqrt,cos,sin,pi

def main():
    S = input()
 
    if S == "A"*3 or S == "B"*3:
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

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

int dfs(long long v, int cnt, long long n)
{
    if (v > n)
        return cnt;

    int t = 0,f = 0,s=0;
    for (long long i = v; i > 0; i/=10) {
        switch (i%10) {
        case 3: t++; break;
        case 5: f++; break;
        case 7: s++; break;
        default: break;
        }
        if (t && f && s) {
            cnt++;
            break;
        }
    }

    cnt = dfs(v*10+3, cnt, n);
    cnt = dfs(v*10+5, cnt, n);
    cnt = dfs(v*10+7, cnt, n);

    return cnt;
}

int main()
{
    long long  n;
    std::cin >> n;
    int cnt = dfs(0, 0, n);
    std::cout << cnt << std::endl;
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M){
    cout << (N * (N - 1) / 2 + (M * (M - 1) / 2)) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


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

typedef struct{
	char name[6];
	long num;
	char f;
}product;

int main(void){
	long n=0, i, j, t, count=0;
	char str[6];
	product p[300000];
	
	scanf("%ld", &n);
	for(i=0; i<n; i++){
		int flag=0;
	
		scanf(" %s %ld", str, &t);
		
		for(j=0; j<count; j++){
			if(strcmp(p[j].name, str)==0){
				p[j].num+=t;
				flag=1;
				break;
			}
		}
		
		if(flag==0){
			strcpy(p[count].name, str);
			p[count].num = t;
			count++;
		}	
		
		//printf("count:%ld\n",count);
	}
	
	
	//ここまではおｋ，あとはソート
	for(i=0; i<count; i++){
		for(j=0; j<count; j++){
			if(strcmp(p[i].name, p[j].name) < 0){
				product tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}	
	
	long r=0;

	while(r<6){
		//printf("now: %ld\n", r);
		for(i=0; i<count; i++){
			if(p[i].name[r]=='\0' && p[i].f != 'N'){
				printf("%s %ld\n", p[i].name, p[i].num);
				p[i].f='N';
			}
		}
		r++;
	}

	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<ll> divisor(ll n){
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    sort(begin(ret),end(ret));
    return(ret);
}

main() {
    int N,M; cin >> N >> M;
    vector<ll> v=divisor((ll)M);
    cout << M/(*lower_bound(v.begin(),v.end(),N)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int ans = 753;
    for(int i = 0; i < s-2; i++){
      int n = Integer.parseInt(S.substring(i, i+3));
      int m = Math.abs(753-n);
      ans = m < ans ? m : ans;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

ll name[5];

int pat[10][3] = {{0,1,2}, {0,1,3}, {0,2,3}, {1,2,3}, {0,1,4}, {0,2,4}, {1,2,4}, {0,3,4}, {1,3,4}, {2,3,4}};


int main(){
    int n;
    cin >> n;
    rep(i, n){
        string s;
        cin >> s;
        if (s[0] == 'M') name[0]++;
        else if (s[0] == 'A') name[1]++;
        else if (s[0] == 'R') name[2]++;
        else if (s[0] == 'C') name[3]++;
        else if (s[0] == 'H') name[4]++;
    }
    ll ans = 0;

    rep(i, 10){
        int p = pat[i][0];
        int q = pat[i][1];
        int r = pat[i][2];
        ans += name[p] * name[q] * name[r];
    }

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

Measured memory_bytes: 256
#include<iostream>

int main(){
    int ss = 0, h = 0, m = 0, s = 0;
    std::cin >> ss;
    h = ss / 3600;
    m = (ss - h * 3600) / 60;
    s = (ss - h * 3600 - m * 60);
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}


Measured memory_bytes: 3096
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

#define debug(x) cout << __LINE__ << " " << #x <<"..." << x << endl
#define dev(x) cout << __LINE__ << " " << #x << "..." ; for(auto &it : x) cout<< it << " "; cout << endl;

const double PI = 3.141592653589793;

void solve()
{
	int n,a,b;
	cin >> n >> a >> b;
	if(a==0)
	{
		cout << "0\n";
		return ;
	}
	int x = n /(a+b);
	int ans = 0;
	ans += x * a;
	ans += min(a,n%(a+b));
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 3628