akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 


int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1];
    mset(dp,0);
    for(int i=n-1;i>=0;i--)
    {
      for(int j=m-1;j>=0;j--)
      {
        if(s[i]==t[j])
        {
          dp[i][j] = 1 + dp[i+1][j+1];
        }
        else
        {
          dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
      }
    }
    int i = 0, j = 0; string lc="";
   while (i < n && j < m) 
   { 
      
      if (s[i] == t[j]) 
      { 
          lc += s[i]; 
          i++; j++;     
      } 
  
     
      else if (dp[i+1][j] > dp[i][j+1]) 
         i++;
      else
         j++; 
   } 
    cout<<lc;
   
    
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
const ll INF = 100000000000000000;

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else cout<<r+100*(10-n)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    long T[] = new long[N];
    long ans = 1;
    for(int i=0; i<N; i++){
      T[i] = sc.nextLong();
      ans = lcm(ans, T[i]);
    }
    out.println(ans);
  }
  
  public static long lcm(long a, long b){
    return a / gcd(a, b) * b;
  }

  public static long gcd(long a, long b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll l;
//ld ;
//string s;

int main() {
    cin >> l;
    ld v = pow((ld)l/3.0,3);
    cout << setprecision(13) <<  v << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,k,ans;
int a[111111],b[111111];
signed main(){
	 cin>>n;
	 rep(i,n)cin>>a[i];
	 //Bi+B(i+1)=2Ai
	 //B0=S-(B1+B2+...Bn);
	 //B0=S-(2A1+2A3+..2A(n-1))
	 //B(i+1)=2Ai-Bi;
	 int sum=0,sum2=0;
	 rep(i,n)sum+=a[i];
	 for(int i=1;i<n;i+=2){
	 	sum2+=a[i]*2;
	 }
	 b[0]=sum-sum2;
	 rep(i,n){
	 	b[i+1]=a[i]*2-b[i];
	 }
	 rep(i,n)cout<<b[i]<<" ";
	 cout<<endl;
}


Measured memory_bytes: 2944
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	static char[] alphabet = { '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' };

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int[] al = new int[alphabet.length];
		String str = sc.next();
		for (int j = 0; j < str.length(); j++) {
			al[wordSearch(str.charAt(j))] += 1;
		}
		for (int j = 0; j < alphabet.length; j++) {
			if (al[j] > 1) {
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}

	public static int wordSearch(char c) {
		for (int i = 0; i < alphabet.length; i++) {
			if (c == alphabet[i]) {
				return i;
			}
		}
		return -1;
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<ll> as(n), bs(n);
	rep(i,0,n) cin >> as[i] >> bs[i];
	ll ans = 0;
	rrep(i,0,n){
		as[i] += ans;
		as[i] %= bs[i];
		as[i] = bs[i]-as[i];
		as[i] %= bs[i];
		ans += as[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

struct p {
    ll cost;
    ll keys = 0;
};

int main() {
    init();

    int n, m;
    cin >> n >> m;
    vector<p> a(m);
    FOR(i, 0, m) {
        int b;
        cin >> a[i].cost >> b;
        FOR(j, 0, b) {
            ll k;
            cin >> k;
            k--;
            a[i].keys |= (1 << k);
        }
    }

    vector<VL> dp(1 << n, VL(m + 1, LLINF / 2));
    dp[0][0] = 0;
    FOR(i, 0, 1 << n)FOR(j, 0, m) {
        chmin(dp[i][j + 1], dp[i][j]);
        chmin(dp[i | a[j].keys][j+1], dp[i][j] + a[j].cost);
    }
    cout << (dp[(1 << n )- 1][m] == LLINF / 2 ? -1 : dp[(1 << n) - 1][m]) << "\n";
}


Measured memory_bytes: 32384
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int x=n,s=0;
    while(x)
    {
        s+=x%10;
        x/=10;
    }
    if(n%s==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}
 

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner str = new Scanner(System.in);
        String S = str.next();
        String T = str.next();

        int A = str.nextInt();
        int B = str.nextInt();

        String U = str.next();

        if(S.equals(U)){
            A -= 1;
        }
        else{
            B -= 1;
        }

        System.out.println(A + " " + B);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int i, j, k, p, q, r, x, y, u, v, n, m;
	cin>>x;
	if(x>=30){
		cout<<"Yes"<<endl;

	}
	else{
		cout<<"No"<<endl;
	}

}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10584
[(a,b,c),(d,e,f),(g,h,i)]=[map(int,input().split())for _ in [0]*3]
print('Yes'if a-b==d-e==g-h and b-c==e-f==h-i and a-d==b-e==c-f and d-g==e-h==f-i else'No')

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        int[] a = new int[26];
        for (char c : S.toCharArray()) {
            a[c-97] += 1;
        }
        String answer = "None";
        for (int i = 0; i < 26;i++) {
            if (a[i] == 0) {
                answer = Character.toString((char) (i+97));
                break;
            }
        }
        System.out.println(answer);
    }
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  
  string a="dream";
  string b="dreamer";
  string c="erase";
  string d="eraser";
  
  int n=s.size();
  int i=n;
  bool flg=true;
  while(i>0){
    if(i<5){
      flg=false;
      break;
    }
    if(s.substr(i-5,5)=="dream"||s.substr(i-5,5)=="erase"){
      i-=5;
    }else if(s.substr(i-6,6)=="eraser"){
      i-=6;
    }else if(s.substr(i-7,7)=="dreamer"){
      i-=7;
    }else{
      flg=false;
      break;
    }
  }
  if(flg) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

int main(){
  double x,h;
  while(1){
    cin>>x>>h;
    if(!x&&!h)break;
    printf("%.6f\n",x*x+x*sqrt(h*h+x*x/4)*2);
  }
  return 0;
}

Measured memory_bytes: 1240
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for _ in range(n):
        s = input()
        if s == "AC":
            ac += 1
        elif s == "WA":
            wa += 1
        elif s == "TLE":
            tle += 1
        else:
            re += 1
    print("AC x {}".format(ac))
    print("WA x {}".format(wa))
    print("TLE x {}".format(tle))
    print("RE x {}".format(re))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9252
#include <bits/stdc++.h>
#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 ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define toInt(x) (x - '0')
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  vi x(3);
  rep(i, 3) { cin >> x[i]; }

  sort(all(x));

  cout << x[2] * 10 + x[1] + x[0] << endl;

  return 0;
}

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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(k >= (int)s.size()) cout << s << endl;
  else{
    s=s.substr(0,k);
    s += "...";
    cout << s << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#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++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
inline double comb(int n, int r) {if (n == 0) { return 0; }if (r == 0) { return 1; }if (r == 1) { return n; }if (n == r) { return 1; }if (r > n / 2) { r = n / 2; }double result = 1;for (double i = 1; i <= r; i++) {result *= (n - i + 1) / i;}return(result);}
vector<pair<long long, long long> > prime_factorize(long long n) {vector<pair<long long, long long> > res;for (long long p = 2; p * p <= n; ++p) {if (n % p != 0) continue;int num = 0;while (n % p == 0) { ++num; n /= p; }res.push_back(make_pair(p, num));}if (n != 1) res.push_back(make_pair(n, 1));return res;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(15);
   int N;
   cin >> N;
   int ans =0;
   if ( N%2 == 1){
       ans  = (N/2)* (N/2) + (N/2);
       cout << ans << endl;
   }
   else if (N%2 == 0){
       ans = (N/2)* (N/2);
       cout << ans << endl;

   }
}



Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
if len(p) == 0 or x < p[0] or p[-1] < x or x not in p:
    ans = x
else:
    d = x
    ans = 0
    for i in range(p[0] - 1, p[-1] + 2):
        if i not in p and abs(x - i) < d:
            ans = i
            d = abs(x - i)
print(ans)

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

int ask(string s) {
#ifdef LOCAL
	string ans = "Atcod3rIsGreat";
	int L1 = s.length(), L2 = ans.length();
	vector< vector<int> > dp(L1+1, vector<int>(L2+1, L1+L2));
	dp[0][0] = 0;
	for(int i = 0; i <= L1; i++) for(int j = 0; j <= L2; j++) {
		if(i < L1) dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1);
		if(j < L2) dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1);
		if(i < L1 && j < L2) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (s[i] != ans[j]));
	}
	return dp[L1][L2];
#else
	cout << "? " << s << endl;
	int a;
	cin >> a;
	return a;
#endif
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string C = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	int N = 62, L = 0;
	vector<int> ans_single(N);
	for(int i = 0; i < N; i++)
		ans_single[i] = ask(C.substr(i, 1));
	L = 130;
	for(int i = 0; i < N; i++) L = min(L, ans_single[i]+1);
	vector<int> cnt(N, 0);
	for(int i = 0; i < N; i++) if(L == ans_single[i]+1) cnt[i] = 1;
	int last = N-1;
	while(cnt[last] == 0) last--;
	cnt[last] = L;
	for(int i = 0; i < last; i++) if(cnt[i]) {
		string s;
		s += C[i];
		while(true) {
			s += C[i];
			int a = ask(s);
			if(a == L-cnt[i]-1) cnt[i]++;
			else break;
		}
		cnt[last] -= cnt[i];
	}
	vector< pair<int, string> > parts;
	for(int i = 0; i < N; i++) if(cnt[i]) {
		string s;
		for(int j = 0; j < cnt[i]; j++) s += C[i];
		parts.push_back({cnt[i], s});
	}
	sort(begin(parts), end(parts));
	while((int)parts.size() > 1) {
		string s1 = parts[0].second, s2 = parts[1].second;
		string s;
		int a = 0, b = 0, l1 = s1.length(), l2 = s2.length();
		while(a < l1 && b < l2) {
			string sq = s;
			sq += s2[b];
			sq += s1.substr(a, l1-a);
			int ans = ask(sq);
			if(ans+(int)sq.length() == L) {
				s += s2[b];
				b++;
			}
			else {
				s += s1[a];
				a++;
			}
		}
		while(a < l1) s += s1[a++];
		while(b < l2) s += s2[b++];
		parts.erase(begin(parts));
		parts[0] = {l1+l2, s};
		int k = 0;
		while(k+1 < (int)parts.size() && parts[k].first > parts[k+1].first) {
			swap(parts[k], parts[k+1]);
			k++;
		}
	}
	cout << "! " << parts[0].second << endl;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, x;
    cin >> n >> x;

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

    vector<vector<int>> p(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        int t = 1 << 30;
        for (int j = 0; j < n; j++) {
            int h = i - j; if (h < 0) h += n;
            p[i][j] = t = min(t, a[h]);
        }
    }

    int64_t r = (int64_t)1 << 60;
    for (int j = 0; j < n; j++) {
        int64_t s = (int64_t)x * j;
        for (int i = 0; i < n; i++) {
            s += p[i][j];
        }
        r = min(r, s);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 16000
from copy import deepcopy
H, W, K = [int(x) for x in input().split()]
c = [[int(x) for x in list(input())] for _ in range(H)]
c.reverse()

max_score = 0
for y in range(H):
    for x in range(W):
        board = deepcopy(c)
        board[y][x] = None  # 消す
        score = 0
        erased = True
        coeff = 1
        while erased:
            erased = False
            # 落下させる
            for i in range(1, H):
                for j in range(W):
                    k = i
                    while k > 0 and board[k - 1][j] == None:
                        k -= 1
                    board[k][j], board[i][j] = board[i][j], board[k][j]

            # 消す
            for i in range(H):
                cnt = 1
                num = board[i][0]
                for j in range(1, W):
                    if board[i][j] != None and board[i][j] == board[i][j - 1]:
                        num = board[i][j]
                        cnt += 1
                    else:
                        if cnt >= K:
                            erased = True
                            score += coeff * cnt * num
                            board[i][j - cnt : j] = [None] * cnt
                        cnt = 1
                if cnt >= K:
                    erased = True
                    score += coeff * cnt * num
                    board[i][j - cnt + 1 : j + 1] = [None] * cnt

            coeff *= 2

        max_score = max(max_score, score)

print(max_score)

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

int main(){
  string s;cin >> s;
  int f,b;
  for(int i=0;i<s.size();++i){
    if(s.at(i)=='A'){
      f=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;--i){
    if(s.at(i)=='Z'){
      b=i;
      break;
    }
  }
  cout << b-f+1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int a[10000],n,min,max,i;
    long long s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    min=max=a[0];
    for(i=1;i<n;i++){
        if(a[i]>max)max=a[i];
        if(a[i]<min)min=a[i];
    }
    printf("%d %d %lld\n",min,max,s);
    return 0;
}



Measured memory_bytes: 2128
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
ll d[101010];
int main()
{
	int num;
	scanf("%d", &num);
	ll x = 1, y = 1;
	for (int i = 0; i < num; i++)
	{
		ll a, b;
		scanf("%lld%lld", &a, &b);
		ll t = max((x + a - 1) / a, (y + b - 1) / b);
		x = a*t, y = b*t;
	}
	printf("%lld\n", x + y);
}

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

score_taro = 0
score_hanako = 0

for i in range(n):
    
    a = input().split()
    b = sorted(a)
    
    if a[0] == a[1]:
        score_taro += 1
        score_hanako += 1
        
    elif a[0] == b[0]:
        score_hanako += 3
        
    else:
        score_taro += 3
        
print(score_taro, score_hanako)


Measured memory_bytes: 5596
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] d = new Integer[n];
        Arrays.setAll(d, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        Set<Integer> set = new HashSet<>(Arrays.asList(d));
        int result = set.size();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 28500
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
int main(){
  ll N_m,N_h;
  ll sum = 0;
  cin >> N_m >> N_h;
  vector<ll> M(N_m);
  for(ll i = 0;i<N_m;i++){
    cin >> M[i];
  }
  sort(M.begin(),M.end());
  for(ll i=0;i<N_m-N_h;i++){
    sum+= M[i];
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 60,MOD = 1000000007;
typedef long long LL;
int n;
char a[2][MaxN];
LL dp[MaxN][3][3];

int main() {
    scanf("%d%s%s",&n,a[0],a[1]);
    int i;
        memset(dp,0,sizeof dp);
    if (a[0][0]==a[1][0]) {
        dp[0][0][0]=dp[0][1][1]=dp[0][2][2]=1;
        i=1;
    } else {
        for (int i=0;i<3;++i) for (int j=0;j<3;++j)
            if (i!=j) dp[0][i][j]=dp[1][i][j]=1;
        i=2;
    }
    for (;i<n;++i) {
        if (a[0][i]==a[1][i]) {
            for (int j=0;j<3;++j) {
                //dp[i][j][j]=0;
                for (int x=0;x<3;++x) for (int y=0;y<3;++y) if (x!=j && y!=j) {
                    dp[i][j][j]+=dp[i-1][x][y];
                    dp[i][j][j]%=MOD;
                }
            }
        } else {
            for (int j=0;j<3;++j) for (int k=0;k<3;++k) if (j!=k) {
                //dp[i][j][k]=0;
                for (int x=0;x<3;++x) for (int y=0;y<3;++y) if (j!=x && k!=y) {
                    dp[i][j][k]+=dp[i-1][x][y];
                    dp[i][j][k]%=MOD;
                }
            }
            i++;
            for (int j=0;j<3;++j) for (int k=0;k<3;++k) dp[i][j][k]=dp[i-1][j][k];
        }
    }
    LL ans=0;
    for (int i=0;i<3;++i) for (int j=0;j<3;++j) ans=(ans+dp[n-1][i][j])%MOD;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import math
menu = []
m1 = []
for i in range(5):
   menu.append(int(input()))
   m1.append(menu[i]%10)
   if(m1[i] == 0): m1[i] += 10
a = m1.index(min(m1))
b = menu.pop(a)
tot = 0
for i in range(4):
   tot += math.ceil(menu[i]/10)*10
tot += b
print(tot)


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

bool bo[1010];
int n,m,mi[1010],ma[1010],bel[1010],sta[1010],tp,dfn[1010],low[1010],x,y,cnt,t[1010],tn,q[1010],l,r,ans[200010];
vector<int> v[1010],p[1010];

void tarjan(int x)
{
	dfn[x]=low[x]=(++cnt),sta[++tp]=x,bo[x]=1;
	for (int i=0,sz=v[x].size(); i<sz; i++)
		if (!dfn[v[x][i]]) tarjan(v[x][i]),low[x]=min(low[x],low[v[x][i]]);
		else if (bo[v[x][i]]) low[x]=min(low[x],dfn[v[x][i]]);
	if (dfn[x]==low[x])
	{
		bel[x]=x;
		while (sta[tp]!=x) bel[sta[tp]]=x,bo[sta[tp]]=0,tp--;
		tp--,bo[x]=0;
	}
}

int main()
{
	scanf("%d%d",&n,&m),cnt=0;
	for (int i=1; i<=m; i++) scanf("%d%d",&x,&y),v[x].push_back(y),p[x].push_back(i);
	memset(bo,0,sizeof(bo)),tp=cnt=0;
	for (int i=1; i<=n; i++) if (!dfn[i]) tarjan(i);
	for (int i=1; i<=n; i++)
	{
		tn=0;
		for (int j=0,sz=v[i].size(); j<sz; j++) t[++tn]=v[i][j];
		for (int j=1; j<=n; j++) mi[j]=ma[j]=-1;
		mi[i]=ma[i]=0;
		for (int j=1; j<=tn; j++) if (mi[t[j]]==-1)
		{
			q[l=r=1]=t[j],mi[t[j]]=j;
			while (l<=r)
			{
				x=q[l++];
				for (int k=0,sz=v[x].size(); k<sz; k++)
					if (mi[v[x][k]]==-1) mi[q[++r]=v[x][k]]=j;
			}
		}
		for (int j=tn; j; j--) if (ma[t[j]]==-1)
		{
			q[l=r=1]=t[j],ma[t[j]]=j;
			while (l<=r)
			{
				x=q[l++];
				for (int k=0,sz=v[x].size(); k<sz; k++)
					if (ma[v[x][k]]==-1) ma[q[++r]=v[x][k]]=j;
			}
		}
		for (int j=0,sz=v[i].size(); j<sz; j++)
			ans[p[i][j]]=((mi[v[i][j]]!=ma[v[i][j]])^(bel[i]==bel[v[i][j]]));
	}
	for (int j=1; j<=m; j++) puts(ans[j]?"diff":"same");
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
main(){

string s,t;
cin>>s>>t;
int n=s.size();
int ans=0;
for(int i=0;i<n;i++){
    if(s[i] != t[i])
    ans++;
}
printf("%d",ans);
}


Measured memory_bytes: 3916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main m = new Main();
        m.solve();
    }
    private void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int R = scan.nextInt();
        int[] r = new int[R];
        for (int i = 0; i < R; i++) {
            r[i] = scan.nextInt()-1;
        }
        int[][] distance = new int[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(distance[i], Integer.MAX_VALUE);
        }
        for (int i = 0; i < M; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            int c = scan.nextInt();
            distance[a][b] = c;
            distance[b][a] = c;
        }
        int[][] dp = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dp[i][j] = distance[i][j];
            }
        }
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (dp[i][k] == Integer.MAX_VALUE) {
                        continue;
                    }
                    if (dp[k][j] == Integer.MAX_VALUE) {
                        continue;
                    }
                    dp[i][j] = Math.min(dp[i][j],dp[i][k] + dp[k][j]);
                }
            }
        }
        LinkedList<Integer> candidates = new LinkedList<>();
        for (int i = 0; i < R; i++) {
            candidates.add(r[i]);
        }
        int answer = Integer.MAX_VALUE;
        List<LinkedList<Integer>> target = permutation(candidates);
        for (LinkedList<Integer> x : target) {
            int prev = x.poll();
            int cost = 0;
            while(!x.isEmpty()) {
                int current = x.poll();
                cost += dp[prev][current];
                prev = current;
            }
            answer = Math.min(answer, cost);
        }
        System.out.println(answer);
    }
    public List<LinkedList<Integer>> permutation(LinkedList<Integer> candidate) {
        if (candidate.size() == 0) {
            List<LinkedList<Integer>> empty = new ArrayList<>();
            empty.add(new LinkedList<>());
            return empty;
        }
        List<LinkedList<Integer>> result = new ArrayList();
        for (int i = 0; i < candidate.size(); i++) {
            LinkedList<Integer> remain = new LinkedList<>(candidate);
            int removed = remain.remove(i);
            List<LinkedList<Integer>> sublist = permutation(remain);
            for (LinkedList<Integer> x : sublist) {
                x.add(0, removed);
                result.add(x);
            }
        }
        return result;
    }
}


Measured memory_bytes: 56232
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    Int k;
    cin >> s >> k;

    int ans;
    if (k == 1) {
        ans = s[0] - '0';
    } else {
        bool flag = true;
        for (int i = 0; i < k; i++) {
            if (s[i] != '1') {
                ans = s[i] - '0';
                flag = false;
                break;
            }
        }

        if (flag) {
            ans = s[0] - '0';
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int inputNum = sc.nextInt();

		for (int i = 0; i < inputNum; i++) {

			while (sc.hasNext()) {
				BigInteger a = sc.nextBigInteger();
				BigInteger b = sc.nextBigInteger();
				BigInteger sum = a.add(b);
				
				if (sum.toString().length() > 80) {
					System.out.println("overflow");
				} else {
					System.out.println(sum);
				}
			}
		}

	}

}

Measured memory_bytes: 26692
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long modpow(long long n,long long k){
    long long res=1;
    while(k>0){
        if(k&1)res=res*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return res;
}
int main(){
    long long n,k;scanf("%lld%lld",&n,&k);
    vector<long long> a(k+1);
    for(long long i=1;i<=k;i++)a[i]=modpow(k/i,n);
    for(long long i=k;i>=1;i--){
        for(long long j=i+i;j<=k;j+=i){
            a[i]=(a[i]+mod-a[j])%mod;
        }
    }
    long long ans=0;
    for(long long i=1;i<=k;i++)ans+=a[i]*i,ans%=mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b;
    cin>>a>>b;
    int n = a.length(), m = b.length();
    int dp[n+1][m+1];
    for(int i = 0; i <= n; i++) dp[i][0] = i;
    for(int j = 0; j <= m; j++) dp[0][j] = j;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            int temp = min(dp[i-1][j]+1, dp[i][j-1]+1);
            int c = (a[i-1] == b[j-1] ? 0 : 1);
            dp[i][j] = min(temp, dp[i-1][j-1]+ c);
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	ll d = (A1 * T1 + A2 * T2) - (B1 * T1 + B2 * T2);

	ll ans;

	if (d == 0) {
		cout << "infinity" << endl;
		return 0;
	}
	else if (d > 0) {
		if (A1 - B1 > 0) {
			cout << 0 << endl;
			return 0;
		}

		ans = (d - (A1 * T1 - B1 * T1)) / d * 2 - 1;

		if ((d - (A1 * T1 - B1 * T1)) % d == 0) --ans;
	}
	else {
		if (A1 - B1 < 0) {
			cout << 0 << endl;
			return 0;
		}

		d = -d;
		ans = (d + (A1 * T1 - B1 * T1)) / d * 2 - 1;

		if ((d - (A1 * T1 - B1 * T1)) % d == 0) --ans;
	}

	cout << ans << endl;


	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    int u[1000], v[1000], d[1000];
    for(int i = 0; i < m; i++) cin >> u[i] >> v[i] >> d[i];
    int t;
    cin >> t;
    for(int i = 0; i < t; i++){
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (k, n) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val m = a.indices.map {
        val next = (it + 1) % n
        (a[next] - a[it] + k) % k
    }.max()!!
    println(k - m)
}


Measured memory_bytes: 82684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int l=0,r=t.size()-1;
    while(l<=r)
    {
        swap(t[l],t[r]);
        l++;r--;
    }
    if(s<t) cout<<"Yes";
    else cout<<"No";
    puts("");
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int t, k;
    cin >> t;
    if(t==1)cout<<0;
    if(t==0)cout<<1;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdbool.h>

typedef struct {
    char suit;
    int num;
} card;

void BubbleSort(int n, card cards[]);
void SelectionSort(int n, card cards[]);
void swap(card *one, card *another);
bool judge_stable(int n, card cards01[], card cards02[]);

int main(void)
{
    int i;

    int n;
    scanf("%d", &n);

    card cards01[36], cards02[36];
    for (i = 0; i < n; i++) {
        scanf(" %c%d", &cards01[i].suit, &cards01[i].num);
        cards02[i] = cards01[i];
    }

    BubbleSort(n, cards01);
    for (i = 0; i < n; i++) {
        if (i != 0) {
            printf(" ");
        }
        printf("%c%d", cards01[i].suit, cards01[i].num);
    }
    printf("\n");
    printf("Stable\n");

    SelectionSort(n, cards02);
    for (i = 0; i < n; i++) {
        if (i != 0) {
            printf(" ");
        }
        printf("%c%d", cards02[i].suit, cards02[i].num);
    }
    printf("\n");
    bool isStable = judge_stable(n, cards01, cards02);
    if (isStable) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }

    return 0;
}

void BubbleSort(int n, card cards[])
{
    int i, j;

    for (i = 0; i < n; i++) {
        for (j = n - 1; j > i; j--) {
            if (cards[j].num < cards[j - 1].num) {
                swap(&cards[j], &cards[j - 1]);
            }
        }
    }
}

void SelectionSort(int n, card cards[])
{
    int i, j;
    int min;

    for (i = 0; i < n; i++) {
        min = i;
        for (j = i; j < n; j++) {
            if (cards[j].num < cards[min].num) {
                min = j;
            }
        }
        swap(&cards[i], &cards[min]);
    }
}

void swap(card *one, card *another)
{
    card tmp = *one;
    *one = *another;
    *another = tmp;
}

bool judge_stable(int n, card cards01[], card cards02[])
{
    int i;
    for (i = 0; i < n; i++) {
        if (cards02[i].suit != cards01[i].suit) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 612
N, T = map(int, input().split())
t = list(map(int, input().split()))

l = [t[0]]
for i in range(1, N):
    l.append(t[i] - t[i - 1])

ans = 0

for ll in l:
    if ll < T:
        ans += ll
    else:
        ans += T

print(ans + T)


Measured memory_bytes: 26708
xs,ys,xt,yt=list(map(int,input().split()))
N=int(input())
a=[]
for i in range(N):
	a.append(list(map(int,input().split())))

# xs,ys,xt,yt=[-1000000000, -1000000000, 1000000000, 1000000000]
# N=1
# a=[[-1000000000, 1000000000, 1]]

class Dijkstra(object):
	"""
	ダイクストラ法,(N^2)
	ステータス:distance(list),prev(list),size(int)
	distancemap[i][j]->Distance of edge i to j
	"""
	def __init__(self, distancemap, start):
		self.start=start
		self.size=len(distancemap)
		self.distance=[float("inf") for x in range(self.size)]
		self.distance[start]=0
		self.prev=[0 for x in range(self.size)]
		self.prev[start]=-1
		yet=list(range(self.size))
		yet.remove(start)
		now=start
		while(yet!=[]):
			nearest_num=0
			nearest_dis=float("inf")
			for i in yet:
				total_dis=distancemap[now][i]+self.distance[now]
				self.distance[i]=min(total_dis, self.distance[i])
				if self.distance[i]<=nearest_dis:
					nearest_dis=self.distance[i]
					nearest_num=i
			yet.remove(nearest_num)
			self.prev[nearest_num]=now
			now=nearest_num

	def route(self,goal):
		route=[]
		while(True):
			route.append(self.prev[goal])
			goal=self.prev[goal]
			if goal==self.start:
				break
		route.reverse()
		return(route)

import math
def solve(xs,ys,xt,yt,N,a):
	a.insert(0,[xs,ys,0])
	a.append([xt,yt,0])
	def distance(i,j):
		x1=a[i][0]
		y1=a[i][1]
		r1=a[i][2]
		x2=a[j][0]
		y2=a[j][1]
		r2=a[j][2]
		d=math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-r1-r2
		if d<0:
			d=0
		return(d)
	distancemap=[[0 for x in range(N+2)] for x in range(N+2)]
	for i in range(N+2):
		for j in range(N+2):
			if i>j:
				distancemap[i][j]=distancemap[j][i]
			else:
				distancemap[i][j]=distance(i,j)

	d=Dijkstra(distancemap, 0)
	return(d.distance.pop())

print(solve(xs, ys, xt, yt, N, a))


Measured memory_bytes: 73180
permutations = {
  ?E => [2, 1, 5, 0, 4, 3],
  ?N => [4, 0, 2, 3, 5, 1],
  ?S => [1, 5, 2, 3, 0, 4],
  ?W => [3, 1, 0, 5, 4, 2],
}
dice = gets.split.map(&:to_i)
gets.chomp.each_char do |d|
  p = permutations[d]
  dice = dice.each_with_index.sort_by {|_, i| p[i] }.map(&:first)
end
p dice[0]

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

int main(){
	int a=0,b=0;
	int n=0;
	cin>>a>>b;
	while((a*n-n+1)<b){
		n++;
	}
	cout<<n<<endl;

	return 0;

}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int A, B, X[100010], Y[100010];

void solve(int &pos, int &sum, int turn, int lr) {
    if(pos < 0) return;
    int* array = (turn ? X : Y);
    int  sz    = (turn ? A : B); 
    int idx = lower_bound(array, array + sz, pos) - array;

    if(lr) {
        if(idx >= sz) {
            pos = -1, sum = -1;
            return;
        }
        int npos = array[idx];
        sum += abs(pos - npos);
        pos = npos;
    }
    else {
        idx--;
        if(idx < 0) {
            pos = -1, sum = -1;
            return;
        }
        int npos = array[idx];
        sum += abs(pos - npos);
        pos = npos;
    }
}

signed main() {
    int Q; cin >> A >> B >> Q;
    for(int i=0; i<A; i++) {
        cin >> X[i];
    }

    for(int i=0; i<B; i++) {
        cin >> Y[i];
    }

    while(Q--) {
        int pos, ans = INF; cin >> pos;
        for(int bit=0; bit<(1<<3); bit++) {
            int cur = pos;
            int fst = (bit >> 0 & 1);
            int lr1 = (bit >> 1 & 1);
            int lr2 = (bit >> 2 & 1);

            int sum = 0;
            solve(cur, sum, fst    , lr1);
            solve(cur, sum, 1 - fst, lr2);
            if(cur < 0) continue;
            chmin(ans, sum);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
const int mod=998244353;
using namespace std;
int n,x[210],y[210];
int ksm(int a,int k){
	int ans=1;
	for(;k;k>>=1,a=1ll*a*a%mod) if(k&1) ans=1ll*a*ans%mod;
	return ans;
}
int main(){
	scanf("%d",&n);
	int ans=(ksm(2,n)-n-1-n*(n-1)/2+mod)%mod;
	for(int i=1;i<=n;i++) scanf("%d %d",&x[i],&y[i]);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			int tmp=0;
			for(int k=j+1;k<=n;k++){
				if(1ll*(x[i]-x[j])*(y[k]-y[j])==1ll*(x[k]-x[j])*(y[i]-y[j])) tmp++;
			}
			ans=(ans+mod+1-ksm(2,tmp))%mod;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n;
  cin >> n;
  double ans = 0;

  for (int i = 0; i < n; i++) {
    double x;
    cin >> x;
    string currency;
    cin >> currency;

    if (currency.compare("BTC") == 0) {
      ans += 380000.0 * x;
    } else if (currency.compare("JPY") == 0) {
      ans += x;
    }
  }

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

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

int main() {
	int n; cin >> n;
	vector<long long> arr(n);
	long long sm = 0;
	for (int i=0; i<n; i++) {
		cin >> arr[i];
		sm ^= arr[i];
	}
	for (int i=0; i<n; i++) {
		cout << (sm^arr[i]);
		cout << " ";
	}
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll MAX = 25;
const ll NIL = -1;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

struct Node {
  ll parent;
  ll left;
  ll right;
};

vector <Node> t(MAX);

void preParse(ll u) {
  if (u == NIL) {
    return;
  }
  cout << ' ' << u;
  preParse(t.at(u).left);
  preParse(t.at(u).right);
}

void inParse(ll u) {
  if (u == NIL) {
    return;
  }
  inParse(t.at(u).left);
  cout << ' ' << u;
  inParse(t.at(u).right);
}

void postParse(ll u) {
  if (u == NIL) {
    return;
  }
  postParse(t.at(u).left);
  postParse(t.at(u).right);
  cout << ' ' << u;
}

int main() {
  ll n;
  cin >> n;
  rep(i, n) {
    t.at(i).parent = NIL;
    t.at(i).left = NIL;
    t.at(i).right = NIL;
  }
  ll id, l, r;
  rep(i, n) {
    cin >> id >> l >> r;
    t.at(id).left = l;
    t.at(id).right = r;
    if (l != NIL) t.at(l).parent = id;
    if (r != NIL) t.at(r).parent = id;
  }
  ll tmp;
  rep(i, n) {
    if (t.at(i).parent == NIL) tmp = i;
  }
  cout << "Preorder" << endl;
  preParse(tmp);
  cout << endl;
  cout << "Inorder" << endl;
  inParse(tmp);
  cout << endl;
  cout << "Postorder" << endl;
  postParse(tmp);
  cout << endl;
}


Measured memory_bytes: 3116