akhauriyash/Code-Regression huggingface dataset:
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const w = args[0][0]
	const cnt = {}

	for (let i = 0; i < w.length; i++) {
		if (!(w[i] in cnt)) cnt[w[i]] = 0
		cnt[w[i]]++
	}

	const keys = Object.keys(cnt)
	let ans = true

	for (let i = 0; i < keys.length; i++) {
		if (cnt[keys[i]] % 2 === 1) ans = false
	}

	console.log(ans ? 'Yes' : 'No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
N,K = map(int, input().split())

okasi = [1 for i in range(N)]

for i in range(K):
  d = int(input())
  list_okasi = list(map(int, input().split()))
  for sunuke in list_okasi:
    okasi[sunuke-1] = 0
    
print(sum(okasi))

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

using namespace std;

const int maxn = 2e5 + 5;

vector <int> g[maxn];
int d[maxn];
bool vis[maxn];

void dfs(int u,int cnt) {
	vis[u] = 1;
	d[u] += cnt;
	for(int i = 0 ; i < g[u].size(); i++) {
		int v= g[u][i];
		if(!vis[v])dfs(v,d[u]);
	}
}



int main() {
	int N, Q;
	cin >> N >> Q;
  for(int i=0; i<N-1; i++){
		int u,v;
		cin >> u >> v;
		g[u].push_back(v);
	}
	for(int i=0; i<Q; i++){
		int p,v;
		cin >> p >> v;
		d[p] += v;
	}
	dfs(1,0);
	for(int i = 1; i <= N; i++) {
		if(i > 1) cout << " ";
		cout << d[i];
	}
	return 0;
}


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

int main() {
    string s,t;
    cin>>s;
    cin>>t;
    t.pop_back();
    if(s==t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const ll inf = 1e15 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 7;
 
using namespace std;

ll dp[110][N];
ll w[110], v[110];

int main()
{
	barnarnar
	ll n, mx;
	cin >> n >> mx;
	forn1(i, n)	cin >> w[i] >> v[i];
	forn1(i, n)	dp[0][i] = -inf;
	dp[0][0] = 0;
	forn1(i, n)
	{
		forn(j, N)
		{
			dp[i][j] = dp[i - 1][j];
			if(j - w[i] >= 0)
			{
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= mx; i++)	ans = max(ans, dp[n][i]);
	cout << ans;
	return 0;
}
/*
5
11000
11100
01100
00000
00000
*/

Measured memory_bytes: 79360
#include <stdio.h>
#include <string.h>
int main()
{
    char s[10],t[10],u[10];
    int a,b,i,j,k;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0)
        a=a-1;
    else if(strcmp(t,u)==0)
        b=b-1;
    printf("%d %d",a,b);
    return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<ll> plis(a), qlis(b), rlis(c), anslis;
    REP(i, 0, a){cin >> plis[i];}
    REP(i, 0, b){cin >> qlis[i];}
    REP(i, 0, c){cin >> rlis[i];}
    sort(ALL(plis), greater<>());
    sort(ALL(qlis), greater<>());
    sort(ALL(rlis), greater<>());
    REP(i, 0, x){
        anslis.pb(plis[i]);
    }
    REP(i, 0, y){
        anslis.pb(qlis[i]);
    }
    REP(i, 0, min(x+y, c)){
        anslis.pb(rlis[i]);
    }
    sort(ALL(anslis), greater<>());
    ll ans = 0;
    REP(i, 0, x+y){
        ans += anslis[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n=1000;

int main(){
    rep(i,n){
        string s;
        cin>>s;
        int m=s.size();
        bool ok=true;
        rep(j,m-1){
            int i1=(s[j]-'A')/3;
            int j1=(s[j]-'A')%3;
            int i2=(s[j+1]-'A')/3;
            int j2=(s[j+1]-'A')%3;
            if(!((i1==i2&&min(j1,j2)+1==max(j1,j2))||(min(i1,i2)+1==max(i1,i2)&&j1==j2)))ok=false;
        }
        if(ok)cout<<s<<endl;
    }

    return 0;
}



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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int n,k;
    cin>>n>>k;
    int a[n];
    f1(i,0,n)
    {
    	cin>>a[i];
    }
    sort(a,a+n);
    f2(i,n-1,0)
    {
    	if(k==0)
    		break;
    	a[i]=0;
    	k--;
    }
    int ans=0;
    f1(i,0,n)
    ans+=a[i];

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

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  rep(i, n) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  sort(rall(a));

  int ans = 0;
  rep(i, n) {
    int target;
    rep(j, 31) {
      if ((1 << j) > a[i]) {
        target = (1 << j) - a[i];
        break;
      }
    }
    if ((a[i] == target && cnt[a[i]] >= 2) ||
        (a[i] != target && cnt[a[i]] >= 1 && cnt[target] >= 1)) {
      ans++;
      cnt[a[i]]--;
      cnt[target]--;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 19712
#include <stdio.h>


int main(void)
{
    int X, Y, i;
    scanf("%d %d", &X, &Y);

    for (i = 0; i <= X; i++)
    {
        if (4 * X - 2 * i == Y)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    
    return 0;
}
	








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

int main(){
    int n,x,ans;
    cin>>n>>x;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    for(int i=0;x>=0&&i<n;i++){
        x-=d.at(i);
        ans=i+1;
        }
    if(x!=0){ans--;}
    cout<<ans<<endl;
    }


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back


int main(void){
  string s;
  int ans = 0;

  cin >> s;

  rep(i,s.sz){
    if(ans == 0 && s[i] == 'C')ans++;
    if(ans == 1 && s[i] == 'F')ans++;
  }

  if(ans == 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int a, b, c;
    cin>>a>>b>>c;
    int m=a+b+c;
    int d=max(a, b);
    d=max(d, c);
    cout<<m-d<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

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


Measured memory_bytes: 256
"""
ALDS1_10_C
最長共通部分列を二次元配列を用いた動的計画法で求める
だた，普通に二次元配列を構成するとTLEになるので工夫しなければならない
IKAPPERさんのコードを参考にしました
"""

def lcs(X, Y):
    m = len(X)
    n = len(Y)
    #xが縦，yが横
    lcs_r = [0 for _ in range(m+1)]
    for y in Y:
        previous = lcs_r[:] #copy.copy 使わなくて済むかも
        for i, x in enumerate(X):
            if x == y:
                lcs_r[i+1] = previous[i]+1
            elif lcs_r[i] > previous[i]:
                lcs_r[i+1] = lcs_r[i]
            else: #ここは省略できる（そのままpreviousがlcs_rに上がってくる）
                lcs_r[i] = previous[i] 
    
    print(lcs_r[-1])



roop = int(input())
for _ in range(roop):
    x = input()
    y = input()
    lcs(x, y)




Measured memory_bytes: 5640
N,T=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
B=sorted(A)
cnt=0
for i in range(N):
  if B[i][1]<=T:
    print(B[i][0])
    exit()
  else:
    cnt+=1
if cnt==N:
  print('TLE')

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

const int MAX_N = 200010;
mint dp[MAX_N];

int main() {
    int N;
    cin >> N;
    vector<int> C(N);
    rep(i, N) cin >> C[i];

    map<int, int> prevPos;
    rep(i, MAX_N) prevPos[i] = -1;
    dp[0] = 1;
    rep(i, N) {
        dp[i + 1] += dp[i];
        int j = prevPos[C[i]];
        if (j >= 0 && i - j > 1) dp[i + 1] += dp[j + 1];
        prevPos[C[i]] = i;
    }

    cout << dp[N].x << endl;
}


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


ll mypower(ll x, ll n){
    if(n==0){
        return 1;
    }
    ll temp = mypower(x, n/2);
    if(n%2==0){
        return (temp*temp)%MOD;
    }else{
        return (((temp*temp)%MOD)*x)%MOD;
    }
}

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans[100001]={};
    ll already[100001]={};
    for(ll i=K; i>=1; i--){
        ll temp = mypower((K/i),N);
        ans[i] += temp-already[i];
        ans[i]%=MOD;

        temp -= already[i];
        temp%=MOD;

        for(ll j=1; j*j<=i; j++){
            if(i%j==0){
                already[j]+=temp;
                already[j]%=MOD;
                if(j*j!=i){
                  already[i/j]+=temp;
                  already[i/j]%=MOD;
                }
            }
        }
    
    } 

    ll sum = 0;
    for(ll i=0; i<=K; i++){
        sum += (ans[i]*i)%MOD;
        sum%=MOD;
    }

    cout<<sum<<endl;
    return 0;
}

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

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

	for (int i = 0; i < N; ++i) {
		cout << Load[i] << endl;
	}
}

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

int main() {
  char A, B, C, D;
  cin >> A >> B >> C >> D;
  int a = A - 48, b = B - 48, c = C - 48, d = D - 48;
  if (a+b+c+d==7) cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if (a+b+c-d==7) cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if (a+b-c+d==7) cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if (a+b-c-d==7) cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if (a-b+c+d==7) cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if (a-b+c-d==7) cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if (a-b-c+d==7) cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if (a-b-c-d==7) cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
int main()
{
    int a;
    cin >> a;
    if(a >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#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>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int 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;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int a,b;
    
    cin >> a >> b;
    
    if ( a > b){
    
    cout << a-1 << endl;
    
    }else{
    
    cout << a << endl;
    
    
    }
    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli n;
    cin >> n;
    if(n<600)
        cout << "8";
    else if(n<800)
        cout << "7";
    else if(n<1000)
        cout << "6";
    else if(n<1200)
        cout << "5";
    else if(n<1400)
        cout << "4";
    else if(n<1600)
        cout << "3";
    else if(n<1800)
        cout << "2";
    else
        cout << "1";
    cout<< endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 3592
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0;
        return 0;
    }
    vl v(n);
    rep(i,0,n){
        cin >> v[i];
    }
    sort a(v);
    cout << v[n/2]-v[n/2-1];
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] scan_str = new String[1000];
		String str = null;
		int i = 0;
		int res;
		// str.length分ループして足し算
		while(true){
			res = 0;
			str = scan.nextLine();
			if("0".equals(str)){
				break;
			}
			scan_str = str.split("");
			for(i=0; i<str.length(); i++){
				res = res + Integer.parseInt(scan_str[i]);
			}
			System.out.println(res);
		}
	}
}


Measured memory_bytes: 27164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n, 0);
    rep(i, q) {
        int c;
        cin >> c;
        c--;
        a[c]++;
    }
    rep(i, n) {
        if (k - (q - a[i]) <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P0016_TreasureHunt
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = new List<List<string>>();
            string readLine;

            do
            {
                readLine = Console.ReadLine();

                if(readLine == "0,0")
                {
                    break;
                }
                else if (readLine != null)
                {
                    var sp = readLine.Split(',').ToList<string>();
                    lines.Add(sp);
                }
            }
            while (readLine != null);

            double xx = 0;
            double yy = 0;
            double angleS = 90;

            foreach (var line in lines) 
            {
                var h = double.Parse(line[0]);
                var angle = double.Parse(line[1]);
                
                var x = cosa(h, angleS);
                var y = sinb(h, angleS);
                xx += x;
                yy += y;

                //Console.WriteLine("{0} {1} {2}", angleS,x, y );
                
                angleS -= angle;
            }

            Console.WriteLine(Math.Truncate(xx));
            Console.WriteLine(Math.Truncate(yy));
            Console.ReadLine();
        }

        static double cosa(double h, double angle) 
        {
            return h * Math.Cos( Math.PI * angle / 180);
        }

        static double sinb(double h, double angle)
        {
            return h * Math.Sin(Math.PI * angle / 180);
        }

    }



    
}

Measured memory_bytes: 5984
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public static int Main()
    {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());
        int Y = int.Parse(Console.ReadLine());

        if (N > K)
        {
            Console.WriteLine(K * X + (N - K) * Y);
        }
        else
        {
            Console.WriteLine(N * X);
        }
        return 0;
    }
}


Measured memory_bytes: 2648
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 2e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if (n == 0)
    {
        int x;
        cin >> x;
        if (x == 1) cout << 1, exit(0);
        else cout << -1, exit(0);
    }
    vi a(n + 1);
    forn(i, n + 1) cin >> a[i];
    if (a[0] > 0) cout << -1, exit(0);
    vi v(n + 1);
    v[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        v[i] = (v[i - 1] - a[i - 1]) * 2;
        if (v[i] <= 0) cout << -1, exit(0);
        v[i] = min(v[i], INFLL);
    }
    if (v[n] < a[n]) cout << -1, exit(0);
    vi vert(n + 1);
    vert[n] = a[n];
    for (int i = n - 1; i >= 0; i--)
    {
        vert[i] = min(vert[i + 1] + a[i], v[i]);
        if (2 * (vert[i] - a[i]) < vert[i + 1]) cout << -1, exit(0);
    }
    ll ans = 0;
    forn(i, n + 1) ans += vert[i];
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 5548
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int cont = 0;
	char a[3];
	rep(i, 3) {
		cin >> a[i];
		if (a[i] == 'o') {
			cont++;
		}
	}
	cout << 700 + cont * 100 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main() {
	int n,k,m,j;
	char c;
	cin>>n>>m;
	int A[n][m];
	for(k=0;k<n;k++)
	{
		for(j=0;j<m;j++)
		{
			cin>>c;
			if(c=='.')
			A[k][j]=1;
			else
			A[k][j]=0;
		}
	}
	long long dp[n][m];
	for(k=0;k<n;k++)
	{
		for(j=0;j<m;j++)
		dp[k][j]=0;
	}
	dp[0][0]=1;
	for(k=1;k<n;k++)
	{
	if(A[k][0]==1&&dp[k-1][0]!=0)
	dp[k][0]=1;
	}
	for(k=1;k<m;k++)
	{
		if(A[0][k]==1&&dp[0][k-1]!=0)
		dp[0][k]=1;
	}
	for(k=1;k<n;k++)
	{
		for(j=1;j<m;j++)
		{
			if(A[k-1][j]==1)
			dp[k][j]=(dp[k][j]%mod+dp[k-1][j]%mod)%mod;
			if(A[k][j-1]==1)
			dp[k][j]=(dp[k][j]%mod+dp[k][j-1]%mod)%mod;
		}
	}
	/*	for(k=0;k<n;k++)
	{
		for(j=0;j<m;j++)
		cout<<A[k][j]<<' ';
		cout<<endl;
	}
	cout<<"next"<<endl;
	for(k=0;k<n;k++)
	{
		for(j=0;j<m;j++)
		cout<<dp[k][j]<<' ';
		cout<<endl;
	}*/
	cout<<dp[n-1][m-1]%mod<<endl;
}
	

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

int main(){
    int N;
    string s,zoo;
    cin >> N >> s;
    
    string str[2];
    str[0] = 'S';
    str[1] = 'W';
    bool ok = false;

    for(int i=0;i<2;i++) for(int j=0;j<2;j++){
        zoo = str[i] + str[j];
        for(int k=1;k<N-1;k++){
            if(zoo[k]=='S'&&s[k]=='o') zoo += zoo[k-1];
            else if(zoo[k]=='S'&&s[k]=='x'){
                if(zoo[k-1]=='S') zoo += 'W';
                else zoo += 'S';
            }
            else if(zoo[k]=='W'&&s[k]=='o'){
                if(zoo[k-1]=='S') zoo += 'W';
                else zoo += 'S';
            }
            else if(zoo[k]=='W'&&s[k]=='x') zoo += zoo[k-1];
        }
        int c = 0;
        for(c=0;c<N;c++){
            int back,front;
            if(c==0){ back=N-1; front=1; }
            else if(c==N-1){ back=N-2; front=0; }
            else { back=c-1; front=c+1; }

            if(zoo[c]=='S' && s[c] == 'o'){
                if(zoo[back]!=zoo[front]){
                    break;
                }
            }else if(zoo[c]=='S' && s[c] == 'x'){
                if(zoo[back]==zoo[front]){
                    break;
                }
            }else if(zoo[c]=='W' && s[c] == 'o'){
                if(zoo[back]==zoo[front]){
                    break;
                }
            }else if(zoo[c]=='W' && s[c] == 'x'){
                if(zoo[back]!=zoo[front]){
                    break;
                }
            }
        }
        if(c==N){
            cout << zoo << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 776
# ABC058C - 怪文書 / Dubious Document (ARC071C)
import sys
input = sys.stdin.readline

from collections import Counter
from string import ascii_lowercase


def main():
    N = int(input())
    D = tuple(Counter(input()) for _ in range(N))
    ans = ""
    for s in ascii_lowercase:
        if all(s in d for d in D):
            ans += s * min(d[s] for d in D)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
/* vector<int> A(N);
vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
tie(b, a) = p.at(i); #pair を分割
tasks.emplace_back(b, a) ＃配列 tasks の最後に (b, を追加
x の二乗 : pow(x, 2.0)
小さい順 : sort(v.begin(), v.
*/
int main() {
int N,count=0;
cin >> N;
vector<int> A(N);
  
rep(i,N){
   cin >> A.at(i);
   if((A.at(i)%2)==0){
     if((A.at(i)%3)!=0 && (A.at(i)%5)!=0){
     	count++;
     }
   }
}

if(count==0) cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        a: [i64; n]
    };
    let mut money = 1000;
    let mut stock = 0;
    for i in 0..n {
        if i+1 < n && a[i] < a[i+1] {
            stock += money/a[i];
            money %= a[i];
        } else if i == n-1 || a[i] > a[i+1] {
            money += a[i] * stock;
            stock = 0;
        }
    }
    println!("{}", money);
}


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

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        person, state = map(int, input().split())
        As[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  # 人一人ごとにループを回す
        if (i>>j) & 1 == 1:   # 人jは正直と仮定
            for x, y in As[j]:
                if (i>>x) & 1 != y:  # 人jは正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:
        # 1の数をカウントし最大となるものを選択
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	int	N;		/* 文字列の長さ		*/
	char	S[51];		/* 入力される文字列	*/
	int	index;		/* 配列のインデックス	*/
	int	counter;	/* ABCのカウンタ	*/

	scanf("%d", &N);
	scanf("%s", &S);
	counter = 0;

	for(index = 0; index < N; ++index){
		if(S[index] == 'A'){
			if((S[index + 1] == 'B') && (S[index + 2] == 'C'))
				++counter;
		}
	}
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));

		String[] d1labeldata = br.readLine().split(" ");
		String[] d2labeldata = br.readLine().split(" ");

		Dice d1 = new Dice(d1labeldata);
		Dice d2 = new Dice(d2labeldata);

		int top;
		for (top = 0; top < 6; top++) {
			if ( d1.label[0].equals(d2.label[top]) ) break;
		}

		//System.out.println(top);

		switch (top) {
		case 0:
			break;
		case 1:
			d2.koroN();
			break;
		case 2:
			d2.koroW();
			break;
		case 3:
			d2.koroE();
			break;
		case 4:
			d2.koroS();
			break;
		case 5:
			d2.koroN().koroN();
			break;
		default:
			System.out.println("No");
		}

		int front;
		for (front = 1; front <= 4; front++) {
			if ( d1.label[1].equals(d2.label[front]) ) break;
		}

		//System.out.println(front);

		switch (front) {
		case 1:
			break;
		case 2:
			d2.kaitenTokei();
			break;
		case 3:
			d2.kaitenHanTokei();
			break;
		case 4:
			d2.kaitenTokei().kaitenTokei();
			break;
		default:
			System.out.println("No");
		}

		if ( d1.label[2].equals(d2.label[2]) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

class Dice {
	String[] label;

	Dice(String[] labeldata) {
		label = new String[labeldata.length];

		for (int i = 0; i < labeldata.length; i++) {
			label[i] = labeldata[i];
		}
	}

	Dice koroN() {
		String temp;
		temp = label[0];
		label[0] = label[1];
		label[1] = label[5];
		label[5] = label[4];
		label[4] = temp;
		return this;
	}

	Dice koroS() {
		String temp;
		temp = label[0];
		label[0] = label[4];
		label[4] = label[5];
		label[5] = label[1];
		label[1] = temp;
		return this;
	}

	Dice koroE() {
		String temp;
		temp = label[0];
		label[0] = label[3];
		label[3] = label[5];
		label[5] = label[2];
		label[2] = temp;
		return this;
	}

	Dice koroW() {
		String temp;
		temp = label[0];
		label[0] = label[2];
		label[2] = label[5];
		label[5] = label[3];
		label[3] = temp;
		return this;
	}

	Dice kaitenTokei() {
		String temp;
		temp = label[1];
		label[1] = label[2];
		label[2] = label[4];
		label[4] = label[3];
		label[3] = temp;
		return this;
	}

	Dice kaitenHanTokei() {
		String temp;
		temp = label[1];
		label[1] = label[3];
		label[3] = label[4];
		label[4] = label[2];
		label[2] = temp;
		return this;
	}

}

Measured memory_bytes: 24388
#include <iostream>
#include <vector>
#include <algorithm>


std::vector<long long> divisors(long long m)
{
    std::vector<long long> ret;
    for (long long i = 1; i * i <= m; i++)
    {
        if (m%i==0)
        {
            ret.push_back(i);
            ret.push_back(m/i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}

long long solve(long long n, long long m)
{
    auto divs = divisors(m);
    long long ans = 1;
    for (auto iter = divs.begin(); iter != divs.end(); iter++)
    {
        if (n*(*iter) <= m)
        {
            ans = *iter;
        }
        else
        {
            break;
        }
    }
    return ans;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;
    std::cout << solve(n, m) << std::endl;
}

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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String s = keyboard.next();
		
		String[] command = new String[s.length()];
		String[] result = new String[s.length()];
		
		for(int i = 0; i < s.length(); i ++) {
			command[i] = s.substring(i, i+1);
		}
		
		int jj = 0;
		int count = 1;
		
			for(int j = s.length() - 1; j >= 0; j--) {
				if(command[j].equals("B")){
					while(j != 0 && command[j-1].equals("B")){
						//一個前がBじゃないか調べる
						count ++;
						j--;
					}
					j -= count;
				}else {
					result[jj] = command[j];
					jj++;
				}
			}

		for(int k = jj - 1; k>=0; k --) {
			System.out.print(result[k]);
		}

		keyboard.close();	
	}
}

Measured memory_bytes: 21588
import array
def main():
  n=2*10**5
  s=input()
  q=int(input())
  rev=0
  l=n-1
  r=n+len(s)
  s=array.array('b',[0]*n+[ord(c) for c in s]+[0]*n)
  for _ in range(q):
    query=input().split()
    if(query[0]=='1'):
      rev=1-rev
    elif((int(query[1])+rev)%2==1):
      s[l]=ord(query[2])
      l-=1
    else:
      s[r]=ord(query[2])
      r+=1
  s=[chr(c) for c in s if c!=0]
  if rev==1:
    return ''.join(s[::-1])
  return ''.join(s)
print(main())

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

vector<vector<vector<double>>> dp;
int N;

double dfs(int s1, int s2, int s3) {
  if (dp[s1][s2][s3]!=-1) return dp[s1][s2][s3];
  double result = 0;
  if (s1!=0) result += (dfs(s1-1,s2  ,s3  ) + (double)N/(s1+s2+s3)) * s1/(s1+s2+s3);
  if (s2!=0) result += (dfs(s1+1,s2-1,s3  ) + (double)N/(s1+s2+s3)) * s2/(s1+s2+s3);
  if (s3!=0) result += (dfs(s1  ,s2+1,s3-1) + (double)N/(s1+s2+s3)) * s3/(s1+s2+s3);
  // cout << s1 << " " << s2 << " " << s3 << "->" << result << endl;
  return dp[s1][s2][s3] = result;
}

int main() {
  cin >> N;
  int s[3] = {}; rep(i,N) { int a; cin >> a; s[a-1]++; } 
  int s1 = s[0], s2 = s[1], s3 = s[2];
  // debug(s,s+3); 
  
  dp.resize(N+1,vector<vector<double>>(N+1,vector<double>(N+1,-1.)));
  double result = dfs(s1,s2,s3);
  cout << setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 217472
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        
        double a[n];
        double sum = 0;
        rep(i,n) {
            cin >> a[i];
            sum += a[i];
        }
        
        double ave = sum/n;
        
        double d = 0;
        rep(i,n){
            d += pow(ave-a[i],2);
        }
        
        double sd = sqrt(d/n);
        
        cout << fixed;
        cout << setprecision(5) << sd << endl;
        
    }
}
    
    







Measured memory_bytes: 3180
#define  _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define mem(a, b) memset(a, b, sizeof(a))
#define fastIO ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<n;i++)
#define dep(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sqr (x) (x * x)
#define ang(a, b, c) acos((sqr(b)+sqr(c)-sqr(a))/(2.0*b*c))
#define dist(x1, y1, x2, y2) sqrt(sqr(x1-x2)+sqr(y1-y2))
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define PI 3.1415926535897932385 
#define inf 1000000000
#define eps 1e-7
#define mod 1000000007 
#define N 1002


int main(){
//#ifndef ONLINE_JUDGE
//	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
//#endif	
	fastIO;
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) cout << "GREATER" << endl;
	else if (b.size() > a.size()) cout << "LESS" << endl;
	else {
		int i;
		for (i = 0; i < a.size(); i++){
			if (a[i] == b[i]) continue;
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				break;
			}
			else {
				cout << "LESS" << endl;
				break;
			}
		}
		if (i == a.size()) cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int r1=a,x1=1,y1=0,r2=b,x2=0,y2=1,r3,q,x3,y3;
        while(r2!=0){
            q=r1/r2;
            r3=r1%r2;
            x3=x1-q*x2;
            y3=y1-q*y2;
            r1=r2;
            r2=r3;
            x1=x2;
            x2=x3;
            y1=y2;
            y2=y3;
        }
        System.out.println(x1+" "+y1);
    }
    
    static int gcd(int a,int b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        return gcd(a,a%b);
    }
}



Measured memory_bytes: 26240
#include<stdio.h>
int main()
{
	char S[4];
	int N=0;
	int i=0;
	char c='+';
	scanf("%s",&S);
	while(i<4){
		if(S[i]==c){
			N++;
		}else{
			N--;
		}
		i++;
	}
	printf("%d",N);
	return 0;
}

Measured memory_bytes: 128
let rv f p q = f q p;;
Scanf.(Array.(scanf " %d" @@ fun n ->
  let a,b = make n 0,make n 0 in
  init n (fun i -> scanf " %d %d" @@ fun u v -> a.(i) <- u; b.(i) <- v);
  let c = init n (fun i -> a.(i)+b.(i),i) in
  sort (rv compare) c;
  print_int @@ fst @@
    fold_left (fun (sum,j) (_,i) ->
      (sum + if j mod 2 = 0 then a.(i) else -b.(i)),j+1
    ) (0,0) c))

Measured memory_bytes: 8960
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll n, m, x, y, cnt = 0;
double D, dis;
int main(){
  	scanf("%lld%lld", &n, &m);
  	D = 1.0 * m;
  	for(register int i = 1; i <= n; ++ i){
    	scanf("%lld%lld", &x, &y);
      	dis = sqrt(x * x + y * y);
      	if(dis > D)
          	continue;
      	++ cnt;
    }
  	printf("%lld\n", cnt);
	return 0;
}

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

int main()
{
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		map<unsigned long long int,unsigned long long int> syain;
		bool flag = true;
		unsigned long long int a,b,c;
		for(int i=0;i<n;i++){
			map<unsigned long long int,unsigned long long int> tmp;
			cin >> a >> b >> c;
			if(syain.find(a) != syain.end() && syain[a] < 1000000)
				syain[a] += b*c;
			else
				syain[a] = b*c;
			if(syain[a] >= 1000000){
				cout << a << endl;				
				flag = false;
			}
		}
		if(flag)
			cout << "NA" << endl;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int INF = 1e9;
auto minn(auto& a, auto b){a = min(a, b);}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  vi a(n);
  trav(i, a) cin >> i;
  vi dp(n + k, INF);
  dp[0] = 0;
  rep(i, 0, n) {
    rep(step, 1, k + 1) {
      if (i + step < n)
	minn(dp[i + step], dp[i] + abs(a[i + step] - a[i]));
    }
  }
  cout << dp[n - 1] << '\n';
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a==b){
	printf("a == b\n");
	}
	if(a<b){
	printf("a < b\n");
	}
	if(a>b){
	printf("a > b\n");
	}
	return 0;
}

Measured memory_bytes: 2576
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#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, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll n;
	scanf("%lld", &n);
	for (ll a = -200; ; ++a) {
		for (ll b = -200; b < 200; ++b) {
			if (a * a * a * a * a - b * b * b * b * b == n) {
				printf("%lld\n%lld\n", a, b);
				return AC;
			}
		}
	}

	Please AC;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
ll n,cnt[26],ans=1;
string s;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>n>>s;
    for(ll i=0;i<n;i++)cnt[s[i]-'a']++;
    for(ll i=0;i<26;i++)ans=(ans * (cnt[i]+1) )%mod;
    cout<<(ans-1+mod)%mod;
}




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

int main() {
  int n, k;
  cin>>n>>k;
  int h[n];
  for (int i=0; i<n; i++) cin>>h[i];

  long long dp[n];
  dp[0] = 0;

  for (int i=1; i<n; i++) {
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    for (int j=2; j<=min(i, k); j++) {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define INF 2147483647
#define maxn 100010
using namespace std;
char s[maxn];
int pos[2][maxn], cnt[2], n;
int solve(int t1, int t2)
{
	int sum = 0;
	for (int i = 1; i <= t1 - 1; i++)
		sum += pos[0][i];
	for (int i = 1; i <= t2 - 1; i++)
		sum += pos[1][i];
	while (t1 <= cnt[0] || t2 <= cnt[1])
	{
		int p1, p2;
		if (t1 > cnt[0]) p1 = n;
		else p1 = pos[0][t1];
		if (t2 > cnt[1]) p2 = n;
		else p2 = pos[1][t2];
		sum += abs(p1 - p2);
		t1++; t2++;
	}
	return sum;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i <= 1; i++)
	{
		scanf("%s", s + 1);
		int tmp = s[1] - '0' + 4;
		for (int j = 1; j <= tmp; j++)
			pos[i][++cnt[i]] = 0;
		for (int j = 1; j <= n - 1; j++)
			if (s[j] != s[j + 1]) pos[i][++cnt[i]] = j;
	}
	int res = INF;
	for (int i = 1; i <= cnt[1]; i += 2)
		res = min(res, solve(1, i));
	for (int i = 1; i <= cnt[0]; i += 2)
		res = min(res, solve(i, 1));
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256