akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define el '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define all(x) x.begin(),x.end()
const int inf = 1e18;

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

    while(t--)
    {
        int x,y;
        cin>>x>>y;
        int sum =0;
        if(x==y&&y==1)
            sum+= 400000;
        int arr[4] = {0,300000,200000,100000};
        if(x<4)
            sum+= arr[x];
        if(y<4)
            sum+= arr[y];
        cout<<sum<<el;
    }
    return 0;
}
// always test the corner cases ALWAYS;


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

A = [0]
B = [0]
C = [0]
for d in range(n):
    a = h[d][0] + max(B[-1],C[-1])
    b = h[d][1] + max(A[-1],C[-1])
    c = h[d][2] + max(A[-1],B[-1])
    A += [a]
    B += [b]
    C += [c]
print(max(A[-1],B[-1],C[-1]))
    

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


int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  int mx = a.back();
  vector<bool> b(mx + 1, true);
  rep(i, n)
  {
    if (i > 0 && a[i] == a[i-1])
    {
      b[a[i]] = false;
      continue;
    }
    if (b[a[i]])
    {
      int j = a[i] * 2;
      while (j <= mx)
      {
        b[j] = false;
        j += a[i];
      }
    }
  }
  int ans = 0;
  rep(i, n)
    if (b[a[i]])
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4008
import sys
sys.setrecursionlimit(10**6)
# if sys.platform in (['ios','darwin','win32']):
# 	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

from string import ascii_lowercase as al

def main():
	c = input().rstrip()
	print(al[al.index(c)+1])

if __name__ == '__main__':
	main()

Measured memory_bytes: 3960
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
// URLD
double dx[4]={0,1,-1,0};
double dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

template< int mod = 1000000007 >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

const int mod = 1000000007;
// const int mod = 998244353;
using mint = ModInt< mod >;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,k;
    cin>>n>>k;
    mint dp[n+1][n+1][k+1]={};
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int c=0;c<=k;c++){
                int nx = c + 2*j;
                if(j && nx-2<=k){
                    dp[i+1][j-1][nx-2] += dp[i][j][c]*mint(j*j);
                }
                if(nx>k)continue;
                dp[i+1][j][nx] += dp[i][j][c];
                dp[i+1][j][nx] += dp[i][j][c] * mint(2 * j);
                if(nx+2<=k)dp[i+1][j+1][nx+2] += dp[i][j][c];
            }
        }
    }
    cout << dp[n][0][k] << endl; 
   

}

Measured memory_bytes: 28928
#include <stdio.h>

int main(){
   int n, *a;
   scanf("%d", &n);
   a = (int *)malloc(n * sizeof(int));

   int i, k;

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

   for(k=n-1;k>=0;k--){
      if(k!=0){
         printf("%d", a[k]);
         printf(" ");
      } else {
         printf("%d\n", a[k]);
      }
   }

   return 0;
}



Measured memory_bytes: 1872
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        string S;
        cin >> S;
        ll Count = 0;
        for(ll i=0; i<S.size(); i++){
                if(i == 0) cout << S[i];
                else if(i==S.size()-1) cout << Count << S[i];
                else Count ++;
        }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int d = sc.nextInt();
			int t = sc.nextInt();
			int s = sc.nextInt();
			
			if(d <= t*s) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			




		}catch(Exception e) {
			e.printStackTrace();
		}

	}


}

Measured memory_bytes: 35640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int startPoint = sc.nextInt();
		
		int[] distance = new int[num];
		int count = 0;
		while (sc.hasNextInt()) {
			distance[count] = Math.abs(startPoint - sc.nextInt());
			count++;
		}
		sc.close();
		
		int tmp,ans = 0;
		if (num > 1) {
			for (int i=0; i<num-1; i++) {
				while ((tmp = distance[i] % distance[i+1]) != 0) {
					distance[i] = distance[i+1];
					distance[i+1] = tmp;
				}
				ans = distance[i+1];
			}
		} else if (num == 1) {
			ans = distance[0];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 58500
#include <iostream>

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

   int count[26];
   for(int i=0; i<26; ++i) count[i] = 0;
   for(int i=0; i<S.size(); ++i){
      count[S[i]-'a']++;
   }
   for(int i=0; i<26; ++i){
      if(count[i]>1) {
	 std::cout << "no" << std::endl;
	 return 0;
      }
   }
   std::cout << "yes" << std::endl;
   return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  if ( n < 1200 ){
    cout << "ABC" << endl;
  }else if ( n >= 1200 && n < 2800 ){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  
  
}



Measured memory_bytes: 256
declare var require: (x: string) => any;

function validate(s: string) {
  if(s[0] != 'A') return false;

  let appeared = false;
  for(var i = 1; i < s.length; i++) {
    if (s[i] === s[i].toUpperCase()){
      if(i==1 || i == s.length-1) return false;
      if(appeared) return false;
      appeared = true;
    }
  }
  return appeared;
}

function Main(input: string[]) {
  console.log(validate(input[0]) ? 'AC' : 'WA');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


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


int main() {
    
    while(1) {
        
        int N, loop, sum = 0, tmp;
        std::scanf("%d", &N);
        if (N ==0) break;
        
        loop = N * (N-1) / 2;
        
        for (int i = 0; i < loop; i++) {
            std::scanf("%d", &tmp);
            sum += tmp;
        }
        
        std::cout << (sum / (N-1) ) << std::endl;
        
        
    }
    
    return 0;
    
    
    
    
    
    
}


Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N,K;
	cin>>N>>K;
	int m=1<<N;
  	if(N==1){
    	if(K==0){
          	cout<<0<<" "<<0<<" ";
          	cout<<1<<" "<<1<<" ";
        }
      	else cout<<-1;
      return 0;
    }
  	
	if(K>=m){
		cout<<-1;
	}
	else if(K==0){
		rep(i,m)cout<<i<<" "<<i<<" ";
	}
	else{
		cout<<0<<" ";
		rep1(i,m-1)if(i!=K)cout<<i<<" ";
		cout<<0<<" "<<K<<" ";
		for(int i=m-1;i>=1;i--)if(i!=K)cout<<i<<" ";
		cout<<K<<" ";
	}
}

Measured memory_bytes: 1792
l, r = map(int, input().split())
m = 2019
a = 2019
if r - l < 2019:
  for i in range(l, r):
    for j in range(i+1, r+1):
      if i * j % m < a:
        a = i*j % m
else:
  for i in range(l, l+2019-1):
    for j in range(i+1, l+2019):
      if i * j % m < a:
        a = i*j % m
print(a)

Measured memory_bytes: 3060
A, B, C, D = (int(i) for i in input().split())  

takalife = A
takaa = B
aotlife = C
aoa = D

i = 0

while A > 0 and C > 0 :
    if i % 2 == 0: #takahashi attack
        C = C - B
    else:
        A = A - D
    i += 1
if C <= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61844
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		long[] arr=new long[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}
		
		long count=0;
		long min=arr[0];
		
		for(int i=1;i<n;i++)
		{
			if(arr[i]>min)
			{
				min=arr[i];
			}
			else
			{
				count=count+(min-arr[i]);
			}
		}
		
		System.out.println(count);
		
	}
	
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], K = line[1];
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (N == 1)
            {
                Console.WriteLine(array[0]);
                return;
            }

            var baseIndex = 0;
            // 0付近の位置を特定する
            for (var i = 0; i < N; i++)
            {
                if (array[i] >= 0)
                {
                    baseIndex = i;
                    break;
                }
            }
            // 0以上が存在しない場合は末尾を設定
            if (array[N - 1] < 0) baseIndex = N - 1;

            var minusPoint = array[N - 1] < 0 ? 0 : 1;
            if (array[baseIndex] == 0)
            {
                K--;
                baseIndex++;
                minusPoint++;
            }

            // ダサいが思いつかないから6パターンに分けてみる
            var min = int.MaxValue;

            // 右に行きっぱなし
            if (baseIndex + K - 1 < N)
                min = Math.Min(array[baseIndex + K - 1], min);

            if (array[0] < 0 && array[N - 1] > 0)
            {
                // 右に行ってから左に行きっぱなし
                for (var hosuu = 0; hosuu < K; hosuu++)
                {
                    var zan = K - hosuu - 1;
                    if (baseIndex + hosuu < 0 || baseIndex + hosuu - zan >= baseIndex) break;
                    if (baseIndex - zan < 0) continue;
                    min = Math.Min(Math.Abs(array[baseIndex + hosuu] * 2) + Math.Abs(array[baseIndex - zan]), min);
                }
            }

            // マイナス方向を起点にする
            baseIndex -= minusPoint;
            // 左に行きっぱなし
            if (baseIndex - K + 1 >= 0)
                min = Math.Min(Math.Abs(array[baseIndex - K + 1]), min);
            //if (baseIndex == 0)
            //    min = Math.Min(Math.Abs(array[baseIndex+K+1]), min);

            if (array[N-1] > 0 && array[0] < 0)
            {
                // 左に行ってから右に行きっぱなし
                for (var hosuu = 0; hosuu < K; hosuu++)
                {
                    var zan = K - hosuu - 1;
                    if (baseIndex - hosuu < 0 || baseIndex - hosuu + zan <= baseIndex) break;
                    if (baseIndex + zan >= N) continue;
                    min = Math.Min(Math.Abs(array[baseIndex - hosuu] * 2) + array[baseIndex + zan], min);
                }
            }
            Console.WriteLine(min);
        }
    }
}


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

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


  for (int i = 0; i < N;  i++) {
    if ( S.at(i) == S.at(K-1)) {
      cout << S.at(i) ;
    }
    else {
      cout << '*' ;
    }
  }

  cout << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a[5];
  int s2[5],i,k=0,t=0;
  int sum=0;
  float s[5],ds[5]={0},dsk=1;

  for(i=0;i<5;i++)
  {
    scanf("%d",&a[i]);
    s[i]=a[i]/10.0;
    //printf("%.1f\n",s[i]);
    s2[i]=s[i];
    ds[i]=s[i]-s2[i];
    if(ds[i]>0)
    {
      if(dsk>ds[i])
      {
        dsk=ds[i];
        //printf("%.1f\n",dsk);
      }
        
      
    }
  }
  for(i=0;i<5;i++)
  {
    if(dsk==ds[i])
      {
        //dsk=ds[i];
        //printf("%.1f\n",dsk);
        k++;
      }
  }
   
  //printf("%.1fiiiii\n",dsk);
  for(i=0;i<5;i++)
  {
    
    if(ds[i]>0&&ds[i]!=dsk)
    {
      //printf("yooyyo\n");
      s2[i]+=1;
      a[i]=s2[i]*10;
    }
    if(t!=k-1&&k>=2&&ds[i]==dsk)
    {
      //printf("yooyyo\n");
      s2[i]+=1;
      a[i]=s2[i]*10;
      t++;
    }
      
   // printf("%d\n",a[i]);
    sum+=a[i];
    //printf("%d\n",sum);
  }
  printf("%d\n",sum);
  return 0;
}
    
      
        
 
    

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

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

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

int main(){
  int n; cin>>n;
 
  vector<int> prime;
  vector<bool> flag(101,true);
  flag[0]=false; flag[1]=false;
  for(int i=2;i<=100;i++){
    if(flag[i]){
      prime.push_back(i);
      for(int j=2*i;j<=100;j+=i) flag[j]=false;
    }
  }
  vector<vector<int>> C(100,vector<int>(100,0));
  for(int i=0;i<100;i++){
    for(int j=0;j<=i;j++){
      if(i==j || j==0) C[i][j]=1;
      else C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
  }
  
  int size=prime.size();
  vector<int> num(size,1);
  for(int i=2;i<=n;i++){
    int log=i;
    for(int j=0;j<size;j++){
      while(log%prime[j]==0){
        num[j]++;
        log/=prime[j];
      }if(log==1) break;
    }
  }
  sort(num.begin(),num.end());
  int c3=0,c5=0,c25=0,c15=0,c75=0;
  for(int i=0;i<size;i++){
    if(num[i]>2) c3++;
    if(num[i]>4) c5++;
    if(num[i]>14) c15++;
    if(num[i]>24) c25++;
    if(num[i]>74) c75++;
  }
  int ans=0;
  ans+=(c3-c5)*C[c5][2];
  if(c5>0)ans+=c5*C[c5-1][2];
  ans+=(c3-c25)*c25;
  ans+=c25*(c25-1);
  ans+=(c5-c15)*c15;
  ans+=c15*(c15-1);
  cout<<ans+c75<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  ll n;
  ll k;
  cin >> n >> k;
  ll res = n%k;
  if(res > abs(res-k)) res = abs(res-k);
  cout << res << endl;
}

Measured memory_bytes: 256
# AOJ 1100: Area of Polygons
# Python3 2018.7.14 bal4u

from decimal import Decimal, ROUND_HALF_UP

def calc_area(pp):
	n, s = len(pp), 0
	for i in range(n): s += (pp[i].real-pp[(i+1)%n].real)*(pp[i].imag+pp[(i+1)%n].imag)
	return abs(s)/2

cno = 0
while True:
	n = int(input())
	if n == 0: break
	pp = [complex(*map(int, input().split())) for i in range(n)]
	input()
	cno += 1
	print(cno, Decimal(str(calc_area(pp))).quantize(Decimal('0.1'), rounding=ROUND_HALF_UP))



Measured memory_bytes: 6388
#include<iostream>
using namespace std;
int main(){
  int K,X;
  cin>>K>>X;
  
  for(int i=X-K+1;i<=X+K-1;i++){
    if(i<-20000){
      i=-20000;
    }
    if(i>20000){
      i=20000;
    }
    cout<<i<<" ";
  }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
#階乗
F = 200005
mod = 10**9+7
fact = [1]*F
inv = [1]*F
for i in range(2,F):
    fact[i]=(fact[i-1]*i)%mod
inv[F-1]=pow(fact[F-1],mod-2,mod)
for i in range(F-2,1,-1):
    inv[i] = (inv[i+1]*(i+1))%mod

ans=1
for i in range(1,min(n,k+1)):
    comb=(fact[n]*inv[i]*inv[n-i])%mod
    h=(fact[n-1]*inv[i]*inv[n-1-i])%mod
    ans=(ans+comb*h)%mod
print(ans)

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

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

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

	ll h[n + 1];
	reps( i, n ) {
		cin >> h[i];
	}

	bool bad[n + 1] = {};
	rep( i, m ) {
		ll a, b;
		cin >> a >> b;
		if ( h[a] <= h[b] ) {
			bad[a] = true;
		}
		if ( h[b] <= h[a] ) {
			bad[b] = true;
		}
	}

	ll cnt = 0;
	reps( i, n ) {
		if ( !bad[i] ) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 4512
def main():
    s = input()
    [k, x] = [int(number) for number in s.split()]

    min = x - k + 1
    max = x + k - 1
    i = min
    list = []
    for i in range(k * 2 - 1):
        list.append(min + i)
    print(' '.join([str(num) for num in list]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(t) (t).begin(),(t).end()
typedef long long ll;

int main() {
	int Ans=0;
	int N; cin >> N;
	int a[N];
	REP(i,N){
		cin >> a[i];
		if (((i+1)%2==1)&&(a[i]%2==1)) Ans++;
	}
	cout << Ans << '\n';
	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String args[]) throws NumberFormatException, IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int dataCount = Integer.parseInt(reader.readLine());
        String[] inputDataList = new String[dataCount];
        for (int i = 0; i < dataCount; i++) {
            inputDataList[i] = reader.readLine();
        }
        for (int i = 0; i < dataCount; i++) {
            String[] data = inputDataList[i].split(" ");
            int a = Integer.parseInt(data[0]);
            int b = Integer.parseInt(data[1]);
            int c = Integer.parseInt(data[2]);
            if (Math.pow(a, 2) + Math.pow(b, 2) == Math.pow(c, 2)) {
                System.out.println("YES");
            } else if (Math.pow(b, 2) + Math.pow(c, 2) == Math.pow(a, 2)) {
                System.out.println("YES");
            } else if (Math.pow(c, 2) + Math.pow(a, 2) == Math.pow(b, 2)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

}

Measured memory_bytes: 26004
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

k = INT()
a = LIST()
l = 2
r = 2
for i in reversed(range(k)):
    l = (l + a[i] - 1) // a[i] * a[i]
    r = r // a[i] * a[i] + a[i] - 1
    if l > r:
        print(-1)
        exit()
print(l, r)

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

using namespace std;
int main(){
	long long n,k,a[100000],dp[100000];
	scanf("%lld %lld", &n, &k);
	for(long long i=0;i<n;i++){
		scanf("%lld", &a[i]);
	}
	for(long long i=1;i<=k;i++){
		dp[i]=abs(a[0]-a[i]);
	}
	for(long long i=k+1;i<n;i++){
		dp[i]=1e9;
		for(long long j=1;j<=k;j++)
		dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
	}
	printf("%lld", dp[n-1]);
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
root = [-1] * N

def parent(x):
    if root[x] < 0:
        return x
    root[x] = parent(root[x])
    return root[x]


def union(x, y):
    x_parent = parent(x)
    y_parent = parent(y)
    if x_parent == y_parent:
        return
    root[x_parent] += root[y_parent]
    root[y_parent] = x


def size(x):
    return -root[x]
    

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    union(a, b)


max_size = 0
for i in range(N):
    max_size = max(size(i), max_size)

print(max_size)

Measured memory_bytes: 16452
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
const int maxn=1e5+10;
int vis[maxn];
int n;
struct Node
{
    int v,shu;
    Node(int x,int y):v(x),shu(y){}
    Node(){}
};
vector<Node >G[maxn];
int ans[maxn];
int maxco=0;
void DFS(int u,int co)
{
    int color=1;
    for(int i=0;i<G[u].size();i++)
    {
        Node node=G[u][i];
        int v=node.v,shu=node.shu;
        if(vis[v]) continue;
        if(ans[shu]) continue;
        if(co==color) color++;
        maxco=max(maxco,color);
        ans[shu]=color;
        vis[v]=1;
        DFS(v,color);
        color++;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].push_back(Node(y,i));
        G[y].push_back(Node(x,i));
    }
    vis[1]=1;
    DFS(1,0);
    cout<<maxco<<endl;
    for(int i=1;i<=n-1;i++)
        cout<<ans[i]<<endl;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;


    ll ans = 100000;
    rep(i, 0, s.size()){
        ll tmp = 0;
        ll count = 0;
        rep(j, 0, s.size()){
            if(s[j] == s[i]){
                tmp = max(tmp, count);
                count = 0;
            }else{
                count++;
            }
        }
        tmp = max(tmp, count);
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 256
let () =
  let s = read_line () in
  let t = read_line () in
  let lss = Array.make_matrix (String.length s + 1) (String.length t + 1) 0 in
  let css = Array.make_matrix (String.length s + 1) (String.length t + 1) [] in
  for i = 1 to String.length s do
    for j = 1 to String.length t do
      if s.[i - 1] = t.[j - 1] then begin
        lss.(i).(j) <- 1 + lss.(i - 1).(j - 1);
        css.(i).(j) <- s.[i - 1] :: css.(i - 1).(j - 1)
      end else if lss.(i).(j - 1) <= lss.(i - 1).(j) then begin
        lss.(i).(j) <- lss.(i - 1).(j);
        css.(i).(j) <- css.(i - 1).(j)
      end else begin
        lss.(i).(j) <- lss.(i).(j - 1);
        css.(i).(j) <- css.(i).(j - 1)
      end
    done
  done;
  (List.iter print_char @@ List.rev @@ css.(String.length s).(String.length t));
  print_newline () 



Measured memory_bytes: 355960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		char charaArray[] = str.toCharArray();

		for(int i=charaArray.length-1; i>=0; i--){
			System.out.print(charaArray[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 16860
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
flag = [False for i in range(n)]
score = {"r":p, "s":r, "p":s}
ans = 0
for i in range(n):
    if i >= k:
        if t[i] == t[i-k]:
            if flag[i-k] == True:
                ans += score[t[i]]
            else:
                flag[i] = True
        else:
            ans += score[t[i]]
    else:
        ans += score[t[i]]
print(ans)

Measured memory_bytes: 10056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={},b[n+1]={},c[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }

  ll dp[n+2][3]={};
  for(int i=1;i<=n;i++){
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }

  ll ans=max(dp[n][0],dp[n][1]);
  ans=max(ans,dp[n][2]);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4992
n, q = map(int, input().split())
c = [(n - 1, -1)]
r = [(n - 1, -1)]
t = 0
for i in range(q):
    k, x = map(int, input().split())
    if k == 1:
        c.append((x - 1, t))
    else:
        r.append((x - 1, t))
        t += 1
c.sort()
r.sort()
idx = 0
ans = (len(c) - 1) * (r[0][0])
for i in range(len(r) - 1):
    x, t = r[i]
    tmp = idx
    while idx < len(c) and c[idx][1] > t:
        idx += 1
    ans += c[idx][0]
    ans += (len(c) - idx - 1) * (r[i + 1][0] - x)
print((n - 2) * (n - 2) - ans + len(c) + len(r) - 2)


Measured memory_bytes: 89728
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1==min(a-1,n-b):
        print(a+((b-a-1)//2))
    else:
        print(n-b+1+((b-a-1)//2))


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int n;
string a,b;
long long mod = 1e9 + 7;

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

    long long ans = 1;
    long long cur = -1;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i]){
            if(cur == -1){
                ans *= 3;
                ans %= mod;
            }
            else if(cur == 0){
                ans *= 2;
                ans %= mod;
            }
            cur = 0;
        }
        else{
            if(cur == -1){
                ans *= 6;
                ans %= mod;
            }
            else if(cur == 0){
                ans *= 2;
                ans %= mod;
            }
            else{
                ans *= 3;
                ans %= mod;
            }
            cur = 1;
            i++;
        }
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n;
  long int x,y,maxsum,minsum,maxdif,mindif,ans;
  long int sum[200000];
  long int dif[200000];

  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%ld %ld",&x,&y);
    sum[i]=x+y;
    dif[i]=x-y;
    if(i==0)
    {
      maxsum=sum[i];
      minsum=sum[i];
      maxdif=dif[i];
      mindif=dif[i];
    }
    if(maxsum<sum[i]) maxsum=sum[i];
    if(minsum>sum[i]) minsum=sum[i];
    if(maxdif<dif[i]) maxdif=dif[i];
    if(mindif>dif[i]) mindif=dif[i];
  }

  if((maxsum-minsum)>(maxdif-mindif)) ans=maxsum-minsum;
  else ans=maxdif-mindif;

  printf("%ld\n",ans);

  return 0;
}

Measured memory_bytes: 1728
#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>;
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);
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1LL; i*i <= n; i++){
        if(n%i == 0) chmin(ans, i+n/i-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;



int main() {
  int n;
  cin>>n;
  int t = 0;
  int scores[] = {0,0};
  priority_queue<int> pq;
  frn(i,n) {
    int x;
    cin>>x;
    pq.push(x);
  }
  while(!pq.empty()) {
    int x = pq.top();
    // dbg(x); nl;
    pq.pop();
    scores[t] += x;
    // dbg(scores[t]); dbg(t); nl;
    t = 1 - t;
  }
  cout<<scores[0]-scores[1];
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

long long i,j,k,N,M,X,Y,K,A[200001],B[200001]={0},n,m,a,b,c;

int main()
{
  cin>>N>>K;
  
  for(i=1;i<=N;i++)
  {
    cin>>A[i];
  }
  
  if(K<=N)
  {
      j=1;
  for(i=0;i<K;i++)
  {
    
    k=A[j];
    j=k;
  }
  
  cout<<j;
    
    return 0;
  }
  
  
  
  j=1;
  for(i=0;i<=N;i++)
  {
    if(B[j]==-1)
    {
      n=j;
      a=i;
      break;
    }
    
    k=A[j];
    B[j]=-1;
    j=k;
  }
  
  
    j=1;
  for(i=0;i<=N;i++)
  {
    if(n==j)
    {
      b=i;
      break;
    }
    
    k=A[j];
    j=k;
  }
  
  c=(K-b)%(a-b);
  
      j=n;
  for(i=0;i<c;i++)
  {
    
    k=A[j];
    j=k;
  }
  
  cout<<j;
  
}

Measured memory_bytes: 6760
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(N):
  if i != N-1 and a[i] <= x:
    ans += 1
    x -= a[i]
  if i == N-1 and a[i] == x:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       string s;
       cin>>s;
       ll wc=0, ans=0;
       for(ll i=s.size()-1; i>=0; i--)
       {
              if(s[i]=='B') ans+=wc;
              else wc++;
       }
       cout<<ans;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

int a[MAXN + 2];

int main() {
	int n;
	cin >> n;
	int x = 0, y = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(x < a[i])
			x = a[i];
	}
	for(int i = 0; i < n; i++)
		if(abs(y - x / 2) > abs(a[i] - x / 2))
			y = a[i];
	cout << x << ' ' << y << endl;
}


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

using namespace std;

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

    long long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    long long ans = 0;
    long long A_max = A[0];
    for (int i = 1; i < N; i++)
    {
        if (A[i] < A_max)
        {
            ans += A_max - A[i];
        }
        else
        {
            A_max = A[i];
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 4684
import sys
si = sys.stdin.readline


def main():
    [n, k] = [int(e) for e in si().split()]
    l = [int(e) for e in si().split()]
    l.sort()
    s = 0
    for i in range(k):
        s += l[i]

    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long long> a(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  vector<long long> ans;
  for(int i=0;i<n-1;i++){
    sum+=(long long)1e9+7-a[i];
    sum%=(long long)1e9+7;
    ans.push_back(a[i]*sum);
  }
  long long res=0;
  for(auto x:ans){
    x%=(long long)1e9+7;
    res+=x;
  }
  res%=(long long)1e9+7;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 6912
import { readFileSync } from "fs";

const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

type Color = "Black" | "White";

{
  const [H, W, K] = [nCin(), nCin(), nCin()];

  const cnt = (() => {
    const css: Color[][] = range(H).map(() =>
      cin()
        .split("")
        .map((c) => (c === "#" ? "Black" : "White") as Color)
    );

    const initialBlackCnt = css
      .map((cs) => cs.reduce((acc, c) => (c === "Black" ? acc + 1 : acc), 0))
      .reduce((acc, x) => acc + x, 0);

    const hPickFn = (n: number, hPicks: [number, boolean][]): number => {
      const wPickFn = (hPicks: [number, boolean][]): number => {
        const wPickFn = (n: number, wPicks: [number, boolean][]): number =>
          n >= W
            ? initialBlackCnt -
                (hPicks
                  .filter(([, b]) => b)
                  .map(([i]) =>
                    range(W)
                      .map((j) => (css[i][j] === "Black" ? 1 : 0))
                      .reduce((acc: number, x) => acc + x, 0)
                  )
                  .reduce((acc: number, x) => acc + x, 0) +
                  range(H)
                    .map((i) =>
                      wPicks
                        .filter(([, b]) => b)
                        .map(([j]) => (css[i][j] === "Black" ? 1 : 0))
                        .reduce((acc: number, x) => acc + x, 0)
                    )
                    .reduce((acc: number, x) => acc + x, 0) -
                  hPicks
                    .filter(([, b]) => b)
                    .map(([i]) =>
                      wPicks
                        .filter(([, b]) => b)
                        .map(([j]) => (css[i][j] === "Black" ? 1 : 0))
                        .reduce((acc: number, x) => acc + x, 0)
                    )
                    .reduce((acc: number, x) => acc + x, 0)) ===
              K
              ? 1
              : 0
            : wPickFn(n + 1, wPicks) +
              wPickFn(
                n + 1,
                wPicks.map(([j, b]) => (j === n ? [j, true] : [j, b]))
              );

        return wPickFn(
          0,
          range(W).map((j) => [j, false] as [number, boolean])
        );
      };

      return n >= H
        ? wPickFn(hPicks)
        : hPickFn(n + 1, hPicks) +
            hPickFn(
              n + 1,
              hPicks.map(([i, b]) => (i === n ? [i, true] : [i, b]))
            );
    };

    return hPickFn(
      0,
      range(H).map((i) => [i, false] as [number, boolean])
    );
  })();

  console.log(cnt);
}


Measured memory_bytes: 39180
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
mx = 0
ans = 1
for i in range(1, n+1):
    v = i
    count = 0
    while v//2 != 0 and v % 2 == 0:
        count += 1
        v = v//2
    if count >= mx:
        ans = i
    mx = max(mx, count)
print(ans)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int A,B;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (A > B) cout << "Alice" << endl;
  else if (A < B) cout << "Bob" << endl;
  else cout << "Draw" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int a, b;
  cin >> a >> b;
  printf("%d %d %.6f\n", a / b, a % b, 1.0 * a / b);
  return 0;
}


Measured memory_bytes: 3196
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;















signed main(){
    ll a, b, c;
    ll k;
    cin >> a >> b >> c >> k;
    ll A = b + c;
    ll B = a + c;
    ll C = a + b;
    if (k%2 == 1)
    cout << (b - a);
    else cout << a - b;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,W;
int w[110],v[110];
umap<int,int> dp[103];
set<P> U,U2;

int DP(int a,int b){
	if(U.find(make_pair(a,b))!=U.end()){
		return dp[a][b];
	}
	if(a==N){
		if(b<=W){
			return 0;
		}
		else{
			return -INF;
		}
	}
	U.insert(make_pair(a,b));
	return dp[a][b]=max(DP(a+1,b+w[a])+v[a],DP(a+1,b));
}

signed main(){
	cin>>N>>W;
	REP(i,N){
		cin>>w[i]>>v[i];
	}
	int ans=DP(0,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 22656
program Project1;
             
{$APPTYPE CONSOLE}
         
uses
  SysUtils,math;
var
  fx,g,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  l:array of Integer;
  //l,l1,l2:int64;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  c1,c2,c3:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);

    SetLength(l,n);
    for i := 0 to n - 1 do
      Read(l[i]);

    count:=0;
    while True do begin
      for i := 0 to n - 1 do begin
        if l[i] mod 2 <> 0 then begin
          Writeln(count);
          Readln;
          Readln;
          exit;
        end;
        l[i]:=l[i] div 2;
      end;
      Inc(count);
    end;

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

int main()
{
	int a[4] = { 0, 0, 0, 0 }, b[3] = { 0, 0, 0 };

	for (int i = 0; i < 6; i++) {
		int k;
		cin >> k;
		a[k - 1]++;
	}

	for (int i = 0; i < 4; i++)
		b[a[i] - 1]++;

	if (b[0] == 2 && b[1] == 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  int sum = A1 + A2 + A3;
  if (sum >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k; cin >> n >> k;
    VI x(n); cin >> x;
    FOR(i, 0, n)x[i] = min(abs(k - x[i]), x[i]) * 2;
    cout << accumulate(all(x), 0) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  if (k * 2 - 1 <= n) cout << "YES" << endl;
  else cout << "NO" << endl;
} 

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int a, b, c;
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> a >> b >> c;

    auto tmp = std::min(a, b + c);
    std::cout << b + c - tmp << std::endl;

    return 0;
}


Measured memory_bytes: 256