akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		kochCurve(0, 0, 100, 0, 0, n);
		System.out.println(100.0 + " " + 0.0);
	}
	
	static void kochCurve(double x1, double y1, double x2, double y2 ,int k , int n) {
		if(k == n) {
			System.out.println(x1 + " " + y1);
			return;
		}
		
		double l = 100 / Math.pow(3, k+1);
		
		double xs = (x2 - x1) / 3 + x1;
		double ys = (y2 - y1) / 3 + y1;
		double xt = (x2 - x1) * 2 / 3 + x1;
		double yt = (y2 - y1) * 2 / 3 + y1;
		
		double dif = 0;
		double xu;
		double yu;
		dif = (-1) / ((y2 - y1) / (x2 - x1));
		if((dif > 0 && x1 < x2) || (dif < 0 && x1 > x2)) {
			xu = ((x1 + x2) / 2) + (Math.sqrt(3) * l) / (2 * Math.sqrt(dif * dif + 1));
		} else {
			xu = ((x1 + x2) / 2) - (Math.sqrt(3) * l) / (2 * Math.sqrt(dif * dif + 1));
		}
		if(x1 < x2) {
			yu = ((y1 + y2) / 2) + (Math.sqrt(3) * l) / (2 * Math.sqrt((1/dif) * (1/dif) + 1));
		} else {
			yu = ((y1 + y2) / 2) - (Math.sqrt(3) * l) / (2 * Math.sqrt((1/dif) * (1/dif) + 1));
		}
		
		k++;
		
		kochCurve(x1, y1, xs, ys, k, n);
		kochCurve(xs, ys, xu, yu, k, n);
		kochCurve(xu, yu, xt, yt, k, n);
		kochCurve(xt, yt, x2, y2, k, n);
	}
	
	static class FastScanner {
	    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;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); 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() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}

}

Measured memory_bytes: 30356
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
void solve(){
    ll a , b ;
    cin >> a >> b ;
    set < int > s ;
    s.insert(1);
    int ans = 1 ;
    for( ll i =  2 ; i*i <= a ; i++){
        if(a%i==0){
            s.insert(i);
            //cout << i << " " ;
            while(a%i==0){
                a/=i;
            }
        }
    }
    if(a!=1){
        s.insert(a);
    }
    for( ll i = 2 ; i*i <= b ; i++){
        if(b%i==0){
            if(s.find(i)!=s.end()) ans++;
            while(b%i==0){
                b/=i;
            }
        }
    }
    if(b!=1){
        if(s.find(b)!=s.end()) ans++;
    }
    cout << ans ;

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
   //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;
using Graph = vector<vector<int>>;

int main() {
  int a, b, c;
  int x, y;
  cin >> a >> b >> c >> x >> y;

  int n = a * x + b * y;

  int m = 2 * c * max(x, y);

  int p = x < y ? b : a;
  int l = 2 * c * min(x, y) + p * abs(x - y);

  int ans = min(n, min(m, l));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,m,k,a,b,c;
	scanf("%d%d%d",&a,&b,&c); 
	
	
	
	printf("%d %d %d",c,a,b);
    return 0;
}




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

using namespace std;

int main(){
    int N,M; 
    cin >> N >> M;
    int H[100010],MA[100010];

    for(int i=1; i<=N; i++){
        cin >> H[i];
        MA[i] = 0;
    }

    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        MA[a] = max(MA[a],H[b]);
        MA[b] = max(MA[b],H[a]);
    }
    int ans = 0;
    for(int i=1; i<=N; i++){
        if(H[i] > MA[i]) {
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1005,mo=1e9+7;
int n,dis[N],f[N][N],l;Vi e[N];
void dfs1(int u, int fa, int dep, int &x){
	umax(x,dep);for(int v:e[u])if(v!=fa)dfs1(v,u,dep+1,x);
}
void dfs(int u, int fa, int dep){
	for(int v:e[u])if(v!=fa)dfs(v,u,dep+1);
	rep(i,0,l-dep)f[u][i]=1;f[u][l-dep+1]=f[u][l-dep+2]=0;
	for(int v:e[u])if(v!=fa)rep(i,0,l-dep)
		f[u][i]=1ll*f[u][i]*(f[v][i]+(i-1>=0?f[v][i-1]:0))%mo;
}
int getans(int u, int v){
	dfs(u,v,0);dfs(v,u,0);
	static int g[N][N];memcpy(g,f,sizeof(f));
	l++;dfs(u,v,0);dfs(v,u,0);l--;
	int res=0;
	rep(x,0,l){
		res=(res+1ll*g[u][x]*g[v][x])%mo;
		if(x)res=(res+1ll*g[u][x]*g[v][x-1])%mo;
		res=(res+1ll*(f[u][x+1]-g[u][x]-g[u][x+1])*g[v][x])%mo;
		res=(res+1ll*g[u][x]*(f[v][x]-g[v][x]-(x-1>=0?g[v][x-1]:0)))%mo;
	//	res=(res+1ll*f[u][x+1]*g[v][x]+1ll*g[u][x]*f[v][x]-1ll*g[u][x]*g[v][x])%mo;
	//	if(x)res=(res+1ll*g[u][x]*f[v][x]+1ll*f[u][x]*g[v][x-1]-1ll*g[u][x]*g[v][x-1])%mo;
	}
//	printf("qwq %d %d %d:%d %d\n",u,v,l,res,f[u][l+1]);
	return res;
}
int main() {
	read(n);rep(i,1,n-1){
		int u,v;read(u);read(v);e[u].pb(v);e[v].pb(u);
	}
	int rt=1;
	rep(i,1,n){int x=0;dfs1(i,0,0,x);dis[i]=x;if(dis[i]<dis[rt])rt=i;}
	l=dis[rt];int mx=0;rep(i,1,n)umax(mx,dis[i]);
	if(mx&1){
		int u=rt,v=0;rep(i,1,n)if(i!=u&&dis[i]==dis[u])v=i;
		l=mx/2;
		int res=((getans(u,v)+getans(v,u))%mo+mo)%mo;
		cout<<res;return 0;
	}
	dfs(rt,0,0);
	int res=0;rep(i,0,l)res=(res+f[rt][i])%mo;cout<<res<<endl;
//	rep(i,0,l)cerr<<i<<' '<<f[rt][i]<<endl;
	return 0;
}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int r = sc.nextInt();
            if(n == 0 && r == 0){
                break;
            }
            int[] card = new int[n];
            for(int i = 0; i < n; i++){
                card[i] = i + 1;
            }
            for(int i = 0; i < r; i++){
                int p = sc.nextInt();
                int c = sc.nextInt();
                int[] cutcard = new int[c];
                for(int j = 0; j < c; j++){
                    cutcard[j] = card[n - p - c + j + 1];
                }
                for(int j = 0; j < p - 1; j++){
                    card[n - p - c + j + 1] = card[n - p + j + 1];
                }
                for(int j = 0; j < c; j++){
                    card[n - c + j] = cutcard[j];
                }
            }
            System.out.println(card[n - 1]);
        }
        sc.close();
    }
}


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

int main(){
    int N; cin >> N;
    vector <int> A(N+1);
    vector <int> B(N);
    rep(i,N+1) cin >> A[i];
    rep(i,N) cin >> B[i];
    
    long long ans=0;
    //N人の勇者チャレンジ
    rep(i,N){
        int sen=B[i]-A[i];
        if (B[i]>=A[i] && (sen < A[i+1])){//隣町の全ボスまでを倒す戦闘力がないとき
            ans=ans+A[i]+sen;
            A[i+1]-=sen;//隣町のボスにダメージを与えとく
        }
        else if (B[i]>A[i] && (sen >= A[i+1])){//隣町の全ボスも倒すことができるとき
            ans=ans+A[i]+A[i+1];
            A[i+1]=0;
        }else if (B[i]<A[i]){//最初の町の全ボスすらも倒せないとき
            ans+=B[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	if (c >= a & c <= b) {
		cout << "Yes" << endl;
		return 0;
	}


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


Measured memory_bytes: 256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define END(s)          {cout<<s; return 0;}
#define CON(s)          {cout<<s; continue;}
#define BRE(s)          {cout<<s; break;}
#define pb              push_back
#define All(a)          a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n;
ll a[440];
ll s[440];
ll dp[440][440];

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) s[i + 1] = s[i] + a[i];
	memset(dp, 0x3f, sizeof(dp));
	rep(i, n) dp[i][i] = 0;
	for(int len = 1; len < n; len++){
		for(int i = 0; i < (n - len); i++){
			int j = i + len;
			ll val = s[j + 1] - s[i];
			for(int k = i; k < j; k++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + val);
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  string S; cin >> S;
  map<char,ll> map;
  for (ll i = 0; i < S.size(); ++i) map[S[i]] += 1;
  if (map.size() == 2 && map[S[0]] == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
int k = 0;
int dfs(vector<int> adj[], int a[], int sv, int n, bool vis[], int val[]){
    vis[sv] = true;
    val[sv] = a[k++];
    int s = 0;
    for(int i = 0; i < adj[sv].size(); i++){
        if(!vis[adj[sv][i]])
        s += dfs(adj, a, adj[sv][i], n, vis, val);
        else
        s += min(val[sv], val[adj[sv][i]]);
    }
    return s;
}
int main(){
  int n;
  cin >> n;
   int a[n];
   int u, v;
  vector<int> adj[n+1];
  for(int i = 0 ; i < n - 1; i++){
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
  }
  for(int i = 0; i < n; i++)
  cin >> a[i];
  int val[n+1];
  memset(val, -1, sizeof(val));
  bool vis[n+1];
  memset(vis, false, sizeof(vis));
  sort(a, a + n, greater<int>());
  cout << dfs(adj, a, 1, n, vis, val) << endl;
  for(int i = 1; i <= n; i++)
  cout << val[i] << " ";
  return 0;
}

Measured memory_bytes: 1920
// 0098.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(long long a=0;a<t;a++) 
//#define startfor(a,b,t) for(long long a=b;a<t;a++)
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	ll sum[105][105];
	ll ans = -9223372036854775;
	cin >> n;
	roop (i, n) {
		roop(j, n) {
			cin >> sum[i][j];
			if (j > 0) { sum[i][j] += sum[i][j - 1]; }
			ans = max(ans, sum[i][j]);
		}
	}
	for (ll j = 0; j < n; j++) {
		for (ll i = 0; i < n; i++) {			
			if (i > 0) 
			{ 
				sum[i][j] += sum[i - 1][j]; 
			}
			ans = max(ans, sum[i][j]);
		}
	}

	for (ll ix = -1; ix < n-1; ix++) {
		for (ll jx = ix + 1; jx < n; jx++) {
			for (ll iy = -1; iy < n - 1; iy++) {
				if (ix == iy&&ix == -1) { continue; }
				for (ll jy = iy + 1; jy < n; jy++) {
					ll jxjy = sum[jx][jy];
					ll jxiy = sum[jx][iy];
					ll ixjy = sum[ix][jy];
					ll ixiy = sum[ix][iy];
					if (ix == -1) { ixiy = 0; ixjy = 0; }
					if (iy == -1) { jxiy = 0; ixiy = 0; }

					ll s = jxjy - ixjy - jxiy + ixiy;
					ans = max(ans, s);
				}
			
			}
		}
	}

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


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

int main() {
    long long dp[21][2];
    int N;

    cin >> N;

    int num[N];

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

    for(int k=0; k<=20; ++k) dp[k][0]=0, dp[k][1]=0;
    dp[num[0]][0]=1;
    for(int i=1; i<N-1; ++i) {
        for(int k=0; k<=20; ++k) dp[k][i%2]=0;
        for(int k=0; k<=20; ++k) {
            if(k+num[i]<=20) dp[k+num[i]][i%2]+=dp[k][(i-1)%2];
            if(k-num[i]>=0)  dp[k-num[i]][i%2]+=dp[k][(i-1)%2];
        }
    }
    cout << dp[num[N-1]][(N-2)%2] << endl;
    return 0;
}



Measured memory_bytes: 3020
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 1 << 29;
int N, M;
int a[51];
int b[51];
int c[51];
int d[51];

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

    cin >> N >> M;
    for(int i = 0; i < N; ++i){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < M; ++i){
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i < N; ++i){
        int dis = INF;
        int ans = 0;
        for(int j = 0; j < M; ++j){
            int x = abs(a[i] - c[j]);
            int y = abs(b[i] - d[j]);
            if(dis > x + y){
                ans = j + 1;
                dis = x + y;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solution(n int, nums []int) int {
	var ans int = 1 << 31
	for i := 1; i <= 100; i++ {
		sum := 0
		for j := 0; j < n; j++ {
			x := nums[j] - i
			sum += x * x
		}
		ans = min(ans, sum)
	}
	return ans
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		nums[i], _ = strconv.Atoi(sc.Text())
	}

	fmt.Println(solution(n, nums))
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

int main() {
    int k;
    cin >> k;

    ll ans = 0;
    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= k; j++) {
            for(int l = 1; l <= k; l++) {
                ans += gcd(gcd(i, j), l);
            }
        }
    }

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],b[100005],ans,ans1;
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("milkvisits.in","r",stdin);
    //freopen("milkvisits.out","w",stdout);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x;
        string s;
        cin>>x>>s;
        if(s[0]=='A'&&a[x]==0)
        {
            a[x]=1;
            ans++;
            ans1+=b[x];
            b[x]=-1;
        }
        if(s[0]=='W'&&b[x]!=-1)b[x]++;
    }
    cout<<ans<<' '<<ans1;
}


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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<string> s(n);
	REP(i, n) cin >> s[i];
	int ans = 0;
	REP(i, n){
		bool flg = true;
		REP(x, n){
			REP(y, n){
				if(s[(x + i) % n][y] != s[(y + i) % n][x]){
					flg = false;
					x = y = n;
				}
			}
		}
		if(flg) {
			ans += n;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int L,R,d,count=0;
    cin >> L >> R >> d;
    for (int i = L; i <= R; i++)
    {
        if (i%d == 0)
        {
            count++;
        }
        
    }
    cout << count << endl;
    return 0;
}


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

typedef long long ll;
const ll MOD = ll(1e9) + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  string str;
  cin >> str;
  int K;
  cin >> K;
  string res = str;
  for(char& c : res) {
    for(char d = 'a'; d<='z' ;++d) {
      const int need = (d-c+26)%26;
      if(need <= K) {
        K -= need;
        c = d;
        break;
      }
    }
  }
  K %= 26;
  while (K-- > 0)
    if (++res.back() > 'z')
      res.back() = 'a';
  cout << res << endl;
  return 0;
};

Measured memory_bytes: 640
N = int(input())
T, A = [], []
for _ in range(N):
    t, a = tuple(map(int, input().split()))
    T.append(t)
    A.append(a)
x, y = 1, 1
for t, a in zip(T, A):
    n = max(-(-x // t), -(-y // a))
    x = n * t
    y = n * a
print(x + y)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>

typedef long long int64;

static int total(const std::vector<int>& xs, int p) {
  int sum = 0;
  for (auto x : xs) {
    sum += (x - p) * (x - p);
  }
  return sum;
}

int main(void) {
  int n;
  std::cin >> n;
  std::vector<int> xs;
  for (int i = 0; i < n; i++) {
    int x;
    std::cin >> x;
    xs.push_back(x);
  }

  int min = INT_MAX;
  for (int i = 1; i <= 100; i++) {
    int sum = total(xs, i);
    min = std::min(sum, min);
  }
  std::cout << min << std::endl;
  return 0;
}


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

int main() {
    long long n, m = 0;
    std::cin >> n;
    std::vector<long long> a(n), b(n);
    for (auto i = 0ll; i < n; i++) {
        std::cin >> a[i];
        if (m < a[i]) m = a[i];
    }
    for (auto i = 0ll; i < n; i++) {
        std::cin >> b[i];
    }

    auto ret = 0ll;
    for (auto i = 0ll; (1ll << i) <= m + b.back(); i++) {
        auto count = 0ll;
        auto s = 1ll << i;
        auto mod = s << 1ll;
        std::vector<long long> b2(n);
        for (auto j = 0ll; j < n; j++) b2[j] = (b[j] % mod);
        std::sort(b2.begin(), b2.end());
        for (auto c : a) {
            c = (c % mod);
            auto t = std::lower_bound(b2.begin(), b2.end(), s - c);
            auto t2 = std::upper_bound(b2.begin(), b2.end(), 2 * s - c - 1);
            auto t3 = std::lower_bound(b2.begin(), b2.end(), 3 * s - c);
            auto t4 = std::upper_bound(b2.begin(), b2.end(), 4 * s - c - 1);
            count += (t2 - t) + (t4 - t3);
        }
        if (count % 2 == 1) ret += (1ll << i);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s
int a, b, x, y;

void extgcd(int a, int b, int& x, int& y)
{
	x = 1;
	y = 0;
	if (b != 0)
	{
		extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
}

int main()
{
	cin >> a >> b;
	extgcd(a, b, x, y);
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 1164
x,n=map(int,input().split())
if(n==0):
  print(x)
else:
  l=list(map(int,input().split()))
  d=100
  for i in range(102):
      if(i not in l and (abs(i-x)<d)):
          d=abs(x-i)
          m=i
  print(m)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
ll n,x;
cin >> n >> x;
vector<ll> a(n);
rep(i,n) cin >> a.at(i);
vector<ll> b(n);
rep(i,n)b.at(i) = abs(a.at(i)-x);
ll ans;
rep(i,n-1){
  if(i == 0) ans = gcd(b.at(i),b.at(i+1));
  else ans = gcd(ans,b.at(i));
}
  if(n==1)ans = b.at(0);
cout << ans << endl;
}


Measured memory_bytes: 4648
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]



a, b = map(int, input().split())

print(a*b - (a+b-1))


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

int main(void){
	int d;
	cin >> d;
	if(d%7 == 2) cout << "sat";
	else if(d%7 == 3) cout << "sun";
	else if(d%7 == 4) cout << "mon";
	else if(d%7 == 5) cout << "tue";
	else if(d%7 == 6) cout << "wed";
	else if(d%7 == 0) cout << "thu";
	else cout << "fri";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    set <int> st[26];
    s = "#" + s;
    for(int i = 1; i <= n; ++i) {
        st[s[i] - 'a'].ins(i); 
    }
    int t;
    cin >> t;
    while(t -- ) {
        int o;
        cin >> o;
        if(o == 1){
            int i;
            char c;
            cin >> i >> c;
            char tmp = s[i];
            st[tmp - 'a'].erase(i);
            s[i] = c;
            st[c - 'a'].ins(i);
        }
        else {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for(int i = 0; i < 26; ++i) {
                ans += st[i].lower_bound(l) != st[i].end() && *st[i].lower_bound(l) <= r;
            }
            cout << ans << "\n";
        }
    }
}


 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 24240
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main(int argc, char** argv)
{
    string S;
    cin >> S;
    int zero = 0, one = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] - '0' == 1) one++;
        else zero++;
    }
    cout << 2 * min(zero, one) << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  int n, m, s, a;
  cin >> n >> m;

  s = 0;
  rep(i, m) {
    cin >> a;
    s += a;
  }

  int r = n - s;
  if (r < 0) {
    r = -1;
  }
  cout << r << endl;
}


Measured memory_bytes: 3648
from sys import exit

N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

def valid(i, j):
    for a, b in zip(A[i:i+M], B):
        if a[j:j+M] == b:
            continue
        else:
            return False
    return True
if N > M:
    for i in range(N-M):
        for j in range(N-M):
            if valid(i, j):
                print("Yes")
                exit()
else:
    if valid(0,0):
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
int a,b,c,d,ans,N,K,q[107][107];
int main(){
	scanf("%d%d",&N,&K);
	if (K>(N-1)*(N-2)/2) printf("-1\n");
	else{
		K=(N-1)*(N-2)/2-K;
		printf("%d\n",N+K-1);
		rep(i,2,N) printf("%d %d\n",1,i);
		rep(i,2,N) rep(j,i+1,N){
			if (K>0) printf("%d %d\n",i,j);K--;
		}
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int l ,r,d;
        cin>>l>>r>>d;
        cout<< r/d - (l-1)/d;
    }
    return 0;
}


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

bool check(int n)
{
    //cout<<n<<endl;
    if (n<5)
    {
        if ((n==2) or (n==3)) { return 1;}
        else {return 0;};
    }
    else
    {
        if ((((n-1) % 6)==0) or (((n+1) % 6)==0)) 
        {
            for (unsigned int i=2;i<=roundf(sqrt(n));++i)
            {
                if (n%i==0) {return 0;}
            }
            return 1;
        }
    }
}

int soNguyenTo(int soA)
{
    if (soA < 2)    
        return 0;

    for (int i = 2; i <= sqrt((float)soA); i ++)
    {
        if (soA%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
    unsigned int x;
    cin>>x;
    while (!soNguyenTo(x))
    {
        ++x;
    }
    cout<<x;
    return 0;
}

Measured memory_bytes: 256
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];
const [d, x] = input[1].split(" ").map((x: string): number => +x);
const a: Array<number> = [];
for (let i = 0; i < n; i++) {
	a.push(+input[i + 2]);
}

let sum = x;
for (const delta of a) {
	sum += 1 + Math.floor((d - 1) / delta);
}

console.log(sum);


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

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

  int ans = 1;
  for (int i=0; i<N; i++) {
    int a = ans * 2;
    int b = ans + K;

    if (a < b) ans = ans * 2;
    else ans = ans + K;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if(a+b>=c)cout<<b+c<<endl;
  else cout<<a+b+b+1<<endl;
}

Measured memory_bytes: 3572
n, c = gets.to_s.split.map{|t| t.to_i }

d = [[0] * (c+1) ] + Array.new(c){ [0] + gets.to_s.split.map{|t| t.to_i } }
grid = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }

counters = Array.new(3){ Array.new(c+1){ 0 } }

# O(N^2)
n.times do |i|
  n.times do |j|
    counters[(i+j)%3][grid[i][j]] += 1
  end
end
# p counters
# O(cP3)
ans = n * n * 1000
1.upto(c) do |s|
  1.upto(c) do |t|
    next if s == t
    1.upto(c) do |u|
      
      next if s == u || t == u
      
      cost = 0
      
      counters[0].each_with_index do |cnt, col|
        next if col == s
        cost += d[col][s] * cnt
      end
      
      counters[1].each_with_index do |cnt, col|
        next if col == t
        cost += d[col][t] * cnt
      end
      
      counters[2].each_with_index do |cnt, col|
        next if col == u
        cost += d[col][u] * cnt
      end
      
      ans = cost if ans > cost
    end
  end
end

puts ans

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

int main(){
	int i,n,k;
	char s[11];
	scanf("%d",&n);
	scanf("%s",s);
	scanf("%d",&k);
	k--;
	for(i=0;i<n;i++){
		if(s[k]=='\0')break;
		if(s[k]!=s[i])s[i]='*';
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  char s;
  cin>>s;
  char ans;
  if(s == 'A') ans = 'T';
  if(s == 'T') ans = 'A';
  if(s == 'C') ans = 'G';
  if(s == 'G') ans = 'C';
  print(ans);
  return 0;
}

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

int main() {
  int l;cin>>l;
  double n=(double)l/3;
  double ans=n*n*n;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 INF = 1LL << 60;

int main(){
  int n, t, a; cin >> n >> t >> a;

  double mi = 1001001001;
  int x;
  rep(i, n){
    int h; cin >> h;
    double tem = t - h * 0.006;
    if(chmin(mi, abs(a-tem))) x = i + 1;
  }

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b >> c;
	sum = a + b + c;
	cout << sum - max(max(a, b), c) << rt;
	please AC;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<numeric>

#define INF (1<<28)
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=(j);i<=(k);i++)
#define fs first
#define sc second
#define pb push_back

using namespace std;

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

int dp1[3][1000000];
int dp2[3][1000000];
int main(){
	vi v1,v2;
	for(int i=1;;i++){
		int t = i * (i+1) * (i+2) / 6;
		if (t > 1000000) break;
		v1.pb(t);
		if(t&1)v2.pb(t);
	}
	rep(i,1000000) dp1[0][i] = dp2[0][i] = i;
	rep(i,v1.size()-1){
		int n = (i+1)&1,c = i&1;
		rep(j,1000000){
			dp1[2][j] = dp1[n][j] = dp1[c][j];
			if(j>=v1[i+1])
				dp1[2][j] = dp1[n][j] = min(dp1[n][j], dp1[n][j-v1[i+1]] + 1);
		}
	}
	rep(i,v2.size()-1){
		int n = (i+1)&1, c = 1&i;
		rep(j,1000000){
			dp2[2][j] = dp2[n][j] = dp2[c][j];
			if(j>=v2[i+1])
				dp2[2][j] = dp2[n][j] = min(dp2[n][j], dp2[n][j-v2[i+1]]+1);
		}
	}
	int n;
	while(cin>>n,n){
		cout << dp1[2][n] << " " << dp2[2][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 24656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

#define in(a,b,c) make_pair(a,pii(b,c))

signed main(void) {
    int h,w,k;
    cin >> h >> w >> k;
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    sx--,sy--,gx--,gy--;
    vs s(h);
    rep(i,h)cin >> s[i];
    vvi d(h,vi(w,INF));
    queue<pip> q;
    rep(i,4){
        d[sx][sy] = 0;
        q.push(in(0,sx,sy));
    }
    int dx[] = {0,1,0,-1};
    int dy[] = {1,0,-1,0};
    while(q.size()){
        pip p = q.front();
        int x = p.second.first;
        int y = p.second.second;
        q.pop();
        rep(i,4)rep(j,k){
            int nx = x + (j+1)*dx[i];
            int ny = y + (j+1)*dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
            if(s[nx][ny] == '@')break;
            int ne = d[x][y] + 1;
            if(d[nx][ny] > ne){
                d[nx][ny] = ne;
                q.push(in(d[nx][ny],nx,ny));
            }else
            if(d[nx][ny] < ne)break;
        }
    }

    int ans = d[gx][gy];
    if(ans == INF) {
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 20068
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (x2 - x1)
y4 = y3 - (y2 - y1)
print("{} {} {} {}".format(x3, y3, x4, y4))

Measured memory_bytes: 2940
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int eval(int n, const vector<vector<int>>& f, const vector<vector<int>>& p, int set){
    vector<int> c(n);
    for(int i = 0; i < 10; i++){
        if((set & (1 << i)) == 0){
            continue;
        }
        for(int j = 0; j < n; j++){
            if(f[j][i]){
                c[j]++;
            }
        }
    }

    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += p[i][c[i]];
    }
    return sum;
}


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

    vector<vector<int>> f(n, vector<int>(10));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }

    vector<vector<int>> p(n, vector<int>(10 + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }

    int ans = eval(n, f, p, 1);
    for(int set = 2; set < 1024; set++){
        ans = max(ans, eval(n, f, p, set));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut ok = 0;
    let mut ng = n;
    println!("0");
    let s = scan.chars();
    if s[0] == 'V' {return;}
    let left = if s[0] == 'M' {0} else {1};
    loop {
        let mid = (ok + ng) / 2;
        println!("{}", mid);
        let s = scan.chars();
        if s[0] == 'V' {
            return;
        }
        let k = (mid % 2) ^ (s[0] == 'F') as usize;
        if left == k {
            ok = mid+1;
        } else {
            ng = mid;
        }
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4948
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;

    int max = 0;
    vector <int> p(N);

    for(int i = 0; i < N; i++){
        cin >> p[i];
        if (max <= p[i]) {
            max = p[i];
        }
    }
    
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += p[i];
    }
    
    sum -= max / 2;
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args){
		int a=0;
		int b[][]=new int[3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				b[i][j]=scan.nextInt();
			}
		}
		a=b[0][0];
		int b1=b[0][0];
		int b2=b[1][0];
		int b3=b[2][0];
		int a2=b[0][1]-b1;
		int a3=b[0][2]-b1;
		if(b2+a2==b[1][1]&&b3+a2==b[2][1]&&b2+a3==b[1][2]&&b3+a3==b[2][2]) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    string o,e,str;
    int len;
    
    cin>>o>>e;
    len=o.size()+e.size();
    for(int i=0;i<len;i++){
        if(i%2==0)cout<<o[i/2];
        else cout<<e[i/2];
    }
    cout<<endl;
    
    return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main()
{
  string s;
  int i;
  bool f;
  while(getline(cin,s),s[0]!='.'){
    stack<char> st;
    f=true;
    for(i=0;i<s.size();i++){
      if(s[i]=='('||s[i]=='['){
	st.push(s[i]);
      }else if(s[i]==')'||s[i]==']'){
	if(!st.empty()&&(st.top()+1==s[i]||st.top()+2==s[i]))st.pop();
	else f=false;
      }
    }
    puts(f&&st.empty()?"yes":"no");
  }
}

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

int main(){

    int table[]={31,28,31,30,31,30,31,31,30,31,30,31};

    int x,y;
    cin>>x>>y;
    cout<<(table[x-1]==table[y-1]?"Yes":"No")<<endl;






    return 0;
}

Measured memory_bytes: 256