akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll sa=0,sb=0,a,b,n,m;
    cin>>n>>m;
    lol(i,n){
	cin>>a;
	sa+=a;
    }
    lol(i,m){
	cin>>b;
	sb+=b;
    }
    cout<<sa*sb<<endl;
    return 0;
}



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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    ll N,M;
    cin>>N>>M;
    vector<ll> A(M);
    for(ll i=0;i<M;i++){
        cin>>A.at(i);
    }
    ll ans=0;
    ans= accumulate(A.begin(),A.end(),0LL);
    ll anns = N-ans;
    if(anns>=0){
        cout<<anns<<endl;
    }
    else{
        cout<<-1<<endl;
    }

}

Measured memory_bytes: 3648
#include<stdio.h>
 #include<ctype.h>
 int main(void)
 {
     char s1[10],s2[10],s3[10];
     char S1,S2,S3;

     scanf("%s %s %s",s1,s2,s3);

     S1= toupper(s1[0]);
     S2= toupper(s2[0]);
     S3= toupper(s3[0]);

     printf("%c%c%c\n",S1,S2,S3);

     return 0;
 }



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    for(int i = 0; i < m; i++){
        cin >> x[i];
    }
    sort(all(x));

    // 座標間の差分の配列をつくる
    vector<int> y;
    for(int i = 1; i < m; i++){
        y.push_back(x[i] - x[i - 1]);
    }
    // 降順でソートする
    sort(all(y), greater<int>());
    // n - 1回大きい差分をスキップできるため、残った差分だけを加算する
    int ans = 0;
    for(int i = n - 1; i < y.size(); i++){
        ans += y[i];
    }
    if(m == 1) cout << 0 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int min = 1 << 30;
    int max = 0;
    for (int i = 0; i < n; ++i) {
      int a = sc.nextInt();
      min = Math.min(min, a);
      max = Math.max(max, a);
    }

    System.out.println(max - min);
    
    sc.close(); 
  }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
using namespace std;
#define MAX 100000

int m,a,b;
vector<int> t;
bool isP[MAX];
int main(){
  for(int i=2;i<MAX;i++)isP[i]=true;
  for(int i=2;i*i<MAX;i++){
    if(!isP[i])continue;
    for(int j=i*i;j<MAX;j+=i){
      isP[j]=false;
    }
  }
  for(int i=2;i<MAX;i++)if(isP[i])t.push_back(i);

  while(1){
    cin>>m>>a>>b;
    if(m==0&&a==0&&b==0)break;
    int ansi=0,ansj=0;
    for(int i=0;i<(int)t.size();i++){
      if(t[i]*t[i]>m)break;
      for(int j=i;j<(int)t.size();j++){
	if(t[i]*t[j]>m)break;
	if(a*t[j]<=t[i]*b){
	  if(ansi*ansj<=t[i]*t[j]){
	    ansi=t[i];
	    ansj=t[j];
	  }
	}
      }
    }
    cout<<ansi<<' '<<ansj<<endl;
  }
  return 0;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{


    int n;
    cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++)cin>>arr[i];


    int dp[n+1],odd[n+1];
    memset(odd,0,sizeof(odd));
    memset(dp,0,sizeof(dp));

    odd[1]=arr[1];

    //(1,3,5,7,9.....)
    for(int i=3;i<=n;i++){
        if(i%2==1)odd[i] = odd[i-2]+arr[i];
    }

    dp[0]=0;
    dp[1]=0;
    // n is odd
    // n is even  (1,3,5,7...) or (2,4,6,8...)
    for(int i=2;i<=n;i++)
    {
        if(i%2==0){
            dp[i] = max(odd[i-1],dp[i-2]+arr[i]);
        }
        else{
            dp[i] = max(dp[i-2]+arr[i],dp[i-1]);
        }
    }
   // for(int i=1;i<=n;i++)cout<<dp[i]<<" ";
   cout<<dp[n];
}


Measured memory_bytes: 8232
from heapq import heappush, heappop

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

for i in range(N):
  ab = list(map(int, input().split()))
  #Ai > M の仕事はいらない
  if ab[0] <= M:
    jobs[ab[0] - 1].append(ab[1])

#最終日はAi=1の仕事のみ選べる。その前の日はAi<=2, ...
#終わりから考えればよさそう
hq = []
ans = 0
for i in range(M):
  for b in jobs[i]:
    heappush(hq, -1 * b)
  if len(hq) > 0:
    m = -1 * heappop(hq)
    ans += m

print(ans)

Measured memory_bytes: 23748
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long x,y,z,k,a[1000],b[1000],c[1000];
    vector<long long>d;
    cin >> x >> y >> z >> k;
    for(int i = 0;i<x; i++)cin >>a[i];
    for(int i = 0;i<y;i++)cin >> b[i];
    for(int i = 0;i<z;i++)cin >> c[i];
    sort(a,a+x,greater<long long>());
    sort(b,b+y,greater<long long>());
    sort(c,c+z,greater<long long>());
    
    for(int i = 0;i<x;i++){
        for(int j = 0;j<y;j++){
            for(int u = 0;u<z;u++){
                if((i+1)*(j+1)*(u+1) <= k){
                    d.push_back(a[i]+b[j]+c[u]);
                }else break;
            }
        }
    }
    sort(d.begin(),d.end(),greater<long long>());
    for(int i = 0; i<k;i++){
        cout << d[i] << endl;
    }
}


Measured memory_bytes: 1400
n = int(input())
num = ["0" for i in range(64)]
for i in range(n):
    query = input().split()
    if query[0] == "0":
        print(0 if num[int(query[1])] == "0" else 1)
    elif query[0] == "1":
        num[int(query[1])] = "1"
    elif query[0] == "2":
        num[int(query[1])] = "0"
    elif query[0] == "3":
        num[int(query[1])] = "1" if num[int(query[1])] == "0" else "0"
    elif query[0] == "4":
        print("1" if num.count("1") == 64 else "0")
    elif query[0] == "5":
        print("1" if num.count("1") >= 1 else "0")
    elif query[0] == "6":
        print("1" if num.count("1") == 0 else "0")
    elif query[0] == "7":
        print(num.count("1"))
    elif query[0] == "8":
        print(int("".join(num[::-1]),2))


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
#define t4(x,y,z,a) cout<<"x is "<<x<<"    y is "<<y<<"    z is "<<z<<"    a is "<<a<<endl;
#define t3(x,y,z) cout<<"x is "<<x<<"    y is "<<y<<"    z is "<<z<<endl;
#define t2(x,y) cout<<"x is "<<x<<"    y is "<<y<<endl;
#define t1(x) cout<<"x is "<<x<<endl;
using namespace std;
const int N = 2e5 + 5;
ll n, k;
ll arr[N];
bool vis[N]={0};
int main()
{
    fastio
    ll t,i,j,l,m,a,b,x,y,z,c,d,e,p,nl,np,q,r;
    string str2,str3;
    ll mx=INT_MIN;
    ll mn=INT_MAX;
    ll ans=0,s1=0,s2=0;
    string s;
    cin>>n>>k;
    rep(i,1,n+1)
    {
        cin>>arr[i];
    }
    ll take = min(k,200000LL);
    k-=take;
    ll cur=1;
    while(take>0)
    {
        cur=arr[cur];
        take--;
    }
    if(k==0)
    {
        cout<<cur;
        return 0;
    }
    ll len=0;
    while(!vis[cur])
    {
        vis[cur]=1;
        len++;
        cur=arr[cur];
    }
    k%=len;
    while(k>0)
    {
        cur=arr[cur];
        k--;
    }

    cout<<cur;
    return 0;

}

Measured memory_bytes: 5404
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	public void run() throws Exception {
		FastIO file = new FastIO();
		int a = file.nextInt();
		int b = file.nextInt();
		int t = file.nextInt();
		int count = 0;
		for (int i = a; i <= t; i += a) count += b;
		System.out.println(count);
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			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;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}


Measured memory_bytes: 23124
string_list = list(input())
string_len = len(string_list)
renzoku_list = []

def find_letter():
  renzoku = 0
  for i in range(string_len):
    if string_list[i]=='A':
      renzoku += 1
    elif string_list[i]=='C':
      renzoku += 1
    elif string_list[i]=='G':
      renzoku += 1
    elif string_list[i]=='T':
      renzoku += 1
    else:
      renzoku_list.append(renzoku)
      renzoku = 0
  renzoku_list.append(renzoku)

find_letter()
  
if renzoku_list:
  max_len = max(renzoku_list)
  print(max_len)
else:
  print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MD 1000000007
using namespace std;
typedef long long ll;
ll n,k;
ll dp[64][52][52],ret[52][2];
int main() {
	memset(dp,0,sizeof(dp));
	memset(ret,0,sizeof(ret));
	scanf("%lld %lld ",&n,&k);
	int g=0,s=1;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			int t;
			scanf("%d ",&t);
			dp[0][i][j] = t;
		}
		ret[i][g] = 1;
	}
	for(int i=1;i<64;i++) {
		for(int j=0;j<n;j++) {
			for(int k=0;k<n;k++) {
				for(int l=0;l<n;l++) {
					dp[i][j][l] += dp[i-1][k][l]*dp[i-1][j][k];
					dp[i][j][l] %= MD;
				}
			}
		}
	}
	ll inc = 1;
	int p = 0;
	while(k > 0) {
		if(k&inc) {

			for(int i=0;i<n;i++) {
				ll val = 0;
				for(int j=0;j<n;j++) {
					val += ret[j][g]*dp[p][j][i];
					val %= MD;
				}
				ret[i][s] = val;
			}
			k -= inc;
		} else {
			for(int i=0;i<n;i++) {
				ret[i][s] = ret[i][g];
			}
		}
		s=1-s;g=1-g;
		inc <<=1;
		p++;
	}
	ll tot = 0;
	for(int i=0;i<n;i++) {
			tot += ret[i][g];
			tot %= MD;
	}
	printf("%lld\n",tot);
}


Measured memory_bytes: 1536
#include <stdio.h>
int main(){
  int a,b,c,d,org;
  scanf("%d",&org);
  a = org%10;
  b = (org/10)%10;
  c = (org/100)%10;
  d = (org/1000)%10;
  if(a == b){
    printf("Bad\n");
  }else if(b == c){
    printf("Bad\n");
  }else if(c == d){
    printf("Bad\n");
  }else{
    printf("Good\n");
  }
    return 0;
  }


Measured memory_bytes: 128
#include <stdio.h>

#define MAX 25

typedef struct {
	int parent;
	int left;
	int right;
} node;

node nodes[MAX] = {0};
int H[MAX];


void preParse(int num) {
	if (num == -1) return;
	printf(" %d", num);
	preParse(nodes[num].left);
	preParse(nodes[num].right);
	return;
}

void inParse(int num) {
	if (num == -1) return;
	inParse(nodes[num].left);
	printf(" %d", num);
	inParse(nodes[num].right);
	return;
}

void postParse(int num) {
	if (num == -1) return;
	postParse(nodes[num].left);
	postParse(nodes[num].right);
	printf(" %d", num);
	return;
}

int search_root(int n) {
	int i;
	for (i = 0; i < n; ++i) {
		if (nodes[i].parent == -1) {
			break;
		}
	}
	return i;
}

int search(int n) {
	int n1, i;
	for (i = 0; i < n; ++i) {
		if (nodes[i].parent == -1) {
			break;
		}
	}
	
	n1 = i;
	while (nodes[n1].left != -1) {
		n1 = nodes[n1].left;
	}
	
	return n1;
}

int main(void) {
	int n;
	int i, tmp, root;
	node init_node;
	init_node.parent = init_node.right = init_node.left = -1;
	for (i = 0; i < MAX; ++i) {
		nodes[i] = init_node;
	}
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &tmp);
		scanf("%d", &nodes[tmp].left);
		scanf("%d", &nodes[tmp].right);
		if (nodes[tmp].left != -1) {
			nodes[nodes[tmp].left].parent = tmp;
		}
		if (nodes[tmp].right != -1) {
			nodes[nodes[tmp].right].parent = tmp;
		}
	}

	root = search_root(n);

//	for (i = 0; i < n; ++i) {
//		printf("node = %d: p = %d: l = %d: r = %d\n", i, nodes[i].parent, nodes[i].left, nodes[i].right);
//	}
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	return 0;
}

Measured memory_bytes: 616
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int limittime = sc.nextInt();
		class Root {
			private int cost;
			private int time;

			public Root(int cost, int time) {
				super();
				this.cost = cost;
				this.time = time;
			}

			public int getCost() {
				return cost;
			}

			public int getTime() {
				return time;
			}
		}

		List<Root> roots = new ArrayList<Root>();
		for (int i = 0; i < n; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			roots.add(new Root(c, t));
		}
		

		int minimamCost = 9999;
		for (int j = 0; j < roots.size(); j++) {
			Root root = roots.get(j);

			if (root.getTime() <= limittime) {
				if (root.getCost() <= minimamCost) {
					minimamCost = root.getCost();
				}
			}
		}

		if (minimamCost == 9999) {
			System.out.println("TLE");
		} else {
			System.out.println(minimamCost);
		}

	}
}


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

const int inf = -1000;

int main() {

    string s;
    cin>>s;

    for(int i=0;i<=2;++i){
        if(s[i]==s[i+1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;
      }


Measured memory_bytes: 256
function Main(s) {
  s[0] = s[0].split(" ").map(a => parseInt(a));
  var n = s[0][0];
  var a = s[0][1];
  var x = s[1].split(" ").map(a => parseInt(a));
  var b = Array(2).fill(0).map(a => Array(n + 1).fill(0).map(a => Array(50 * n + 1).fill(0)));
  var ans = 0;
  b[0][0][0] = 1;
  for(var i = 1; i <= n; i++){
    b[i&1][0][0] = 1;
    for(var j = 1; j <= i; j++){
      for(var k = 0; k <= j * 50; k++){
        b[i&1][j][k] = b[(i+1)&1][j][k];
        if(k >= x[i-1])b[i&1][j][k] += b[(i+1)&1][j-1][k-x[i-1]];
      }
    }
  }
  for(var j = 1; j <= n; j++){
    ans += b[n&1][j][j*a];
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 16048
import java.util.Scanner;

public class Main {

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

    int[] w = new int[n];

    for (int i = 0; i < n; ++i)
      w[i] = sc.nextInt();

    int minDiff = 100 * n;

    for (int i = 0; i < n - 1; ++i) {
      int s1 = 0, s2 = 0;

      for (int j = 0; j <= i; ++j)
        s1 += w[j];
      for (int j = i + 1; j < n; ++j)
        s2 += w[j];

      int diff = Math.abs(s2 - s1);
      minDiff = (diff < minDiff) ? diff : minDiff;
    }

    System.out.println(minDiff);
  }
}

Measured memory_bytes: 22736
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int b[26] = {0};
    for(int i = 0 ; i < s.length() ; i++) {
        int a = s[i] - 'a';
        b[a] = 1;
    }
    for( char i = 'a' ; i <= 'z' ; i++ ) {
        if ( b[i - 'a'] == 0 ) {
            cout << i;
            return 0;
        }
    }
    cout << "None";
}




Measured memory_bytes: 512
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""
各マスのdp
下から来たものと左から来たものを足す
その後、重なっているところを引く
"""
MOD = 998244353
A, B, C, D = lr()  # Cは縦
dp = [[0] * (D+1) for _ in range(C+1)]   # 1-indexed
dp[A][B] = 1
for i in range(A, C+1):
    for j in range(B, D+1):
        # iが縦
        if i > A:
            dp[i][j] += dp[i-1][j] * j
        if j > B:
            dp[i][j] += dp[i][j-1] * i
        if i > A and j > B:
            dp[i][j] -= dp[i-1][j-1] * (i-1) * (j-1)
        dp[i][j] %= MOD

answer = dp[C][D]
print(answer%MOD)


Measured memory_bytes: 136656
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	ll ans = 0;
	

	cin >> a;

	map<string, ll> map;

	rep(i, 0, a) {
		string c;
		cin >> c;
		map[c]++;
	}
	cin >> b;
	rep(i, 0, b) {

		string c;
		cin >> c;
		map[c]--;
	}
	fore(i,map) {

		ans = max(ans, i.second);
	}
	//sort(map.begin(), map.end());
	
	cout << ans << endl;
	


	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine((char)(GetChar() + 1));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

typedef vector<int>  vi;
typedef set<char> setchar;
typedef set<int> sett;
typedef deque <int> dq;
typedef long long ll;
#define vec(a)  a.begin(),a.end()
#define pb     push_back
#define pf     push_front
#define mem(a,b) memset(a,b,sizeof(a));
#define inI(a)  scanf("%d",&a);
#define inL(a)  scanf("%lld",&a);
#define SWAP(a,b) a= a^b, b=a^b, a=a^b
#define uff ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
//int fx[]={+0,-1,-1,-1,+0,+1,+1,+1};
//int fy[]={-1,-1,+0,+1,+1,+1,+0,-1};
int fx[]= {0,-1,0,+1};
int fy[]= {-1,0,+1,0};



int main()
{
    uff
    //freopen("input.txt","r",stdin);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a%2==b%2)
        cout<<((b-a)/2)<<endl;
    else
        cout<<min(a-1,n-b)+1+((b-a-1)/2)<<endl;



    return 0;

}







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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, m, c;
    cin >> n >> m >> c;
    int sum = c, count = 0;
    //sum += c;
    int* b = new int[m];
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        if (sum > 0) count++;
        sum = c;
    }
    cout << count;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L){
  sort(L.begin(), L.end());
  long long max = *(L.end() - 1);
  long long sum = accumulate(L.begin(), L.end() - 1, 0LL);
  if(sum > max){
    cout << YES << endl;
    return;
  }
  cout << NO << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> L(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&L[i]);
  }
  solve(N, std::move(L));
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def inv(x):
    return pow(x, mod - 2, mod)

def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k % mod
    d = 1
    for k in range(1, b+1):
        d = d * k % mod
    return r * inv(d) % mod

def main():
    h,w,a,b = LI()
    c1 = nCb(h-a-1+b, b)
    c2 = nCb(w-b-1+a, a)
    r = 0
    for i in range(1, min(h-a, w-b)+1):
        r += c1 * c2
        r %= mod
        c1 = c1 * (h-a-i) * inv(b+i) % mod
        c2 = c2 * (w-b-i) * inv(a+i) % mod

    return r

print(main())



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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3912
def fn(n, a):
    res = 0
    while n > 0:
        res += n % a
        n //= a

    return res


def solve(N):

    ans = 10 ** 5
    for i in range(N+1):
        tmp = fn(i, 6) + fn(N-i, 9)
        ans = min(ans, tmp)

    return ans


if __name__ == "__main__":
    N = int(input())
    print(solve(N))


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

long long GetGreatestCommonDivisor(long long a, long long b) {
    long long m = a;
    long long n = b;
    long long temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}

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

    ll ans = 0;

    for (ll i = 1; i <= k; i++) {
        for (ll j = 1; j <= k; j++) {
            for (ll x = 1; x <= k; x++) {
                ll tmp = i;
                tmp = GetGreatestCommonDivisor(tmp, j);
                tmp = GetGreatestCommonDivisor(tmp, x);
                ans += tmp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
vector<int> par(1000000);//それぞれの頂点の親,最大値をsizeにする
vector<int> dis(1000000);//ランク
int n;
class union_find{
  public:
  void init(){
    for(int i = 0;i < n;i++){
      par[i] = i;//最初、親は自分自身とする
      dis[i] = 0;
    }
  }
  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = root(par[x]);
    }
  }
  //xとyが同じ集合に属すか否か
  bool same(int x,int y){
    //cout << x << " " << y << endl;
    return (root(x) == root(y));
  }
  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y)return;
    if(dis[x] < dis[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(dis[x] == dis[y])dis[x]++;
    }
  }
};

//union_find tree;
//tree.init //これで初期化
//tree.unite(a,b) //aとbのグループを併合
//tree.same(a,b) //aとbが同じグループか(trueかfalse)
int main(){
  ll m;
  cin >> n >> m;
  union_find tree;
  tree.init();
  vector<vector<ll>> lan(m);
  for(int i = 0;i < n;i++){
    ll kazu = 0;
    cin >> kazu;
    for(int j = 0;j < kazu;j++){
      ll in = 0;
      cin >> in;
      in--;
      lan[in].push_back(i);
    }
  }
  for(int i = 0;i < m;i++){
    ll size = lan[i].size();
    if(size <= 1)continue;
    for(int j = 0;j < size - 1;j++){
      tree.unite(lan[i][j],lan[i][j + 1]);
    }
  }
  bool res = true;
  for(int i = 0;i < n - 1;i++){
    if(!tree.same(i,i + 1))res = false;
  }
  if(res)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 12544
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  int l = 0, r = n - 1;
  bool isleft = true;
  for (int i = n - 1; i >= 0; i--) {
    b[isleft ? l++ : r--] = a[i];
    isleft = !isleft;
  }
  for (int x: b) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3712
input = [input() for i in range(2)]
N=int(input[0])
S=input[1]
s1=len(S)//2
s2=len(S)

if len(S)%2!=0:
    print('No')
else:
    if S[0:s1]==S[s1:s2]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
n=0
m=input()
c=[0 for i in xrange(m)]
t=[0 for i in xrange(m)]


def d(u):
    global n
    if t[u]:return
    n = n + 1
    t[u]=[u+1,n]
    for i in c[u]:d(i-1)
    n = n + 1
    t[u][2:]=[n]

def dfs():
    for i in range(m):
     l=map(int,raw_input().split())
     c[l[0]-1]=l[2:]
    for i in range(m):
     d(i)
     print " ".join(map(str,t[i]))

dfs()

Measured memory_bytes: 6472
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    string n;
    cin >> n;
    for(int i=0;i<n.size();i++){
        for(int j=i+1;j<n.size();j++){
            if(n[i]==n[j]){
                cout << "no";
                return 0;
            }
        }
    }
    cout << "yes";
}

Measured memory_bytes: 256
const val mod = 1e9.toLong()+7L
class MInt(_x: Long){
    var x : Long = (_x%mod+mod)% mod
    public final operator fun unaryMinus(): MInt = MInt(-x)
    public final operator fun plus(a : MInt) = MInt(x+a.x)
    public final operator fun minus(a : MInt) = MInt(x-a.x)
    public final operator fun times(a : MInt) = MInt(x*a.x)
    public final operator fun div(a : MInt) = this*a.invMod()

    public final fun pow(t : Long) : MInt {
        if (t == 0L) return MInt(1)
        var a = pow(t shr 1)
        a *= a
        if (t and 1L == 1L) a *= this
        return a
    }
    private final fun extGcd(a: Long, b : Long) : Triple<Long, Long, Long>{
        if(b == 0L) return Triple(1, 0, a)
        val q = a / b
        val (_x,y, g) = extGcd(b, a-q*b)
        val z = _x - q*y
        return Triple(y, z, g)
    }
    public final fun invMod() : MInt {
        var (_x,y,g) = extGcd(x,mod)
        _x %= mod
        if(_x<mod) _x += mod
        return MInt(_x)
    }
}

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    var sum = MInt(0)
    for(i in k..(n+1)){
        val sumN = MInt(n) * MInt(n+1) / MInt(2L)
        val sumNK = MInt(n-i) * MInt(n-i+1) / MInt(2L)
        val sumK1 = MInt(i-1) * MInt(i) / MInt(2L)
        val inSum = sumN - sumNK - sumK1 + MInt(1)
        sum += inSum
    }
    println(sum.x)
}

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

using namespace std;

typedef long long int lli;

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

    int n, m, u, v, s, t;
    cin >> n >> m;
    vector<vector<int>> g(n+1, vector<int>()), mod3(n+1, vector<int>(3, 0));

    for (int i=0; i<m; i++) {
        cin >> u >> v;
        g[u].push_back(v);
    }
    cin >> s >> t;

    priority_queue<pair<lli, int>> qu;
    qu.push(make_pair(0, s));

    while (!qu.empty()) {
        lli num = -qu.top().first + 1LL;
        int crnt = qu.top().second;
        qu.pop();

        for (auto gg : g[crnt]) {
            if (mod3[gg][num%3]) continue;
            mod3[gg][num%3] = 1;
            qu.push(make_pair(-num, gg));

            if (gg==t && num%3==0) {
                cout << num/3 << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long ans = LLONG_MAX;
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> P(R);
    for ( int i = 0; i < R; i++ ) {
        cin >> P[i];
        P[i]--;
    }
    sort( P.begin(), P.end() );
    
    
    long long dist[200][200];
    
    for ( int i = 0; i < 200; i++ ) {
    for ( int j = 0; j < 200; j++ ) {
        if ( i == j ) { dist[i][j] = 0; }
        else { dist[i][j] = LLONG_MAX; }       
    }
    }
    
    for ( int i = 0; i < M; i++ ) {
        long long a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    
    for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
    for ( int k = 0; k < N; k++ ) {
        if ( dist[j][i] == LLONG_MAX || dist[i][k] == LLONG_MAX ) { continue; }
        dist[j][k] = min( dist[j][k], dist[j][i] + dist[i][k] );
    }
    }
    }
    
    
    do {
        
        long long d = 0;
        for ( int i = 1; i < P.size(); i++ ) {
            if ( dist[ P[i-1] ][ P[i] ] == LLONG_MAX ) { d = LLONG_MAX; break; }
            d += dist[ P[i-1] ][ P[i] ];
        }
        
        ans = min( ans, d );
        
    } while ( next_permutation( P.begin(), P.end()) );
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int left=0;
	int right=mod;
	while(left+1<right){
		int M=(left+right)/2;
		long long t=0;
		for(int j=0;j<a;j++){
			int f=(p[j]-1)/M;

			t+=f;
		}
		if(b>=t)right=M;
		else left=M;
	}
	printf("%d\n",right);
}

Measured memory_bytes: 2516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000005];
int main()
{
	map<int,int> maps;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	ll ans = 0;
	for(int i=1;i<=n;i++)maps[i + a[i]]++;
	for(int i=1;i<=n;i++){
		if(maps.count(i - a[i])) {
			ans+=maps[i - a[i]];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

const int MAXN = 400010;
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef std::pair<int, int> pi;
int n; pi ls[MAXN]; LL ans;
int li[MAXN], bak, rs[MAXN], R[MAXN];
void gma(int & x, int y) { x < y ? x = y : 0; }
int lb(int x) { return std::lower_bound(li + 1, li + 1 + bak, x) - li; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	int lm = INF, la = -INF, rm = INF, ra = -INF;
	for (int i = 1; i <= n; ++i) {
		std::cin >> ls[i].first >> ls[i].second;
		if (ls[i].first > ls[i].second)
			std::swap(ls[i].first, ls[i].second);
		lm = std::min(lm, ls[i].first);
		la = std::max(la, ls[i].first);
		rm = std::min(rm, ls[i].second);
		ra = std::max(ra, ls[i].second);
		li[++bak] = ls[i].first, li[++bak] = ls[i].second;
	}
	ans = (LL) (la - lm) * (ra - rm);
	std::sort(li + 1, li + 1 + bak);
	bak = std::unique(li + 1, li + 1 + bak) - li - 1;
	for (int i = 1; i <= n; ++i)
		gma(R[lb(ls[i].first)], li[lb(ls[i].second)]);
	int r = la;
	for (int i = 1; i <= n && li[i] <= rm; ++i) {
		// std::cout << i << ' ' << r << std::endl;
		ans = std::min(ans, (LL) (r - li[i]) * (ra - lm));
		r = std::max(r, R[i]);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 6016
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include<unordered_set>
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'a'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}



int main()
{
	int a, b;
	cin >> a >> b;
	cout<<max({ a + b ,a - b,a*b }) << endl;


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace std
{
    class Test {
        static void Main(string[] args) {
            List<int> ary = new List<int>();
            var num = Console.ReadLine();
            var input = Console.ReadLine().Split(' ');
             var n = int.Parse(num);
            for (int i = 0; i< n; i++) {
                var inp = int.Parse(input[i]);
                ary.Add(inp);
            }
           
            Test obj = new Test();
            obj.insertionSort(ary, n);
            
        }






        public void insertionSort(List<int> ary, int num) {
        
          int v, i, j, k;
       
            for (i = 0; i <= num -1; i++) {
    
                v = ary[i];
                j = i-1;
          

             while(j >= 0 && ary[j] > v) {
                ary[j+1] = ary[j];
                 j--;
                 ary[j+1] = v;  
             }
               
               for( k = 0; k < num; k++) { 
                   Console.Write(ary[k]);
                if(k < num - 1) Console.Write(" "); //空白
               }
            /*   if(i < num - 1)*/  Console.WriteLine("");//改行
            }   

 
        }







    }
}



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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;

ll dp[101005];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, w, p;
    cin >> n >> p;
    w = 100000;
    memset(dp, INF, sizeof(dp));
    dp[0] = 0;
    loop(n) {
        int wi, v;
        cin >> v >> wi;
        for (int curw = w; curw >= wi; --curw) {
            if (dp[curw - wi] != LLINF) {
                dp[curw] = min(dp[curw], dp[curw - wi] + v);
            }
        }
    }
    for (int i = w; i >= 0; --i) {
        if (dp[i] <= p) {
            RET(i);
        }
    }

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <algorithm>
//#include <utility>
//#include <stack>
//#include <queue>
//#include <tuple>
//#include <set>
//#include <map>
//#include <unordered_map>
//#include <vector>
//#include <functional>
//#include <bitset>
//#include <cmath>
using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    lint K;
    cin >> K;

    cout << 50 << endl;
    lint A[50];
    for(int i=0;i<50;i++) A[i]=50+K/50;
    for(int i=0;i<50-K%50;i++){
        lint max=-1;
        int mi=0;
        for(int j=0;j<50;j++){
            if(max<=A[j]){
                max=A[j];
                mi=j;
            }
        }
        for(int j=0;j<50;j++) A[j]++;
        A[mi]-=51;
    }

    for(int i=0;i<49;i++) cout << A[i] << ' ';
    cout << A[49] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
/*
signed main(){
  vector<int> v;
  int n,k;
  cin>>n>>k;
  lp(i,n){
    int a;
    cin>>a;
    v.push_back(a);
  }
  int a[101][200];
  lp(i,101)lp(j,200)a[i][j]=-INF;
  lp(i,n){
    if(i==0){
      a[0][1]=v[i];
      if(v[i]<0){
        a[0][2]=0;
      }
    }
    else{
      int x=i;
      while(1){
        if(a[i-1][x]==-INF) break;
        int ch=a[i-1][x];
        a[i][x+1]=max(v[i]+ch,a[i][x+1]);
        if(v[i]<0)a[i][x+2]=ch;
        x++;
      }
    }
  }
  int b[101][200];
  lp(i,101)lp(j,200)b[i][j]=-INF;
  lp(z,n){
    int i=n-z-1;
    if(i==0){
      b[0][1]=v[i];
      if(v[i]<0){
        b[0][2]=0;
      }
    }
    else{
      int x=i;
      while(1){
        if(b[i-1][x]==-INF) break;
        int ch=b[i-1][x];
        b[i][x+1]=max(v[i]+ch,a[i][x+1]);
        if(v[i]<0)b[i][x+2]=ch;
        x++;
      }
    }
  }
  int aans[101],bans[101];
  int maxi=-INF;
  lp(i,101){
    if(i==0) continue;
    lp(j,101){
      maxi=max(maxi,a[j][i]);
    }
    aans[i]=maxi;
    cout<<aans[i]<<endl;
  }
  maxi=-INF;
  lp(i,101){
    if(i==0) continue;
    lp(j,101){
      maxi=max(maxi,b[j][i]);
    }
    bans[i]=maxi;
  }
  int ans=-INF;
  lp(z,k){
    int i=z+1;
    int j=k-i;
    ans=max(aans[i]+bans[j],ans);
  }
  cout<<ans<<endl;
  return 0;
}
*/

signed main(){
  int n,qq;
  cin>>n>>qq;
  vector<pair<pair<int,int>,int>> v;
  lp(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    v.push_back({{a-c,b-c},c});
    //cout<<a-c<<" "<<b-c<<" "<<c<<endl;
  }
  sort(v.begin(),v.end());
  priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> q;
  int vit=0;
  int ans=0;
  int anst=0;
  lp(i,qq){  
    int d;
    cin>>d;
    if(vit!=v.size()){
      while(vit!=v.size()){
        if(v[vit].first.first<=d){
          pair<int,pair<int,int>> p={v[vit].second,{v[vit].first.first,v[vit].first.second}};
          q.push(p);
          vit++;
        }
        else break;
      }
    }
    while(!q.empty()){
      if(q.top().second.second<=d) q.pop();
      else break;
    }
    if(q.empty()) cout<<-1<<endl;
    else{
      cout<<q.top().first<<endl;
    }
    //cout<<q.size()<<endl;
  }

  return 0;
}

Measured memory_bytes: 15468
#include <stdio.h>

int main ()
{
    int tc, i, n[100], gcd, lcm, a, b, c, d, t, r, s;

    while (scanf ("%d", &tc) == 1){
        for (i = 0; i < tc; i++){
            scanf ("%d", &n[i]);
        }
        a = n[0];
        b = n[1];
        r = n[0] * n[1];
        for (i = 2; i <= tc; i++){

         if (a==0){
            gcd=a;
        }
        else if (b==0) {
            gcd=b;
        }
        else {
                d=a;
                c=b;
            while (c!=0){
                t=c;
                c=d%c;
                d=t;
            }
            gcd = d;
        }

         lcm = r / gcd;
         a = lcm;
         b = n[i];

         r = a * b;

        }
      printf("%d\n", lcm);

    }
    return 0;
}



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

using namespace std;

int main(int argc, char *argv[]) {
  int weight;
  int item[10] = {1, 2, 4, 8, 16, 32,
                  64, 128, 256, 512};
  vector< vector<int> > result;
  while (cin >> weight) {
    vector<int> r;
    for (int i = 10; i > 0; i--)
      if (weight >= item[i-1]) {
        r.push_back(item[i-1]);
        weight -= item[i-1];
      }
    result.push_back(r);
  }

  for (int i = 0; i < result.size(); i++) {
    vector<int> r = result[i];
    for (int j = r.size(); j > 0; j--) {
      if (j != r.size())
        cout << ' ';
      cout << r[j-1];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
a ,b= list(map(int,input().split()))

def gcd(a,b):
    X = max(a,b)
    g=0
    for i in range(1,X+1):
        if a%i == 0 and b%i == 0:
            g = i
    return g




answer = gcd(a,b)
print(int(a*b/answer))

Measured memory_bytes: 3060
input_list = [input() for i in range(2)]
M = input_list[0]
N = input_list[1]

ans = []

for i in range(len(M)-len(N)+1):

    num = 0

    substring = input_list[0][i:i+len(N)]

    for j in range(len(N)):

        if substring[j] != N[j]:

            num += 1

    ans.append(num)

print(min(ans))

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

const int N = 1000010;

char s[N], tmp[N];

int ct[3], fucked[N];

vector<int> pos, pos2;

int main() {
    int n, tp = 0; scanf("%s", tmp + 1); n = strlen(tmp + 1);
    for (int i = 1; i <= n; i++) 
        if (tp == 0 || s[tp] != tmp[i]) s[++tp] = tmp[i];
    n = tp;
    for (int i = 1; i <= n; i++) ct[s[i] - 'A']++;
    int mn = 0, mx = 0;
    for (int i = 1; i < 3; i++) {
        if (ct[mn] > ct[i]) mn = i;
        if (ct[mx] <= ct[i]) mx = i;
    }
    int diff = ct[mx] - (n - ct[mx] - ct[mn]);
    for (int i = 0, j = 0; i < n; i = j) if (i == 0 || s[i] == 'A' + mn) {
        j = i + 1;
        while (j <= n && s[j] != 'A' + mn) j++;
        if (j == i + 1) continue;
        if (j == i + 2 && j <= n && i) {
            if (s[i + 1] == 'A' + mx) pos2.push_back(i + 1);
        } else {
            if (s[i + 1] == 'A' + mx) pos.push_back(i + 1);
            if (j - 1 != i + 1 && s[j - 1] == 'A' + mx) pos.push_back(j - 1);
        }
    }
    int pos1 = 0, pos3 = 0;
    for (int i = 1; i <= diff; i++) {
        if (pos1 < pos.size()) fucked[pos[pos1]] = 1, pos1++;
        else fucked[pos2[pos3]] = fucked[pos2[pos3] - 1] = 1, pos3++;
    }
    tp = ct[0] = ct[1] = ct[2] = 0;
    for (int i = 1; i <= n; i++) if (!fucked[i]) 
        tmp[++tp] = s[i], ct[s[i] - 'A']++;
    diff = ct[mx] - ct[mn];
    ct[0] = ct[1] = ct[2] = 0;
    for (int i = 1; i <= tp; i++) {
        if (diff && i < tp && tmp[i] != mn + 'A' && tmp[i + 1] != mn + 'A' && tmp[i] != tmp[i + 1] && (i + 2 > tp || tmp[i + 2] != mn + 'A'))
            diff--, i++;
        else putchar(tmp[i]), ct[tmp[i] - 'A']++;
    }
    return 0;
}


Measured memory_bytes: 7412