akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  vector<int> mi, ma;
  UnionFind(int n=0): d(n,-1) {
     rep(i,n)mi.push_back(i);
     rep(i,n)ma.push_back(i);
  }
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    mi[x] = min(mi[x],mi[y]);
    ma[x] = max(ma[x],ma[y]);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
  int Min(int x) {return mi[find(x)];}
  int Max(int x) {return ma[find(x)];}
};
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int t; cin >> t;
   while(t--){
      int n; cin >> n;
      ll ans = 0;
      vector<pair<int,int>> postiv,negtiv;
      rep(i,n){
         int k, l, r; cin >> k >> l >> r;
         ans += r;
         int m = l-r;
         if (m>=0)postiv.push_back({m,k});
         else negtiv.push_back({m,k});
      }
      sort(postiv.begin(),postiv.end());
      reverse(postiv.begin(),postiv.end());
      sort(negtiv.begin(), negtiv.end());
      UnionFind uf(n+2);
      for (auto &&i : postiv){
         i.second = min(i.second, int(postiv.size()));
         if (uf.same(i.second, 0))continue;
         uf.unite(i.second, uf.Min(i.second)-1);
         ans += i.first;
      }
      for (auto &&i : negtiv){
         i.second = max(i.second+1, int(postiv.size()+1));
         if (uf.same(i.second, n+1))ans += i.first;
         else uf.unite(i.second, uf.Max(i.second)+1);
      }
      cout << ans << endl;
   }
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
#define len(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define chmax(x, v) x = max((x), (v))
#define chmin(x, v) x = min((x), (v))
using namespace std;
using ll = long long;

bool solve() {
	int n; cin >> n;
	multiset<int> s;
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		s.insert(x);
	}
	int diam = *s.rbegin();
	int lowestAnchor = diam;
	for (int i = 0; i <= diam; ++i) {
		int dist = max(i, diam-i);
		chmin(lowestAnchor, dist);
		auto it = s.find(dist);
		if (it == s.end()) return false;
		s.erase(it);
	}
	if (!s.empty() && *s.begin() <= lowestAnchor) {
		return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	if (solve()) {
		cout << "Possible\n";
	} else {
		cout << "Impossible\n";
	}
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main()
{
    ll A, V;
    cin >> A >> V;
    ll B, W;
    cin >> B >> W;
    ll T;
    cin >> T;
    ll D = abs(A - B);
    ll D2 = (V - W) * T;
    puts(D <= D2 ? "YES" : "NO");
}

Measured memory_bytes: 3584
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

double a,b,x;
double v(double s){
    if(b<=a*tan(s)){
        return b*b*a/tan(s)/(double)2;
    }
    else{
        return (double)a*a*(2*b-a*tan(s))/(double)2;
    }
}
double binary_search(double l,double r){
    if(r-l<0.00000001){
        return l;
    }
    double m=(l+r)/2;
    if(v(m)>=x){
        return binary_search(m,r);
    }
    else{
        return binary_search(l,m);
    }
}
int main(){
    cin>>a>>b>>x;
    printf("%0.10lf\n",180/M_PI*binary_search(0,89.9999999/180*M_PI));
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    int N;
	int evennum = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if (num%2 == 0) evennum ++;
	}
	int res = pow(3, N) - pow(2, evennum);
	cout << res;
	return 0;
}
	

Measured memory_bytes: 640
void main()
{
    dchar[] s = readln.chomp.to!(dchar[]);

    dchar[] t = s.dup;
    reverse(t);
    long cnt;
    foreach (i; 0 .. s.length/2)
    {
        if (s[i] != t[i]) ++cnt;
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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


int main (void) {
  int N;
  std::cin >> N;

  std::unordered_map<int, int> t;
  for(int i=0; i<N; i++){
    int A; std::cin >> A;
    if ( t.count(A) == 0 ) t[A] = 1;
    else t[A]++;
  }


  int ans = 0;
  int two_pair = 0;
  for(auto itr = t.begin(); itr != t.end(); ++itr){
    if ( itr->second == 2 ) two_pair++;
    if ( itr->second >= 3 ) {
      if ( itr->second % 2 == 0 ) {
        ans += ( itr->second - 2 ) / 2;
        itr->second = 2;
        two_pair++;
      }
      else {
        ans += ( itr->second -1 ) / 2;
        itr->second = 1;
      }
    }
  }

  if ( two_pair % 2 == 0 ) {
    ans += (two_pair/2);
  }
  else {
    ans += (two_pair+1)/2;
  }

  std::cout << N - (2*ans) << std::endl;

  return 0;
}

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

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

  ll a[N];
  ll sum[N+1] = {};
  ll sump[N+1] = {};
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum[i+1] = sum[i] + a[i];
    if(a[i] > 0LL) sump[i+1] = sump[i] + a[i];
    else sump[i+1] = sump[i];
  }

  /*for(int i=0;i<=N;i++){
    cout << sum[i] << " ";
  }
  cout << endl;
  for(int i=0;i<=N;i++){
    cout << sump[i] << " ";
  }
  cout << endl;*/

  ll ans = 0LL;
  for(int i=0; i<=N-K; i++){
    ll tmp;
    ll sm = sum[i+K] - sum[i];
    tmp = max(0LL, sm);
    tmp += sump[i] - sump[0];
    tmp += sump[N] - sump[i+K];

    ans = max(ans, tmp);
  }

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

Measured memory_bytes: 2688
#include <iostream>
#define N 182
#define N1 4
using namespace std;
void func(int,int,int);
int n,c,data[N];

int main(){
  data[0]=0;
  for(int i=1;i<=N;i++) data[i]=i*i;
  while(1){
    cin>>n;
    if(!n) break;
    c=0;
    func(0,0,data[N-1]);
    cout<<c<<endl;
  }
}

void func(int d,int sum,int b){
  if(d==N1){
    if(sum==n) c++;
    return ;
  }
  for(int i=0;i<=N;i++){
    if(sum+data[i]>n) break;
    if(b>=data[i]) func(d+1,sum+data[i],data[i]);
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void){
	char a[4][131072] = {""},s[131072];
	int n,i,j;
	scanf("%d%s",&n,s);
	a[0][0]='S',a[0][1]='S';
	a[1][0]='S',a[1][1]='W';
	a[2][0]='W',a[2][1]='S';
	a[3][0]='W',a[3][1]='W';
	for(i = 1;i < n-1;i++){
		for(j = 0;j < 4;j++){
			if(a[j][i] == 'S'){
				if(s[i] == 'o'){if(a[j][i-1] == 'S'){a[j][i+1] = 'S';}else{a[j][i+1] = 'W';}}
				else{if(a[j][i-1] == 'S'){a[j][i+1] = 'W';}else{a[j][i+1] = 'S';}}
			}
			if(a[j][i] == 'W'){
				if(s[i] == 'o'){if(a[j][i-1] == 'S'){a[j][i+1] = 'W';}else{a[j][i+1] = 'S';}}
				else{if(a[j][i-1] == 'S'){a[j][i+1] = 'S';}else{a[j][i+1] = 'W';}}
			}
		}
	}
	for(j = 0;j < 4;j++){
		if(a[j][n-1] == 'S'){if((s[n-1] == 'o' && a[j][n-2] != a[j][0]) || (s[n-1] == 'x' && a[j][n-2] == a[j][0])){continue;}}
		else{if((s[n-1] == 'o' && a[j][n-2] == a[j][0]) || (s[n-1] == 'x' && a[j][n-2] != a[j][0])){continue;}}
		if(a[j][0] == 'S'){if((s[0] == 'o' && a[j][n-1] != a[j][1]) || (s[0] == 'x' && a[j][n-1] == a[j][1])){continue;}}
		else{if((s[0] == 'o' && a[j][n-1] == a[j][1]) || (s[0] == 'x' && a[j][n-1] != a[j][1])){continue;}}
		printf("%s\n",a[j]);return 0;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> inputList = new ArrayList<>();
		while (sc.hasNext()) {
			inputList.add(sc.nextInt());
		}
		List<Integer> tmpList = new ArrayList<>();
		for (int tmp : inputList) {
			tmpList.add(tmp);
		}
		Collections.sort(tmpList);
		int max = tmpList.get(tmpList.size() - 1);
		boolean[] primeArray = new boolean[max + 1];
		Arrays.fill(primeArray, true);
		primeArray[0] = false;
		primeArray[1] = false;
		primeFalse(2, primeArray);
		for (int i = 3; i < primeArray.length;i+=2) {
			if(primeJudge(i)){
				primeFalse(i, primeArray);
			}
		}
		for (int n : inputList) {
			int count = 0;
			int primeNum = 0;
			do {
				primeNum = nextPrime(primeNum, primeArray);
				if (primeNum < 0 || primeNum > n) {
					break;
				} else {
					count++;
				}
			} while (true);
			System.out.println(count);
		}
	}
	
	public static boolean primeJudge(int n) {
		int a = (int)Math.sqrt(n) + 1;
		for (int i = 2; i < a; i++) {
			if(n % i == 0){
				return false;
			}
		}
		return true;
	}
	
	public static void primeFalse(int n, boolean[] array) {
		int tmp = n;
		while (tmp < array.length) {
			array[tmp] = false;
			tmp += n;
		}
		array[n] = true;
	}
	
	public static int nextPrime(int n, boolean[] array) {
		int tmp = n + 1;
		while (tmp < array.length) {
			if (array[tmp++]) {
				return --tmp;
			}
		}
		return -1;
	}
}



Measured memory_bytes: 28244
N = int(input())
A, B = map(int, input().split())
scores = list(map(int, input().split()))

na, nb, nc = 0, 0, 0
for i in scores:
  if i <= A:
    na += 1
  elif i <= B:
    nb += 1
  else:
    nc += 1
    
print(min(na,nb,nc))

Measured memory_bytes: 3064
#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>;

int main() {
  string s, t;
  cin >> s >> t;
  int ls = s.size();
  int lt = t.size();
  vector<string> ss;
  for (int i = 0; i + lt - 1 < ls; ++i) {
    bool ok = true;
    rep(j, lt) {
      if (s[i + j] != '?' && s[i + j] != t[j]) ok = false;
    }
    string u = "";
    rep(j, ls) {
      if (j >= i && j < i + lt) u += t[j-i];
      else if (s[j] == '?') u += 'a';
      else u += s[j];
    }
    if (ok) ss.push_back(u);
  }
  sort(ss.begin(), ss.end());
  if (ss.size() == 0) ss.push_back("UNRESTORABLE");
  cout << ss[0] << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<cstring>
#define loop(i,r,l) for(int (i)=(r);(i)<(l);(i)++)
#define rep(i,n) loop(i,0,n)
#define INF 1000000007
using namespace std;

int main(){
    int K,T,d,val=0;
    cin>>K>>T;
    rep(i,T){
        cin>>d;
        val=max(val,d);
    }
    int res=2*val-K-1;
    if(res>0)cout<<res<<endl;
    else cout<<0<<endl;
}

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


#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

string a,b;
int main() {
    cin >> a>>b;

    b = b.erase(b.length() - 1);
   
    if (a == b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3624
s = input()
q = int(input())
insts = [input().split() for _ in range(q)]

for inst in insts:
    a, b = int(inst[1]), int(inst[2]) + 1
    if inst[0] == "replace":
        p = inst[3]
        s = s[:a] + p + s[b:]
    elif inst[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif inst[0] == "print":
        print(s[a:b])



Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
int ans, r, g, b;
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>();
	string str = next<string>();
	rep(i, 0, n)
		if (str[i] == 'R') r++;
		else if (str[i] == 'G') g++;
		else b++;
	ans = r*g*b;
	rep(i, 0, n)
		rep(l, 1, n)
		{
			int j = i+l, k = i+2*l;
			if (k >= n) continue;
			if (str[i]+str[j]+str[k] == 'R'+'G'+'B') ans--;
		}
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}

int main() {
  int n,x; cin>>n>>x;
  if (x==1||x==2*n-1) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  if (n==2) {
    // x==2
    cout<<"1 2 3"<<endl;
    return 0;
  }
  int an[2*n-1]={};
  bool use[2*n-1]; fill(use,use+2*n-1,false);
  if (x==2) {
    an[n]=4;
    an[n-1]=1;
    an[n-2]=2;
    an[n-3]=3;
    for(int i=0;i<4;i++) use[i]=true;
  } else {
    an[n]=x-2;
    an[n-1]=x+1;
    an[n-2]=x;
    an[n-3]=x-1;
    for(int i=0;i<4;i++) use[x+i-3]=true;
  }
  for(int i=0,j=0;i<2*n-1;i++) {
    if (an[i]>0) continue;
    while(use[j]) j++;
    an[i]=j+1;
    use[j]=true;
  }
  for(int i=0;i<2*n-1;i++) {
    cout<<an[i]<<endl;
  }
}

Measured memory_bytes: 2432
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

place = -1
gap = 1000000

for i in range(N):
    tmp = T - H[i]*0.006
    if gap > abs(A-tmp):
        gap = abs(A-tmp)
        place = i

print(place+1)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Procon
{
  public Procon() {}
  static void Main(string[] agrs)
  {
    new Procon().Do();
  }

  Scanner cin;

  public void Do()
  {
    cin = new Scanner();
    int N = cin.nextInt();
    int[] h = cin.arrayInt();

    int i;
    for (i=0;; i++) {
      int ok = 0;
      for (int j=0;j<N; j++) {
        if (h[j] != 0) {
          ok = 1;
        }
      }
      if (ok == 0) {
        break;
      }
      mizuyari(h, N);
    }
    Console.WriteLine(i);
  }

  public void mizuyari (int[] h, int N) {
    int min = 101;
    int l = 0;
    int r = N;

    for (int i=0; i<N; i++) {
      if (h[i] == 0) {
        if (min > 100) {
          l = i+1;
          continue;
        }
        r = i;
        break;
      } else if (h[i] < min) {
        min = h[i];
      }
    }

    if (min > 100) {
      return;
    }

    for (int i=l; i<r; i++) {
      h[i] = h[i] - 1;
    }
    return;
  }
}


class Scanner
{
  string[] s;
  int i;
  int max_i;

  public Scanner()
  {
    s = new string[0];
    max_i = 0;
    i = 0;
  }

  public string nextString()
  {
    if (i >= s.Length) 
    {
      s = Console.ReadLine().Split(' ');
      max_i = s.Length;
      i = 0;
      if (max_i == 0) 
      {
        return "";
      }
      return s[i++];
    } else 
    {
      return s[i++];
    }
  }

  public int nextInt()
  {
    return int.Parse(nextString());
  }


  public long nextLong()
  {
    return long.Parse(nextString());
  }

  public double nextDouble()
  {
    return double.Parse(nextString());
  }

  public string[] arrayString()
  {
    return Console.ReadLine().Split(' ');
  }

  public int[] arrayInt()
  {
    string[] str = Console.ReadLine().Split(' ');
    int[] array = new int[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = int.Parse(str[i]);
    }
    return array;
  }

  public long[] arrayLong()
  {
    string[] str = Console.ReadLine().Split(' ');
    long[] array = new long[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = long.Parse(str[i]);
    }
    return array;
  }

  public double[] arrayDouble()
  {
    string[] str = Console.ReadLine().Split(' ');
    double[] array = new double[str.Length];
    for (int i=0; i<str.Length; i++) 
    {
      array[i] = double.Parse(str[i]);
    }
    return array;
  }
}


Measured memory_bytes: 11092
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    val X = Array.ofDim[Int](N + 1)
    rep(N) { i =>
      X(i) = ni()
    }
    X(N) = M
    val ms = X.min
    rep(N + 1){ i => X(i) -= ms }

    var g = X(0)
    rep(N, 1) { i =>
      g = gcd(g, X(i))
    }

    out.println(g)
  }


  def gcd(a: Int, b: Int): Int = {
    if (b == 0) a
    else {
      val r = a % b
      if (r == 0) b
      else gcd(b, r)
    }
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }
}

Measured memory_bytes: 38760
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

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

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string N;
  std::cin >> N;

  bool judge = false;
  for (auto c : N) {
    if (c == '9') judge = true;
  }

  if (judge) print("Yes");
  else print("No");

  return 0;
}


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

int main() {
    string S,T;
    cin >> S >> T;
    
    bool flg = true;
    for ( int i = 0; i < S.size(); ++i){
        if ( S[i] != T[i] ) flg = false;
    }
    
    if ( flg ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int l = sc.nextInt();
            List<int[]> edges = new ArrayList<>();
            int n = 1;
            while (true) {
                if (l == 1) {
//                    edges.add(new int[]{n, -1, 1});
//                    n++;
                    break;
                }
                edges.add(new int[]{n, n + 1, 0});
                edges.add(new int[]{n, n + 1, (l + 1) / 2});
                if (l % 2 != 0) {
                    edges.add(new int[]{n, -1, l / 2});
                }
                n += 1;
                l /= 2;
            }
            pw.println(n + " " + edges.size());
            for (int i = 0; i < edges.size(); i++) {
                int a = edges.get(i)[0];
                int b = edges.get(i)[1]; if (b == -1) b = n;
                int c = edges.get(i)[2];
                pw.println(a + " " + b + " " + c);
            }

        }


    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 22740
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[1],reverse=False)
down = sorted(ab,key=lambda a:a[0],reverse=False)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2][1]+up[N//2-1][1])
    l = (down[N//2][0]+down[N//2-1][0])
    print(r-l+1)

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

int main(){
	string a;
	string b;
	string c;
	cin >> a >> b >> c;
	a[0] = a[0] - 32;
	b[0] = b[0] - 32;
	c[0] = c[0] - 32;

	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
const ll INF = 1e18;
using namespace std;
// using namespace atcoder;



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


void Main()
{
    ll n;
    cin >> n;

    vector<ll> A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    
    // (A, B) -> (y=A/Bx上のベクトル数, y=-B/Ax上のベクトル数)
    map<pair<ll, ll>, pair<ll, ll> > p;

    ll zeros = 0;
    rep(i, n) {
        ll x = A[i];
        ll y = B[i];
        if (x == 0 && y == 0) {
            zeros++;
            continue;
        }

        ll gcd = GCD(abs(x), abs(y));
        x /= gcd;
        y /= gcd;

        // 第一象限版を探す
        ll x1 = x;
        ll y1 = y;
        ll vertical = false;
        if (x == 0 || y == 0) {
            x1 = 1;
            y1 = 0;
            vertical = y != 0;
        }
        if (x < 0 && y < 0) { x1 = -x; y1 = -y; }
        else if (x < 0 && y > 0) { x1 = y; y1 = -x; vertical = true; }
        else if (x > 0 && y < 0) { x1 = -y; y1 = x; vertical = true; }

        if (!p.count({x1, y1})) {
            p[{x1, y1}] = {0, 0};
        }
        if (vertical) {
            p[{x1, y1}].second++;
        }
        else {
            p[{x1, y1}].first++;
        }
    }

    ll mod = 7+1e9;
    vector<ll> pow2(n+1);
    pow2[0] = 1;
    rep(i, n) pow2[i+1] = pow2[i] * 2 % mod;

    ll res = 1;
    for (auto& pa: p) {
        res = res * (pow2[pa.second.first] + pow2[pa.second.second] - 1) % mod;
    //     cout << pa.first.first << "," << pa.first.second << ":" << pa.second.first << "," << pa.second.second;
    //     cout << endl;
    }
    res = res + zeros + mod - 1;
    res %= mod;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 23440
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		
		int[] arr = new int[n];
		for (int i=0; i<n; i++)
			arr[i] = in.nextInt();
		
		long res = Long.MAX_VALUE;
		for (int i=-100; i<=100; i++) {
			long cost = 0;
			for (int j=0; j<n; j++)
				cost += (arr[j]-i)*(arr[j]-i);
			res = Math.min(res, cost);
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<vector>
using namespace std;
int len, ans, nowmax;
int h[20];
int main(){
	cin >> len;
	for(int i = 0;i < len;++i){
		cin >> h[i];
		if(h[i] >= nowmax){
			++ans;
			nowmax = h[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
# 親の顔より見たPairs
# 小さい順に見てk番目
# x以下の数がk個以上となる最小のxを求める
# x以下の数がk個以上かつx−1以下の数はk個未満
from bisect import bisect_left, bisect_right

import sys

input = sys.stdin.buffer.readline
n, k = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

minus_num = bisect_left(A, 0)
zero_num = bisect_right(A, 0) - minus_num
plus_num = n - (minus_num + zero_num)

seki_minus = plus_num * minus_num
seki_plus = plus_num * (plus_num - 1) // 2 + minus_num * (minus_num - 1) // 2
seki_zero = zero_num * (plus_num + minus_num) + zero_num * (zero_num - 1) // 2
assert seki_minus + seki_plus + seki_zero == n * (n - 1) // 2

mA = A[:minus_num]
pA = A[-plus_num:]


# ある数以下のものが何個有るかを返す関数
def calc(num):
    res = 0
    if num < 0:
        lim = minus_num - 1
        mmA = mA[::-1]
        for i in range(plus_num):
            while lim >= 0:
                if mmA[lim] * pA[i] <= num:
                    lim -= 1
                else:
                    break
            res += minus_num - (lim + 1)
    elif num == 0:
        res = seki_zero + seki_minus
    else:
        # pA
        lim = plus_num - 1
        for i in range(plus_num):
            while lim >= 0:
                if pA[lim] * pA[i] > num:
                    lim -= 1
                else:
                    break
            if lim >= i:
                res -= 1
            res += lim + 1
        # mA
        lim = minus_num - 1
        mmA = mA[::-1]
        for i in range(minus_num):
            while lim >= 0:
                if mmA[lim] * mmA[i] > num:
                    lim -= 1
                else:
                    break
            if lim >= i:
                res -= 1
            res += lim + 1
        assert res % 2 == 0
        res //= 2
        res += seki_minus
        res += seki_zero
    return res


ok = 10 ** 20
ng = -(10 ** 20)

while ok - ng > 1:
    mid = (ok + ng) // 2
    if calc(mid) >= k:
        ok = mid
    else:
        ng = mid
    # print(ok, ng)


print(ok)


Measured memory_bytes: 159284
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int h,w,ch,cw,dh,dw;
string s[1000];
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};

vector<ll> dijkstra(const vector<vector<pair<int,int>>>& graph,int s){
    int n=(int)graph.size();
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    vector<ll> dist(n,linf);
    dist[s]=0;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            int w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                pq.push({dist[u],u});
            }
        }
    }
    return dist;
}

int main(){
    cin>>h>>w>>ch>>cw>>dh>>dw;
    --ch;--cw;--dh;--dw;
    rep(i,h)cin>>s[i];
    vector<vector<pair<int,int>>> g(h*w);
    rep(x,h){
        rep(y,w){
            if(s[x][y]=='#')continue;
            int f=x*w+y;
            for(int i=0;i<4;++i){
                int nx=x+dx[i];
                int ny=y+dy[i];
                int t=nx*w+ny;
                if(nx<0||h<=nx||ny<0||w<=ny||s[nx][ny]=='#')continue;
                g[f].push_back({t,0});
            }
            for(int i=-2;i<=2;++i){
                int nx=x+i;
                for(int j=-2;j<=2;++j){
                    int ny=y+j;
                    int t=nx*w+ny;
                    if(nx<0||h<=nx||ny<0||w<=ny||s[nx][ny]=='#')continue;
                    g[f].push_back({t,1});
                }
            }
        }
    }
    vector<ll> d=dijkstra(g,ch*w+cw);
    rep(i,h){
        rep(j,w){
            if(d[i*w+j]==linf)d[i*w+j]=-1;
        }
    }
    cout<<d[dh*w+dw]<<endl;
}


Measured memory_bytes: 125580
#include <iostream>
using namespace std;
int d[105]={0},f[105]={0};
bool vi[105]={0};
int Time=0;
int k[105][105];

void dfs(int r,int n){

	vi[r]=true;
	d[r]=Time;
for(int i=0;i<n;i++){
	if(vi[i]!=true && k[r][i]==1){
		Time=Time+1;
		d[i]=Time;
		dfs(i,n);
		f[i]=Time;
	}
}
Time=Time+1;
f[r]=Time;
}
int main() {
int n,l,a,b;
cin>>n;
for(int j=0;j<n;j++){
	cin>>l>>a;
	for(int i=0;i<a;i++){
		cin>>b;
		k[j][b-1]=1;
	}
}
for(int g=0;g<n;g++){
	if(vi[g]!=true){
		Time=Time+1;
		dfs(g,n);
	}
	
}
for(int k=0;k<n;k++){

cout<<k+1<<" "<<d[k]<<" "<<f[k]<<endl;
}	
	return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint a,b,c; scanf("%lld %lld.%lld",&a,&b,&c);

  lint d=a*(b*100+c)/100;
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;

typedef long long ll;

typedef struct{
    ll i;
    ll j;
} T;

int main() {
    ll h, w, d;
    cin >> h >> w >> d;
    T A[300*300];
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            ll t;
            cin >> t;
            t--;
            A[t].i = i;
            A[t].j = j;
        }
    }
    ll map[300*300];
    for (ll i = 0; i < d; i++) {
        map[i] = 0;
        ll j = i;
        while(j+d < h*w) {
            T t1 = A[j];
            T t2 = A[j+d];
            map[j+d] = map[j] + abs(t2.i-t1.i) + abs(t2.j-t1.j);
            j += d;
        }
    }

    ll q;
    cin >> q;
    for (ll qi = 0; qi < q; qi++) {
        ll l, r;
        scanf("%ld %ld", &l, &r);
        printf("%ld\n", map[r-1]-map[l-1]);
    }
    
    return 0;
}


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


int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    ll i;ll m=0;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	m=max(m,a[i]);
	}
	//cout<<"Maximum   ="<<m<<endl;
	ll bool1[m+1];
	memset(bool1,0,sizeof(bool1));
	ll j;
	sort(a,a+n);
	
	for(i=0;i<n;i++)
	{
		for(j=a[i];j<=m;j=j+a[i])
		{
			bool1[j]++;
		}
	}
	//cout<<"yo"<<endl;
	/*for(i=0;i<=m;i++)
	{
		cout<<i<<"  "<<bool1[i]<<endl;
	}*/
	ll cnt=0;
	for(i=0;i<n;i++)
	{
		if(bool1[a[i]]>1)
		cnt++;
	}
	cout<<n-cnt<<endl;
	return 0;
}
	

Measured memory_bytes: 13012
import sys

input = sys.stdin.readline

def main():
    t = 'ATGC'
    ans = 0
    S = input()
    temp = 0
    for s in S:
        if s in t:
            temp += 1
        else:
            ans = max(ans, temp)
            temp = 0

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define  INF 1ll<<60
signed main(){
  int n,k=0,maxi=0,final;
  cin>>n;
  vector<int> vet(n);
  for(int i=0; i<n; i++){
    cin>>vet[i];
  }
  for(int i=0; i<n; i++){
    if(i!=n-1){
      if(vet[i]>=vet[i+1]){
        k++;
      }else{
        k=0;
      }
    }
    if(k>maxi){
      maxi=k;
      final=i-k;
    }
  }
  cout<<maxi<<endl;
}

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

int n, m;
int x11[55], y11[55], x22[55], y22[55];

int get_dist(int id1, int id2) {
	return labs(x11[id1] - x22[id2]) + labs(y11[id1] - y22[id2]);
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++) scanf("%d%d", &x11[i], &y11[i]);
	for(int i=0;i<m;i++) scanf("%d%d", &x22[i], &y22[i]);
	for(int i=0;i<n;i++) {
		int id = 0, dist = get_dist(i, 0);
		for(int j=1;j<m;j++) {
			int cur = get_dist(i, j);
			if(cur<dist) {
				dist = cur; id = j;
			}
		}
		printf("%d\n", id+1);
	}
	
	return 0;
}

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

using namespace std;

const int N=1e5+10;

int n,des,a[N];

string solve(){
    int ans=0;
    for(int i=1;i<=n;i++) ans=__gcd(ans,a[i]);
    if (des%ans||des>(*max_element(a+1,a+n+1))) return "IMPOSSIBLE";
    return "POSSIBLE";
}
int main(){
    scanf("%d%d",&n,&des);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    cout<<solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int p[n];
  rep(i,n) {
    R p[i];
    p[i]--;
  }
  int a[n],b[n],k=1;
  rep(i,n) a[i]=40000*i+1;
  rrep(i,n) {
    b[i]=40000*(n-1-i)+k;
    k++;
  }
  REP(i,1,n) {
    int x=a[p[i]]+b[p[i]];
    int y=a[p[i-1]]+b[p[i-1]]+1;
    b[p[i]]+=y-(a[p[i]]+b[p[i]]);
  }
  PR(a,n);
  PR(b,n);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        while (sn.hasNext()) {
            long a = sn.nextLong();
            long b = sn.nextLong();
            System.out.printf("%d %d\n", gcd(a, b), lcm(a, b));
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }
}

Measured memory_bytes: 18140
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

//https://algo-logic.info/permutation/
int main() {
    ll n;
    cin >> n;
    vll p(n),q(n);
    REP(i,n){
        cin >> p[i];
    }
    REP(i,n){
        cin >> q[i];
    }

    vll one_case(n);
    REP(i,n){ // one_case = {1,2,3,...n-1} とする
        one_case[i] = i+1;
    }

    ll ii=0,p2,q2;
    do {
        if(one_case == p){
            p2 = ii;
        }
        if(one_case == q){
            q2 = ii;
        }
        ii++;
    } while (next_permutation(one_case.begin(), one_case.end()));
    // 順列の最後になるまで one_case を並び替えながらループ

    cout << abs(p2-q2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    int n;
    cin>>n;
    n %= 10;
    if(n == 3) cout<<"bon";
    else if(n == 0 || n==1 || n==6 || n==8) cout<<"pon";
    else cout<<"hon";
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int cards[4][13]={{}};
    char a;
    int m;
    
    for(int i=0;i<n;i++){
        cin >> a >> m;
        if (a=='S'){
            cards[0][m-1]=1;
        }else if (a=='H'){
            cards[1][m-1]=1;
        }else if (a=='C'){
            cards[2][m-1]=1;
        }else if (a=='D'){
            cards[3][m-1]=1;
        }
    }
    for(int j=0;j<4;j++){
        for(int l=0;l<13;l++){
            if(cards[j][l]!=1){
                if(j==0){
                    cout << 'S' << " " << l+1 << endl;
                }else if (j==1){
                    cout << 'H' << " " << l+1 << endl;
                }else if (j==2){
                    cout << 'C' << " " << l+1 << endl;
                }else{
                    cout << 'D' << " " << l+1 << endl;
                }
                
            }
        }
    }
}


Measured memory_bytes: 3084
object Main { 
  def main(args:Array[String]) {
    val ABC = readLine().split(' ').map(_.toInt).toList
    val A = ABC(0)
    val B = ABC(1)
    val C = ABC(2)

    var ans = 0
    if(A - B >= C) ans = 0
    else ans = C - (A - B)
    println(ans)
  }
}


Measured memory_bytes: 25492
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    h = list(map(int, input().split()))

    ok = True
    h[0] -= 1
    for i in range(1, N):
        if h[i] > h[i-1]:
            h[i] -= 1
        elif h[i] == h[i-1]:
            pass
        else:
            ok = False
            break
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()
            

Measured memory_bytes: 14172
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	vi Par,Rank;
	Union_Find_Tree(int n){
		Par=Rank=vi(n);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		if(Rank[x]<Rank[y]) Par[x]=y;
		else{
			Par[y]=x;
			if(Rank[x]==Rank[y]) Rank[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){
		return Find_Par(x)==Find_Par(y);
	}
};

const int M=2005;
ll n,m,x,two[M];
vip a;
vvp g;

ll dfs(int v,int w,int goal){
	if(v==goal) return -1;
	for(auto p:g[v]){
		ll u=p.first,c=p.second;
		if(u==w) continue;
		ll e=dfs(u,v,goal);
		if(e!=inf) return max(c,e);
	}
	return inf;
}

int main(){
	cin>>n>>m>>x;
	a=vip(m);
	g=vvp(n);
	two[0]=1;
	for(int i=1;i<M;i++) two[i]=two[i-1]*2%mod;
	for(int i=0;i<m;i++){
		ll u,v,c;
		cin>>u>>v>>c;
		a[i]={c,{u-1,v-1}};
	}
	sort(a.begin(),a.end());
	Union_Find_Tree uft(n);
	ll sum=0;
	vip b;
	for(int i=0;i<m;i++){
		P p=a[i].second;
		ll c=a[i].first,u=p.first,v=p.second;
		if(!uft.Same(u,v)){
			uft.Unite(u,v);
			g[u].push_back({v,c});
			g[v].push_back({u,c});
			sum+=c;
		}
		else b.push_back(a[i]);
	}
	ll res=0;
	vl d(m-n+1);
	if(sum==x) res=(two[n-1]+mod-2)%mod*two[m-n+1]%mod;
	for(int i=0;i<m-n+1;i++){
		P p=b[i].second;
		ll u=p.first,v=p.second,e=dfs(u,-1,v);
		d[i]=b[i].first-e;
	}
	sort(d.begin(),d.end());
	ll t=1;
	for(auto i:d) if(sum+i==x) (t*=2)%=mod;
	(t+=mod-1)%=mod;(t*=2)%=mod;
	for(auto i:d) if(sum+i>x) (t*=2)%=mod;
	(res+=t)%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 384
import fractions
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
g = a[0]
for i in range(n):
    g = fractions.gcd(g, a[i])
if k % g == 0 and k <= a[-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

int main(){
    int  n;
    double i,j,k;
    
    cin >> n;
    k=n;
    
    i=n;

    if(n % 2 != 0){
        i= n+1;
    }
    j=i/2;
    double ans;
    ans = j/k;
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int gcd(long long int a, long long int b);
int main() {
	
	//C
	long long int A, B;
	cin >> A >> B;
	cout <<  A * B / gcd(A, B) << endl;
	return 0;
	//B
	/*int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int i;
	for (i = 0; i < n; i++) {
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
	return 0;*/
}
long long int gcd(long long int a,long long  int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int l, m, n;
	while (scanf("%d", &l), l)
	{
		int ans = 0;
		for (int i = 0; i < 12; ++i)
		{
			int t;
			scanf("%d %d", &m, &n);
			l -= m - n;
			if (l <= 0 && !ans)
				ans = i+1;
		}
		if (ans)
			printf("%d\n", ans);
		else
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  int fans=0;
  for(int a=0;a<=K&&a<=N;a++){
    for(int b=0;b<=a&&a+b<=K;b++){
      for(int c=0;a+b+c<=K&&c<=N&&a+c<=N;c++){
        for(int d=0;d<=c&&a+b+c+d<=K;d++){
          priority_queue<int> pq,qp;
          ans=0;
          for(int i=0;i<a;i++){
            ans+=v[i];pq.push(-1*v[i]);
          }
          for(int i=0;i<b;i++){
            int p=pq.top();pq.pop();ans+=p;
          }
          for(int i=0;i<c;i++){
            ans+=v[N-1-i];qp.push(-1*v[N-1-i]);
          }
          for(int i=0;i<d;i++){
            int p=qp.top();qp.pop();ans+=p;
          }
          fans=max(ans,fans);
        }
      }
    }
  }
  cout<<fans<<endl;
}


Measured memory_bytes: 256