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

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

using namespace std;

int main() {

    ll a[3]; rep(i,3) cin >> a[i];
    if(a[0]%2 == 0 ||a[1]%2 == 0 ||a[2]%2 == 0 ) cout << 0;
    else {
        sort(a,a+3);
        cout << (a[0]*a[1]);
    }
    

    return 0;
}











Measured memory_bytes: 3620
import Data.Array
import Control.Monad

main = do
  getLine
  co <- getContents
  compute $ lines co

compute :: [String] -> IO ()
compute js = do
  let ar = accumArray (+) 0 (1,4) $ [ (s2i j, 1) | j <- js ]
  mapM_ (\(a,b) -> putStrLn (unwords [a, "x", show b])) $ zip ["AC","WA","TLE","RE"] $ elems ar

s2i "AC" = 1
s2i "WA" = 2
s2i "TLE" = 3
s2i "RE" = 4


Measured memory_bytes: 4964
#include <cstdio>

int main(void) {
    int N, x, a, b;
    long long int ans=0, sum, tmp;
    scanf("%d %d", &N, &x);
    scanf("%d", &a);
    for(int i=1 ; i<N ; i++) {
        scanf("%d", &b);
        sum=a+b;
        if(sum>x) {
            tmp=sum-x;
            ans+=tmp;
            if(tmp>b) {
                a-=tmp-b;
                b=0;
            } else {
                b-=tmp;
            }
        }
        a=b;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int k, t;
    cin >> k >> t;
    vector<int> a(t);
    rep(i, t) cin >> a[i];
    sort(all(a));
    int b = k - a[t - 1];
    cout << max(a[t - 1] - b - 1, 0LL) << endl;
}

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

//関数
void display(vector<long> c){
    for(int i=0;i<c.size();i++){
        cout<<c.at(i)<<" ";
    }
    cout<<endl;
}

double katamuki(long x,long y,long X,long Y){//(x,y)から(X,Y)に向かうベクトルの傾き(-pi~pi)
    return atan2(Y-y,X-x);
}
double kakusa(double a, double b){//角度aからbまで反時計回りでなんぼか
    if(b-a>=0){
        return b-a;
    }else{
        return 2*M_PI-a+b;
    }
}

double kaku(long i,long j, long k,vector<long> x,vector<long> y){//i to j to kの反時計回りの角。0<=i,j,k<x.size()=y.size()
    return kakusa(katamuki(x.at(i),y.at(i),x.at(j),y.at(j)),katamuki(x.at(j),y.at(j),x.at(k),y.at(k)));
}

//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    
    vector<long> x(N+1),y(N+1);//最初にダミーを入れる
    for(int i=1;i<=N;i++){
        cin>>x.at(i)>>y.at(i);
    }
        
    
    //計算
    vector<long> c(2);//凸包。反時計回りに巻く。
    c.at(0)=0;//これはダミー
    c.at(1)=1;//これを更新
    
    long temphigh=y.at(1);//最高点をスタートに。
    for(int i=2;i<=N;i++){
        if(temphigh<y.at(i)){
            temphigh=y.at(i);
            c.at(1)=i;
        }
    }
    x.at(0)=x.at(c.at(1))+1;//右から水平に近づく
    y.at(0)=y.at(c.at(1));
    
    long last=1;//=c.size()-1
    while(c.at(1)!=c.at(last) || last==1){
        double tempkaku=3*M_PI;//>2*M_PI
        long kouho;
        for(int i=1;i<=N;i++){//ダミー以外で探す
            if(i!=c.at(last)){
                //cout<<"arg("<<c.at(last-1)<<"to"<<c.at(last)<<"to"<<i<<")="<<kaku(c.at(last-1),c.at(last),i,x,y);
                if(kaku(c.at(last-1),c.at(last),i,x,y)<tempkaku){
                    tempkaku=kaku(c.at(last-1),c.at(last),i,x,y);
                    kouho=i;
                    //cout<<"deepest ";
                }
                //cout<<"deeper ";
            }
            //cout<<"deep "<<"kouho:"<<kouho<<endl;
        }
        c.push_back(kouho);
        last++;
       // cout<<"cycle"<<endl;
    }
    c.at(0)=c.at(last-1);//ダミーを埋めてサイクル完成(両端以外が本質、両端は便利のため)
    
   // display(c);
    
    
    vector<double> ans(N+1);//0はダミーだったので使わない
    for(int i=1;i<last;i++){
        ans.at(c.at(i))=kaku(c.at(i-1),c.at(i),c.at(i+1),x,y)/(2*M_PI);
    }
    
    //出力
    for(int i=1;i<=N;i++){
        cout<<ans.at(i)<<endl;
    }

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,a,b,c,d,h,w,x,y;
string str;

signed main(){

  cin >> str;
  if(str.length()==2) cout << str;
  else{
    FOR(i,3){
      cout <<str[2-i] ;
    }}
  cout fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) if(s[i] == t[i]) ++ans;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> rabits(n);
  for(int i = 0;i < n;i++){
    cin >> rabits[i];
  }

  int ans = 0;
  for(int i = 0;i < n;i++){
    if(rabits[rabits[i] - 1] - 1 == i){
      ans++;
    }
  }
  ans /= 2;

  cout << ans << endl;
}


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

long long N;
string s;
string t = "keyence";

void input(){
    cin >> s;
}

bool solve(){
    int s_index = 0;
    int t_index = 0;
    while(s_index < s.size() && t_index < t.size() && s[s_index] == t[t_index]){
        s_index++;
        t_index++;
    }
    if(t_index == t.size()){
        return true;
    }
    string rest_s = s.substr(s_index, s.size()-s_index);
    string rest_t = t.substr(t_index, t.size()-t_index);
    string pat = ".*" + rest_t;
    bool ret = regex_match(rest_s, regex(pat));
    // cout << rest_s << " " << pat ;
    return ret;
}

int main(void){
    // Your code here!
    input();
    bool ret = solve();
    string ans = (ret)?"YES":"NO";
    cout << ans << endl;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < int(e.size()); ++i) cout << o[i] << e[i];
  if (o.size() > e.size()) cout << o.back();
  cout << endl;
}



Measured memory_bytes: 384
def cut(ch, cw):
    total = ch*cw
    if not ch % 2 or not cw % 2:
        x = ch*cw // 2
        return x, x
    else:
        x = max(ch*(cw//2), cw*(ch//2))
        return x, total - x


h, w = map(int,input().split())

ans = h*w

for i in range(2):
    yh = h // 3 + i
    s = [yh*w]
    ch = h - yh
    s += cut(ch, w)
    ans = min(ans, max(s) - min(s))

for i in range(2):
    yw = w // 3 + i
    s = [h*yw]
    cw = w - yw
    s += cut(h, cw)
    ans = min(ans, max(s) - min(s))

print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	vector<ll> p3(1, 1);
	REP(i, 30) p3.emplace_back(p3.back() * 3);
	
	int Q;
	cin >> Q;
	while (Q--) {
		ll y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		--y1; --x1; --y2; --x2;
		
		ll ans = abs(y2 - y1) + abs(x2 - x1);
		for (int k = 29; k >= 0; --k) {
			bool done = false;
			REP(i, 2) {
				ll by1 = y1 / p3[k], bx1 = x1 / p3[k], by2 = y2 / p3[k], bx2 = x2 / p3[k];
				
				if (by1 == by2 && by1 % 3 == 1 && abs(bx1 - bx2) >= 2) {
					y1 %= p3[k]; y2 %= p3[k];
					ans = abs(x2 - x1) + min(y1 + y2 + 2, 2 * p3[k] - (y1 + y2));
					done = true;
					break;
				}
				
				swap(x1, y1); swap(x2, y2);
			}
			if (done) break;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
#define lc o<<1
#define rc o<<1|1
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+10;
const int maxm = 2000+10;
const int mod = 1e9+7;
const double eps = 1e-8;
int a[maxn];
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n; cin>>n;
    cout<<1ll*n*(n-1)/2<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    ll K;
    cin >> K;
    vector<ll> A;
    vector<ll> dsum(60, 0);
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
        int d = 0;
        while(tmp > 0){
            if(tmp & 1){ dsum[d]++; }
            d++;
            tmp /= 2;
        }
    } // end i
    stack<int> stk;
    ll pp = 0;
    ll harf = N / 2;
    for (ll i = dsum.size() - 1; i >= 0; --i) {
        ll curr = 1ll << i;
        if(dsum[i] <= harf){
            if((pp | curr) <= K){
                pp |= curr;
                stk.push(i);
//                cerr << "push:" << i << endl;
            }
            else{
                if(stk.empty()) continue;
                int j = stk.top();
                if(N - 2 *dsum[i]  > ((N - 2 * dsum[j]) << (j - i))){
//                    cerr << "pop:" << j << endl;
                    stk.pop();
                    pp &= !(1ll << j);
                    pp |= curr;
                    stk.push(i);
//                    cerr << "push:" << i << endl;
                }
            }
        }
    } // end i
    if(pp > K){
        throw "out";
    }
//    cerr << "pp:" << pp << endl;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += A[i] ^ pp;
    } // end i
    cout << ans << endl;


}

int main(int argc, char *argv[]) {
    string FileName("D"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


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

// vector<vector<int>> G(n); // 各頂点がどこに繋がっているか
vector<bool> seen; // 一度検知したらtrue
vector<int> todo; // 検知かつ未訪問のもの
vector<int> res;
// seen.assign(n, false); // 初期化
// res.assign(n, 0);

void dfs(const vector<vector<int>> &G, int v){
  seen[v] = true;
  rep(i, G.at(v).size()){
    if(seen[G.at(v).at(i)-1] == true) continue;
    res[G.at(v).at(i)-1] += res[v];
    dfs(G, G.at(v).at(i)-1);
  }
}

int main(){
  // 入力
  int n, q;
  cin >> n >> q;
  vector<vector<int>> G(n);
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b);
    G[b-1].push_back(a); // 無向グラフとして扱う
  }
  int p[q], x[q];
  rep(i, q) cin >> p[i] >> x[i];
  
  // xの値をpにしたがってresにとりあえず足す
  res.assign(n, 0);
  rep(i, n) res[i] = 0;
  rep(i, q) res[p[i]-1] += x[i];
  // もうxとpは使わない
  
  // a、bにしたがってresの値を合体していく
  seen.assign(n, false);
  dfs(G, 0);
  
  // 出力
  rep(i, n-1) cout << res[i] << " ";
  cout << res[n-1] << endl;
  return 0;
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    auto x3 = x2 - (y2 - y1);
    auto y3 = y2 + (x2 - x1);

    auto x4 = x3 - (x2 - x1);
    auto y4 = y3 - (y2 - y1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();

    out.println("" + s1.charAt(0) + s2.charAt(0) + s3.charAt(0));
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 10320
#include<stdio.h>

int main (){
    int K,A,B;
    int sum=0;

    scanf("%d",&K);
    scanf("%d %d", &A, &B);

    while (sum < B){
        sum += K;
        if (sum >= A){
            break;
        }
    }
    sum > B ? printf("NG\n") : printf("OK\n");
    return 0;
}

Measured memory_bytes: 1644
abcd = input()

op = ['+', '-']

for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp_ans = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
            if eval(tmp_ans) == 7:
                print(tmp_ans+'=7')
                exit()
                

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,s,i;
	cin>>a>>b>>c;
	for(i=1;i<100;i++)
	{
		s=a*i;
		if(s%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}

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

using namespace std;

int main(){
    int a,b,c,temp;
    cin >> a >> b >> c;
    if(a > b) swap(a,b);
    if(b >c ) swap(b,c);
    if(a > b) swap(a,b);
    cout << a << " " << b << " "<< c << "\n";
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // long longの1次元の型に vll という別名をつける
using vvll = vector<vll>; // long longの2次元の型に vvll という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pll という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------



int main() {
   int n;
   cin>>n;
   if(n==0)cout<<1<<endl;
   else cout<<0<<endl;
}



Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		double total = 0;
		int a[] = new int [n];

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

			total += a[i];
		}

		int count = 0;
		for(int i = 0; i < n; i++){
			if(a[i] >= total/(4*m)){
				count++;
			}
		}

		if(count >= m){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21972
X = int(input())
if 400<=X<=599:
    print("8")
elif 600<=X<=799:
    print("7")
elif 800<=X<=999:
    print("6")
elif 1000<=X<=1199:
    print("5")
elif 1200<=X<=1399:
    print("4")
elif 1400<=X<=1599:
    print("3")
elif 1600<=X<=1799:
    print("2")
elif 1800<=X<=1999:
    print("1")

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

#define FIO    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;



int main()
{    
    FIO;
    int x;
    cin>>x;
    if(!x)
    	cout<<1;
    else
    	cout<<0;
}


Measured memory_bytes: 3576
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b,h,m;cin>>a>>b>>h>>m;
  ld PI=acos(-1.0);
  ld t=fabs(((ld)h+m/60.0)/12.0-(ld)m/60.0)*PI*2;
  //cout<<t<<endl;
  lfs<<sqrt(a*a+b*b-2*a*b*cos(t))<<endl;
  return 0;
}

Measured memory_bytes: 4200
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0){x = 0;}
  if(y == 0){y = 0;}
  printf("%.3f %.3f\n",x,y);
 }
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back

const int N = 2e5 + 10;

int n;
int a[N];
multiset<int> st;

signed main()
{
    scanf("%d", &n);
    FOR(i, 1, n) {
        int x; scanf("%d", &x);
        st.insert(x);
    }
    int ans = 0;
    while(st.size() > 0)    {
        auto it = st.end(); it --;
        int cur = (*it); st.erase(it);
        FOR(i, 0, 30) if((1 << i) >= cur) {
            int rem = (1 << i) - cur;
            it = st.find(rem);
            if(it != st.end()) {
                ans ++; st.erase(it);
            }
        }
    }
    printf("%d", ans);
}


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

short erase[12][6];
char board[12][7];

int dec_delete(int x,int y);
void make_delete(int x,int y);
void delete(void);
void down(void);

int main(void){
  int T,i,j,k,num,tmp[2];
  scanf("%d%*c",&T);
  while(T--){
    for(i=0;i<12;i++) scanf("%6s%*c",board[i]);
    num=0;
    do{
      num++;
      tmp[0]=tmp[1]=0;
      for(i=0;i<12;i++) for(j=0;j<6;j++) erase[i][j]=0;     
      for(i=0;i<12;i++) for(j=0;j<6;j++) if(board[i][j]!='O' && board[i][j]!='.' && erase[i][j]==0) dec_delete(i,j);     
      for(i=0;i<12;i++) for(j=0;j<6;j++) tmp[0]+=(board[i][j]=='.');
      for(i=0;i<12;i++) for(j=0;j<6;j++)  if(erase[i][j]>=4) make_delete(i,j);
      delete();
      for(i=0;i<12;i++) for(j=0;j<6;j++) tmp[1]+=(board[i][j]=='.');
      down();
    }while(tmp[1]!=tmp[0]);
    printf("%d\n",num-1);
  }
  return 0;
}

int dec_delete(int x,int y){
  int tmp=1;
  erase[x][y]=1;
  if(x!=0 && board[x-1][y]==board[x][y] && erase[x-1][y]==0) tmp+=dec_delete(x-1,y);
  if(y!=0 && board[x][y-1]==board[x][y] && erase[x][y-1]==0) tmp+=dec_delete(x,y-1);
  if(x!=11 && board[x+1][y]==board[x][y] && erase[x+1][y]==0) tmp+=dec_delete(x+1,y);
  if(y!=5 && board[x][y+1]==board[x][y] && erase[x][y+1]==0) tmp+=dec_delete(x,y+1);
  erase[x][y]=tmp;
  return tmp;
}
  
void make_delete(int x,int y){
  if(erase[x][y]==100) return;
  erase[x][y]=100;
  if(x!=0){
    if(board[x-1][y]==board[x][y])make_delete(x-1,y);
    else if(board[x-1][y]=='O') erase[x-1][y]=100;
  }
  if(y!=0){
    if(board[x][y-1]==board[x][y]) make_delete(x,y-1);
    else if(board[x][y-1]=='O') erase[x][y-1]=100;
  }
  if(x!=11){
    if(board[x+1][y]==board[x][y]) make_delete(x+1,y);
    else if(board[x+1][y]=='O') erase[x+1][y]=100;
  }
  if(y!=5){
    if(board[x][y+1]==board[x][y]) make_delete(x,y+1);
    else if(board[x][y+1]=='O') erase[x][y+1]=100;
  }
}

void delete(void){
  int i,j;
  for(i=0;i<12;i++) for(j=0;j<6;j++) if(erase[i][j]==100) board[i][j]='.';
}

void down(void){
  int i,j,num;
  for(i=0;i<6;i++){
    num=0;
    for(j=11;j>=0;j--){
      if(board[j][i]=='.') num++;
      else board[j+num][i]=board[j][i];
    }
    for(j=num-1;j>=0;j--) board[j][i]='.';
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int maxm = 100001;
int n, m;
long long dp[maxm];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	long long ret = 0;
	for(int i = 0; i < n; i++){
		long long w, v;
		cin >> w >> v;
		for(int j = m - w; j >= 0; j--){
			dp[j + w] = max(dp[j + w], dp[j] + v);
			ret = max(ret, dp[j + w]);
		}
	}
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1024
N, A, B  = map(int, input().split())

diff = abs(A - B)

if diff % 2 == 0:
  print(diff//2)
else:
  L = min(A, B) + (max(A, B) - min(A, B) - 1) // 2
  R = N - max(A, B) + (max(A, B) - min(A, B) + 1) // 2
  print(min(L, R))

Measured memory_bytes: 3060
#!/usr/bin/env python3
def right_triangle(edge):
    # a < b < c
    return (edge[0] ** 2 + edge[1] ** 2 == edge[2] ** 2)

n = int(input())
for i in range(n):
    edge = sorted([int(x) for x in input().split()])
    if right_triangle(edge):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 6728
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n,k = LI()
from scipy.special import comb
ans = 0
mod = 10**9+7
l = [i for i in range(n+1)]
a = sum(l[:k])
b = sum(l[-k:])
for i in range(k,n+2):
    ans += b-a+1
    a += i
    b += n-i
print(ans%mod)

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

int main(){
    string s;
    cin >> s;
    
    string ans = "Yes";
    
    long n = s.size();
    //奇数
    for(int i = 0; i < n; i+=2){
        if(s[i]=='L'){
            ans = "No";
            break;
        }
    }
    
    for(int i = 1; i < n; i+=2){
        if(s[i]=='R'){
            ans = "No";
            break;
        }
    }
    cout << ans;
}


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

stringstream input;

struct complex{
	bool ov;
	int re, im;

	complex( int re_, int im_, bool ov_ = false ):
		re(re_), im(im_), ov(ov_)
		{
			if( !ov ){
				ov = max( abs(re), abs(im) ) > 10000;
			}
		}

	complex operator -(){
		return complex( -re, -im, ov );
	}
	void operator +=( const complex &c ){
		*this = complex( re + c.re, im + c.im, ov | c.ov );
	}
	void operator -=( const complex &c ){
		*this = complex( re - c.re, im - c.im, ov | c.ov );
	}
	void operator *=( const complex &c ){
		*this = complex(
			re * c.re - im * c.im,
			re * c.im + im * c.re,
			ov | c.ov
		);
	}
};
const complex i( 0, 1 );

complex term();
complex factor();
complex expr();

complex expr(){
	complex c = term();
	char ch;
	for(;;){
		if( input.peek() == '+' ){
			input >> ch;
			c += term();
		}
		else if( input.peek() == '-' ){
			input >> ch;
			c -= term();
		}
		else break;
	}
	return c;
}

complex term(){
	complex c = factor();
	char ch;
	while( input.peek() == '*' ){
		input >> ch;
		c *= factor();
	}
	return c;
}

complex factor(){
	char ch;
	if( input.peek() ==  '(' ){
		input >> ch;
		complex c = expr();
		input >> ch;
		return c;
	}
	if( input.peek() == 'i' ){
		input >> ch;
		return i;
	}
	if( input.peek() == '+' ){
		input >> ch;
		return factor();
	}
	if( input.peek() == '-' ){
		input >> ch;
		return -factor();
	}
	
	int val;
	input >> val;
	return complex( val, 0, input.fail() );
}

int main(){
	for( string s; getline( cin, s ); ){
		input.clear();
		input.str(s);
		complex c = expr();

		if( c.ov ) cout << "overflow";
		else{
			if( c.re ){
				cout << c.re;
				if( c.im > 0 ) cout << '+';
			}
			else if( !c.im )
				cout << '0';

			if( c.im ){
				cout << c.im << 'i';
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
use proconio::marker::Bytes;
fn main() {
    proconio::input! {
        n: usize,
        s1: Bytes,
        s2: Bytes,
    }
    let mut t = 1;
    let mut p = 0;
    let mut i = 0;
    while i < n {
        if s1[i] == s2[i] {
            t *= 3 - p;
            i += 1;
            p = 1;
        } else {
            t *= match p {
                0 => 6,
                1 => 2,
                2 => 3,
                _ => panic!(),
            };
            i += 2;
            p = 2;
        }
    }
    println!("{}", t % MOD);
}
const MOD: u64 = 1000000007;


Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;cin>>n;
	vector<int> S(n);
	rep(i,n)cin>>S[i];
	int q;cin>>q;
	vector<int> T(q);
	rep(i,q)cin>>T[i];
	int count = 0;
	rep(i,q)
	{
		rep(j,n)
		{
			if(T[i]==S[j]){count++;break;}
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

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

    int a,b;
    cin >> a >> b;
    int ans = max(0,a-2*b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define pb 				push_back
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 55;
ll modpow(ll a,ll b,int mod = LLONG_MAX) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}

signed main(){
	FLASH
	string s;
	cin >> s;
	int fir = 10 * (s[0] - '0') + (s[1] - '0');
	int sec = 10 * (s[2] - '0') + (s[3] - '0');
	if (fir <= 12 and fir != 0 and (sec > 12 or sec == 0)) cout << "MMYY";
	else if ((fir > 12 or fir == 0) and sec != 0 and sec <= 12) cout << "YYMM";
	else if (fir != 0 and fir <= 12 and sec != 0 and sec <= 12) cout <<"AMBIGUOUS";
	else cout <<"NA";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split(' ')))
p0 = sum(x)/n
if p0-int(p0) > 0.5:
    p = (int(p0)+1)
else:
    p = (int(p0))
ans = 0
i = 0
while i < n:
    ans += (x[i]-p)*(x[i]-p)
    i += 1
    
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, tmp;
set<int> st;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (!st.empty()) {
            auto x = st.begin();
            if (*x > tmp) {
                cnt++;
            }
        }
        st.insert(tmp);
    }
  	cnt++;
    cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
template<class T> inline constexpr T min(vector<T>v){return *min_element(v.begin(),v.end());}
template<class T> inline constexpr T max(vector<T>v){return *max_element(v.begin(),v.end());}
int main (){
    ll n,m;
    cin>>n>>m;
    vector<ll>x(n+1),y(m+1);
    cin>>x[n]>>y[m];
    rep(i,0,n)cin>>x[i];
    rep(i,0,m)cin>>y[i];
    if(max(x)<min(y))cout<<"No ";
    cout<<"War\n";
}


Measured memory_bytes: 256
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = prev_lcm * t // tmp
        prev_lcm = lcm
    print(lcm)


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

std::string s;
std::string t;
std::string u;

int a;
int b;

int main() {
    std::cin >> s >> t;
    std::cin >> a >> b;
    std::cin >> u;

    if (s==u) {
        a -= 1;
    } else {
        b -= 1;
    }
    std::cout << a << ' ' << b << std::endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#define INFTY 999999999

int n, sum;

void merge(long long int *A, int left, int mid, int right) 
{
  int n1, n2;
  n1 = mid - left;
  n2 = right - mid;
  
  long long int L[n1+1], R[n2+1];
  for(int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for(int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  int s, t;
  s = 0; t = 0;
  for(int i = left; i < right; i++) {
    if(L[s] <= R[t]) {
      A[i] = L[s];
      s++;
    }
    else {
      A[i] = R[t];
      t++;
    }
    sum++;
  }
  
}

void mergeSort(long long int A[], int left, int right) 
{
  if(left + 1 < right) {
    int mid = (int)((left + right) / 2);
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  long long int A[n];
  for(int i = 0; i < n; i++) {
    std::cin >> A[i];
  }
  sum = 0;
  mergeSort(A, 0, n);

  for(int i = 0; i < n; i++) {
    if(i != n - 1) {
      std::cout << A[i] << " ";
    }
    else {
      std::cout << A[i];
    }
  }
  std::cout << "\n" << sum << "\n";
}


Measured memory_bytes: 10824
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn=100005;
int ufs[maxn];
int find(int x){
  return x==ufs[x]?x:ufs[x]=find(ufs[x]);
}
bool link(int a,int b){
  if(find(a)==find(b))return false;
  else{
    ufs[find(a)]=find(b);return true;
  }
}
struct node{
  int x,y,num;
}P[maxn];
bool cmp1(const node &A,const node &B){
  return A.x<B.x;
}
bool cmp2(const node &A,const node &B){
  return A.y<B.y;
}
struct edge{
  int a,b,w;
  edge(){}
  edge(int _a,int _b,int _w){
    a=_a;b=_b;w=_w;
  }
  bool operator <(const edge &B)const{
    return w<B.w;
  }
}E[maxn<<1];int tot=0;
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i){
    scanf("%d%d",&P[i].x,&P[i].y);P[i].num=i;
  }
  sort(P+1,P+n+1,cmp1);
  for(int i=1;i<n;++i){
    E[++tot]=edge(P[i].num,P[i+1].num,P[i+1].x-P[i].x);
  }
  sort(P+1,P+n+1,cmp2);
  for(int i=1;i<n;++i){
    E[++tot]=edge(P[i].num,P[i+1].num,P[i+1].y-P[i].y);
  }
  sort(E+1,E+tot+1);
  for(int i=1;i<=n;++i)ufs[i]=i;
  int ans=0;
  for(int i=1;i<=tot;++i){
    if(link(E[i].a,E[i].b))ans+=E[i].w;
  }
  printf("%d\n",ans);
  return 0;
}


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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r"))
    freopen (in, "r", stdin);
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int d[Sz];

int lucky (int n) {
  while (n) {
    if (d[n % 10])
      return 0;
    n /= 10;
  }
  return 1;
}       
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n; cin >> n;
  int k; cin >> k;
  for (int i = 1; i <= k; i++) {
    int x; cin >> x;
    d[x] = 1;
  }

  while (!lucky(n)) n++;
  cout << n;

  return 0;
}






// Coded by Z..


Measured memory_bytes: 256
/*
   _  __  U _____ u  _  __    
  |"|/ /  \| ___"|/ |"|/ /    
  | ' /    |  _|"   | ' /     
U/| . \\u  | |___ U/| . \\u   
  |_|\_\   |_____|  |_|\_\    
,-,>> \\,-.<<   >>,-,>> \\,-. 
 \.)   (_/(__) (__)\.)   (_/  
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define zhfs main
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 1; i <= n; i++)
bool g[17][17];
int zhfs()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		g[u][v] = g[v][u] = true;
	}
	vector<int> p;
	int fc = 1;
	for (int i = 1; i <= n; i++)
	{
		fc *= i;
		p.push_back(i);
	}
	int res = 0;
	for (int i = 1; i <= fc; i++)
	{
		if (p[0] != 1) continue;
		bool ok = true;
		for (int j = 1; j < (int)p.size(); j++)
		{
			if (!g[p[j - 1]][p[j]]) ok = false;
		}
		if (ok) res++;
		next_permutation(p.begin(), p.end());
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());

    int res = 0;
    int t;
    rep(i, n) {
        t = a[i];
        int cnt = 0;
        while(t == a[i]) {
            ++i, ++cnt;
        }
        if (cnt < t) res += cnt;
        else if (cnt > t) res += cnt - t;
        --i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
bool compare_by_c(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ll n,m;
    ll a[100010];
    pair<ll,ll> bc[100010];
    
    std::cin >> n>>m;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        std::cin >> bc[i].first>>bc[i].second;
    }
    sort(a,a+n);
    sort(bc,bc+m,compare_by_c);
    
    ll now = 0;
    ll result = 0;
    for (int i = 0; i < m; i++) {
        ll target = distance( a , lower_bound( a + now, a + n, bc[m-1-i].second ) )  -  1;
        if(target-now>=0){
            if((target-now+1) <= bc[m-i-1].first){
                result += (target-now+1)*bc[m-i-1].second;
                now = target +1;
            }else{
                result += bc[m-i-1].first*bc[m-i-1].second;
                now = now + bc[m-i-1].first;
            }
        }else{
            break;
        }
    }
    for (int i = now; i < n; i++) {
        result += a[i];
    }
    std::cout << result << std::endl;
    
    
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int N; cin >> N;
	long *a = new long[N];
	long *b = new long[N];
	
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}

	long offset = 0;
	long count = 0;
	for (int i = N - 1; i >= 0; i--) {
		a[i] += offset;
		long c = a[i] % b[i];
		c = (b[i] - c) % b[i];
		count += c;
		offset += c;
	}

	cout << count << endl;
	return 0;
}

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

int main ()
{
	long long int n, l, sum=0, lest=999979999997999;

	scanf("%lld %lld", &n, &l);

	for (int i=1;i<=n;i++)
	{
		sum=sum+l+i-1;
		
		if (abs(lest)>abs((l+i)-1))
			lest=l+i-1;
	}

	printf("%lld\n", sum-lest);

	return 0;
}



Measured memory_bytes: 128
use std::collections::BTreeMap;

type Vu = Vec<u8>;

fn count_pairs(s: Vu) -> BTreeMap<[Vu; 2], i64> {
    let mut ret = BTreeMap::new();
    let n = s.len();
    for flags in 0..1<<n {
        let mut ss = [vec![], vec![]];
        for i in 0..n {
            ss[flags >> i & 1].push(s[i]);
        }
        *ret.entry(ss).or_insert(0) += 1;
    }
    ret
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let s = sc.read::<String>().into_bytes();
    let map0 = count_pairs(s.clone().into_iter().take(n).collect());
    let map1 = count_pairs(s.clone().into_iter().rev().take(n).collect());
    let ans: i64 = map0.iter().map(|(k, v)| v * map1.get(k).unwrap_or(&0)).sum();
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

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

int main() {
  int N,count=1,num=0;
  cin >> N;
  vector<int> light(N);
  
    for (int i = 0; i < N; i++) {
    cin >> light.at(i);
    }
  int ON =0;
	for (int i = 0; i < N; i++) {
          ON =  light.at(ON);
  		  if (ON ==2){
            break;
   		 }if (ON !=2) {
    		 count ++;
    	 }
          ON = ON - 1;
 	  }
    if (ON ==2){
              cout << count << endl;}
    else {cout << "-1" << endl;  
         }
  }


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

vector<tuple<int, int, int>> E;
int dist[300][300], D[300][300];
bool used[300][300];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	long long ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
		cin >> dist[i][j];
		D[i][j] = dist[i][j];
		E.push_back(make_tuple(D[i][j], i, j));
	}
	for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (dist[i][j] != D[i][j]) {
		cout << "-1\n";
		return 0;
	}
	sort(E.begin(), E.end());
	for (auto e : E) {
		int w, u, v;
		tie(w, u, v) = e;
		for (int i = 0; i < N; i++) {
			if (used[u][i] && used[i][v] && D[u][i] + D[i][v] == D[u][v]) {
				w = 0;
				break;
			}
		}
		used[u][v] = true;
		ans += w;
	}
	cout << ans / 2 << '\n';
	return 0;
}

Measured memory_bytes: 2424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var sa = Input();
		int ki = 0;
		for(int i = 0; i < n; i++)
		{
			var a =sa[i].ToLong();
			if(a%2==1)
				ki++;
		}
		
		if(ki % 2 == 1)
		{
			Console.WriteLine("NO");
			return;
		}
		Console.WriteLine("YES");
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 20064
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> l(2*n);
	for(int i=0;i<2*n;++i)
		cin>>l[i];
	sort(begin(l),end(l));
	int ans=0;
	for(int i=0;i<2*n;i+=2)
		ans+=l[i];
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll MOD = 924844033;
ll add(ll x, ll y)
{
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y)
{
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y)
{
	return (x * y) % MOD;
}

const int N = 2020;
ll A[N];
ll nA[N];
int m;
ll B[N];
ll dp[N][N][4];
ll C[N][N];
ll f[N];

void solveDP(int n)
{
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++)
			for (int k = 0; k < 4; k++)
				dp[i][j][k] = 0;
	dp[0][0][1] = 1;
	for (int i = 0; i < n; i++)
		for (int g = 0; g <= i; g++)
			for (int mask = 0; mask < 4; mask++)
			{
				if (dp[i][g][mask] == 0) continue;
				dp[i + 1][g][mask >> 1] = add(dp[i + 1][g][mask >> 1], dp[i][g][mask]);
				if ((mask & 1) == 0)
					dp[i + 1][g + 1][mask >> 1] = add(dp[i + 1][g + 1][mask >> 1], dp[i][g][mask]);
				if (i != n - 1)
					dp[i + 1][g + 1][(mask >> 1) | 2] = add(dp[i + 1][g + 1][(mask >> 1) | 2], dp[i][g][mask]);
			}
	for (int i = 0; i <= n; i++)
	{
		B[i] = 0;
		for (int mask = 0; mask < 4; mask++)
			B[i] = add(B[i], dp[n][i][mask]);
	}
	return;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int n, k;
	scanf("%d%d", &n, &k);
	A[0] = 1;
	m = 0;
	int w = n / k;
	solveDP(w);
	for (int it = 0; it < k - (n % k); it++)
	{
		for (int i = 0; i <= m + w; i++)
			nA[i] = 0;
		for (int i = 0; i <= m; i++)
			for (int j = 0; j <= w; j++)
				nA[i + j] = add(nA[i + j], mult(A[i], B[j]));
		m += w;
		for (int i = 0; i <= m; i++)
			A[i] = nA[i];
	}
	w++;
	solveDP(w);
	for (int it = 0; it < (n % k); it++)
	{
		for (int i = 0; i <= m + w; i++)
			nA[i] = 0;
		for (int i = 0; i <= m; i++)
			for (int j = 0; j <= w; j++)
				nA[i + j] = add(nA[i + j], mult(A[i], B[j]));
		m += w;
		for (int i = 0; i <= m; i++)
			A[i] = nA[i];
	}
	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = mult(f[i - 1], i);
	ll ans = 0;
	for (int i = 0; i <= n; i++)
	{
		ll val = mult(A[i], f[n - i]);
		if (i % 2 == 0)
			ans = add(ans, val);
		else
			ans = sub(ans, val);
	}
	printf("%lld\n", ans);

	return 0;
}

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

using namespace std;

struct str{
    char a[101];
};

int main()
{
    int n,l; cin >> n >> l;
    cin.ignore();
    str s[100];
    for(int i=0; i<n;i++){
        cin.getline(s[i].a,l+1);
    }
    str rem;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(strcmp(s[i].a,s[j].a)>0){
                 rem=s[i];
                  s[i]=s[j];
                  s[j]=rem;

            }
            else if(strcmp(s[i].a,s[j].a)==0){
                if(strlen(s[i].a)>strlen(s[j].a)){
                   rem=s[i];
                  s[i]=s[j];
                  s[j]=rem;

                }
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<s[i].a;
    }
}


Measured memory_bytes: 256