akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

class DisjointSet {
public:
  vector<int> rank, p;
  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size,0);
    p.resize(size,0);
    for (int i=0; i<size; i++) {
      makeSet(i);
    }
  }
  void makeSet(int x) {
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x,int y) {
    return findSet(x)==findSet(y);
  }
  void unite(int x,int y) {
    link(findSet(x),findSet(y));
  }
  void link(int x,int y) {
    if (rank[x]>rank[y]) {
      p[y]=x;
    } else {
      p[x]=y;
      if (rank[x]==rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x!=p[x]) {
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  DisjointSet ds=DisjointSet(n);
  int com, x, y;
  for (int i=0; i<q; i++) {
    cin >> com >> x >> y;
    if (com==0) {
      ds.unite(x,y);
    } else if (com==1) {
      cout << (ds.same(x,y)?1:0) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3184
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int num(ll n){
    int count=0;
    while(n>0){
        n/=10;
        count++;
    }
    return count;
}
int main(){
 ll n;cin>>n;
 int ans=num(n);
 for(ll a=1LL;a*a<=n;a++){
     if(n%a!=0)continue;
     ll b=n/a;
     int tmp=num(b);
     ans=min(ans,tmp);
 }
 cout<<ans<<endl;
}

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


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int X,j=2;
  cin>>X;
  int max = (int)sqrt(X)+1;
  int ans = 1;

  for(int i=2;i<=max;i++){ //i^j
    while(pow(i,j) <= X){
      if(pow(i,j) >= ans){
        ans = pow(i,j);
      }
      j++;
    }
    j=0;
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;

int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r(n);
    vector<int> g(n);
    vector<int> b(n);
    r[0] = 0; g[0] = 0; b[0] = 0;
    long long ans = 0;
    for(int i = 1; i < n; i++){
        r[i] = r[i-1];
        g[i] = g[i-1];
        b[i] = b[i-1];
        if(s[i] == 'R'){
            r[i] ++;
        }else if(s[i] == 'G'){
            g[i] ++;
        }else{
            b[i] ++;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = i+3; j < n; j++){
            if(s[i] != s[j]){
                if(s[i] != 'R' && s[j] != 'R'){
                    ans += r[j] - r[i];
                    if((j-i) % 2 == 0 && s[(j+i)/2] == 'R'){
                        ans --;
                    }
                }else if(s[i] != 'G' && s[j] != 'G'){
                    ans += g[j] - g[i];
                    if((j-i) % 2 == 0 && s[(j+i)/2] == 'G'){
                        ans --;
                    }
                }else if(s[i] != 'B' && s[j] != 'B'){
                    ans += b[j] - b[i];
                    if((j-i) % 2 == 0 && s[(j+i)/2] == 'B'){
                        ans --;
                    }
                }
            }
        }
    }
    cout << ans << endl; 
    return 0;
}





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

int main()
{
    int n, q;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    cin >> q;
    int m[q];
    for (int i = 0; i < q; i++)
    {
        cin >> m[i];
    }
    set<int> m_set;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int sum = 0;
        for (int j = 0; j < n; j++)
        {
            if (bit & (1 << j))
            {
                sum += A[j];
            }
        }
        m_set.insert(sum);
    }
    for (int i = 0; i < q; i++)
    {
        auto itr = m_set.find(m[i]);
        if (itr != m_set.end())
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 3112
s = gets.chomp
t = gets.chomp

ans = 10 ** 20

m = s.size
n = t.size

(0..m-n).each do |i|
  tmp = 0
  (0..n-1).each do |j|
    if s[i..i+n-1][j] != t[j]
      tmp += 1
    end
  end
  ans = [ans, tmp].min
end
puts ans

Measured memory_bytes: 15352
i=61,f[],c,m,s;main(y){for(;s?++f[y*12+*f+"=>?2J13IK<@V&"[--s]]:~scanf("%d,%d,%d",f,&y,&s)?s=s*4+1:++i<180?i%12>1?(y=f[i])?y>m?m=y:1:++c:1:!printf("%d\n%d\n",c,m););}

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

int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if (a+b==15)
	{
		cout<<"+\n";
	}
	else if (a*b==15)
	{
		cout<<"*\n";
	}
	else
	{
		cout<<"x\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
ll k;
void solve1()
{
	ll x=49+k/50;
	for(int i=1;i<=50;i++)
		printf("%lld ",x);
	printf("\n");
}
void solve2()
{
	ll x=50+k/50,d=50-(k%50);
	for(int i=1;i<=d;i++)
		printf("%lld ",x-50+d-1);
	for(int i=d+1;i<=50;i++)
		printf("%lld ",x+d);
	printf("\n");
}
int main()
{
	scanf("%lld",&k);
	printf("50\n");
	if(k%50==0)solve1();
	else solve2();
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(10)]
    a = [list(map(int, input().split())) for _ in range(h)]
    ans = 0

    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

    for x in range(h):
        for y in range(w):
            pos = a[x][y]

            if pos >= 0:
                ans += c[pos][1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll x;
    cin >> x;
    ll s = 100;
    ll year = 0;
    while(s<x){
        s = (s+s*0.01);
        year++;
    }
    cout << year << endl;
}

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

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

    int judge[n] = {};  // ACのとき1
    int correct = 0;
    int penalty = 0;
    int pen[n] = {};

    for(int i = 0; i < m; i++) {
        int p;
        string s;

        cin >> p >> s;
        if(s == "AC" && judge[p - 1] == 0) {
            judge[p - 1] = 1;
            correct++;
            penalty += pen[p - 1];
        }
        if(s == "WA" && judge[p - 1] == 0) {
            pen[p - 1]++;
        }
	}

    cout << correct << ' ' << penalty << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        int k=in.nextInt();
        int arr[]=new int[n];
        int dup[]=new int[200000+1];
        for (int i = 0; i < arr.length; i++) {
            arr[i]=in.nextInt();
            dup[arr[i]]++;
        }
        Arrays.sort(dup);
        long ans=0;
        for(int i=dup.length-1;i>=0;i--){
            if(k==0 && dup[i]!=0){
                ans=ans+dup[i];
            }
            if(dup[i]!=0 && k!=0){
                k--;
            }
        }
        System.out.println(ans);
    }
}


class Fast {
    BufferedReader br;
    StringTokenizer st;

    public Fast() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}



Measured memory_bytes: 47828
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN = 4 * 1000 * 100 + 20;
const int MLOG = 18;
const int NMAX = 20;

signed main(){
	IO;
	int n, A, B;
	cin >> n >> A >> B;
	int X[n], ans = 0;
	for(int i = 0; i < n; i++) cin >> X[i];
	for(int i = 1; i < n; i++){
		ans += min(B, A * (X[i] - X[i - 1]));
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>

struct Point { double x, y; };

void koch(int n, Point a, Point b);

int main() {
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


void koch(int n, Point a, Point b) {
    if (n == 0) return ;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}



Measured memory_bytes: 2692
sa = input()
sb = input()
sc = input()
a, b, c =0,0,0
pointer = 'a'
while True:
    # print(pointer, a, b, c)
    if pointer == 'a':
        if a == len(sa):
            print('A')
            break
        pointer = sa[a]
        a += 1
        
    elif pointer == 'b':
        if b == len(sb):
            print('B')
            break
        pointer = sb[b]
        b += 1
        
    elif pointer == 'c':
        if c == len(sc):
            print('C')
            break

        pointer = sc[c]
        c += 1
        
        
    
    

Measured memory_bytes: 3064
import java.util.*;

// ABC 79-D
// https://beta.atcoder.jp/contests/abc079/tasks/abc079_d

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int C = in.nextInt();
		
		HashMap<Integer, ArrayList<Rokuga>> startTimes = new HashMap<Integer, ArrayList<Rokuga>>();
		
		for (int i = 0; i < N; i++) {
			int startTime = in.nextInt() - 1;
			int endTime = in.nextInt();
			int channel = in.nextInt();
			
			ArrayList<Rokuga> a = new ArrayList<Rokuga>();
			if (startTimes.containsKey(startTime)) {
				a = startTimes.get(startTime);
			}
			
			boolean isSameIn = false;
			
			for (int j = 0; j < a.size(); j++) {
				Rokuga r = a.get(j);
				if (r.endTime == endTime && r.channel == channel) {
					isSameIn = true;
				}
			}
			
			if (!isSameIn) {
				a.add(new Rokuga(endTime, channel));
			}
			startTimes.put(startTime, a);
		}
		
		HashMap<Integer, Integer> endTimes = new HashMap<Integer, Integer>(); // Stores endtime => number of rokuga ends in that end time
		int[] channels = new int[C + 1]; // Stores the end time of that channel
		Arrays.fill(channels, -1);
		int answer = 0;
		int temp = 0;
		
		for (int i = 0; i <= 100000; i++) {			
			// Start recording 
			if (startTimes.containsKey(i)) {
				ArrayList<Rokuga> arrlist = startTimes.get(i);
				for (int j = 0; j < arrlist.size(); j++) {
					int startTime = i;
					int endTime = arrlist.get(j).endTime;
					int channel = arrlist.get(j).channel;
					
					int tempAdd = 1;
					
					// Check if we can overlap the recording
					if (channels[channel] >= i) {
						// If recording stop time is less than current recording stop one, extend the recording stop time to current one. 
						// So that one recording machine can handle two recordings
						if (channels[channel] < endTime) {
							int n = endTimes.get(channels[channel]) - 1;
							if (n == 0) {
								endTimes.remove(channels[channel]);
							} else {
								endTimes.put(channels[channel], n);
							}
							channels[channel] = endTime;
						}
						tempAdd = 0;
					} else {
						channels[channel] = endTime;
					}
					
					if (endTimes.containsKey(endTime)) {
						endTimes.put(endTime, endTimes.get(endTime) + 1);
					} else {
						endTimes.put(endTime, 1);
					}
					temp += tempAdd;
				}
			}
			
			// Stop all rokuga that ends in this second
			if (endTimes.containsKey(i)) {
				temp -= endTimes.get(i);
				endTimes.remove(i);
			}

			answer = Math.max(answer, temp);
		}
		System.out.println(answer);
	}
}

class Rokuga {
	int endTime;
	int channel;
	
	public Rokuga(int endTime, int channel) {
		this.endTime = endTime;
		this.channel = channel;
	}
}

Measured memory_bytes: 110568
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  rep(i,m)cin >> a[i] >> b[i];
  rep(i,m){
    a[i]--;
    b[i]--;
  }
  int cnt=0;
  rep(i,m){
    UnionFind k(n);
    rep(j,m){
      if(j==i)continue;
      k.unionSet(a[j],b[j]);
    }
    if(k.size(0)!=n)cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M (((long long)1e9)+7)
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("res.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    if(*s.rbegin()=='s')	s+="es";
    else s+='s';
    cout<<s;
   	return 0;
}

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


int main(){
  
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin>>a>>b;
	ll n=1,cnt=0;
	while(n<b){
		cnt++;
		n+=a;
		n--;
	}
	cout<<cnt;

    return 0;
}

Measured memory_bytes: 256
n, k, *p = map(int, open(0).read().split())

q = []
for p_i in p:
  q.append((p_i+1)/2)
  
s = [0]
pre_s = 0
for q_i in q:
  pre_s += q_i
  s.append(pre_s)

ans = 0
for i in range(n-k+1):
  if ans < (s[i+k] - s[i]):
    ans = s[i+k] - s[i]
    
print(ans)

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

int main() {
  int A,B ;
  cin>> A >> B;
    if (A==1 && B==2)
    {
      cout<< 3;
    }
    if (A==2 && B==3)
    {
      cout<< 1;
    }
    if (A==1 && B==3)
    {
      cout<< 2;
    }
    if (A==2 && B==1)
    {
      cout<< 3;
    }
    if (A==3 && B==2)
    {
      cout<< 1;
    }
    if (A==3 && B==1)
    {
      cout<< 2;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 82;
int A[N];
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int>wpos,rpos;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W')
			wpos.push_back(i);
		else
			rpos.push_back(i);
	}
	int wctr, rctr;
	wctr = 0, rctr = rpos.size()-1;
	int ans = 0;
	while ((wctr < wpos.size()) && rctr >= 0 && (wpos[wctr] < rpos[rctr]) ) {
		ans++;
		wctr++, rctr--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4628
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int num = r * 100 + g * 10 + b;
	if (num % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int main(){
    string s;
    cin >> s;
    //vector<char> c;

    int size = s.size();

    int c0 = 0,c1 = 0;
    for(int i=0; i<size ; ++i){
        if(s[i] == '0')c0++;
        if(s[i] == '1')c1++;
    }
    cout << min(c0,c1)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from heapq import heapify, heappop, heappush
from copy import deepcopy

N = int(input())
A = inpl()

before = deepcopy(A[:N])
heapify(before)
middle = A[N:-N]
after = [-a for a in A[-N:]]
heapify(after)

sb = sum(A[:N])
sa = -sum(A[-N:])

SB = [sb]
SA = [sa]

for m in middle:
    b = heappop(before)
    if b < m:
        heappush(before, m)
        sb += m - b
    else:
        heappush(before, b)
    SB.append(sb)    

for m in middle[::-1]:
    m = -m
    a = heappop(after)
    if a < m:
        heappush(after, m)
        sa += m - a
    else:
        heappush(after, a)
    SA.append(sa) 

    
print(max([b+a for b, a in zip(SB, SA[::-1])]))

Measured memory_bytes: 37596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {

            var NM = ReadSplitLong();
            var N = NM[0];
            var M = NM[1];


            var LR = ReadSplitLongLines(M);

            var min = LR.Max(x => x[0]);
            var max = LR.Min(x => x[1]);

            var a = max - min + 1;
            Console.WriteLine(a < 1 ? 0 : a);

            Console.ReadKey();
        }



        #region MyRegion

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        /// <summary>
        /// 空白区切の数値を取得する
        /// </summary>
        /// <returns>The read split int.</returns>
        public static int[] ReadSplitInt()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        /// <summary>
        /// 空白区切の数値を取得
        /// </summary>
        /// <returns>The read split long.</returns>
        public static long[] ReadSplitLong()
        {
            return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }


        public static int[][] ReadSplitIntLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitInt()).ToArray();
        }

        public static long[][] ReadSplitLongLines(int n)
        {
            return Enumerable.Range(0, n).Select(x => ReadSplitLong()).ToArray();
        }

        public static long[][] ReadSplitLongLines(long n)
        {
            var ret = new List<long[]>();
            for (long i = 0; i < n; i++)
            {
                ret.Add(ReadSplitLong().ToArray());
            }

            return ret.ToArray();
        }

        #endregion

    }
}


Measured memory_bytes: 25656
require 'prime'
MOD = 1000000007
N = gets.to_i

memo = Hash.new(0)
(2..N).each do |i|
  Prime.prime_division(i).each do |k, v|
    memo[k] += v
  end
end

counter = 1
memo.each do |k, v|
  counter *= v + 1
end
puts counter % MOD

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const int MOD = 998244353;
const double PI = 3.141592653589793;
const ll INF =  1e18 + 7;
const int nax = 100005;
ll lev[15][15];
ll cost[15];
ll n, m, x;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {

		cin >> n >> m >> x;

		for (int i = 0; i < n; i++) {
			cin >> cost[i];
			for (int j = 0; j < m; j++) {
				cin >> lev[i][j];
			}
		}
		int MASK = (1 << n);

		auto check = [&](ll c) {

			bool poss = false;
			for (int mask = 0; mask < MASK; mask++) {
				// cout << "msk: " << mask << endl;
				ll rem_c = c;
				vector<ll> level(m, 0);
				for (int i = 0; i < n; i++) {
					if ( (mask & (1 << i)) && rem_c >= cost[i]) {
						rem_c -= cost[i];
						for (int j = 0; j < m; j++) {
							level[j] += lev[i][j];
						}
					}
				}
				bool ch = true;
				// cout << "mask: " << mask << "   ";
				for (int j = 0; j < m; j++) {
					// cout << level[j] << " " ;
					ch &= (level[j] >= x);
				}
				// cout << endl;
				if (ch) {
					poss = true;
					// break;
				}
			}
			return poss;
		};

		ll ans = INF;
		ll s = 0, e = INF;
		while (s <= e) {
			ll mid = (s + e) / 2;
			if (check(mid)) {
				ans = mid;
				e = mid - 1;
			}
			else s = mid + 1;
		}
		cout << (ans == INF ? -1 : ans);
	}
	return 0;
}




















Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 55;
int A[MAX_N][MAX_N];
char ans[MAX_N][MAX_N];

int main2() {
  int N = nextLong();
  int K = nextLong();
  REP(i, N) REP(j, N) A[i][j] = nextLong();

  const ll L = 1e10;


  int s = 2*N;
  int t = 2*N+1;
  atcoder::mcf_graph<ll, ll> graph(N+N+2);
  REP(i, N) {
    REP(j, N) {
      graph.add_edge(i, N + j, 1, L - A[i][j]);
    }
  }
  REP(i, N) {
    graph.add_edge(s,     i, K, 0);
    graph.add_edge(N + i, t, K, 0);
  }
  graph.add_edge(s, t, N*K, L);

  ll cap, cost;
  tie(cap, cost) = graph.flow(s, t, (ll)N*K);

  ll val = N*K*L - cost;
  REP(i, N) REP(j, N) ans[i][j] = '.';
  for (auto e : graph.edges()) {
    if (e.flow > 0 && e.from < N && N <= e.to) {
      ans[e.from][e.to - N] = 'X';
    }
  }

  cout << val << endl;
  REP(i, N) cout << ans[i] << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int count = 0;
    for(int i = 1;i + 1 < n;i++)
    {
        if((v.at(i - 1) > v.at(i) && v.at(i) > v.at(i + 1)) || (v.at(i - 1) < v.at(i) && v.at(i) < v.at(i + 1)))
        {
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
t = input()
b = input()

table = [[0 for i in range(len(t))] for j in range(len(b))]


if len(t) > len(b):

    if t[0] == b[0]:
        table[0][0] = 1
    
    for i in range(1, len(t)):
        if t[i] == b[0]:
            table[0][i] = table[0][i-1] + 1
        else:
            table[0][i] = table[0][i-1]
    
    
    for i in range(1, len(b)):
        
        if b[i] == t[i]:
            table[i][i] = table[i-1][i-1]

        for j in range(i+1, len(t)):
            if b[i] == t[j]:
                table[i][j] = table[i-1][j-1] + table[i][j-1]
            else:
                table[i][j] = table[i][j-1]

    print(table[len(b)-1][len(t)-1] % 1000000007)

elif len(t) == len(b):
    if t == b:
        print(1)
    else:
        print(0)
        
else:
    print(0)


Measured memory_bytes: 44504
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int[] A = nextIntArray(N);

		int cnt = 0;
		for(int i=1;i<N-1;i++) {
			if((A[i-1] < A[i] && A[i] < A[i+1])||(A[i-1] > A[i] && A[i] > A[i+1])) {
				cnt++;
			}
		}
		out.println(cnt);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(void){
	int n;
	int p[65000];
	int m[65000];
	LL MAX,sum;
	int l;
	int i;
	while(1){
		cin>>n;
		if(n==0)	break;
		MAX=0;
		for(i=0;i<n;i++){
			cin>>p[i];
			MAX+=p[i];
		}
		l=MAX;
		MAX*=(LL)n;
		for(i=0;i<n-1;i++)	cin>>m[i];
		sort(m,m+n-1,greater<int>());
		for(i=0;i<n-1;i++){
			l+=m[i];
			sum=(n-(i+1))*l;
			//MAX=max(MAX,sum);
			if(MAX>sum)	break;
			MAX=sum;
		}
		cout<<MAX<<endl;
	}
	return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>

using namespace std;

string getOperator(int a, int b);

int main()
{
	string input1, input2;
	cin >> input1;
	cin >> input2;

	cout << "a" << getOperator(stoi(input1), stoi(input2)) << "b" << endl;

	return 0;
}

string getOperator(int a, int b)
{
	if (a > b)
	{
		return " > ";
	}
	else if (a < b)
	{
		return " < ";
	}
	else
	{
		return " == ";
	}
}


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

int main()
{
    string a,b,c;
    
    cin>>a>>b>>c;
   if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
             cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        aa: [usize; m]
    }
    let sum = aa.into_iter().fold(0, |sum, a| sum + a);
    if n >= sum {
        println!("{}", n - sum);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,dp[2000004],a[2000004];
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=1; i<=n; i++)
    cin >> a[i];
    dp[1] = 0;
    for(int i=2; i<=n; i++){
        if(i == 2)dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        else dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]) , dp[i - 1] + abs(a[i] - a[i - 1]));
    }
    
    cout << dp[n];
    
    
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, q, b, c, num[100005] = {}, sum = 0;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		num[a]++;
		sum += a;
	}
	cin >> q;
	rep(i, q) {
		cin >> b >> c;
		sum = sum + (c - b) * num[b];
		num[c] += num[b];
		num[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4368
#include <stdio.h>

int main() {
    int K, A, B;

    scanf("%d", &K);
    scanf("%d %d", &A, &B);

    int i;
    int flag = 0;

    for(i = A; i < B+1; i++) {
        if(i%K == 0) {
            flag = 1;
        }
    }     

    if(flag == 1) {
        printf("OK");
    } else {
        printf("NG");
    }

    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[1000];
    int i,j;
    cin>>s;
    j=strlen(s);
    if(s[j-1]=='s')
    {
        cout<<s;
        cout<<"es"<<endl;
    }
    else
    {
         cout<<s;
        cout<<"s"<<endl;
    }
}


Measured memory_bytes: 3632
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto N = readln.split.to!(int[]), a=N[0], b=N[1], c=N[2], d=N[3];
	if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)) writeln("Yes");
	else writeln("No");
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

void out(int u, int v){
	printf("%d %d\n", u, v);
}

int main(){
	int n, tmp = 1; scanf("%d", &n);
	while(tmp <= n) tmp <<= 1;
	tmp >>= 1;
	if(tmp == n) return puts("No"), 0;
	puts("Yes");
	for(int i = 2; i < n; i += 2){
		int u = i, v = i + 1;
		out(u, 1); out(v, 1); out(u, v + n), out(v, u + n);
	} out(n + 1, 2 + n);
	if(n % 2 == 0){
		int p = n ^ 1 ^ tmp;
		out(tmp, n + n);
		if(!p) out(1, n);
		else out(p, n);
	}
	return 0;
}

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

#define ll long long
#define din(a) (scanf("%d",&a));
#define dout(a) (printf("%d\n",a));

using namespace std;
string s;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	int len=s.size();
	cout<<s[0]<<len-2<<s[len-1]<<endl;
	return 0;
} 

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

int main() {
    long long x;
    cin >> x;
    long long ans = (x / 11) * 2;
    x -= 11 * (x / 11);
    if (x > 0) {
        x -= 6;
        ans++;
    }
    if (x > 0) {
        ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int i;
  long long a, b, N, x;
  cin >> N >> x;
  long long count=0;
  for (int i=0; i<N; i++){
    cin >>a;
    if (i == 0){
      b = a;
      continue;
    }
    if ((a + b)>x){
      count+=a+b-x;
      if ((x-b)>=0){
        b = x-b;
      }
      else{
        b = 0;
      }
    }
    else{b = a;}
  }
  cout << count<<endl;
}

Measured memory_bytes: 256
def make_yakusu(n):
	yakusu=[]
	for i in range(1,int(n**0.5)+1):
		if n%i==0:
			yakusu.append(i)
			if i!=n//i:
				yakusu.append(n//i)
	return yakusu
x=int(input())
ans=0
yakusu=make_yakusu(x)
for i in yakusu:
	if x//i-1>=i+1:
		ans+=x//i-1
print(ans)


Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <string>
#include <random>
#include <queue>


using namespace std;

// ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
// ans += val; // to simplify: ans = ans + val; and its variants
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer
// ans = min(ans, new_computation); // min/max shortcut
// alternative form but not used in this book: ans <?= new_computation;
// some code use short circuit && (AND) and || (OR)

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define INF 1000000000
#define M_PI 3.14159265358979323846

void printVector2d(vector<vector<int>> a){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a[i].size();j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"end"<<endl;
}

void printVector(vector<ll> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i]<<endl;
    }
}

void printVectorPair(vector<pair<int,int>> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i].first<<" "<<a[i].second<<endl;
    }
}

void printMap(map<char, int> mp){
    for(auto x:mp){
        cout<<x.first<<": "<<x.second<<endl;
    }
}

void printMapVec(map<int, vector<int>> mpV){
    for(auto x:mpV){
        cout<<x.first<<": ";
        for(auto y:x.second){
            cout<<y<<" ";
        }
        cout<<endl;
    }
}

void printQueue(queue<char> q){
    while(!q.empty()){
        cout<<q.front()<<" ";
        q.pop();
    }
    cout<<" ##### ";
}
//
void solve(){
    int n;
    ll ai,curr_max,tot_ans;
    tot_ans=0;
    cin>>n;
    for(int i =0;i<n;i++){
        cin>>ai;
        if(i==0){
            curr_max = ai;
            continue;
        }
        if(ai>=curr_max)
            curr_max = ai;
        else
            tot_ans+=curr_max-ai;
    }
    cout<<tot_ans<<endl;
}

int main() {
    //solve();
    int T;
//    cin >> T;
    T=1;
    for (int case_num = 1; case_num <= T; case_num++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum (Node x ){

}

Node treeSearch (Node u, int k ){

}

Node treeSuccessor (Node x ){

}

void treeDelete (Node z ){
	Node y;	// node to be deleted
	Node x;	// child of y
}

void insert (int k ){
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc (sizeof (struct node ) );
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	if (x == NIL ){
		root = z;
	}else{
		do{
			if (x->key < k ){
				y = x->right;
			}else{
				y = x->left;
			} // end if

			if (y != NIL ){
				y->parent = x;
			}else{
				if (x->key < k )
					x->right = z;
				else
					x->left = z;
			} // end if
			x = y;
		}while (x != NIL ); // end while
	} // end if
}

void inorder (Node u ){
	if (u == NIL ) return;
	inorder (u->left );
	printf (" %d", u->key );
	inorder (u->right );
}

void preorder (Node u ){
	if (u == NIL ) return;
	printf (" %d", u->key );
	preorder (u->left );
	preorder (u->right );
}

int main()
{
	int n, i, x;
	char com[20];

	root = NIL;
	scanf ("%d", &n );
	for (i = 0; i < n; i++ ){
		scanf ("%s", com );
		if (com[0] == 'i' ){	// case insert 
			scanf ("%d", &x );
			insert (x );
		}else
		if (com[0] == 'p' ){ // case print
			inorder (root );
			printf ("\n" );
			preorder (root );
			printf ("\n" );
		} // end if
	}	// end for

	return 0;
}

Measured memory_bytes: 24040
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    a = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    xor = 0
    for i in a:
        xor ^= i

    ans = []
    for i in a:
        ans.append(xor ^ i)
    print(*ans)




main()


Measured memory_bytes: 31564
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int x1,y1,x2,y2;
    cin >> x1>>y1>>x2>>y2;
    int x_diff = x2-x1;
    int y_diff = y2-y1;
    cout << x2-y_diff << " " << y2+x_diff << " " << x1-y_diff << " " << y1+x_diff << endl;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

move = ''
xz = abs(tx-sx)
yz = abs(ty-sy)
move += 'U'*yz + 'R'*xz + 'D'*yz + 'L'*xz
move += 'L'*1 + 'U'*(yz+1) + 'R'*(xz+1) + 'D'*1
move += 'R'*1 + 'D'*(yz+1) + 'L'*(xz+1) + 'U'*1
print(move)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  char S[100000+10];
  cin >> S;
  int N = strlen(S);
  int i = N-1;
  while(i > 0){
    if(S[i] == 'r' && S[i-1] == 'e'){
      if(S[i-2] == 'm' && S[i-3] == 'a' && S[i-4] == 'e' && S[i-5] == 'r' && S[i-6] == 'd'){
        i -= 7;
      }else if(S[i-2] == 's' && S[i-3] == 'a' && S[i-4] == 'r' && S[i-5] == 'e' ){
        i -= 6;
      }else{
        cout << "NO" << endl;
        return 0;
      }
    }else if((S[i] == 'e' && S[i-1] == 's' && S[i-2] == 'a' && S[i-3] == 'r' && S[i-4] == 'e')
          || (S[i] == 'm' && S[i-1] == 'a' && S[i-2] == 'e' && S[i-3] == 'r' && S[i-4] == 'd')){
      i -= 5;
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
main()
{
	int n,x;
	cin>>n>>x;
	vector<int>a(n+1);
	if(n==1){
		int b;
		cin>>b;
		cout<<abs(b-x)<<endl;
	}else{
	rep(i,n) {
		cin>>a[i];
		a[i]=abs(a[i]-x);
		}
	sort(a.begin(),a.end());
	int ans=a[0];
	for(int i=1;i<n;i++){
		ans=gcd(ans,a[i]);
	}
	cout<<ans<<endl;
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  string kigo = ".,!? ";
  string a = "abc";
  string d = "def";
  string g = "ghi";
  string j = "jkl";
  string m = "mno";
  string p = "pqrs";
  string t = "tuv";
  string w = "wxyz";
  string syu;
  int keta,n,count;
  int flag1 = 0;
  int flag2 = 0;
  cin >> n;
  string nn;
  for(int i = 0; i < n;i++){
    cin >> nn;
    syu = "";
    for(int i = 0; i < nn.length();i++){
      if(nn[i] == '1'){
        flag1 = 1;
        flag2 += 1;
      }else if(nn[i] == '2'){
        flag1 = 2;
        flag2 += 1;
      }else if(nn[i] == '3'){
        flag1 = 3;
        flag2 += 1;
      }else if(nn[i] == '4' ){
        flag1 = 4;
        flag2 += 1;
      }else if(nn[i] == '5'){
        flag1 = 5;
        flag2 += 1;
      }else if(nn[i]== '6'){
        flag1 = 6;
        flag2 += 1;
      }else if(nn[i] == '7'){
        flag1 = 7;
        flag2 += 1;
      }else if(nn[i] == '8'){
        flag1 = 8;
        flag2 += 1;
      }else if(nn[i] == '9'){
        flag1 = 9;
        flag2 += 1;
      }else if(nn[i] == '0'){
        if(flag1 == 0){
        }else{
          flag2 -= 1;
          if(flag1 == 1){
            syu += kigo[(flag2)%5];
            flag1 = 0;
          }else if(flag1 == 2){
            syu += a[flag2%3];
            flag1 = 0;
          }else if(flag1 == 3){
            syu += d[flag2%3];
            flag1 = 0;
          }else if(flag1 == 4){
            syu += g[flag2%3];
            flag1 = 0;
          }else if(flag1 == 5){
            syu += j[flag2%3];
            flag1 = 0;
          }else if(flag1 == 6){
            syu += m[flag2%3];
            flag1 = 0;
          }else if(flag1 == 7){
            syu += p[flag2%4];
            flag1 = 0;
          }else if(flag1 == 8){
            syu += t[flag2%3];
            flag1 = 0;
          }else if(flag1 == 9){
            syu += w[flag2%4];
            flag1 = 0;
          }
          flag2 = 0;
        }
      }
    }
      cout << syu << endl;
  }
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;
ll mn1=-9223372036854775808;
int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------


void solve()
{
    ll n;
    cin>>n;
    ll c1=INT_MAX,c2=INT_MIN,c3=INT_MAX,c4=INT_MIN;
    for(int i=0;i<n;i++)
    {
        ll xi,yi;
        cin>>xi>>yi;
        c1=min(c1,xi+yi);
        c2=max(c2,xi+yi);
        c3=min(c3,xi-yi);
        c4=max(c4,xi-yi);
    }
    cout<<max(c2-c1,c4-c3)<<endl;
}
int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);

}


Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
int n,k,cnt,a[maxn],b[maxn],tree[maxn*4];
LL sum[maxn],t[maxn*2],l[maxn],r[maxn],dp[maxn];
void Pushdown(int i)
{
	if(!tree[i]) return;
	tree[i<<1]=tree[i<<1|1]=tree[i];
	tree[i]=0;
}
void Modify(int i,int l,int r,int ql,int qr,int d)
{
	if(l>r||ql>qr) return;
	if(ql<=l&&r<=qr) { tree[i]=d; return; }
	Pushdown(i);
	int mid=(l+r)>>1;
	if(ql<=mid) Modify(i<<1,l,mid,ql,qr,d);
	if(qr>mid) Modify(i<<1|1,mid+1,r,ql,qr,d);
}
int Query(int i,int l,int r,int p)
{
	if(l==r) return tree[i];
	Pushdown(i);
	int mid=(l+r)>>1;
	if(p<=mid) return Query(i<<1,l,mid,p);
	else return Query(i<<1|1,mid+1,r,p);
}
LL Query(int p)
{
	int c=Query(1,1,cnt,p);
	if(!c) return 0;
	return 1ll*dp[c]+(t[l[c]]-t[p]+k)%k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		sum[i]=sum[i-1]+a[i];
		if(b[i]==1&&2*a[i]>k) { printf("-1\n"); return 0; }
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==1) l[i]=(-2*sum[i-1]%k+k)%k,r[i]=(-2*sum[i]%k+k)%k;
		else l[i]=0,r[i]=k-1;
		t[i*2-1]=l[i],t[i*2]=r[i];
	}
	sort(t+1,t+n*2+1);
	cnt=unique(t+1,t+n*2+1)-t-1;
	for(int i=1;i<=n;i++)
		l[i]=lower_bound(t+1,t+cnt+1,l[i])-t,r[i]=lower_bound(t+1,t+cnt+1,r[i])-t;
	for(LL i=n;i;i--)
	{
		dp[i]=Query(l[i]);
		if(l[i]>r[i]) Modify(1,1,cnt,r[i]+1,l[i]-1,i);
		else { Modify(1,1,cnt,1,l[i]-1,i); Modify(1,1,cnt,r[i]+1,cnt,i); }
	}
	LL ans=dp[1];
	for(int i=1;i<=cnt;i++) ans=min(ans,Query(i));
	printf("%lld\n",ans+sum[n]*2);
}


Measured memory_bytes: 7040
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    Set<Integer> set = new HashSet<>();
    set.add(n);
    while(true){
      int m = set.size();
      if(n%2 == 0){
        n /= 2;
      }else{
        n = n*3+1;
      }
      set.add(n);
      
      if(set.size() == m){
        break;
      }
    }
    System.out.println(set.size()+1);
  }
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

/**
 * func: (long long) -> boolean
 * binary_search() returns the minimum element x which satisfies f(-∞) != f(x)
 * e.g.
 * i:    1 2 3 4 5 6 7 8 9
 * f(i): 0 0 0 0 0 0 1 1 1
 *                   ^
 *                   x
 */
template<class F>
ll binary_search(F func) {
    ll l = -2e18, r = 2e18;
    bool l_value = func(l);

    while (l != r) {
        ll m = (l + r);
        if( m % 2 == 0 ) m /= 2;
        else m = (m-1) / 2;
        if (func(m) != l_value) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return l;
}

int main() {
    long long N, K;
    cin >> N >> K;
    vector<ll> G[2];
    ll zero = 0;
    for (int i = 0; i < N; i++) {
        long long g;
        cin >> g;
        if (g == 0) {
            zero++;
        } else if (g > 0) {
            G[1].push_back(g);
        } else {
            G[0].push_back(-g);
        }
    }
    sort(G[0].begin(), G[0].end());
    sort(G[1].begin(), G[1].end());


    auto f = [&](vector<ll> &g, long long x) {
        long long ans = 0;
        for (int i = 0; i < g.size(); i++) {
            long long id = min<ll>(i, upper_bound(g.begin(), g.begin() + i, x / g[i]) - g.begin());
            ans += id;
        }
        return ans;
    };
    auto counter = [&](long long x) {
        if (x == 0) {
            long long tot = 0;
            tot += zero * (G[0].size() + G[1].size());
            tot += zero * (zero - 1) / 2;
            tot += 1ll * G[0].size() * G[1].size();
            return tot;
        } else if (x > 0) {
            long long tot = 0;
            // 0以下
            tot += zero * (G[0].size() + G[1].size());
            tot += zero * (zero - 1) / 2;
            tot += 1ll * G[0].size() * G[1].size();

            // 0より大きい
            tot += f(G[0], x);
            tot += f(G[1], x);

            return tot;
        } else {
            x = -x;
            long long tot = 0;

            for (int i = 0; i < G[0].size(); i++) {
                long long id = G[1].end() - lower_bound(G[1].begin(), G[1].end(), (x+G[0][i]-1) / G[0][i]);
                tot += id;

            }

            return tot;
        }
    };

    auto ff = [&](long long x){
        return counter(x) >= K;
    };
    cout << binary_search(ff) << endl;

    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string T;
    cin >> T;
    for (int i = 0; i < T.length(); i++)
    {
        if (T.at(i) == '?'){
            T.at(i) = 'D';
        }
    }
    cout << T ;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		double power = 1;
		
		for(int i = 1; i <= N; i++){
			power = (i * power) % (Math.pow(10, 9) + 7);
		}
		System.out.println((int)power);
	}

}

Measured memory_bytes: 21844