akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

constexpr int modulo = 1000000007;

template <size_t N, size_t MaxPrimeSize>
struct primes_t {
  constexpr static size_t maxPrimeSize = MaxPrimeSize;
  constexpr primes_t() : primes(), count(), notSieves() {
    primes[count++] = 2;
    notSieves[0] = notSieves[1] = true;
    for (int i = 2; i < N; i++) {
      if (notSieves[i]) {
        continue;
      }
      primes[count++] = i;
      for (int64_t j = 2; i * j < N; j++) {
        notSieves[i * j] = true;
      }
    }
  }
  int64_t primes[MaxPrimeSize];
  int count;

 private:
  bool notSieves[N];
};

static constexpr auto primes = primes_t<1001, 169>{};

std::vector<int> primeFactorization(int n) {
  std::vector<int> ret{};
  int const maxPrimteCandidate = static_cast<int>(sqrt(n));
  for (int i = 0;; i++) {
    auto const prime = primes.primes[i];
    if (n <= 1 || prime > maxPrimteCandidate) {
      break;
    }
    while (n % prime == 0) {
      ret.push_back(prime);
      n /= prime;
    }
  }
  if (n > 1) {
    ret.push_back(n);
  }
  return ret;
}

int solve(int n) {
  if (n == 1) {
    return 1;
  }
  std::vector<int> allFactors{};
  for (int i = 2; i <= n; i++) {
    auto factors = primeFactorization(i);
    allFactors.insert(allFactors.end(), factors.begin(), factors.end());
  }
  std::sort(allFactors.begin(), allFactors.end());
  int64_t ret = 1;
  for (auto itr = allFactors.begin(); itr != allFactors.end();) {
    auto const nextItr = std::upper_bound(itr, allFactors.end(), *itr);
    ret *= ((nextItr - itr) + 1);
    ret %= modulo;
    itr = nextItr;
  }
  return static_cast<int>(ret);
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


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


// 2011/10/23

// 0078 ûw
public class Main {

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int size = readIntArray()[0];
		if (size == 0)
			return false;
		                       
		int[][] map = new int[size][size];
		
		int x = size / 2;
		int y = size / 2 + 1;
		
		for(int i = 1; i <= size * size; i++) {
			if (map[x][y] != 0) {
				x = (x - 1+size) % size;
				y = (y + 1) % size;
			}
			map[x][y] = i;
			x = (x + 1) % size;
			y = (y + 1) % size;
		}
		
			
		// ðÌ\¦
		for( y = 0; y < size; y++) {
			for( x = 0; x < size; x++) {
				System.out.printf("%4d", map[x][y]);
			}
			System.out.printf("\n");
		}
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "5:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

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

int main() {
  int M, D;
  cin >> M >> D;

  int sum = 0;
  for (int i = 1; i <= M; i++) {
    for (int j = 22; j <= D; j++) {
      int d1 = j % 10;
      if (d1 < 2) continue;
      int d10 = (j - d1) / 10;
      if (i == d1 * d10) sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int val[MAX_N];

class UF {
private:
    int sz;
public:
    vector<int> kind;   //所属しているグループ番号
    vector<vector<int> > inc;   //グループのメンバー
    UF(){}
    UF(int node_size){ sz = node_size; kind.resize(sz),inc.resize(sz); rep(i,sz){ kind[i] = i; inc[i].pb(i); } }
    bool same(int a,int b){ return kind[a] == kind[b]; }
    void unite(int a,int b)
    { if(same(a,b)) return; if(inc[kind[a]].size() < inc[kind[b]].size()) swap(a,b);
        int ga = kind[a],gb = kind[b]; rep(i,inc[gb].size()) kind[inc[gb][i]] = ga;
        inc[ga].insert(inc[ga].end(),inc[gb].begin(),inc[gb].end()); inc[gb].clear(); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = len(s);
    vi vec(n+1);
    rep(i,n+1){
        if(i == 0){
            vec[i] = (s[i]-'a')%26;
        }else if(i == n){
            vec[i] = (26-(s[i-1]-'a'))%26;
        }else{
            vec[i] = ((s[i]-'a')+26-(s[i-1]-'a'))%26;
        }
    }
    int q;
    cin >> q;
    UF uf(n+1);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        uf.unite(l-1,r);
    }
    rep(i,n+1){
        uf.unite(i,n-i);
    }
    rep(i,n+1){
        int val = 0;
        if(len(uf.inc[i])){
            rep(j,len(uf.inc[i])){
                val += vec[uf.inc[i][j]];
            }
        }
        if(val % 26){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        if(n==0){
            System.out.println(x);
            System.exit(0);
        }
        int number[] = new int[201];
        Arrays.fill(number,1);
        for(int i=0;i<n;i++){
            int p = sc.nextInt();
            number[p]=0;
        }
        for(int i=0;i<=200;i++){
            if(x-i <= 0)continue;
            if(x+i > 200)continue;
            if(number[x-i]==1){
                System.out.println(x-i);
                System.exit(0);
            }
            if(number[x+i]==1){
                System.out.println(x+i);
                System.exit(0);
            }
        }
        System.out.println(0);//配列全て0で埋まっている
    }
}

class Monmo {
    
}



Measured memory_bytes: 35732
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll INF = (1LL << 60);

int N, K;
vector<int> H;

void input(){
    cin >> N >> K;
    H.resize(N);
    for (int i = 0; i < N; ++i)
        cin >> H[i];
}

int main(){
    input();

    vector<vector<ll>> DP(N, vector<ll>(N + 1, INF));
    DP[0][0] = 0;
    DP[0][1] = H[0];

    for (int i = 1; i < N; ++i){
        DP[i][0] = 0;
        DP[i][1] = H[i];
        for (int j = 2; j <= N; ++j){
            ll tmp = INF;
            for (int k = 0; k < i; ++k)
                tmp = min(tmp, DP[k][j - 1] + max(0, H[i] - H[k]));
            DP[i][j] = tmp;
        }
    }

    /*
    for (int i = 0; i < N; ++i){
        for (int j = 0; j <= N; ++j){
            if (DP[i][j] == INF) cout << "INF ";
            else cout << DP[i][j] << " ";
        }
        cout << endl;
    }
    */

    ll res = INF;
    for (int i = 0; i < N; ++i)
        res = min(res, DP[i][N - K]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]

ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]

i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())

ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]

def main(N, Q, S, lrs):
    S2 = [0] * (N)
    for i in range(1, N):
        if S[i-1] == 'A' and S[i] == 'C':
            S2[i] = S2[i-1] + 1
        else:
            S2[i] = S2[i-1]
    for l, r in lrs:
        count = S2[r-1] - S2[l-1] 
        print(count)

N, Q = i2nn()
S = i2s()
lr = ss2nnn(ii2ss(Q))
main(N, Q, S, lr)


Measured memory_bytes: 29188
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m;
string str, ans, ansbuf;

bool hantei(bool last, bool first){
	bool left  = last;
	bool now = first;
	bool right;
	ansbuf = "";
	
	for(ll i = 0; i < n; i++){
		ansbuf += (now)? "S" : "W";
		if(str[i] == 'o'){
			right = (now)? left : !left;
		}
		else{
			right = (now)? !left : left;
		}
		left = now;
		now = right;
	}
	return left == last && now == first;
}

int main() {
	cin >> n >> str;
	
	ans = "-1";
	ans = hantei(true, true)? ansbuf : ans;
	ans = hantei(true, false)? ansbuf : ans;
	ans = hantei(false, true)? ansbuf : ans;
	ans = hantei(false, false)? ansbuf : ans;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
const int MAXINT=200;
int dx[6]={1,-1,0,0,1,-1};
int dy[6]={0,0,1,-1,1,-1};
bool used[MAXINT][MAXINT];
bool rock[MAXINT][MAXINT];

int main(){
	int t,n;
	while(cin>>t>>n,t||n){
		rep(i,MAXINT){
			fill(used[i],used[i]+MAXINT,false);
			fill(rock[i],rock[i]+MAXINT,false);
		}
		int x,y;
		rep(i,n){
			cin>>x>>y;
			rock[y+MAXINT/2][x+MAXINT/2]=true;
		}
		cin>>x>>y;
		used[y+MAXINT/2][x+MAXINT/2]=true;
		queue<piii> que;
		que.push(piii(0,pii(x+MAXINT/2,y+MAXINT/2)));
		while(!que.empty()){
			piii now=que.front();
			used[now.second.second][now.second.first]=true;
			que.pop();
			rep(i,6){
				int nextx=now.second.first+dx[i],nexty=now.second.second+dy[i];
				if(used[nexty][nextx]||rock[nexty][nextx])continue;
				if(now.first+1>t)continue;
				used[nexty][nextx]=true;
				que.push(piii(now.first+1,pii(nextx,nexty)));
			}
		}
		int cnt=0;
		rep(i,MAXINT){
			rep(j,MAXINT){
				if(used[i][j])cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 3240
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  ll ans = min({abs(A1 - A2) + abs(A2 - A3), abs(A1 - A3) + abs(A2 - A3),
                abs(A1 - A3) + abs(A2 - A1)});
  cout << ans << endl;
  return 0;
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  int A=a.at(0);
  int B=b.at(0);
  int C=c.at(0);
  cout << char(A-32) << char(B-32) << char(C-32) << endl;
}


Measured memory_bytes: 3560
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a = input()
    n = ord(a)
    if 65 <= n and n <= 65+26:
        print('A')
    else:
        print('a')

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 72948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+9;
int n,f[N];
bool vis[N];
int a[N];
string s;
int ans;
inline void add(int x,int y){for(;x<N;x+=(x&-x))f[x]+=y;}
inline int query(int x){int ans=0;while(x)ans+=f[x],x-=(x&-x);return ans;}
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;cin>>s;s=" "+s;
    int cnt=0;
    //for(int i=1;i<=2*n;i++)cout<<s[i];
    //cout<<endl;
    for(int i=1;i<=2*n;i++)if(i%2){if(s[i]=='W')a[++cnt]=i;}else if(s[i]=='B')a[++cnt]=i;
  //  for(int i=1;i<=cnt;i++)cout<<a[i]<<endl;
    if(cnt!=n)cout<<0<<endl;
    else{
        int tt=0;
        ll ans=1;
        for(int i=1;i<=n;i++)ans=1ll*ans*(a[i]-tt-1)%mod,tt+=2;
        for(int i=1;i<=n;i++)ans=1ll*ans*i%mod;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1360
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c - min(a - b, c) << endl;
}


Measured memory_bytes: 3624
#!/usr/bin/env python

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

a, = read_line(int)
b, = read_line(int)
c, = read_line(int)
d, = read_line(int)

train = a if a < b else b
bus = c if c < d else d

print(train + bus)


Measured memory_bytes: 3060
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/

int dp[100005][3];

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    for(int i = 1; i <= n; ++i){
        dp[i][0] = max(dp[i - 1][1] + b[i - 1], dp[i - 1][2] + c[i - 1]);
        dp[i][1] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][2] + c[i - 1]);
        dp[i][2] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + b[i - 1]);
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

return 0;
}

Measured memory_bytes: 5540
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,c,x,y = na()
tot = c*2
ans = 0
if a+b <= tot:
    ans = a*x + b*y
else:
    if a > tot and b > tot:
        mi = min(x,y)
        ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a > tot and b <= tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a <= tot and b > tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*2*c
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
    else:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
print(ans)


Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())

L = [int(input()) for i in range(N)]
inf = 99999999999

def dfs(cursor, a, b, c):
  if cursor == N:
    return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else inf

  a_pattern = dfs(cursor+1, a + L[cursor], b, c) + 10
  b_pattern = dfs(cursor+1, a, b + L[cursor], c) + 10
  c_pattern = dfs(cursor+1, a, b, c + L[cursor]) + 10
  no_pattern = dfs(cursor+1, a, b, c)
  return min(a_pattern, b_pattern, c_pattern, no_pattern)


print(dfs(0,0,0,0))


  

Measured memory_bytes: 3064
from collections import deque

H,W = map(int,input().split())

L = []

black = 0

for i in range(H) :
    S = input()
    black += S.count("#")
    L.append(S)

dxy = [(-1,0),(1,0),(0,-1),(0,1)]

q = deque([(0,0)])

DISTANCE = [[float("inf") for x in range(W)] for y in range(H)]
DISTANCE[0][0] = 0

while q :
    y,x = q.popleft()
    
    for dy,dx in dxy :
        ny,nx = y+dy,x+dx
        
        if (ny < 0) or (ny >= H) or (nx < 0) or (nx >= W) :
            continue
        
        if L[ny][nx] == "#" :
            continue
        
        if DISTANCE[y][x] + 1 >= DISTANCE[ny][nx] :
            continue
        
        DISTANCE[ny][nx] = DISTANCE[y][x] + 1
        q.append([ny,nx])

if DISTANCE[H-1][W-1] == float("inf") :
    ans = -1
else :
    ans = H*W - (DISTANCE[H-1][W-1] + 1) - black

print(ans)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  string s,t;cin >> s >> t;
  int n = s.length(), m = t.length();
  int dp[2][m+1];
  //0:左,1:上,2:左上
  int pre[n+1][m+1];
  int *prev = dp[0];
  int *next = dp[1];
  REP(i,n+1) pre[i][0] = 1;
  REP(j,m+1){
    prev[j] = 0;
    next[j] = 0;
    pre[0][j] = 0;
  }
  REP(i,n){
    REP(j,m){
      if(s[i] == t[j]){
        next[j+1] = prev[j]+1;
        pre[i+1][j+1] = 2;
      }
      else{
        if(next[j]>prev[j+1]){
          next[j+1] = next[j];
          pre[i+1][j+1] = 0;
        }else{
          next[j+1] = prev[j+1];
          pre[i+1][j+1] = 1;
        }
      }
    }
    swap(next,prev);
  }
  swap(next,prev);
  vector<char> ans;
  for(int i=n,j=m; i>=0 && j>=0;){
    if(pre[i][j] == 0)j--;
    else if(pre[i][j] == 1)i--;
    else{
      i--;
      j--;
      ans.push_back(s[i]);
    }
    if(ans.size()==next[m])break;
  }
  reverse(ans.begin(),ans.end());
  REP(i,ans.size()) cout << ans[i];
  cout << endl;
  return 0;
}


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

int main(){
    int n, m, a[200010]={};
    cin >> n;
    for(int i=2;i<=n;i++){
        cin >> m;
        a[m]+=1;
    }
    for(int i=1;i<=n;i++){
        cout << a[i] << endl;
    }
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, x;
  cin >> a >> b >> x;
  cout << b/x - a/x + !(a%x) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


void inserctionSort(int A[], int N);
void print(int A[],int N);

int main(){

	int N,i,j;
	int A[1000];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	print(A, N);
	inserctionSort(A, N);
	

	return 0;

}

void inserctionSort(int A[], int N){

	int i, j;
	int v;

	for (i = 1; i < N; i++) {
		v = A[i];
		for (j = i - 1; j >= 0 && A[j] > v; j--) {
			A[j + 1] = A[j];
		}

		A[j+1] = v;

		print(A, N);
	
	}


}


void print(int A[],int N){

	int i;

	for (i = 0; i < N; i++){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}

	printf("\n");


}

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

int main()
{
    string S;
    cin >> S;
    set<char> s;
    for (int i = 0; i < S.size(); ++i){
        s.insert(S[i]);
    }
    if(s.size()==2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

  main(){
    int x[5],y[5],min=1000,s=0,sum=0,i; 
    
    for(i=0;i<5;i++){
     scanf("%d",&x[i]);//x[5]の要素がそろう
     y[i]=x[i];
    }
    
    for(i=0;i<5;i++){
        x[i]=x[i]%10;
          if(min>x[i]&&x[i]!=0){
            min=x[i];
             s=i;  //最後に来るiを指定
          }
    }
    // printf("%d  %d %d",s,x[s],y[s]);
     for(i=0;i<5;i++){
      if(i!=s){
        if(y[i]%10!=0){
        sum +=(y[i]/10+1)*10;
        }
        else
          sum +=y[i];
      }
     //  printf("%d\n",sum);
    }
    printf("%d",sum+y[s]);
} 

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	//??????(homework)
	int num1=0,num2=0,num3=0,num4=0,num5=0,num6=0,num7=0,num8=0,num9=0,t=0;
	cin>>num1>>num2>>num3>>num4>>num5;
	num6=num2/num4;
	num7=num2%num4;
	if(num7!=0){
		num6=num6+1;
	}
	num8=num3/num5;
	num9=num3%num5;
	if(num9!=0){
		num8=num8+1;
	}
	if(num6<num8){
		t=num6;
		num6=num8;
		num8=t;
	}
	num9=num1-num6;
	cout<<num9;
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <math.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );
  while ( n-- )
  {
    double dh, dm, res;
    int h, m;

    scanf ( "%d:%d", &h, &m );

    dh = h * 30.; dm = m * 6.;
    dh += dm / 12.;
    res = fmod ( dh - dm + 720., 360. );
    res = res > 180.
        ? 360. - res
        : res;

    if      ( res < 30. ) puts ( "alert" );
    else if ( res < 90. ) puts ( "warning" );
    else                  puts ( "safe" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
n, m = [int(i) for i in input().split()]
dic = {}
for i in range(n):
  a, b = [int(i) for i in input().split()]
  if not a in dic:
    dic[a] = b
  else:
    dic[a] += b
ndic = sorted(dic.items())

ans = 0
for i, v in ndic:
  if m <= v:
    ans += m * i
    break
  else:
    ans += v * i
    m -= v
print(ans)

Measured memory_bytes: 23008
#include<iostream>
#include<vector>
#include<string>
int N;
using namespace std;
vector<int> A;
vector<int> B;
vector<int> C;


int gcd(int a,int b)
{
  if (a % b == 0){
    return b;
  }
  else{
    return gcd(b , a % b);
  }
}

int main(){
  cin >> N;
  A.resize(N);
  B.resize(N);
  C.resize(N);

  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  B[0] = A[0];
  for(int i=1;i<N;i++){
    B[i] = gcd(B[i-1],A[i]);
  }
  C[N-1] = A[N-1];
  for(int i=N-2;i>=0;i--){
    C[i] = gcd(A[i],C[i+1]);
  }

  int ans = max(C[1],B[N-2]);
  for(int i=1;i<N-1;i++){
    ans = max(ans,gcd(B[i-1],C[i+1]));
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[2] - a[0] << endl;

}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } 
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b,c,x,y;
	cin >>a >>b >>c >>x >>y;
	ll ans = a*x + b*y;
	VI ss;
	rep(i, x+y+1){
		
		ll w = max(0LL, a * (x-i)) + max(0LL,b* (y-i)) + max(0LL, c*i*2);
		
		ans = min(ans, w);
	
	}
	
	cout << ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 256
import math
N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
k = 0
total = 0
for j in range(N-1):
    for i in range(j + 1, N):
        total += ((xy[j][0] - xy[i][0])**2 + (xy[j][1]-xy[i][1])**2)**(1/2)
    k += 1
total = total * 2
print(total/N)


Measured memory_bytes: 9452
inCount = int(input())
publicBuilds = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(inCount):
    b, f, r, v = map(int, input().split())
    publicBuilds[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, publicBuilds[b][f])))
        if f > 1 and b < 3:
            print("#" * 20)


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

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

  int x, y, z, count = 0;

  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      z = S -x - y;
      if(z >= 0 && z <= K) {
        count++;
      }
    }
  }
  cout << count << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



i64 n, m, a[101010], b[101010];
i64 d[101010];
struct UnionFind {
	vector<int> par, depth, sz;
	UnionFind(int n) : par(n+1), depth(n+1), sz(n+1){
		for(int i = 0; i <= n; i++){
			par[i] = i;
			depth[i] = 0;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		sz[x] += sz[y];
		sz[y] = sz[x];
		if(depth[x] < depth[y]){
			par[x] = y;
		}
		else{
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};
void solve(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	
	i64 ans = n*(n-1)/2;
	UnionFind uf(n);
	for(int i = m-1; i >= 0; i--){
		d[i] = ans;
		if(uf.same(a[i],b[i])) continue;
		ans -= (i64)uf.size(a[i])*uf.size(b[i]);
		uf.unite(a[i], b[i]);
		if(ans <= 0) break;
	}
	
	for(int i = 0; i < m; i++){
		cout << d[i] << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 4864
package main

import (
	"fmt"
	"math"
)

func isPrime(x int) bool {
	if x==2 {
		return true
	}
	if x%2==0 {
		return false
	}

	for i:=3; i<int(math.Sqrt(float64(x))); i+=2 {
		if x%i == 0 {
			return false
		}
	}

	return true
}

func main() {
	var x int
	fmt.Scan(&x)

	for i:=x;; i++ {
		if isPrime(i) {
			fmt.Println(i)
			break
		}
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define endl "\n"
#define int long long int 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
 /*   #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin) ;
    freopen("output.txt","w",stdout) ;
    #endif */
    int n , q ;
    cin >> n >> q ;
    string s; 
    cin >>s ;
    int len = s.size();
    vector<int>pre(len+1) ;
    for(int i = 1 ; i < len ; i++ )
    {
         pre[i] = pre[i-1] ;
         if(s[i] == 'C' && s[i-1] == 'A')
         {
           pre[i] ++;
         }
    }
    for(int i = 0 ; i < q ; i++ )
    {
       int l , r ;
       cin >> l >> r ;
       l-- ;r--;
       int ans = pre[r] ;
       if(l)
       {
            ans-= pre[l-1] ;
            if(s[l] == 'C' && s[l-1] == 'A') ans--;
       } 
       cout<<ans<<endl;
    }

   return 0 ;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char s[101];
int flag[101]={0},ans1,ans2,i,j,n,f;
int main()
{
	cin>>n>>s;
	for(i=0;i<n;i++)
	{
		f=1;
		if(s[i]==')'&&flag[i]==0)
		{
			for(int j=i;j>=0;j--)
			{
				if(s[j]=='('&&flag[j]==0)
				{
					flag[j]=1;flag[i]=1;	f=0;	break;
				}
			}
			ans1+=f;
		}
		if(s[i]=='('&&flag[i]==0)
		{
			for(int j=i;j<n;j++)
			{
				if(s[j]==')'&&flag[j]==0)
				{
					flag[j]=1;flag[i]=1;	f=0;	break;
				}
			}
			ans2+=f;
		}	
	}
	for(i=1;i<=ans1;i++)	cout<<"(";
	cout<<s;
	for(i=1;i<=ans2;i++)	cout<<")";
	cout<<endl;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String S = sc.next();
        int q = Integer.parseInt(sc.next());
        for (int i = 0; i < q; i++) {
            String command = sc.next();
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (command.equals("print")) {
                out.printf("%s\n", S.substring(a, b + 1)) ;
            } else if (command.equals("reverse")) {
                String T = S;
                S = T.substring(0, a);
                for (int j = b; j >= a; j--) {
                    S += T.substring(j, j + 1);
                }
                S += T.substring(b + 1);
            } else if (command.equals("replace")) {
                String replace = sc.next();
                S = S.substring(0, a) + replace + S.substring(b + 1);
            }
        }
        out.flush();
    }
}


Measured memory_bytes: 61456
from collections import deque
mod = 10**9 + 7
n, k = map(int, input().split())


# 根を見つけないといけない->Union Find
class UnionFind:
    def __init__(self, n):
        self.par = [-1]*(n+1)  # 頂点番号とindexをそろえるためにn+1。idx0は使わない
        self.rank = [0]*(n+1)

    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])  # 再帰で根までたどる.その過程で根とつなぎかえる
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        else:
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)  # 根同じならTrue違うならFalseを返す

    def size(self, x):
        return -self.par[self.find(x)]


edges = [[]*n for _ in range(n)]
UF = UnionFind(n)
for _ in range(n-1):
    a, b = map(int, input().split())
    UF.union(a, b)
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

root = UF.find(1)
#print(root)
root -= 1
d = deque([root])
visited = [False]*n
visited[root] = True
colored = [-1]*n
colored[root] = k
while d:
    p = d.pop()
    count = 0
    for c in edges[p]:
        if visited[c]:
            continue
        visited[c] = True
        d.append(c)
        if p == root:
            colored[c] = (k-1-count) % mod
        else:
            colored[c] = (k-2-count) % mod
        count += 1
ans = 1
for i in range(n):
    ans = ans*colored[i] % mod
print(ans)

Measured memory_bytes: 98072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long v[100010];
long long vs[100010];
void init(long long n){
	rep(i,n) v[i]=i;
    rep(i,n) vs[i]=1;
}
//頂点aが属するrootを求める
long long root(long long a){
	if(v[a]==a) return a; //aはroot
	return (v[a]=root(v[a])); //aの親のroot
}
//頂点aとbが同一グループか?
bool is_same_set(long long a,long long b){
	return root(a)==root(b);
}
//頂点aとbを同一グループにまとめる
void unite(long long a,long long b){
    if(!is_same_set(a,b)){
        long long tmp=vs[root(a)]+vs[root(b)];
        v[root(a)]=root(b);
        vs[root(a)]=tmp;
        // cout<<vs[root(a)]<<" "<<vs[root(b)]<<endl;
    }else{
        v[root(a)]=root(b);
    }
}
int main(){
    long long n,m; cin>>n>>m;
    init(n+1);
    long long a[m],b[m]; rep(i,m) cin>>a[i]>>b[i];
    long long ans[m];
    ans[m-1]=n*(n-1)/2;
    for(long long q=m-1;q>=0;q--){
        // cout<<root(a[q])<<" "<<root(b[q])<<endl;
        // cout<<vs[root(a[q])]<<" "<<vs[root(b[q])]<<endl;
        ans[q-1]=ans[q];
        if(!is_same_set(a[q],b[q])) ans[q-1]-=vs[root(a[q])]*vs[root(b[q])];
        unite(a[q],b[q]);
    }
    rep(i,m) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 5248
// 素数を和を求めるプログラム
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

int main(void)
{
    bool flag = true;
    int n, num, last_num, total_num, sum;
    vector<int> prime;

    // 初期値の設定
    num = last_num = 2;
    prime.push_back(num);

    while(1)
    {
        cin >> n;

        if( n == 0 )
        {
            // 入力終了
            break;
        }

        num = last_num;
        total_num = prime.size();

        // 素数を探索する処理
        // ( ただし, 同じ素数を2回探索しないようする )
        while( total_num <= n )
        {
            num++;
            flag = true;

            for(unsigned int i = 0; i < prime.size(); i++)
            {
                if( num % prime[i] == 0 )
                {
                    // 素数で割り切れる数は, 素数ではない
                    flag = false;
                    break;
                }
            }

            if( flag == true )
            {
                // 素数が見つかった
                prime.push_back(num);
                // 見つかった最後の素数を記憶する
                last_num = num;
                total_num++;
            }
        }

        sum = 0;

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

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

    }

    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n)
{
    ll ans = 0;
    while(n!=0)
    {

        ans += n%10;
        n/=10;
    }
    return ans;
}
int main()
{
ll n,a,b;
cin>>n;
ll ans = solve(n);
//cout<<ans;
if(n%ans==0) cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
#define REP(i,n) for (int i = 1; i<= (n); i++)
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
const long double PI = acos(-1);
using ll = long long;
using ld = long double;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 13) {
        ans = b;
    } else if (a >= 6 && a <= 12) {
        ans = b / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main (args:Array<String>){
    var strLen = readLine()!!.toInt()
    var strS = readLine()!!
    var count = 0

    while(strLen >= 3){
        var abcIndex = strS.indexOf("ABC")
        if(abcIndex == -1){
            break
        }
        else {
            strS = strS.drop((abcIndex + 3))
            count++
            strLen -= abcIndex + 3
        }
    }
    print(count)
}

Measured memory_bytes: 35972
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (long long i = 0; i < m; i++)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  ll f = 0, l = 1000000000;
  ll h[n];
  REP(i, n) cin >> h[i];
  while((l - f) > 1){
    ll m = (l + f)/2;
    ll k[n];
    REP(i, n) k[i] = h[i] - (m*b);
    ll p = 0;
    REP(i, n){
      if(k[i] > 0){
        p += (1 + (k[i]-1) / (a-b));
      }
    }
    if(p <= m) l = m;
    else f = m;
  }
  cout << l << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 1e18;

signed main() {
  int a, b, q;
  cin >> a >> b >> q;
  vector<int> s(a), t(b), x(q);
  for (auto &&w : s) {
    cin >> w;
  }
  s.push_back(inf);
  s.push_back(-1 * inf);
  for (auto &&w : t) {
    cin >> w;
  }
  t.push_back(inf);
  t.push_back(-1 * inf);
  for (auto &&w : x) {
    cin >> w;
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for (auto &&w : x) {
    int res = inf;
    int ls = lower_bound(s.begin(), s.end(), w) - s.begin();
    int lt = lower_bound(t.begin(), t.end(), w) - t.begin();
    for (int is : {ls - 1, ls})
      for (int it : {lt - 1, lt}) {
        res = min(res, abs(w - s[is]) + abs(s[is] - t[it]));
        res = min(res, abs(w - t[it]) + abs(s[is] - t[it]));
      }
    cout << res << endl;
  }
}


Measured memory_bytes: 3680
n,m = map(int,input().split())
l = [list(input()) for i in range(n)]
gyou = []
retsu = []
count = 0
for i in range(n):
    a = "."
    count = 0
    for j in range(m):
        if a == l[i][j]:
            count += 1
    if count != m:
        gyou.append(i)
for i in range(m):
    a = "."
    count = 0
    for j in range(n):
        if a == l[j][i]:
            count += 1
    if count != n:
        retsu.append(i)

for i in range(n):
    if i in gyou:
        for j in range(m):
            if j in retsu:
                if j == retsu[-1]:
                    print(l[i][j])
                else:
                    print(l[i][j],end="")




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

int main() {
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (s.find(a) == s.end()) {
      s.insert(a);
    }
    else {
      s.erase(a);
    }
  }
  int ans = s.size();
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int g = 0, p = 0;
    for(int i=0;i<s.size();++i){
        if(s[i] == 'g')g++;
        else p++;
    }

    cout << (g - p) / 2 << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a;cin>>a;
	cout<<a*a*a;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteString(" ")
		}
		fmt.Fprintf(io.writer, "%v", v)
	}
	io.writer.WriteString("\n")
}

func (io *Io) Printfln(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format + "\n", a...)
}

func main() {
	io := NewIo()
	defer io.Flush()
	s := io.Next()
	vowel := false
	for _, c := range []byte("aiueo") {
		if s[0] == c {
			vowel = true
		}
	}
	if vowel {
		io.Println("vowel")
	} else {
		io.Println("consonant")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const int BIG = 998244353;

ll gcd(ll c, ll d) {
	if (c < d) { swap(c, d); }
	if (d == 0) { return c; }
	
	return gcd(d, c%d);
}

ll lcm(ll c, ll d) { return c * d / gcd(c, d); }







int main() {

	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll c, d, cd;

	c = B / C - (A - 1) / C;
	d = B / D - (A - 1) / D;
	cd = B / lcm(C, D) - (A - 1) / lcm(C, D);

	
	cout << B-(A-1)-c-d+cd;

	system("PAUSE");
}

Measured memory_bytes: 504
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    if(i==0 || i==H-1 || j==0 || j==W-1){
                        cout << '#';
                    }else{
                        cout << '.';
                    
                    }
                }cout << endl;
            }cout << endl;
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod= 998244353;
int D[100005];
int num[100005];
ll multi(ll a,ll b,ll mod){
	ll ans=0;
	while(b){
		if(b&1)
			ans=(ans+a)%mod;
		a=(a<<1)%mod;
		b>>=1;
	}
	return ans;
}
ll qpow(ll a,ll b,ll mod){
	ll ans=1;
	while(b){
		if(b&1)
			ans=multi(ans,a,mod);
		a=multi(a,a,mod);
		b>>=1;
	}
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	int m=0;
	memset(num,0,sizeof num);
	for(int i=0;i<n;i++){
		scanf("%d",D+i);
		m=max(m,D[i]);
		num[D[i]]++;
	}
	if(num[0]!=1||D[0]!=0){
		printf("0");
		return 0;
	}
	ll ans=1;
	for(int i=1;i<=m;i++){
		if(num[i]==0){
			ans=0;
			break;
		}
		ans=ans*qpow(num[i-1],num[i],mod)%mod;
	}
	printf("%lld",(ans+mod)%mod);
}

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

int main() {
	long long n,k,x,i,j,ans=0,cur=0,res=0;
	cin >> n;
	vector<string> s(n);
	for(i=0; i<n; i++){
		cin >> s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s.begin(),s.end());
	cur=1;
	for(i=1; i<n; i++){
		if(s[i]==s[i-1]){
			ans+=cur;
			cur++;
		}else{
			cur=1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  10005;  
const int M = 1001;
#define FI first
#define SE second
typedef pair<int, int>pii;
int mod = 1000000007;
int rec[101][101];
int main()  
{  

   // ios::sync_with_stdio(0);
   int n, h, w;
   while (~scanf("%d%d", &h, &w))
   {
      scanf("%d", &n);
      int cur = 0;
      for (int i = 1; i <= n; i++)
      {
         int x;
         scanf("%d", &x);
         while (x--)
         {
            int r = cur/w;
            int c = cur%w;
            if (r&1)
               c = w - c - 1;
            rec[r][c] = i;
            cur++;
         }      
      }
      for (int i = 0; i < h; i++)
         for (int j = 0; j < w; j++)
            printf("%d%c", rec[i][j], j == w - 1?'\n':' ');
   }
   return 0;
}  

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

int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	int ans = 0;
	double area = (double)w * (double)h / 2.0;
	if (w == x * 2 && h == y * 2) ans = 1;
	cout << setprecision(15) << area << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;



int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> map(m,1);
  int a, k;
  for(int i = 0; i < n; i++){
    cin >> k;
    vector<int> tmap(m,0);
    for(int j = 0; j < k; j++){
      cin >> a;
      tmap.at(a-1) = 1;
    }
    for(int j = 0; j < m; j++){
      map.at(j) &= tmap.at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < m; i++){
    ans += map.at(i);
  }
  cout << ans << endl;
  return 0;

}


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

int main(){
    long long n,max,min,sum;
    int a[25565] = {0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    max = a[0];
    min = a[0];
    sum = a[0];
    for(int i=1;i<n;i++){
        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1276