akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

int main(){
	int n,a,b,c,d;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);

	vector<vector<mint>> dp(2,vector<mint>(n+1));
	dp[0][0]=1;
	for(int x=a;x<=b;x++){
		fill(dp[1].begin(),dp[1].end(),0);
		for(int y=c;y<=d;y++){
			mint p=pow(fact_inverse(x),y);
			for(int w=n;w>=y*x;w--){
				dp[1][w]+=dp[0][w-y*x]*p*fact_inverse(y);
			}
		}
		rep(w,n+1) dp[0][w]+=dp[1][w];
	}
	cout<<fact(n)*dp[0][n]<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll a,b;
	cin>>a>>b;
	ll gc=gcd(a,b);
	vector<bool> is_prime(1000001,true);
	vi prime;
	for(ll i=2;i<=1000000;i++){
		if(is_prime[i]){
			prime.pb(i);
			for(ll j=i*i;j<=1000000;j+=i) is_prime[j]=false;
		}
	}
	ll ans=1;
	for(int i:prime){
		if(gc%i==0) ans++;
		while(gc%i==0) gc/=i;
	}
	if(gc!=1) ans++;
	cout<<ans;
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 1020
main :: IO ()
main = do
    let m = 1000000007

    n <- readLn :: IO Int
    as <- map read . words <$> getLine :: IO [Integer]
    let l = foldl1 lcm as
    let ans = sum $ map (\a -> (l `div` a) `mod` m) as
    print $ ans `mod` m


Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++) 

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n, 0);
    rep(i, 0, n) cin >> x[i];
    vector<int> diff;
    vector<int> fire(n, 0);
    int ans = abs(x[0])+abs(x[0]-x[k-1]);
    rep(i, 0, n-k+1) {
        int l = abs(x[i]) + abs(x[i] - x[i+k-1]);
        int r = abs(x[i+k-1]) + abs(x[i+k-1]-x[i]);

        ans = min({l, r, ans});
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b)	System.out.printf("a < b\n");
		if(a > b)	System.out.printf("a > b\n");
		if(a == b)	System.out.printf("a == b\n");
	}
}



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

using namespace std;

int main(){

    int N;
    vector<int> v, c;
    cin >> N;
    v.reserve(N);
    c.reserve(N);

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

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

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(v[i] > c[i]){
            ans += (v[i] - c[i]);
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		if(A<=9 && B<=9)
		{
			System.out.println(A*B);
		}
		else {
			System.out.println("-1");
		}

	}

}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;
int mod_pow(int x,int n,int mod){
  int res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}

int lcm(int a,int b){return (a/__gcd(a,b)) * b;}
int carmichealLambda(int n){
  int res = 1;
  if(n % 8 == 0) n/=2;

  auto compute = [&](int i){
    int sub = i - 1;
    n/=i;
    while(n%i == 0) n/=i, sub *=i;
    res = lcm(res,sub);
  };

  for(int i=2;i*i<=n;i++) if( n % i == 0) compute(i);
  if(n != 1) compute(n);
  return res;
}

signed main(){
  cin>>n;
  int car = carmichealLambda(n);
  int car2 = carmichealLambda(car);
  int ans = car2;
  if(mod_pow(n,1,car)==1) ans = 1;
  
  for(int i=1;i*i<=car2;i++){
    if(mod_pow(n,car2/i,car) == 1) Min(ans,car2/i);
    if(mod_pow(n,i,car) == 1) Min(ans,i);
  }
  
  if(car != 1 && mod_pow(n,car2,car) !=  1)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

/////////////         modの計算

int mod = 1000000007;

ll mod_adjust(ll a) {//	余りをとる(0～mod-1に調整する)
	if (a >= mod) {
		return a % mod;
	}
	if (a < 0) {
		a *= -1;
		a %= mod;
		return mod - a;
	}
	return a;
}
int mod_add(int a, int b) {//	足し算
	ll k = mod_adjust((ll)a); k += mod_adjust((ll)b);
	k = mod_adjust(k);
	return (int)k;
}
int mod_sub(int a, int b) {//	引き算
	return mod_add(a, -b);
}
int mod_multi(int a, int b) {//	掛け算
	ll k = mod_adjust((ll)a);
	k *= mod_adjust((ll)b);
	k = mod_adjust(k);
	return (int)k;
}

int main() {
	vector<int> v;
	v.push_back(0); v.push_back(0); v.push_back(0);

	int N; cin >> N;
	int ans = 1;
	for (int i = 0; i < N; i++) {
		int count = 0;
		int x; cin >> x;

		for (auto itr = v.begin(); itr != v.end(); itr++) {
			if (*itr == x) { count++; if (count == 1) { *itr = *itr + 1; } }
		}
		sort(v.begin(), v.end());
		ans = mod_multi(ans, count);
	}

	cout << ans << endl;

	return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N));
    for (int i=0; i<2; i++){
        for (int j=0; j<N; j++){
            cin >> A.at(i).at(j);
        }
    }

    int ans = 0, buf = 0;
    for (int i=0; i<N; i++){
        buf = 0;
        for (int j=0; j<=i; j++) buf += A.at(0).at(j);
        for (int j=i; j<N; j++) buf += A.at(1).at(j);
        ans = max(buf, ans);
    }

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

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_139
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            string t = Read();
            int cnt = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == t[i]) cnt++;
            }
            WriteLine(cnt);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
def main():
  N=input()
  A=sorted(map(int,input().split()))
  M=A[-1]+1
  B=[True]*M
  c=0
  x=0
  for i in A:
    if B[i]:
      if i!=c:
        for j in range(i*2,M,i):
          B[j]=False
        x+=1
        c=i
      else:
        B[i]=False
        x-=1
  print(x)
main()

Measured memory_bytes: 32288
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  =long long;
int main()
{

    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }



    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <queue>

class TBinaryHeap
{
    std::vector<int> FArray;
    void BubbleUp(int Index)
    {
        assert(FArray.size() > Index);
        if(Index == 1) return;
        int Parent = Index / 2;
        if(FArray[Index] <= FArray[Parent]){
            return;
        }
        std::swap(FArray[Index], FArray[Parent]);
        BubbleUp(Parent);
    }
    void BubbleDown(int Index)
    {
        assert(FArray.size() > Index);
        int Left  = Index * 2;
        int Right = Index * 2 + 1;
        if(Left  >= FArray.size()) return;
        
        int Target = Right >= FArray.size() ? Left : FArray[Left] > FArray[Right] ? Left : Right;
        if(FArray[Target] > FArray[Index]){
            std::swap(FArray[Index], FArray[Target]);
            BubbleDown(Target);
        }
    }
public:
    TBinaryHeap()
    {
        FArray.reserve(2000000);
        FArray.resize(1); // dummy
    }
    void push(const int& Value)
    {
        FArray.push_back(Value);
        BubbleUp(FArray.size()-1);
    }
    void pop()
    {
        assert(FArray.size() >= 1);
        FArray[1] = FArray.back();
        FArray.pop_back();
        if(FArray.size() == 1) return; // dummy???????????????
        BubbleDown(1);
    }
    const int& top()
    {
        return FArray[1];
    }
};
int main()
{
    char Line[19];
    int Value;

    // std::priority_queue<int> S;
    TBinaryHeap S;
    while(1){
        std::fgets(Line, 19, stdin);
        if(Line[0] == 'i'){
            S.push(std::atoi(&Line[7]));
        }else
        if(Line[1] == 'x'){
            std::printf("%d\n", S.top());
            S.pop();
        }else{
            break;
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long

/* Sparse Tableを利用したRangeMinimumQuery */
template <typename T>
struct RMinQ_SparseTable {
private:
	// log_table : logの値
	// table[i][k] : インデックスiから長さ1<<kの最小値のインデックス
	vector<int> log_table;
	vector<vector<int>> table;
public:
	// n : 要素数
	// element : 要素
	int n;
	vector<T> element;
	// コンストラクタ
	RMinQ_SparseTable(vector<T> vec) {
		n = vec.size();
		element.resize(n);
		for (int i = 0; i < n; ++i)
			element[i] = vec[i];
		// log_tableを構築
		log_table.resize(n + 1, 0);
		for (int i = 2; i <= n; ++i)
			log_table[i] = log_table[i >> 1] + 1;
		// tableを構築
		table.resize(n, vector<int>(log_table[n] + 1));
		for (int i = 0; i < n; ++i)
			table[i][0] = i;
		for (int k = 1; (1 << k) <= n; ++k) {
			for (int i = 0; i + (1 << k) <= n; ++i) {
				int c1 = table[i][k - 1], c2 = table[i + (1 << (k - 1))][k - 1];
				if (element[c1] < element[c2]) table[i][k] = c1;
				else table[i][k] = c2;
			}
		}
	}
	// [l, r)の範囲の最小値のインデックスを求める
	int query_idx(int l, int r) {
		int d = r - l;
		int k = log_table[d];
		if (element[table[l][k]] < element[table[r - (1 << k)][k]])
			return table[l][k];
		return table[r - (1 << k)][k];
	}
	// [l,r)の範囲の最小値を求める
	T query_value(int l, int r) {
		return element[query_idx(l, r)];
	}
};

int main() {
	int N, L; cin >> N >> L;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) cin >> a[i];

	RMinQ_SparseTable<int> st(a);
	for (int i = 0; i <= N - L; ++i) {
		cout << st.query_value(i, i + L);
		if (i != N - L) cout << " ";
	}
	cout << endl;

	return 0;
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999

//整数と、リストの次要素を指すポインタをまとめた構造体slobjを定義
typedef struct slobj_{
    int key;
    struct slobj_ *next;
}*slobj;

//slobj型の変数のポインタをslist型と定義→いずれリストの先頭要素を指す
typedef struct{
    slobj head;
}*slist;

//slist型の空リスト1つを作る関数
slist slist_new(void){
    slist L;
    NEW(L,1);
    L->head=NULL;
    return L;
}

//keyにxを持つリスト要素を作る関数
slobj slobj_new(int x){
    slobj p;
    NEW(p,1);
    p->key=x;
    p->next=NULL;
    return p;
}

//slobj型の要素pをリストLの先頭に挿入する関数
void slist_insert_head(slist L,slobj p){
    p->next=L->head;
    L->head=p;
    
    return;
}

//リスト探索
slobj slist_search(slist L, int k){
    slobj p=L->head;
    slobj q=NULL;

    while(p!=NULL){
        if(p->key==k){
            q=p;
            break;
        }
        else{
            p=p->next;
        }
    }

    return q;
}

int main(void){
    int s;
    scanf("%d", &s);

    slist L=slist_new();
    slobj p=slobj_new(s);
    slist_insert_head(L,p);

    int a=s;
    int i=1;
    while(1){
        i++;
        //もしaiが偶数なら
        if(a%2==0){
            a=a/2;
        }
        //もしaiが奇数なら
        else{
            a=3*a+1;
        }

        slobj q=slist_search(L,a);
        if(q!=NULL){
            break;
        }
        else{
            p=slobj_new(a);
            slist_insert_head(L,p);
        }

    }

    printf("%d\n",i);
    
    return 0;
    
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>

#define endl "\n"

using namespace std;

char S[3];
char T[3];

char init;
int result;

void solution() {
    for(int i = 0; i < 3; i++) {
        if(S[i] == init) break;
        if(S[i] == T[i]) result++;
    }
}

int main() {
    init = S[0];
    for(int i = 0; i < 3; i++) {
        cin >> S[i];
        if(S[i] == init) break;

    }
    for(int i = 0; i < 3; i++) {
        cin >> T[i];
        if(T[i] == init) break;
    }

    solution();

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
memo = {} #メモ化されないと時間がかかる
def fib(n):
  if n == 0 or n == 1:
    return 1
  # else:
  #   return fib(n-1) + fib(n-2)
  else:
    if n-1 not in memo:
      memo[n-1] =fib(n-1)
    if n-2 not in memo:
      memo[n-2] = fib(n-2)
    return memo[n-1]+memo[n-2]
print(fib(int(input())))



Measured memory_bytes: 5600
#include <stdio.h>
#include <string.h>

int main(){

  char str[200010];
  int len,i,ans=0,flag=0,count=0;

  scanf("%s",str);

  len=strlen(str);

  for(i=0;i<len;i++){
    if(str[i]=='A' && flag==0){
      flag=1;
    }
    if(flag==1){
      count++;
      if(str[i]=='Z'){
        ans=count;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 384
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;


void solve();

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

void solve(){
    ll n,m,x;cin>>n>>m>>x;
    vl c(n);
    vvl a(n,vl(m));
    rep(i,n){
        cin>>c[i];
        rep(j,m)cin>>a[i][j];
    }

    ll ans=LINF;
    rep(i,1<<n){
        vl b(m);
        ll cost=0;
        rep(j,n){
            if(i>>j&1){
                rep(k,m){
                    b[k]+=a[j][k];
                }
                cost+=c[j];
            }
        }
        bool ok=true;
        rep(j,m){
            if(b[j]<x)ok=false;
        }
        if(ok)chmin(ans,cost);
    }

    cout<<(ans==LINF?-1:ans)<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int W[N];
    int min=200;
    int ABS;
    int sum1=0;
    int sum2=0;
    for (int i=0;i<N;i++){
        cin >> W[i];
        sum1=sum1+W[i];
    }
    for (int j=0;j<N;j++){
        sum1=sum1-W[j];
        sum2=sum2+W[j];
        ABS=abs(sum2-sum1);
        if(ABS<min)
        {min=ABS;
            
        }
        
        
    }
    cout << min << endl;
    return 0;
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var nn, h, n, w int
	fmt.Scan(&nn)
	for h = 1; h <= 3500; h++ {
		for n = h; n <= 3500; n++ {
			a := nn*h*n
			b := 4*h*n-nn*n-nn*h
			if b > 0 && a%b == 0 {
				w = a/b
				fmt.Print(h)
				fmt.Print(" ")
				fmt.Print(n)
				fmt.Print(" ")
				fmt.Print(w)
				return
			}
		}
	}
}

Measured memory_bytes: 512
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		String S = I.next();
		int N = S.length();
		int ans = 0;
		for (int i = 0; i < N/2; i++) {
			char L = S.charAt(i);
			char R = S.charAt(N-i-1);
			if (L!=R) ans++;
		} 
		O.pln(ans);
	}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(max(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25636
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll a, b; cin>>a>>b;
    cout << max(a+b, max(a-b, a*b));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int i[114514];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d=0,e;
	cin >>a>>i[0];
	for(int n=1;n<a;n++){
		cin >>i[n];
		if(i[n]>i[n-1]) i[n]--;
		if(i[n-1]>i[n]) d++;
	}
	if(d>0) cout <<"No\n";
	else cout <<"Yes\n";
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    n: i64,
  }

  println!(
    "{}",
    match n % 10 {
      2 | 4 | 5 | 7 | 9 => "hon",
      3 => "bon",
      _ => "pon",
    }
  );
}


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

using namespace std;
#define M 1005
#define N 15
int a[M];
int b[M];
int c[M];
int dp[M][4500];
int n,m;
int mx;

int solve(int idx,int mask)
{
    if(idx == m)
    {
        if(mask == mx)
        {
            return 0;
        }
        return 1e9;
    }

    if(dp[idx][mask] != -1)
    {
        return dp[idx][mask];
    }
    int temp = mask | c[idx];
    int A = solve(idx + 1, temp) + a[idx];
    int B = solve(idx + 1, mask);

    return dp[idx][mask] = min(A,B);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    mx = (1<<n) - 1;
    for(int i = 0 ; i < m ; i++)
    {
        cin>>a[i]>>b[i];
        for(int j = 0 ; j < b[i] ; j++)
        {
            int x;
            cin>>x;
            c[i] |= (1<<(x - 1)) ;
        }
    }
    int ans = solve(0,0);
    cout<<((ans != 1e9)?ans:-1)<<endl;

    return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/


Measured memory_bytes: 21320
#include <stdio.h>

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

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

struct RW {
    ll S, T, X;
};

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> p;
    vector<RW> R(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> R[i].S >> R[i].T >> R[i].X;
        RW r = R[i];
        p.push_back(r.S-r.X-1);
        p.push_back(r.S-r.X);
        p.push_back(r.T-r.X-1);
        p.push_back(r.T-r.X);
    }
    sort(R.begin(), R.end(), [](RW& a, RW& b){ return a.X < b.X; });
    vector<ll> D(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> D[i];
        p.push_back(D[i]);
    }
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());

    vector<int> num(p.size(), -1);
    set<int> todo;
    for ( int i = 0; i < p.size(); i++ ) todo.insert(i);
    for ( int i = 0; i < N; i++ ) {
        ll p1 = lower_bound(p.begin(), p.end(), R[i].S-R[i].X) - p.begin();
        ll p2 = lower_bound(p.begin(), p.end(), R[i].T-R[i].X) - p.begin();
        auto it = todo.lower_bound(p1);
        while ( it != todo.end() && *it < p2 ) {
            ll v = *it;
            num[v] = i;
            it = next(it);
            todo.erase(v);
        }
    }

    for ( int i = 0; i < Q; i++ ) {
        ll v = lower_bound(p.begin(), p.end(), D[i]) - p.begin();
        ll ans;
        if ( num[v] >= 0 ) {
            ans = R[num[v]].X;
        } else {
            ans = -1;
        }
        cout << ans << "\n";
    }
    return 0;
}

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


int main(){
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++)
        cout<<s<<' ';
    if(s==1e9){
        for(int i=0;i<n-k;i++){
            cout<<1<<' ';
        }
    }else{
        for(int i=0;i<n-k;i++)
            cout<<(int)1e9<<' ';
    }


}



Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
 
struct node{
    int key;
    int left;
    int right;
};
 
void insert(struct node*, int, int);
void print1(struct node*, int);
void print2(struct node*, int);
 
int main()
{
    char s[10];
    struct node *t;
    int m;
    int a;
 
    scanf("%d", &m);
    t=(struct node*)malloc(sizeof(struct node)*m);
 
    int count=0;
    for(int i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ scanf("%d", &a); insert(t, count, a); count++; }
        if(s[0]=='p'){
            if(count>0) print1(t, 0);
            printf("\n");
            if(count>0) print2(t, 0);
            printf("\n");
        }
    }
     
    return 0;
 
}
 
void print1(struct node *t, int p)
{
    if(t[p].left>=0) print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0) print1(t, t[p].right);
}
 
void print2(struct node *t, int p)
{
    printf(" %d", t[p].key);
    if(t[p].left>=0) print2(t, t[p].left);
    if(t[p].right>=0) print2(t, t[p].right);
}
 
void insert(struct node *t, int count, int z)
{
    int x=0, y;
    if(count<1) x=-1;
 
    t[count].key = z;
    t[count].left = -1;
    t[count].right= -1;
 
    while(x>=0){
        y = x; // ????????¨????
        if(z < t[x].key)
            x = t[x].left; // ??????????????§????
        else
            x = t[x].right; // ??????????????§????
    }
 
    if(count<1){}
    else if(z < t[y].key){
        t[y].left = count; // z ??? y ?????????????????????
    }
    else {
        t[y].right = count; // z ??? y ?????????????????????
    }
}

Measured memory_bytes: 8580
using System;

class Atcoder121
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int t = int.Parse(input[2]);

        Console.WriteLine(t / a * b);
    }
}

Measured memory_bytes: 13140
# ABC096C - Grid Repainting 2
h, w = list(map(int, input().rstrip().split()))
arr = [list(input().rstrip()) for _ in range(h)]
arr.insert(0, ["."] * (w + 2))
arr.append(["."] * (w + 2))
for i in arr[1:-1]:
    i.insert(0, ".")
    i.append(".")

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if arr[i][j] == "#":
            if (
                arr[i - 1][j] != "#"
                and arr[i + 1][j] != "#"
                and arr[i][j - 1] != "#"
                and arr[i][j + 1] != "#"
            ):
                print("No")
                break
    else:
        continue
    break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, a[400];
ll DP[400][400], s[401];
int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> a[i];
	for (int i = 0; i != N; ++i)
		s[i + 1] = s[i] + a[i];
	for (int i = 1; i != N; ++i) {
		for (int j = 0; i + j != N; ++j) {
			DP[j][i + j] = llmax;
			for (int k = j; k != i + j; ++k) {
				DP[j][i + j] = min(DP[j][i + j], DP[j][k] + DP[k + 1][i + j] + s[i + j + 1] - s[j]);
			}
		}
	}
	cout << DP[0][N - 1] << endl;
	return 0;
}

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

int main() {
    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    int sum = 0;
    int minimum = 100000;
    for (int i = 0; i < t; i++) {
        sum += a.at(i);
        minimum = min(minimum, max(0, abs((k - sum) - sum) - 1));
    }
    
    cout << minimum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int l=s.length();
  int c=0;
  for(int i=0;i<l;i++)
  {
    if(s[i]!=t[i])
      c++;
  }
  cout<<c<<"\n";
  return 0;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int K;cin >> K;
    string S;cin >> S;
    if(S.size() <= K)cout << S << endl;
    else{
        rep(i,K)cout << S[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<ll> a(N);
    for (auto &&i : a) {
        cin >> i;
    }
    SORT(a);
    vector<ll> v(N);
    partial_sum(ALL(a), v.begin());
    ll mx   = a[0];
    int ans = 0;
    FOR(i, 1, N) {
        if (a[i] <= 2 * v[i - 1])
            ans++;
        else
            ans = 0;
    }
    ans++;
    print(ans);

    return 0;
}

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

using namespace std;

const int maxn = 2001;

int a[maxn];
bitset<(maxn * maxn)> dp[2];

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

    int sum = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    dp[0].set(0);
    for (int i = 1; i <= n; i++)
        dp[i & 1] = dp[(i - 1) & 1] | (dp[(i - 1) & 1] << a[i - 1]);

    int answer = 0;
    for (int i = (sum + 1) / 2; i < (maxn * maxn) and !answer; i++)
        if (dp[n & 1][i])
            answer = i;

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> g(n);    
    rep(i, 0, n-1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);        
        g[b].push_back(a);
    }
    vector<ll> x(n, 0);
    rep(i, 0, q) {
        ll p, y;
        cin >> p >> y;
        p--;
        x[p] += y;
    }

    vector<bool> ok(n, false);
    ok[0] = true;
    queue<ll> que;
    que.push(0);
    while (!que.empty()) {
        ll v = que.front();
        que.pop();

        for(auto nv : g[v]) {
            if (ok[nv] == true) continue;

            ok[nv] = true;
            x[nv] += x[v];
            que.push(nv);
        }
    }

    rep(i, 0, n) cout << x[i] << " ";
    cout << endl;
}

Measured memory_bytes: 17904
#include<stdio.h>
#define LEN 25
#define NIL -1

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

Tree t[25];
int n;
int Depth[25],Height[25];

int calHeight(int key);
void calDepth(int key,int depth);
int findsibling(int key);
void print(void);

int main(){
  int i,j;
  int root,r,l,key;

  //in
  scanf("%d",&n);

  //ini
  for(i=0;i<n;i++)
    t[i].parent=t[i].left=t[i].right=NIL;

  //in
  for(i=0;i<n;i++){
    scanf("%d%d%d",&key,&l,&r);
    t[key].left=l;
    t[key].right=r;
    if(l!=NIL) t[l].parent=key;
    if(r!=NIL) t[r].parent=key;
  }

  //findroot
  for(i=0;i<n;i++)
    if(t[i].parent==NIL){
      root=i;
      break;
    }

  calHeight(root);
  calDepth(root,0);

  print();

  return 0;
}

int calHeight(int key){
  int h1=0,h2=0;
  
  if(t[key].left!=NIL)
    h1=calHeight(t[key].left)+1;
  if(t[key].right!=NIL)
    h2=calHeight(t[key].right)+1;

  return Height[key]=( h1>h2 ? h1 : h2 );
}
void calDepth(int key,int depth){
  Depth[key]=( Depth[key]>depth ? Depth[key] : depth);

  if(t[key].left!=NIL)
    calDepth(t[key].left,depth+1);
  if(t[key].right!=NIL)
    calDepth(t[key].right,depth+1);
}
int findsibling(int key){

  if(t[key].parent==NIL)return NIL;

  if(t[t[key].parent].left != key && t[t[key].parent].left != NIL)
    return t[t[key].parent].left;
  if(t[t[key].parent].right != key && t[t[key].parent].right != NIL)
    return t[t[key].parent].right;

  return NIL;
}
void print(void){
  int i,j,k;
  int l,tmp;
  int degree;
  
  for(i=0;i<n;i++){
    degree=0;
    if(t[i].left!=NIL)degree++;
    if(t[i].right!=NIL)degree++;
    
    printf("node %d: ",i);
    printf("parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",t[i].parent,findsibling(i),degree,Depth[i],Height[i]);

    if(t[i].parent==NIL)
      printf("root");
    else if(t[i].left!=NIL || t[i].right!=NIL)
      printf("internal node");
    else 
     printf("leaf");

    printf("\n");
  }
}



Measured memory_bytes: 2096
#include<iostream>
#include<stdio.h>
using namespace std;
#define ll long long int

int main()
{
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int i=0;
	if(a%k==0)
	{
		cout<<"OK"<<endl;
		return 0;
	}
	else
	{
		i = a + k - (a%k);
		if(i<=b)
		{
			for(; i <= b; i += k)
			{
				if(i%k == 0)
				{
					cout<<"OK"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int a[200001],b[200001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int c=1,ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]!=c)ans++;
		else c++;	
	}
	if(ans==n)ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
main(){
  int a[1000],i,j,temp;
  for(i=0;i<10;i++)
    scanf("%d",&a[i]);
  for(i=9;i>0;i--){
    for(j=0;j<i;j++){
      if(a[j]<a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  for(i=0;i<3;i++)
    printf("%d\n",a[i]);
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python
# coding: utf-8

# In[15]:


N,Q = map(int, input().split())
S = list(input())
mylist = [0]
cnt = 0
for i in range(1,len(S)):
    if S[i-1] == "A" and S[i] == "C":
        cnt += 1
    mylist.append(cnt)
for _ in range(Q):
    l,r = map(int, input().split())
    ans = mylist[r-1] - mylist[l-1]
    print(ans)


# In[ ]:






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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<int> a(N), b(N), c(N);
	for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> dp(N, vector<int>(3));
	dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
	for(int i = 1; i < N; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	int ans = max(max(dp[N - 1][0], dp[N - 1][1]), dp[N - 1][2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9864
<?php
fscanf(STDIN, "%d", $N);
$xy =array();
$pq =array();
$xyk =array();
$kaburi = array();
$kaburi[] = -1;
for($i=0;$i<$N;$i++){
  fscanf(STDIN, "%d %d", $x,$y);
  $xy[] = array('x'=>$x,'y'=>$y);
  if(isset($xyk[$x.'-'.$y])){
      $kaburi[] = $i;
  }else{
    $xyk[$x.'-'.$y]=1;
  }
}

if($N==1){
  echo "1"."\n";
  exit;
}

for($i=0;$i<$N;$i++){
  for($j=$i+1;$j<$N;$j++){
    if(!in_array($i, $kaburi)&&!in_array($j, $kaburi)){
      $p = $xy[$i]['x']-$xy[$j]['x'];
      $q = $xy[$i]['y']-$xy[$j]['y'];
      if($p<0){
        $p = -1*$p;
        $q = -1*$q;
      }
      if($p==0&&$q<0){
        $q = -1*$q;
      }
      if($p==0&&$q==0){
      }elseif(isset($pq[$p.'-'.$q])){
        $pq[$p.'-'.$q] = $pq[$p.'-'.$q]+1;
      }else{
        $pq[$p.'-'.$q] = 1;
      }
    }
  }
}
if(count($pq)<1){
  echo $N."\n";
  exit;
}
arsort($pq);
 
 
foreach($pq as $value){
  echo ($N-$value)."\n";
  exit;
}
 
?>

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=110000;
int a[N], b[N];
map<int, vi> adj;
map<int, int> v;

void dfs(int i) {
    if(v[i]) return;
    v[i]=1;
    for(int j:adj[i]) dfs(j);
}

int main() {
    int i, n, ans;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        a[n]^=a[i];
    }
    for(i=0; i<n; i++) {
        scanf("%d", &b[i]);
        b[n]^=b[i];
        adj[b[i]].pb(a[i]);
    }
    adj[b[n]].pb(a[n]);
    if(multiset<int>(a, a+n+1)!=multiset<int>(b, b+n+1))
        return printf("-1\n"), 0;
    ans=n+1;
    for(i=n; i>=0; i--) {
        if(i<n && a[i]==b[i]) ans--;
        else if(!v[b[i]]) {
            dfs(b[i]);
            ans+=(i==n? -1:1);
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 29184
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 10000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buff[20],len; len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buff[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buff[--len]+'0');
}
inline void writeln(ll x)
{
	write(x); putchar('\n');
}
inline void writesp(ll x)
{
	write(x); putchar(' ');
}
int n,h,w;
int main()
{
	n=read(); h=read(); w=read();
	writeln((n-h+1)*(n-w+1));
	return 0;
}

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


    ll k,b,m,q;
    ll c,d,t,i,j,a,n;
    vector<ll> v,s;
    map< pair<ll,ll> ,pair<ll,ll> > ma,sa;
    map< pair<ll,ll> ,pair<ll,ll> > :: iterator it,ki;
    string st,et;
    cin>>n;
    n = n-1;
    for(i=1;i<=n;i++){
        cin>>a;
        v.push_back(a);
    }
    a= v[0];
    for(i=1;i<n;i++){
        if(v[i-1]>v[i]){
            v[i-1]=v[i];
        }
    }
    for(i=0;i<n;i++){
        a = a+v[i];
    }
    cout<<a<<endl;
}


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

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.D
{
    public class Program
    {
        public static int N { get; private set; }
        public static int K { get; private set; }
        public static List<int> P { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            K = inputs[1];
            P = CR.GetIntegers().ToList();

            var dicKitaichi = Enumerable.Range(1, 1000).ToDictionary(x => x, y => (double)Enumerable.Range(1, y).Sum() / y);
            var current = Enumerable.Range(0, K).Sum(i => dicKitaichi[P[i]]);

            var max = current;

            for (int i = 0; i < P.Count - K; i++)
            {
                current -= dicKitaichi[P[i]];
                current += dicKitaichi[P[i + K]];

                max = Math.Max(max, current);
                //if (P[i] <= P[i + K])
                //{
                //    pSumMax_StartIndex = i + 1;
                //    pSumMax = currentPSum;
                //}
            }

            //var max = Enumerable.Range(pSumMax_StartIndex, K).Sum(x => dicKitaichi[P[x]]);

            return max;
        }
    }
}


Measured memory_bytes: 32860
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAXN=18;
int n;
int a[MAXN][MAXN];
ll dp[1<<MAXN];
vector<int>nums[MAXN];
vector<int>his_nums[(1<<MAXN)];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<(1<<n);i++){
		dp[i]=0;
		for(int j=0;j<n;j++){
			for(int k=0;k<j;k++){
				if(((1<<j)&i)&&((1<<k)&i)){
					dp[i]=dp[i]+a[j][k];
				}
			}
		}
		nums[__builtin_popcount(i)].push_back(i);
	}
	for(int i=0;i<(1<<n);i++){
		vector<int>p;
		for(int j=0;j<n;j++){
			if(!((1<<j)&i)){
				p.push_back(j);
			}
		}
		int x=p.size();
		for(int j=0;j<(1<<x);j++){
			int num=0;
			for(int k=0;k<x;k++){
				if(j&(1<<k)){
					num|=(1<<(p[k]));
				}
			}
			his_nums[i].push_back(num);
		}
		/*
		int x=__builtin_popcount(i);
		for(int j=0;j<=n-x;j++){
			for(auto y:nums[j]){
				if(i&y) continue;
				his_nums[i].push_back(y);
			}
		}
		*/
	}
	//cout<<"ok\n";
	for(int i=1;i<=n;i++){
		for(auto x:nums[i]){
			for(auto y:his_nums[x]){
				dp[x|y]=max(dp[x|y],dp[x]+dp[y]);
			}
		}
	}
	cout<<dp[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 178076
package MyApp;
use utf8;
use 5.016;

say func(map { chomp; $_ } <>);

sub func {
    my ($n1, $n2, $n3) = split / /, shift;
    if ($n2 > $n1) {
        return 'Yes' if ($n2 > $n3 and $n1 < $n3);
        return 'No';
    }
    return 'Yes' if ($n1 > $n3 and $n2 < $n3);
    return 'No';
}

1;
__END__


Measured memory_bytes: 512