akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int x;
    cin>>x;

    int ans = 100;
    int c = 0;
    while( ans < x )
    {
        ans += ans/100;
        c++;
    }

    cout<<c<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3616
def resolve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    point = {"r": P, "s": R, "p": S}
    T = input()

    res = [0] * N
    for i, t in enumerate(T):
        if i - K < 0:
            res[i] = point[t]
        if i - K >= 0 and (res[i - K] == 0 or T[i - K] != T[i]):
            res[i] = point[t]

    print(sum(res))

resolve()

Measured memory_bytes: 4084
#include <iostream>
using namespace	std;
int main(){

  int n,a[100],result=0;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n-1;i++) for(int j=n-2;j!=i-1;j--) if(a[j]>a[j+1]){
        swap(a[j],a[j+1]);
        result++;
      }
  for(int i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<result<<endl;

  return 0;

}

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

int n, d;
int x[15][15];

int dist(int a, int b) {
  int ttl = 0;
  for (int i = 0; i < d; i++)
    ttl += (x[a][i] - x[b][i]) * (x[a][i] - x[b][i]);
  return ttl;
}

bool issq(int x) {
  int y = (int)round(sqrt(x));
  return y * y == x;
}

int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < d; j++)
      cin >> x[i][j];
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (issq(dist(i, j)))
        ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;//lessは大きい順にならべるよ
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )



int main(){
  string S, T;
  cin >> S >> T;
  string ans;
  ans = T+S;
  cout << ans << endl;

  
}



Measured memory_bytes: 256
//Ringo's Favorite Numbers

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int d,n;cin>>d>>n;
    if(n==100)n++;
    ll ans = 1;
    rep(i,0,d){
        ans*=100;
    }
    cout<<ans*n<<nnn;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private int A;
    private int B;
    private int C;
    private int D;
    private int E;
    private int F;

    public Main() {
	A = Integer.parseInt(scan.next());
	B = Integer.parseInt(scan.next());
	C = Integer.parseInt(scan.next());
	D = Integer.parseInt(scan.next());
	E = Integer.parseInt(scan.next());
	F = Integer.parseInt(scan.next());

	scan.close();
    }

    public final void answer() {
	// int i = 1;
	// System.out.println(IntStream.rangeClosed(0, F/(100*B))
	// 		   .map(j -> 100*A*i + 100*B*j)
	// 		   .filter(w -> w <= F)
	// 		   .boxed()
	// 		   .collect(Collectors.toList()));
	Set<Integer> waterSet = IntStream.rangeClosed(0, F/(100*A))
	    .mapToObj(i -> IntStream.rangeClosed(0, F/(100*B))
		      .map(j -> 100*A*i + 100*B*j)
		      .filter(w -> w > 0 && w <= F)
		      .boxed()
		      .collect(Collectors.toSet()))
	    .reduce(new HashSet<>(),
		    (l1, l2) -> {
			l1.addAll(l2);
			return l1;
		    });

	Set<Integer> sugarSet = IntStream.rangeClosed(0, F/C)
	    .mapToObj(i -> IntStream.rangeClosed(0, F/D)
		      .map(j -> C*i + D*j)
		      .filter(s -> s <= F)
		      .boxed()
		      .collect(Collectors.toSet()))
	    .reduce(new HashSet<>(),
		    (s1, s2) -> {
			s1.addAll(s2);
			return s1;
		    });

	Solution result = waterSet.stream()
	    .mapToInt(water -> water.intValue())
	    .mapToObj(water -> sugarSet.stream()
		      .mapToInt(sugar -> sugar.intValue())
		      .filter(sugar -> sugar <= water*E/100)
		      .mapToObj(sugar -> new Solution(water, sugar))
		      .filter(sol -> sol.total <= F)
		      .max(Comparator.naturalOrder())
		      .get())
	    .max(Comparator.naturalOrder())
	    .get();

	System.out.println(String.valueOf(result.total) + ' ' + result.sugar);
	
    }

    private static class Solution implements Comparable<Solution> {
	int water;
	int sugar;
	int total;

	public Solution(int w, int s) {
	    water = w;
	    sugar = s;
	    total = w + s;
	}

	@Override
	public int compareTo(Solution o) {
	    return this.sugar*o.total - o.sugar*this.total;
	}
    }
}


Measured memory_bytes: 40188
#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)]


n = int(input())

print(n*800 - n//15*200)


Measured memory_bytes: 9156
import java.util.List;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final String s = scanner.next();

        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> s.charAt(i) == 'o' ? 1 : -1)
                .collect(Collectors.toList());

        System.out.println(answer(list));
    }

    private static String answer(final List<Integer> list) {
        final int[] a1 = {1, -1};
        final int[] a2 = {1, -1};
        final Function<int[], String> answerGenerator = array -> IntStream.range(0, list.size())
                .mapToObj(i -> new StringBuilder(array[i] == 1 ? "S" : "W"))
                .collect(Collectors.joining());

        final int[] array = new int[list.size()];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                array[0] = a1[i];
                array[1] = a2[j];
                if (simulate(array, list)) {
                    return answerGenerator.apply(array);
                }
            }
        }
        return "-1";
    }

    private static boolean simulate(final int[] array, final List<Integer> list) {
        for (int i = 1; i < array.length - 1; i++) {
            array[i + 1] = array[i] * list.get(i) * array[i - 1];
        }
        return isCorrect(array, list, array.length - 1) && isCorrect(array, list, 0);
    }

    private static boolean isCorrect(final int[] array, final List<Integer> list, final int index) {
        final int former = (array.length + index - 1) % array.length;
        final int latter = (index + 1) % array.length;
        return array[index] * list.get(index) * array[former] * array[latter] == 1;
    }
}


Measured memory_bytes: 38452
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int kosu=sc.nextInt();
		int[] kgmmc=new int[kosu];

		for(int i=0; i<kosu; i++){
			kgmmc[i]=sc.nextInt();
		}

		int tmp1=0;
		int tmp2=0;

		for(int i=0; i<kosu; i++){
			for(int j=i; j<kosu; j++){
				if(kgmmc[i]<kgmmc[j]){
					tmp1=kgmmc[i];
					tmp2=kgmmc[j];
					kgmmc[i]=tmp2;
					kgmmc[j]=tmp1;
				}
			}
		}

		int dansu=1;
		int ookisa=kgmmc[0];
		for(int i=0; i<kosu; i++){
			if(kgmmc[i]<ookisa){
				dansu++;
				ookisa=kgmmc[i];
			}
		}

		System.out.println(dansu);
	}
}

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

int main(){
    char data[4];
    scanf("%s",&data);
    int a=data[0]-'0', b=data[1]-'0', c=data[2]-'0', d=data[3]-'0';
    if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
//#define A first
//#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
int n=100,m=100;
int a[105][105];
int A,B;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	read(A); read(B);
	A--; B--;
	int i,j,x,y;
	for (i=51;i<=n;i++){
		for (j=1;j<=m;j++){
			a[i][j]=1;
		}
	}
	for (x=1;A&&x<50;x+=2){
		for (y=1;A&&y<=m;y+=2){
			a[x][y]=1;
			A--;
		}
	}
	for (x=52;B&&x<=n;x+=2){
		for (y=1;B&&y<=m;y+=2){
//			printf("B=%d\n",B);
			a[x][y]=0;
			B--;
		}
	}
	printf("%d %d\n",n,m);
	for (i=1;i<=n;i++){
		for (j=1;j<=m;j++){
			if (a[i][j])printf(".");
			else printf("#");
		}
		printf("\n");
	}
	return 0;
}

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

int main() {

    int i, n, t, max_c = -1, flag = 0, minimam_c = 1000;

    cin >> n >> t;

    vector<int> C(n), T(n), good_C;

    // 値を代入
    for ( i = 0; i < n; i++) {
        cin >> C.at(i) >> T.at(i);
    }

    // tより小さいものがあるかチェック
    for ( i = 0; i < n; i++) {
        if (T.at(i) <= t) {
            flag = 1;
            good_C.push_back(i);
        }
    }

    // for ( i = 0; i < good_C.size(); i++) {
    //     cout << good_C.at(i) << endl;
    // }

    if (flag == 0) {
        printf("TLE\n");
        return 0;
    }

    for (i = 0; i < good_C.size(); i++) {
        if (C.at(good_C.at(i)) < minimam_c) {
            minimam_c = C.at(good_C.at(i)); 
        }
    }

    cout << minimam_c << endl;
    return 0;
}


Measured memory_bytes: 256
stack = []
gets.split(' ').each { |v|
  case v
  when /^[0-9]+$/; stack.push v.to_i
  when /^\+$/; stack.push(stack.pop + stack.pop)
  when /^-$/;
    v1 = stack.pop
    stack.push(stack.pop - v1)
  when /^*$/; stack.push(stack.pop * stack.pop)
  else puts "Error : not match"
  end
}
puts stack.pop

Measured memory_bytes: 8524
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double area = (double)(H)*(double)(W)/2.0;
  printf("%lf %d\n", area, (2*x==W) && (2*y==H));
  return 0;
}


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

import sys

if __name__ == '__main__':
    while True :
        h, w = map(int, raw_input().split())
        if h == 0 and w == 0:
            break

        for i in range(h):
            for j in range(w):
                sys.stdout.write('#' if (i+j) % 2 == 0 else '.')
            print
        print




Measured memory_bytes: 4640
import numpy as np
n = int(input())
x = [int(i) for i in input().split()]

index_hold = np.argsort(x)
index_hold_rev = [0 for i in range(n)]
for i in range(n):
    index_hold_rev[index_hold[i]] = i
for i in range(n):
    if index_hold_rev[i] < n/2:
        print(x[index_hold[int(n/2)]])
    else:
        print(x[index_hold[int(n/2-1)]])


Measured memory_bytes: 34172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

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

    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    int itr[3] = {0};
    int now = 0;
    while(itr[now] < int(S[now].size())) {
        now = S[now][itr[now]++] - 'a';
    }
    cout << char('A'+now) << endl;
}


Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
SUM = [0]
mp = {}
res = 0
for i in range(len(A)):
    SUM.append(A[i]+SUM[i])
for i in range(len(SUM)):
    SUM[i] = SUM[i] % M
    if not SUM[i] in mp:
        mp.update({SUM[i]:0})
    else:
        mp.update({SUM[i]:mp[SUM[i]]+1})
    res = res + mp[SUM[i]]
print(res)


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

int main(){
	int s1,s2,s3,s4,s;
	
	cin >> s1 >> s2 >> s3 >> s4;
	s = s1 + s2 + s3 + s4;
	cout << s/60 << "\n" << s%60 << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,A=0,B=0;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  rep(i,n){
  if(i%2==0) A+=a.at(i);
  else B+=a.at(i);
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> data(M, vector<int>(2));
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int nummin = 1;
    int nummax = 100000;
    for (int i = 0; i < M; i++) {
        nummin = max(nummin, data.at(i).at(0));
        nummax = min(nummax, data.at(i).at(1));
    }
    int ans = max(nummax - nummin + 1, 0);
    cout << ans << endl;
}


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

int main(void){
    vector<vector<int>> c(3, vector<int>(3));
    for (int i=0; i<3; i++){
        for (int j=0; j<3; j++){
            cin >> c[i][j];
        }
    }
    int a;
    vector<int> b;
    for (int i=0; i<3; i++){
        a = min(c[i][0], min(c[i][1], c[i][2]));
        if (i == 0){
            for (int j=0; j<3; j++) b.emplace_back(c[i][j] - a);
        } else{
            for (int j=0; j<3; j++){
                if (a + b[j] != c[i][j]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

  for(int i =0 ; i<N ; i++){
    string s;
    cin >> s ;
    
    if( s == "Y" ){
	  cout << "Four" << endl;
      break;
    }
  
    else{
      if( i<N-1 ){
      continue;
      }
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
// a_2 = a_1 xor a_3 = (a_0 xor a_2) xor a_3
// このことから、 a_0 xor a_3 = 0 つまり a_0 = a_3であることがわかる。
// N == 3*k (k = 1,2,3,...)のとき、
// {a_i}が3つの数から成り、b_0, b_1, b_2として、b_0 xor b_1 = b_2が成り立つか判定
// N % 3 != 0 なら、全ての数が等しくなるか(0になる)どうか判定
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    if(N % 3) {
        int a;
        cin >> a;
        if(a != 0) { cout << "No" << endl; return 0; }
        for(int i = 1; i < N; ++i) {
            int tmp;
            cin >> tmp;
            if(a != tmp) { cout << "No" << endl; return 0;}
        }
        cout << "Yes" << endl;
        return 0;
    }

    map<int,int> Map;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        ++Map[a];
    }
    vector<int> B, Num;
    for(auto &p : Map) {
        B.push_back(p.first);
        Num.push_back(p.second);
    }
    /*
    for(int i = 0; i < Num.size(); ++i) {
        cout << "B: " << B[i] << " Num: " << Num[i] << endl;
    }
    */
    if(Num.size() > 3) { cout << "No" << endl; return 0; }
    if(Num.size() == 3) {
        if(Num[0] != Num[1] || Num[1] != Num[2] || Num[2] != Num[0]) { cout << "No" << endl; return 0;}
        //cout << B[0] << " xor " << B[1] << " = " << (B[0] ^ B[1]) << endl;
        if((B[0] ^ B[1]) == B[2]) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    if(Num.size() == 2) {
        if(Num[0] > Num[1]) { swap(Num[0], Num[1]); swap(B[0], B[1]); }
        if(B[0] != 0) { cout << "No" << endl; return 0; }
        if(Num[0] * 2 == Num[1]) { cout << "Yes" << endl; }
        else cout << "No" << endl;
        return 0;
    }
    if(Num.size() == 1) {
        if(B[0] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4860
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                300005
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________
ll a[N];
int main()
{
    ll n,m,r,s,p,x=0;
    string t;
    cin>>n>>m>>r>>s>>p>>t;
    for(int i=0;i<n;i++)
    {
        if(i<m)
        {
            if(t[i]=='r') a[i]=p;
            if(t[i]=='s') a[i]=r;
            if(t[i]=='p') a[i]=s;
            x+=a[i];
        }
        else
        {
            if(t[i]==t[i-m] && a[i-m]!=0) continue;
            if(t[i]=='r') a[i]=p;
            if(t[i]=='s') a[i]=r;
            if(t[i]=='p') a[i]=s;
            x+=a[i];
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 1280
import math
def do():
    l = 0
    r = 10**9 + 1
    res = 10**10
    while l <= r:
        mid = (l+r) // 2
        if do2(mid) is True: # 作れるなら
            res = min(res, mid)
            r = mid - 1
        else:
            l = mid + 1
    return l


def do2(target):
    res = 0
    if target == 0:
        return False
    t = math.log(target, 2)
    kk = k
    for i in range(n):
        if target >= dat[i]:
            break
        kk -= math.ceil(dat[i] / target) - 1
        if kk < 0:
            return False
    return True

n, k = map(int, input().split())
dat = list(map(lambda x: int(x), input().split()))
dat.sort(reverse=True)
print(do())


Measured memory_bytes: 104648
// Inshallah, Boys played well !!

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int> 
#define vpi vector<pair<int,int> >
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ff(i,s,e) for(int i=s;i<=e;i++)
#define fb(i,e,s) for(int i=e;i>=s;i--)
#define maxn 1005
int dp[maxn][maxn];
char grid[maxn][maxn];
signed main(){
    int n,m,x,y,z;
    cin >> n >> m;
    ff(i,0,n){
        ff(j,0,m){
            if(i==0 || j==0)
                grid[i][j]='#',dp[i][j]=0;
            else
                cin >> grid[i][j];
        }
    }
    dp[1][1]=1;
    ff(i,1,n){
        ff(j,1,m){
            if(i==1 && j==1)
                continue;
            if(grid[i][j]=='#')
                dp[i][j]=0;
            else    
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=1000000007;
        }
    }
    cout << dp[n][m];
}

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

int a[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    for (int i = 1; i < n; i++)
        if (a[i] > a[i - 1])
            ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3552
a =int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())
A = abs(a%10-10)
B = abs(b%10-10)
C = abs(c%10-10)
D = abs(d%10-10)
E = abs(e%10-10)
lst= [A,B,C,D,E]
ad = 0
cnt = 0
for i in lst:
    if (i != 10) and (i>ad):
        ad = i
    if i == 10:
        cnt += 1
ans = (a//10+b//10+c//10+d//10+e//10+5-cnt)*10-(ad)
print(ans)

Measured memory_bytes: 9156
#include <algorithm>
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    string S; cin >> S;
    string ans;
    if (S[0] == S[1] && S[1] == S[2]) {
        ans = "No";
    } else {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = list(input())
T = list(input())
a = []

for i in range(len(S)-len(T)+1):
    n = 0
    for j in range(len(T)):
        if S[j+i] == T[j]:
            n += 1
        else:
            continue
    a.append(n)

print(len(T)-max(a))

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

using namespace std;

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll sum = 0;
  ll i;
  for(i=1;i<=N;i++)
    if(i%3 !=0 && i%5 != 0) sum += i;
  cout << sum << endl;
}

Measured memory_bytes: 3636
R, G, B, N = map(int, input().split())
r, g, b = sorted([R, G, B], reverse=True)
ans = 0
for i in range(int(N / r) + 1):
  for j in range(int((N - i * r) / g) + 1):
    if (N - i * r - j * g) % b == 0:
      ans += 1
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	sort.Sort(sort.IntSlice(list))

	result := 0
	for i := 0; i < n-1; i++ {
		result += list[i]
	}
	result += list[n-1] / 2
	fmt.Println(result)

}


Measured memory_bytes: 512
while True:
  n=int(input())
  if n==0:
    break
  else:
    max_s=0
    min_s=2000
    sum_s=0
    for i in range(n):
      s=int(input())
      sum_s=sum_s+s
      if s<min_s:
        min_s=s
      if s>max_s:
        max_s=s
    print((sum_s-max_s-min_s)//(n-2))


Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = l;i < r;i++)
#define de(x) cout<<#x<<" = "<<x<<endl
int main()
{
	int n,h,a[100007],b[100007];
	cin>>n>>h;
	rep(i,0,n) scanf("%d%d",&a[i],&b[i]);
	sort(a,a + n);
	sort(b,b + n);
	int m = b[n - 1],d = n - 1,ans = 0;
	while(h > 0){
		if(m > a[n - 1])
		ans++,h-=m,m = b[--d];
		else
		break;
	}
	if(h>0) ans += (h / a[n - 1] + (int)((h % a[n - 1]) > 0));
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int l, r;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A') {
      l = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'Z') {
      r = i;
      break;
    }
  }
  cout << r - l + 1 << endl;
  return 0;
}


Measured memory_bytes: 720
N = int(input())
L = list(map(int, input().split()))
ans=0

for i in L:
    for j in L:
        for k in L:
            if (not i==j and not j==k and not i==k):
                if ( i+j>k and  i+k>j and k+j>i):
                    ans+=1

ans=ans/6
print(int (ans))


Measured memory_bytes: 9120
#include<cstdio>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a == 5 && b== 7 && c == 5) printf("YES\n");
	else if(a == 7 && b == 5 && c == 5) printf("YES\n");
	else if(a == 5 && b == 5 && c == 7) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,k,v[103];
bool viz[1<<17];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>v[i];
    for(int i=0;i<=k;++i)
        if(!viz[i])
            for(int j=1;j<=n;++j)
                viz[min(i+v[j],k+1)]=1;
    if(viz[k]) cout<<"First";
    else cout<<"Second";
    return 0;
}


Measured memory_bytes: 384
k = int(input())
s = input()

# nCr(n, r, m)
mod = 1000000007
n = len(s) + k

fac = [1,1] # 階乗 n!
inv = [0,1] # 逆元 1/n
finv = [1,1] # 逆元の階乗 (n^-1)! = (1/n)!

for i in range(2, n+1):
    fac.append( (fac[-1] * i ) % mod )
    inv.append( (-inv[mod%i] * (mod//i)) % mod )
    finv.append( (finv[-1] * inv[-1]) % mod )

def nCr(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

# a^n mod m
def modpow(a, n, m):
    x = 1
    while n > 0:
        if n & 1: x *= a
        a *= a; a %= m
        n >>= 1
    return x

n = len(s)
ans = 0
for i in range(k+1):
    a = modpow(25, i, mod)
    b = modpow(26, k-i, mod)
    c = nCr(n-1+i, n-1, mod)
    ans += a * b * c
    ans %= mod
print(ans)


Measured memory_bytes: 226804
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    string s[10];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    bool ho[10], ho1[10];
    int ans = 0;
    for (int bit = 0; bit < (1 << h); bit++) {
        for (int i = 0; i < h; i++) {
            if (bit & (1 << i)) {
                ho[i] = 1;
            }
            else {
                ho[i] = 0;
            }
        }
        for (int bit1 = 0; bit1 < (1 << w); bit1++) {
            for (int i1 = 0; i1 < w; i1++) {
                if (bit1 & (1 << i1)) {
                    ho1[i1] = 1;
                }
                else {
                    ho1[i1] = 0;
                }
            }
            int co = 0;
            for (int j = 0; j < h; j++) {
                for (int k = 0; k < w; k++) {
                    if (ho[j] == 1 && ho1[k] == 1 && s[j][k] == '#') {
                        co++;
                    }
                }
            }
            if (co == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nw = Input.ar;
        var wv = Input.twodim(nw[0]);
        var dp = new long[nw[0] + 1, nw[1] + 1];
        for (var i = 1; i <= nw[0]; i++)
            for (var j = 0; j <= nw[1]; j++)
                if (j - wv[i - 1][0] >= 0)
                    dp[i, j] = Max(dp[i - 1, j], dp[i - 1, j - wv[i - 1][0]] + wv[i - 1][1]);
                else dp[i, j] = dp[i - 1, j];
        var max = 0L;
        for (var i = 0; i <= nw[1]; i++)
            max = Max(max, dp[nw[0], i]);
        WriteLine(max);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static string[] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 91104
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int cnt = 0;

    for(int i = 0; i < n; ++i) {
    	if(isPrime(sc.nextInt())){
    		cnt += 1;
    	}
    }

    System.out.println(cnt);
  }

  public static boolean isPrime(int p) {
  	if(p == 2) return true;
  	if(p % 2 == 0) return false;
	for(int q = 3; q < Math.sqrt(p) + 1; q += 2){
		if(p % q == 0){
			return false;
		}
	}
  	return true;
  }
}

Measured memory_bytes: 41316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll INF = 100000000;
const ll MOD = 1000000007;

//UnionFind 
struct UnionFind
{
    std::vector<ll> uni;
    ll num;
    UnionFind(ll s) : uni(s, -1),num(s) {}

    //頂点aが所属するグループ
    ll root(ll a)
    {
        if (uni[a] < 0)
        {
            return a;
        }
        return uni[a] = root(uni[a]);
    }

    //a,bをつなげる
    bool connect(ll a, ll b)
    {
        a = root(a);
        b = root(b);
        if (a == b)
        {
            return false;
        }

        if (uni[a] > uni[b])
        {
            std::swap(a, b);
        }

        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    //a,bが同グループか確認
    bool isConnect(ll a, ll b)
    {
        return root(a) == root(b);
    }

    //aが属するグループの要素数
    ll size(ll a)
    {
        return -uni[root(a)];
    }

    //グループ数を返す
    ll groups(){
        std::set<ll> b;
        for(ll i=0;i<num;i++){
            b.insert(root(i));
        }
        return b.size();
    }
};

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //問題文中の添え字が0-indexか1-indexか確認!

    ll n,m;
    std::cin>>n>>m;
    UnionFind cards(n);
    rep(i,0,m){
        ll a,b,c;
        std::cin>>a>>b>>c;
        cards.connect(a,b);
    }
    std::cout<<cards.groups();
    return 0;
}

Measured memory_bytes: 5760
fn check(a: &Vec<bool>, v: &Vec<Vec<i32>>, n: usize) -> bool {
    for i in 0..n {
        if a[i] {
            for j in 0..n {
                if v[i][j] == -1 {
                    continue;
                }

                let aj = if a[j] { 1 } else { 0 };
                if v[i][j] != aj {
                    return false;
                }
            }
        }
    }
    //println!("{:?}, {:?}", a, v);
    true
}

fn comb(vv: &mut Vec<Vec<bool>>, v: &mut Vec<bool>, n: usize) {
    if n == 0 {
        vv.push(v.clone());
    } else {
        let mut x = v.clone();
        x.push(true);
        comb(vv, &mut x, n - 1);

        let mut y = v.clone();
        y.push(false);
        comb(vv, &mut y, n - 1);
    }
}

fn combinations(n: usize) -> Vec<Vec<bool>> {
    let mut vv = vec![];
    let mut v = vec![];
    comb(&mut vv, &mut v, n);
    vv
}

fn main() {
    let n = read::<usize>();
    let mut v = vec![vec![-1; n]; n];

    for i in 0..n {
        let a = read::<usize>();
        for _ in 0..a {
            let w = read_vec::<i32>();
            v[i][(w[0] - 1) as usize] = w[1];
        }
    }

    let mut max = 0;
    let a = combinations(n);
    //println!("{:?}", a);
    for ai in a {
        if check(&ai, &v, n) {
            max = std::cmp::max(ai.iter().filter(|&t| *t).count(), max);
        }
    }
    println!("{}", max);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
 
int main(void) {
  char S[11];
  int i;
  int ans=0;
  int cnt=0;
 
  scanf("%s", S);
 
  for(i=0; i<11; i++) {
      if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T')
	cnt++;
      else {
        if(ans<cnt)
	    ans=cnt;
	  cnt=0;
	}
    }
 
  printf("%d", ans) ;
  return 0 ;
}

Measured memory_bytes: 128
from sys import stdin

n = int(stdin.readline().rstrip())

an = list(map(int, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += bn[an[i]-1]
    if i != 0:
        if an[i-1]+1 == an[i]:
            ans += cn[an[i-1]-1]

print(ans)

Measured memory_bytes: 38480
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.r = [0] * n
        self.par = list(range(n))

    def root(self, x):
        #親、根の特定
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        #共通根があるか
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        #根の結合,ランク
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.r[x] == self.r[y]:
                self.r[x] += 1
                self.par[y] = x
                return
            elif self.r[x] > self.r[y]:
                self.par[y] = x
                return
            else:
                self.par[x] = y
        return

n, m = rm()
u = UnionFind(n)
for _ in range(m):
    a, b = rm()
    a, b = a-1, b-1
    u.unite(a,b)
for i in range(n):
    u.root(i)
print(max(collections.Counter(u.par).values()))













Measured memory_bytes: 51468
#include <stdio.h>
#include <stdlib.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define min(x, y) ((x) > (y) ? (y) : (x))
#define max(x, y) ((x) > (y) ? (x) : (y))
#define shrine 1
#define temple -1
#define position 0

struct qwe {
  int id, spt, ns[2], nt[2];
  long long x;
};

int qwe_asc(const void *a, const void *b){
  struct qwe *A = (struct qwe *)a, *B = (struct qwe *)b;
  if(A->x > B->x) return  1;
  if(A->x < B->x) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int a, b, q;
  scanf("%d%d%d", &a, &b, &q);
  struct qwe *r;
  r = malloc(sizeof(struct qwe) * (a + b + q));
  int c = 1;
  while(c <= a){
    scanf("%lld", &r[c].x);
    r[c].id = c;
    r[c].spt = shrine;
    c++;
  }
  while(c <= a + b){
    scanf("%lld", &r[c].x);
    r[c].id = c;
    r[c].spt = temple;
    c++;
  }
  while(c <= a + b + q){
    scanf("%lld", &r[c].x);
    r[c].id = c;
    r[c].spt = position;
    c++;
  }
  

  r[0].x = -100000000000000; r[0].spt = 100;
  r[a + b + q + 1].x = 100000000000000; r[a + b + q + 1].spt = 100;

  qsort(r, c, sizeof(struct qwe), qwe_asc);

 

  int s = 0, t = 0;
  for(int i = 1; i <= c; i++){
    if(r[i].spt == shrine) s = i;
    if(r[i].spt == temple) t = i;
    r[i].ns[0] = s; r[i].nt[0] = t;
  }
  
  s = a + b + q + 1; t = a + b + q + 1; int p[100000], f = 0;
  for(int i = a + b + q; i >= 1; i--){
    if(r[i].spt == shrine) s = i;
    if(r[i].spt == temple) t = i;
    r[i].ns[1] = s; r[i].nt[1] = t;

    if(r[i].spt == position){
      p[f++] = i;
    }
  }
 

  int k; long long temp[4]; long long ans[100000]; long long Min;
  for(int i = 0; i < f; i++){
    k = p[i];
    temp[0] = max(r[k].x - r[r[k].ns[0]].x, r[k].x - r[r[k].nt[0]].x);
    temp[1] = min(2 * r[r[k].nt[1]].x - r[r[k].ns[0]].x - r[k].x,
		  2 * r[r[k].ns[1]].x - r[r[k].nt[0]].x - r[k].x);
    temp[2] = min(r[r[k].nt[1]].x - 2 * r[r[k].ns[0]].x + r[k].x,
		  r[r[k].ns[1]].x - 2 * r[r[k].nt[0]].x + r[k].x);
    temp[3] = max(r[r[k].nt[1]].x, r[r[k].ns[1]].x) - r[k].x;
    Min = 1000000000000000;
    for(int i = 0; i < 4; i++){
     
      Min = min(Min, temp[i]);
    }
    
    ans[r[k].id - a - b - 1] = Min;
  }

  for(int i = 0; i < q; i++) printf("%lld\n", ans[i]);

  return 0;
}
    


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

public class Main {
	static final int INF = 1000000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			
			int[][] cost = new int[m][m];
			int[][] time = new int[m][m];
			for(int i = 0; i < m; i++){
				for(int j = 0; j < m; j++){
					cost[i][j] = INF;
					time[i][j] = INF;
				}
			}
			for(int i = 0; i < n; i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				cost[a][b] = sc.nextInt();
				cost[b][a] = cost[a][b];
				time[a][b] = sc.nextInt();
				time[b][a] = time[a][b];
			}
			for(int k = 0; k < m; k++){
				for(int i = 0; i < m; i++){
					for(int j = i; j < m; j++){
						cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
						cost[j][i] = cost[i][j];
						time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
						time[j][i] = time[i][j];
					}
				}
			}
			int k = sc.nextInt();
			for(int i = 0; i < k; i++){
				int p = sc.nextInt() - 1;
				int q = sc.nextInt() - 1;
				int r = sc.nextInt();
				if(r == 0){
					System.out.println(cost[p][q]);
				}else if(r == 1){
					System.out.println(time[p][q]);
				}
			}
		}
		
		sc.close();
	}

}

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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define P pair<ll, int>

const int INF = 1e9;
const long double pi=3.14159265358979323846;

#define E pair<int, ll>

#define pb push_back

ll mod;

const int K_SIZE = 3000010;

ll kai[K_SIZE];
ll inv_kai[K_SIZE];
ll inve[10010];

ll beki(ll x, ll a)
{
	if(x==0) return 0;
	if(a==0) return 1;
	if(a==1) return x;
	ll tmp=beki(x, a/2);
	tmp=tmp*tmp%mod;
	if(a%2==0) return tmp;
	else return tmp*x%mod;
}

ll inv(ll x)
{
	return beki(x, mod-2);
}

void make_kai(int n)
{
	kai[0]=1;
	inv_kai[0]=1;
	for(int i=1; i<=n; i++)
	{
		kai[i]=kai[i-1]*(ll)i%mod;
		inv_kai[i]=inv(kai[i]);
	}
}

ll cb(int s, int t)
{
	if(s==t) return 1;
	if(t==-1) return 0;
	ll tmp=kai[s];
	tmp=(tmp*inv_kai[t])%mod;
	return tmp*inv_kai[s-t]%mod;
}

ll gcd(ll x, ll y)
{
	if(x<0) x=-x;
	if(y<0) y=-y;
	while(x>0)
	{
		if(x>y) swap(x, y);
		y%=x;
	}
	return y;
}

ll lcm(ll x, ll y)
{
	return x/gcd(x, y)*y;
}

int main() {
  	//cout << 'a' << endl;
	ll n;
	cin >> n >> mod;
	make_kai((int)3*n+3);
	ll t=kai[(int)3*n-1];
	rep(i, 3*n)
	{
		inve[i+1]=inv((ll)i+1);
	}
	ll dp[6010][2010]={};
  	dp[0][0]=1;
	for(int i=1; i<(ll)3*n; i++)
	{
		for(int k=0; k<=n; k++)
		{
			ll tmp=dp[i-1][k];
			if(k>0)
			{
				if(i>1) tmp+=dp[i-2][k-1];
				if(i>2) tmp+=dp[i-3][k-1];
			}
			dp[i][k]=tmp*inve[i]%mod;
		}
	}
  	//rep(i, 3*n) cout << dp[i] << ' ';
  	//cout << endl;
  	ll ans=0;
 	for(int k=0; k<n; k++)
 	{
 		for(int j=1; j<=3; j++)
 		{
 			ans=(ans+dp[(int)3*n-j][k])%mod;
 		}
 	}
 	ans=(ans+dp[(int)3*n-1][n])%mod;
	cout << t*ans%mod << endl;

	return 0;
}

Measured memory_bytes: 96768
n = int(input())
a_lst = [int(elem) for elem in input().split()]
b_lst = [(a - i - 1) for i, a in enumerate(a_lst)]
b_lst = sorted(b_lst)

med = b_lst[n // 2]
res = 0
for i in range(n):
    res += abs(b_lst[i] - med)
print(res)

Measured memory_bytes: 26020
def main():
    n = int(input())

    r = [0, 0, 0, 0]
    for _ in range(n):
        i = input()

        if i == 'AC':
            r[0] += 1
        elif i == 'WA':
            r[1] += 1
        elif i == 'TLE':
            r[2] += 1
        else:
            r[3] += 1

    print('AC x {}'.format(r[0]))
    print('WA x {}'.format(r[1]))
    print('TLE x {}'.format(r[2]))
    print('RE x {}'.format(r[3]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
#include <iostream>

using namespace std;

int main(){
  long long N,K,i,j,n=0;
  cin >> N >> K;
  if (K==0) {
    cout << (N*N);
    return 0;
  }
  for (j=K+1;j<=N;j++) {
    if (N%j>=K-1) {
      n+=(N/j) * (j-K) + N%j -(K-1);
    } else {
      n+=(N/j) * (j-K);
    }
  }
  cout << n;
  return 0;
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;
const ll MAX = 51;

bool Poss(ll n, const vector<ll>& srcs, const vector<ll>& tars, ll mask) {
  vector<bitset<MAX>> can(MAX);
  VEVE(i, 0, MAX) can[i][i] = true;
  VEVE(j, 1, MAX) if (mask >> j & 1)
      VEVE(i, 0, MAX) {
        can[i][i % j] = true;
      }
//  DEBUG(can);
  VEVE(k, 0, MAX) VEVE(i, 0, MAX) VEVE(j, 0, MAX) {
        can[i][j] = can[i][j] or (can[i][k] and can[k][j]);
      }
  VEVE(i, 0, n) if (not can[srcs[i]][tars[i]]) return false;
  return true;
}

void Solve(ll) {
  ll n;
  cin >> n;
  vector<ll> srcs(n), tars(n);
  RARA(s, srcs) cin >> s;
  RARA(t, tars) cin >> t;
  if (not Poss(n, srcs, tars, (ll(1) << MAX) - 1)) {
    cout << "-1\n";
    return;
  }
  ll res = 0;
  DYDY(i, MAX, 0) {
    if (not Poss(n, srcs, tars, res | ((ll(1) << i) - 1))) {
      res |= ll(1) << i;
    }
  }
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 256