akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;

int main(){
  long long N;cin>>N;
  vector<long long>A(N);
  long long ans=0;
  vector<long long>dp(100007);

  for(int i=0;i<N;i++){
      cin>>A[i];
      dp[A[i]]+=1;
      ans+=A[i];

  }
  long long Q;cin>>Q;
  vector<long long>B(Q);
  vector<long long>C(Q);
  for(int i=0;i<Q;i++){
      cin>>B[i]>>C[i];
      ans+=(C[i]-B[i])*dp[B[i]];
      dp[C[i]]+=dp[B[i]];
      dp[B[i]]=0;
      cout<<ans<<endl;
  


  }
  

  
    





}

Measured memory_bytes: 6332
n = int(input()) -2
a = list(map(int, input().split()))

sa = sorted(a,reverse=True)

c = 1
ans = sa[0]


for i in range(1, len(sa)):
    if n <= 0:
        break
    elif n == 1:
        ans += sa[i]
        n -= 1
    else:
        ans += sa[i]*2
        n -= 2
        # print(sa[i])

print(ans)



Measured memory_bytes: 31432
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
4 2 3
---+/
/+---test
5 3 100
---+/

void main(string[] args) {
  long N, K, S;
  readf(" %d %d %d ", &N, &K, &S);

  auto S_ = S+1;
  if (S_ > 10000) S_ -= 2;

  foreach (i; 0..K) {
    S.write;
    if (i != N-1) " ".write;
  }
  foreach (i; K..N) {
    S_.write;
    if (i != N-1) " ".write;
  }
  writeln;
}


Measured memory_bytes: 1404
#include <stdio.h>
void print(int a[], int n){
    for(int i = 0; i < n; i++) {
        if(i == n-1) printf("%d\n", a[i]);
        else printf("%d ", a[i]);
    }
}

void insertSort(int a[], int n){
    for(int i = 1; i < n; i++){
        int j = i-1;
        int v = a[i];
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        print(a, n);
    }
}
int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);

    print(a, n);

    insertSort(a, n);
    return 0;
}


Measured memory_bytes: 2040
require 'set'

def run(s)
  ans=[]
  for i in 0..s.size-2
    l1=s[0..i]
    r1=s[i+1..-1]
    l2=l1.reverse
    r2=r1.reverse
    ans.push(l1+r1)
    ans.push(l1+r2)
    ans.push(l2+r1)
    ans.push(l2+r2)
  end
  return ans
end

m=gets.to_i
for i in 0..m-1
  s=gets.chomp
  s2=s.reverse
  a=run(s)
  b=run(s2)
  set=Set.new(a+b)
  puts set.size
end

Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[10],i;
    for(i=1;i<=5;i++)
        cin>>a[i];
    for(i=1;i<=5;i++)
    {
        if(a[i]==0)
          cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
import sys

class UnionFind():
    def __init__(self, num):
        self.par = [-1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        prx = self.par[rx]
        pry = self.par[ry]
        if rx != ry:
            if prx <= pry:
                self.par[ry] = rx 
                self.par[rx] += pry
            else:
                self.par[rx] = ry
                self.par[ry] += prx
        return

def inpl(): return list(map(int, input().split()))
input = sys.stdin.readline

N, M = inpl()
Edge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]

UF = UnionFind(N)
ic = N*(N-1)//2
Ans = []
for i, (a, b) in enumerate(Edge[::-1]):
    Ans.append(ic)
    ra = UF.find(a)
    rb = UF.find(b)
    if ra != rb:
        ic -= UF.par[ra]*UF.par[rb]
        UF.union(a, b)
for a in Ans[::-1]:
    print(a)


Measured memory_bytes: 121052
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));+
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

void Ok()
{
    long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb[1013],ccc,ddd;
    string spc,in,store;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>aaa;
    cin>>bbb;
    a = strlen(aaa);
    b = strlen(bbb);
    Min = 9999999;
    ans_1 = (a - b) + 1;
    for(i=0;i<(ans_1);i++)
    {
        ans_2 = i + (b - 1);
        cnt_1 = 0;
        for(j=i,k=0;j<=ans_2;j++,k++)
        {
            if(aaa[j]!=bbb[k])
                cnt_1++;
        }
        Min = min(Min,cnt_1);
    }
    cout<<Min<<endl;

    return;
}

int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int x[m];
  vector<int> v;
  for(int i=0;i<m;i++){
    cin>>x[i];
  }
  sort(x,x+m);
  for(int i=1;i<m;i++)v.push_back(x[i]-x[i-1]);
  sort(v.begin(),v.end());
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<m-n;i++){
    ans+=v[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1276
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(r, g, b, n) = getArray[Int]

    var count = 0

    for(rn <- 0 to n) {
      for(gn <- 0 to n) {
        if ((n - rn * r - gn * g) / b >= 0 && (n - rn * r - gn * g) % b == 0) {
          count += 1
        }
      }
    }

    out.println(count)

    out.flush()
  }
}

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

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

    bool ans = false;

    if (N[0] == '7') ans = true;
    if (N[1] == '7') ans = true;
    if (N[2] == '7') ans = true;

    cout << ((ans) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#define k 1024
#define r(a) for(int i=0;i<a;i++)
#define s(a) scanf("%d",&a);
#define m(a,b) a<b?a:b
int w,n,m,c[k],d[k],p[k];main(){s(n)s(m)r(n)s(d[i])r(m)s(c[i])r(n)p[i+1]=1e9;r(m*n)w=n-i%n,p[w]=m(p[w],p[w-1]+c[i/n]*d[w-1]);printf("%d\n",p[n]);}

Measured memory_bytes: 1040
#include <iostream>
#include <iomanip>

using namespace std ;
int main ()
{
    double a=0 , c=0 , d=0 , e=0 ;
    cin >> a ;
    c=3.141592653589 ;
    d=2*c*a ;
    e=a*a*c ;
    cout << fixed << setprecision(6) << e << " " << d << endl ;
    return 0 ;
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main() {
    string divide[4] = {"dream", "erase", "dreamer", "eraser"};
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool can = true;
    for (int i = 0; i < s.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            if (s.substr(i, divide[j].size()) == divide[j]) {
                can2 = true;
                i += divide[j].size();
            }
        }
        if(!can2) {
            can = false;
            break;
        }
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {
	static int[] array;
	static int count;

	public static void merge(int left,int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] l = new int[n1 + 1];
		int[] r = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			l[i] = array[left + i];
		}
		for (int i = 0; i < n2; i++) {
			r[i] = array[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;
		int i = 0, j = 0;
		for (int k = left; k < right; k++) {
			count++;
			if (l[i] <= r[j]) {
				array[k] = l[i++];
			} else {
				array[k] = r[j++];
			}
		}
	}
	public static void mergeSort(int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(left, mid);
			mergeSort(mid, right);
			merge(left, mid, right);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		mergeSort(0, n);
		for (int i = 0; i < n; i++) {
			if (i == n - 1) {
				System.out.println(array[i]);
			} else {
				System.out.print(array[i] + " ");
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 172864
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll k;
    cin>>k;
    ll now = 7%k;
    rep(i, k){
        if(now == 0) {
            cout<<i+1<<endl;
            return 0;
        }
        now = (now*10+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007
#define pii pair<long long,long long>
 
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
unordered_map<char,pii>dir;
ll D=1e9;
bool check(ll x,ll y,ll z,ll X,ll Y,ll Z)
{
	return x<=X && x>=0 && y>=0 && y<=Y && z>=0 && z<=Z;
}

int main()
{
	ios_base::sync_with_stdio(false);

	
	ll x,k,d;
	cin>>x>>k>>d;

	ll a=abs(x);

	ll num=a/d;

	num=min(num,k);
	k-=num;
	a-=d*num;
	

	if(k>0)
	{
		if(k&1)
		{
			// if(abs(a-d)<a)
				a=abs(a-d);
		}
	}

	cout<<a<<endl;
	
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, m, k; cin >> n >> m >> k;
    rep(i,n+1){
        rep(j,m+1){
            if(i*m+j*n-2*i*j==k){
                cout << "Yes" << endl;
                return 0;
            } 
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('c2.in')
# sys.stdin = open('gen_c/c10.in')


def solve_it_large(n, l, t, x, w):
    ants = []
    for i in range(n):
        ants.append([x[i], w[i], (x[i] + w[i] * t) % l, i])
    # ants.sort()

    n_intersections = 0
    x0, w0, dest0, i0 = ants[0]
    for x, w, dest, i in ants:
        if w != w0:
            d = (w0 * (x - x0) + l) % l
            intersections = 0
            if 2 * t >= d:
                intersections = (2 * t - d) // l + 1
            n_intersections += intersections

    res = [0] * n
    shift = n_intersections
    for i in range(n):
        res[ants[(i + w0 * shift) % n][3]] = ants[i][2]
    return res


def solve_it_chameleons(n, l, t, x, w):
    initial_color = [i for i in range(n)]

    chameleons = [[x[i], w[i], initial_color[i]] for i in range(n)]
    initial_color_clockwise = [chameleons[i][2] for i in range(n)]

    x0, w0, color0 = chameleons[0]
    for i in range(n):
        if w[i] != w0:
            d = (w0 * (x[i] - x0)) % l
            meet = 0
            if 2 * t >= d:
                meet = (2 * t - d) // l + 1
            color0 += w0 * meet
            color0 %= n

    # The chameleon (let's call him chameleon 0) initially at x0 is at (x0 + w0 * t) % l at the end,
    # Initially, its color is color0 and it changed <meet> times.
    # The final clockwise colors are a translation of the initial clockwise colors.

    x_final = [(x[i] + w[i] * t) % l for i in range(n)]
    x_final.sort()
    i = x_final.index((x0 + w0 * t) % l)
    if i + 1 < n and x_final[i] == x_final[i + 1]:
        if w0 == 1:
            i += 1
    res = [0] * n
    for k in range(n):
        color = (color0 + k) % n
        res[color] = x_final[(i+k) % n]
    return res


if __name__ == '__main__':

    n, l, t = map(int, input().split())
    x = []
    w = []
    for i in range(n):
        _x, _w = map(int, input().split())
        if _w == 2:
            _w = -1
        x.append(_x)
        w.append(_w)

    res = solve_it_chameleons(n, l, t, x, w)
    for i in range(n):
        print(res[i])


Measured memory_bytes: 27628
n=int(input())
xys=[list(map(int,input().split()))for _ in range(n)]

ans=0
def dist(p1,p2):
	return ((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5

for i in range(n):
	for j in range(i+1,n):
		ans+=dist(xys[i],xys[j])
ans*=2
ans/=n
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
template<class T>
struct SWAG {
	struct node {
		T val, sum;
		node(T v, T s) : val(v), sum(s) {}
	};
	stack<node> F, B;
	T fold_all() const {
		if (empty()) return T();
		if (F.empty()) return B.top().sum;
		if (B.empty()) return F.top().sum;
		return F.top().sum + B.top().sum;
	}
	void push(T x) {
		if (B.empty()) B.emplace(x, x);
		else {
			T s{B.top().sum + x};
			B.emplace(x, move(s));
		}
	}
	void pop() {
		assert(!empty());
		if (F.empty()) {
			F.emplace(B.top().val, B.top().val); B.pop();
			while (B.size()) {
				F.emplace(B.top().val, B.top().val + F.top().sum);
				B.pop();
			}
		}
		F.pop();
	}
	bool empty() const {
		return size() == 0;
	}
	uint_fast32_t size() const {
		return F.size() + B.size();
	}
};

template<class T>
struct monoid {
	const static T UNITY = 0;
	T val;
	monoid() : val(UNITY) {}
	monoid(T x) : val(x) {}
	T operator+(const monoid& rhs) const {return this->val + rhs.val;}
	// T operator+(const monoid& rhs) const {return this->val * rhs.val;}
	operator T() const {
		return val;
	}
	friend istream& operator>>(istream& lhs, monoid& rhs) {
		cin >> rhs.val;
		return lhs;
	}
};

using mono = monoid<long long>;

template<class T, class U = long long>
vector<int> syaku(const vector<T>& v, const function<bool(T)>& f) {
	SWAG<T> S;
	int l = 0, r = 0;
	const int N = v.size();
	vector<int> res;
	while (l < N) {
		while (r < N && f(S.fold_all() + v[r])) S.push(v[r++]);
		res.push_back(r);
		l++;
		if (r < l) r++;
		else S.pop();
	}
	return move(res);
}


int main() {
	int N, Q; cin >> N >> Q;
	vector<mono> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	while (Q--) {
		long long x; cin >> x;
		auto r = syaku<mono>(v, [&](mono a) -> bool {return a.val <= x;});
		long long res = 0;
		for (int i = 0; i < N; i++) {
			res += r[i] - i;
		}
		cout << res << endl;
	}
}
// int main() {
// 	int N, K; cin >> N >> K;
// 	vector<mono> v(N);
// 	for (int i = 0; i < N; i++) cin >> v[i];
// 	if (*min_element(v.begin(), v.end()) == 0) {
// 		cout << N << endl;
// 		return 0;
// 	}
// 	// cout << syaku<mono, long long>(v, [&](mono x){
// 	// 	return x <= K;
// 	// }, [](int l, int r, long long& res) -> void {
// 	// 	res = max<long long>(res, r - l);
// 	// }) << endl;
// 	cout << syaku<mono, long long>(v, [&](mono x){
// 		return x <= K;
// 	}) << endl;
// }


Measured memory_bytes: 5888
from collections import defaultdict
from queue import deque
N = int(input())
colors = [None]*N
edges = defaultdict(list)
for i in range(N-1):
    u,v,w = map(int,input().split())
    edges[u-1].append((v-1, w))
    edges[v-1].append((u-1, w))
colors[0] = 0
q = deque([0])
while q:
    u = q.popleft()
    for v,w in edges[u]:
        if colors[v] != None:
            continue
        if edges[v] != []:
            q.append(v)
        if w % 2 == 0:
            colors[v] = colors[u]
        else:
            colors[v] = 1 ^ colors[u]
for c in colors:
    print(c)

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N, l, r;
	while(cin >> N >> l >> r && N+l+r){
		vector<int32> P(N);
		REP(i, N) cin >> P[i];
		int32 res = l-1;
		sort(all(P), greater<int32>());
		FOR(i, l-1, r){
			if(P[res]-P[res+1] <= P[i]-P[i+1]){
				res = i;
			}
		}
		cout << res+1 << endl;
	}
}


Measured memory_bytes: 3124
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int,int> P;

int n;
string s;
bool checker(){
    rip(i,n-1,0){
        if(s[i] != s[n-2-i]){
            return true;
        }
    }
    return (s[n-1] == '1' || s[0] == '0');
}

int main(){
    cin >> s;
    n = s.size();
    if(checker()){
        cout << -1 << endl;
        return 0;
    }
    vector<P> ans(0);
    int now = n/2;
    for(int i = n/2-1;i>-1;i--){
        ans.push_back(mp(i,now));
        if(s[i] == '1'){
            now = i;
        }
    }
    rip(i,n,n/2 + 1){
        ans.push_back(mp(n/2,i));
    }
    rip(i,n-1,0){
        printf("%d %d\n",ans[i].first + 1, ans[i].second + 1);
    }
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <queue>
 
class Baseball{
	int score, out_count;
	std::queue<bool> runners;
public:
	Baseball() : score(), out_count(){}
	void hit();
	void homerun();
	void out();
	int get_score() {return score;}
	int get_out() {return out_count;}
};

void Baseball::hit(){
	runners.push(true);
	if(runners.size() == 4){
		++score;
		runners.pop();
	}
}

void Baseball::homerun(){
	score += runners.size() + 1;
	while(!runners.empty()){
		runners.pop();
	}
}

void Baseball::out(){
	++out_count;
}

int main(){
	int inning;
	std::cin >> inning;
	for(int i = 0; i < inning; ++i){
		Baseball game;
		while(game.get_out() != 3){
			std::string event;
			std::cin >> event;
			if(event == "HIT"){
				game.hit();
			}
			else if(event == "HOMERUN"){
				game.homerun();
			}
			else if(event == "OUT"){
				game.out();
			}
		}
		std::cout << game.get_score() << std::endl;
	}
}

Measured memory_bytes: 1220
s,t=[0]*26,[0]*26
for a,b in zip(input(),input()):
  s[ord(a)-ord('a')]+=1
  t[ord(b)-ord('a')]+=1
u,v=[],[]
for a,b in zip(s,t):
  if a!=b:
    u.append(a)
    v.append(b)
print('YNeos'[sorted(u)!=sorted(v)::2])

Measured memory_bytes: 43548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s,t;cin>>s>>t;
    bool can=false;
    rep(i,s.size()){
        string tr = s.substr(i + 1) +s.substr(0, i + 1);
        if(t==tr) can=true;
    }

    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    string s;
    for(int i=0; i<3; i++){
        cin>>s;
        cout<<char(toupper(s[0]));
    }
    cout<<endl;
}


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

int main() {
    //
    long long num;
    long long sum = 0;

    cin >> num;

    vector<long long> vec(num);
    for (int i = 0; i < num; i++) cin >> vec.at(i);

    for (int i = 1; i < num; i++) {
        if (vec.at(i - 1) > vec.at(i)) {
            sum += vec.at(i - 1) - vec.at(i);
            vec.at(i) += vec.at(i - 1) - vec.at(i);
        }
    }

    cout << sum;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e6 + 5;
int a[MAXN];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int k, n; read(k), read(n);
  for (RI i = 1; i <= n; ++i) read(a[i]);
  int ans = k;
  for (RI i = 1; i < n; ++i) ans = min(ans, k - (a[i + 1] - a[i]));
  ans = min(ans, k - (a[1] + k - a[n]));
  cout << ans;

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define nn 3008
#define mod 1000000007
#define ll long long	 
int f[nn][nn];
int s[nn][nn];
int n;
string dif;
void calc(int i)
{
	for(int j=1;j<=i+1;j++) s[i][j]=(s[i][j-1]+f[i][j])%mod;
}
int sum(int i,int l,int r)
{
	return (s[i][r]-s[i][l-1])%mod;
}
int main()
{
	cin>>n>>dif;
	f[1][1]=1;calc(1);//j smallest
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		if(dif[i-2]=='<')
			f[i][j]=sum(i-1,1,j-1);	
		else
			f[i][j]=sum(i-1,j,i);	
		calc(i);
	}
	cout<<(mod+s[n][n]%mod)%mod;
	return 0;
}

Measured memory_bytes: 69504
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

bool comp(const pair<int,string>& p1, const pair<int,string>& p2)
{
    if(p1.first > p2.first){
        return true;
    } else if(p1.first < p2.first){
        return false;
    } else {
        return p1.second < p2.second;
    }
}

int main()
{
    int n;
    while(cin >> n, n){
        cin.ignore();
        
        map<string,int> m;
        
        vector<string> v(n);
        for(int i = 0; i < n; ++i){
            getline(cin,v[i]);
        }
        char k;
        cin >> k;
        
        for(int i = 0; i < n; ++i){
            stringstream ss(v[i]);
            string word;
            while(ss >> word){
                if(word[0] == k){
                    ++m[word];
                }
            }
        }
        
        if(m.size() == 0){
            cout << "NA" << endl;
            continue;
        }
        
        vector<pair<int,string> > res;
        for(map<string,int>::iterator it = m.begin(); it != m.end(); ++it){
            res.push_back(pair<int,string>((*it).second,(*it).first));
        }
        sort(res.begin(),res.end(),comp);
        for(int i = 0; i < 5 && i < (int)res.size(); ++i){
            if(i != 0) cout << ' ';
            cout << res[i].second; 
        }
        cout << endl;
    }
}

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

using namespace std;
typedef long long ll;

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

  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());

  int l = 0;
  vector<int> v;
  while (l < n) {
    if (v.size() == 0) v.push_back(d[l]);
    else if (v.back() < d[l]) v.push_back(d[l]);
    l++;
  }
  cout << v.size() << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n;
int a[20];
int main() {
    cin >> n;
    int l=0;LL t=n;
    while (t) a[++l]=t%10,t/=10;
    int ans=(l-1)*9;
    int s=0;
    for (int i=1;i<=l;++i) s+=a[i];
    ans=max(ans,s);
    for (int i=1;i<l;++i) {
        if (a[i]<9) {
            a[i]=9;
            a[i+1]--;
            int p=i+1;
            while (a[p]<0) a[p]+=10,a[p+1]--,p++;
        }
        s=0;
        for (int j=1;j<=l;++j) s+=a[j];
        ans=max(ans,s);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d, n;
	cin >> d >> n;
	int cnt = 0;
	int div = 1;
	rep(i,d) div *= 100;
	for(int i = 1; i >= 0; i++){
		if(i%div == 0){
			int tmp = i / div;
			if(tmp % 100 != 0){
				cnt++;
				if(cnt == n){
					cout << i << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
sys.setrecursionlimit(10 ** 9)
 
def func(h,ans):  
  if h == 1:
    return ans+1
  if h > 1:
    return 2 * func(math.floor(h/2),ans) + 1
  
h = int(input())
ans = 0
print(func(h,ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
typedef long long ll;
const int INF = 1001001001;
const double PI = 3.141592653589793238;


/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 


///////////////////////////////////////////////////////////////////////////


int main() {

    ll N, ans;
  cin >> N;
    ans = 1;
    bool over = false, 
         zero = false;

    rep(i, N){
        ll a;
        cin >> a;
        if(a == 0){
            zero = true;
        }
        if(a > 1000000000000000000){
            over = true;
        }
        if(a > 1000000000 && ans >= 1000000000){
            over = true;
        }
        ans *= a;

        if(ans > 1000000000000000000){
            over = true;
        }
    }

    if(over && !zero){
        cout << "-1" << endl;
    }
    else if(zero){
        cout << "0" << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        ArrayList<Integer> d = new ArrayList<Integer>();
        for(int i=0; i<N; i++){
            d.add(Integer.parseInt(sc.next()));
        }
        
        List<Integer> d_sorted = new ArrayList<Integer>(new HashSet<>(d));
        Collections.sort(d_sorted, Comparator.reverseOrder());
        
        System.out.println(d_sorted.size());
    }
}

Measured memory_bytes: 21844
sx,sy,tx,ty=map(int,input().split())
xgap=tx-sx
ygap=ty-sy
ans=''
ans+='L'+'U'*(ygap+1)+'R'*(xgap+1)+'D'
ans+='R'+'D'*(ygap+1)+'L'*(xgap+1)+'U'
ans+='U'*ygap+'R'*xgap+'D'*ygap+'L'*xgap
print(ans)

Measured memory_bytes: 3060
import math

ceil = math.ceil

def main():
    N = int(input())
    ans = [0]*N
    for i in range(N-1):
        C, S, F = map(int, input().split())
        ans[i] = S + C
        for j in range(i):
            nxt = ceil((ans[j]-S)/F)
            ans[j] = max(0, nxt)*F + S + C
    
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		ll n;
		cin>>n;
		ll k;
		cin>>k;
		ll a[n];
		ll m=0,z=0,p=0;
		vector<ll> neg,pos;
		FOR(i,0,n)
		{
			cin>>a[i];
			if(a[i]<0)
			{
				m++;
				neg.pb(a[i]);
			}
			else if(a[i]==0)
			z++;
			else
			{
				p++;
				pos.pb(a[i]);
			}
		}
		sort(pos.begin(),pos.end());
		sort(neg.begin(),neg.end());
		if(k<=(m*p))
		{
			ll cnt;
			ll l=(-1*INF),r=-1,mid;
			while(l<r)
			{
				cnt=0;
				mid=(l+r-1)/2;
				int j=0;
				FOR(i,0,m)
				{
					while(j<p && (neg[i]*pos[j])>mid)
					j++;
					cnt+=(p-j);
				}
//				cout<<l<<' '<<r<<' '<<mid<<' ';
				if(cnt<k)
				l=mid+1;
				else
				r=mid;
//				cout<<l<<' '<<r<<'\n';
			}
			cout<<l;
		}
		else
		{
			k-=(m*p);
			ll o=(z*(z-1))/2+z*(m+p);
			if(k<=o)
			{
				cout<<0;
			}
			else
			{
				k-=o;
				ll cnt;
				ll l=1,r=INF,mid;
//				cout<<k<<'k'<<'\n';
				while(l<r)
				{
					cnt=0;
					mid=(l+r)/2;
					int j=m-1;
					FOR(i,0,m)
					{
						while(j>=i && (neg[i]*neg[j])<=mid)
						j--;
						cnt+=min(m-j-1,m-i-1);
					}
//					cout<<cnt<<' ';
					j=p-1;
					FOR(i,0,p)
					{
						while(j>=0 && (pos[i]*pos[j])>mid)
						j--;
						cnt+=min(j+1,i);
//						if(j>=i)
//						cnt--;
					}
//					cnt/=2;
//					cout<<l<<' '<<r<<' '<<mid<<' '<<cnt<<'\n';
					if(cnt<k)
					l=mid+1;
					else
					r=mid;
				}
				cout<<l;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3572
// ABC043B - バイナリハックイージー

#include <bits/stdc++.h>
using namespace std;

int main() {
	string S;
	cin >> S;

	stack<char> stack;

	for(int i = 0; i < S.size(); i++) {
		switch (S[i]) {
		case '1':
			stack.push('1');
			break;
		case '0':
			stack.push('0');
			break;
		case 'B':
			if (!stack.empty()) {
				stack.pop();
			}
			break;
		default:
			break;
		}
	}

	string answer;
	while (!stack.empty()) {
		answer += stack.top();
		stack.pop();
	}

	reverse(answer.begin(), answer.end());
	cout << answer << endl;

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

bool islunlun( ll n )
{
    int prev = n%10;
    n /= 10;
    while( n )
    {
        int now = n%10;
        if( abs(now-prev) > 1 )
            return 0;
        prev = now;
        n /= 10;
    }
    return 1;
}

ll nextlunlun( ll n )
{
    vector<int>num;
    int cnt = 0;
    while( n )
    {
        num.pb(n%10);
        cnt++;
        n /= 10;
    }

    for(int i=0;i<cnt;i++)
    {
        ll try_n = 0;
        for(int j=cnt-1;j>i;j--)
            try_n = 10*try_n + num[j];
        try_n = 10*try_n + num[i]+1;
        int cc = num[i];
        for(int j=i-1;j>=0;j--)
        {
            try_n = 10*try_n;
            if( cc > 0 )
                try_n += cc--;
        }
        if( islunlun(try_n) )
            return try_n;
    }
}

int main() 
{
    fastio();

    ll k;
    cin>>k;

    ll now = 1;
    k--;
    while( k-- )
    {
        now = nextlunlun(now);
    }
    cout<<now,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  int ans = 0;
  bool exist_even = true;
  while(exist_even){
    for(int i=0; i<N; i++){
      if(A.at(i)%2 != 0){
        exist_even = false;
      }else{
        A.at(i) /= 2;
      }
    }
    if(exist_even){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

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

int main(){
	string s;
	while(cin >> s){
		int JOI=0, IOI=0;
		for(string::size_type i=0; i<s.size(); i++){
			if(s.find("JOI",i) == i){
				JOI++;
			}
			if(s.find("IOI",i) == i){
				IOI++;
			}
		}
		cout << JOI << endl << IOI << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (ll i = max(1ll, K); i <= N; ++i) {
    ans += N / i * max(0ll, (i - K));
    ans += max(0ll, (N % i) - K + 1);
  }
  if (K == 0) {
    ans -= N;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define beg begin()
#define end end()

void _main(){
    int n,m;cin >> n >> m;
    vector<int> a(n);
    double line =0;
    rep(i,n){
        cin >> a[i];
        line += a[i];
    }
    line /= 4*m;
    sort(a.beg,a.end);
    auto mcheck = [&](){
        rep(i,m){
            int t = a.back();
            a.pop_back();
            if(t < line) return false;
        }
        return true;
    };
    if(mcheck()) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}
int main() {
　  cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  int ct = 0;
  REP(i, s.size()-1)
  {
    if (ct == 1) ct++;
    else if (ct == 2)
    {
      ans++;
      ct = 0;
    }
    else if (s[i] == s[i+1])
    {
      ans++;
      ct++;
    }
    else ans++;
  }
  if (ct != 1) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 720
import sys
"""
奇数の場合は0が一つと偶数番号が2個ずつ存在している
偶数の場合は奇数番号が2個ずつ並んでいる
それらの条件を満たす場合に、並び替えることが可能で、
"""

N = int(input())
L = list(map(int, input().split()))
number_dict = {}

MOD = 10 ** 9 + 7

for l in L:
  if l in number_dict:
    number_dict[l] += 1
  else:
    number_dict[l] = 1

if N%2 ==1:
  if 0 in number_dict and number_dict[0] != 1:
    print(0)
    sys.exit()
  number_dict.pop(0)
  ran = range(2, N, 2)
else:
  ran = range(1, N, 2)

# チェック
for i in ran:
  if i not in number_dict:
    print(0)
    sys.exit()
  if number_dict[i] != 2:
    print(0)
    sys.exit()
  number_dict.pop(i)


if len(number_dict.keys()) == 0:
  print(2**int(N/2) % MOD )
else:
  print(0)

Measured memory_bytes: 14436
# include <bits/stdc++.h>
using namespace std;
long long a, b,k,k1,w;
int main()
{
	cin>>a>>b;
	for (int i=1; i<=100000;i++)
	{
		k=(i*8)/100;
		k1=(i*1)/10;
		if (k==a && k1==b)
		{
			w=1;
			cout<<i<<endl;
			break;
		}
	}
	if (w==0)
	{
		cout<<"-1"<<endl;
	}
}

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

int main(){
	int N;
	int a, b, c;
	int s;
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d%d%d", &a, &b, &c);
		a = a * a; b = b * b; c = c * c;
		
		if(a < b){
			s = a; a = b; b = s;
		}
		if(a < c){
			s = a; a = c; c = s;
		}
		
		if(a == b + c) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 1008
fun main(args: Array<String>) {
    val S = readInputLine()
    
    when (S) {
        "SUN" -> println(7)
        "MON" -> println(6)
        "TUE" -> println(5)
        "WED" -> println(4)
        "THU" -> println(3)
        "FRI" -> println(2)
        "SAT" -> println(1)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31564
N = int(input())
Sli = {"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(N):
  S = input()
  Sli[S] += 1
  
print("AC x "+str(Sli["AC"]))
print("WA x "+str(Sli["WA"]))
print("TLE x "+str(Sli["TLE"]))
print("RE x "+str(Sli["RE"]))

Measured memory_bytes: 69848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  
  cin >> N >> K;
  
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  
  vector<int> cost(N, 10000000000);
  
  cost.at(0) = 0;
  
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= min(i, K); j++) {
      cost.at(i) = min(cost.at(i), cost.at(i - j) + abs(h.at(i) - h.at(i - j)));
    }
  }
  
  cout << cost.at(N - 1) << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve(){
    int n;
    cin >> n;
    vector<vector<int>> p(n,vector<int>(n));
    rep(i,0,n) rep(j,0,n) cin >> p[i][j];

    vector<vector<int>> cumsum(n,vector<int>(n));
    rep(y,0,n){
        cumsum[y][0]=p[y][0];
        rep(x,1,n) cumsum[y][x]=cumsum[y][x-1]+p[y][x];
    }
    rep(y,1,n) rep(x,0,n) cumsum[y][x]+=cumsum[y-1][x];

    auto rectangle_sum=[&](int y1,int x1,int y2,int x2){
        int res=0;
        res+=cumsum[y2][x2];
        if(y1!=0) res-=cumsum[y1-1][x2];
        if(x1!=0) res-=cumsum[y2][x1-1];
        if(y1!=0 and x1!=0) res+=cumsum[y1-1][x1-1];
        return res;
    };
    int ans=0;
    rep(y1,0,n){
        rep(y2,y1,n){
            int opt_x=0;
            rep(x,0,n){
                int frame_sum=rectangle_sum(y1,opt_x,y2,x);
                if(y1<=y2-2 and x>=opt_x+2) frame_sum-=rectangle_sum(y1+1,opt_x+1,y2-1,x-1);
                ans=max(ans,frame_sum);

                int sum1=rectangle_sum(y1,opt_x,y2,x),sum2=rectangle_sum(y1,x,y2,x);
                if(y1<=y2-2 and x>=opt_x+1) sum1-=rectangle_sum(y1+1,opt_x+1,y2-1,x);
                if(sum2>sum1){
                    opt_x=x;
                    ans=max(ans,sum2);
                }
            }
        }
    }

    cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3660
N = int(input())
S = [input() for _ in range(N)]
ac,wa,tle,re=0,0,0,0
for i in range(len(S)):
  if S[i] == 'AC':
    ac+=1
  elif S[i] == 'WA':
    wa+=1
  elif S[i] == 'TLE':
    tle+=1
  else:
    re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)


Measured memory_bytes: 16156
#!/usr/bin/python3
# -*- coding: utf-8 -*-



N = int(input())
An = [int(input()) for _ in range(N)]
mxAn = [0,0]
for a in An:
  if mxAn[0] < a:
    mxAn = sorted([mxAn[1],a])

for a in An:
  if a == mxAn[1]:
    print(mxAn[0])
  else:
    print(mxAn[1])


Measured memory_bytes: 68952
import java.util.*;

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

        if(a - 2*b >= 0){
            System.out.println(a-2*b);
        } else {
            System.out.println(0);
        }
    }
}


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

int main() {
  int D;
  cin >> D;
  
  if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
  else if(D == 23) cout << "Christmas Eve Eve" << endl;
  else if(D == 24) cout << "Christmas Eve" << endl;
  else cout << "Christmas" << endl;
}

Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <chrono>
//#include <random>

#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define long int64_t
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ std::cerr << name << " : " << arg1 << std::endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<> dis(0, INF<<1);

const int N = 10000001;
const int mod = 998244353;

int modexp(int a, int b = mod - 2)
{
	int r = 1;
	while(b)
	{
		if(b & 1)
			r = (r * 1ll * a) % mod;
		a = (a * 1ll * a) % mod;
		b >>= 1;
	}
	return r;
}

int f[N];

int main()
{
	fio;
	f[0] = 1;
	for(int i=1; i<N; i++)
		f[i] = (f[i-1] * 1ll * i) % mod;
	int n, t = 1, a = 0;
	cin >> n;
	for(int i=(n >> 1) + 1; i<=n; i++)
	{
		t = (3ll * t) % mod;
		int x = (modexp(f[i]) * 1ll * modexp(f[n-i])) % mod;
		x = (x * 1ll * f[n]) % mod;
		x = (x * 1ll * modexp(2, n-i)) % mod;
		a += x;
		a %= mod;
	}
	a = (a + a) % mod;
	t = (t * 1ll * t) % mod;
	cout << (t - a + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 39296
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;

using namespace std;
#define N 200010
ll n,m,a[N],cnt[N],sum[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    lol(i,N)cnt[i]=0,sum[i]=0;
    lol(i,n){
	cin>>a[i];
	if(a[i]<N)cnt[a[i]]++;
    }
    lol(i,N){
	for(ll j=i-cnt[i]+1;j<=i;j++)sum[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=sum[i]==0;
    lol(i,m){
	ll x,y;cin>>x>>y; x--;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]]+1;
	    if(p>=1){
		sum[p]--;
		if(sum[p]==0)ans++;
	    }
	    cnt[a[x]]--;
	}
	a[x]=y;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]];
	    if(p>=1){
		if(sum[p]==0)ans--;
		sum[p]++;
	    }
	    cnt[a[x]]++;
	}
	cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6272