akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll mod;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    ll p;
    cin >> p;
    mod = p;
    vector<ll> a(p);
    rep(i, p) cin >> a[i];
    vector<mint> ans(p);
    //debug(mod);
    combination comb(p-1);
    

    rep(i, p) {
        if (a[i]==0) continue;
        ans[0] += 1;
        vector<mint> power(p);
        power[0] = 1;
        rep(j, p) {
            if (j==0) continue;
            power[j] = power[j-1] * mint(i);
        }
        rep(j, p) {
            mint res = mint(1);
            if ((p-1-j)%2==1) res *= -1;
            res *= comb(p-1, j);
            res *= power[p-1-j];
            ans[j] -= res;
        }
    }

    rep(i, p) {
        cout << ans[i] << " ";
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 512
/*
 *  Author : Jun_SH
 *  Solution for ABC 145 A
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a;
    cin>>a;
    cout<<a*a<<endl;
}


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

int main() {
  int n,m,day=0;
  cin >> n >> m;
  vector<int>  a(m);
  for (int i=0; i<m; i++) {
    cin >> a[i];
    day+=a[i];
  }
  if (n<day) cout << -1 << endl;
  else cout << n-day<< endl;
}


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

int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n+1];
  long long dp[n+1];
  a[0] = dp[0] = 0;
  for ( long long i = 1; i <= n; i++ ) {
    cin >> a[i];
    dp[i] = dp[i-1] + a[i];
  }

  unordered_map<long long, long long> um;
  for ( long long i = 0; i <= n; i++ ) {
    um[dp[i]%m]++;
  }

  long long ans = 0;
  for ( auto p:um ) {
    long long num = p.second;
    ans += num*(num-1)/2;
  }

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


Measured memory_bytes: 5260
#include<bits/stdc++.h>
using namespace std;
int ans[2][105];
int main(){
    int n;
    cin >> n;
    int a[2][n];
    for(int i=0;i<2;i++)for(int j=0;j<n;j++)cin >> a[i][j];
    ans[0][0]=a[0][0];
    ans[1][0]=a[1][0]+a[0][0];
    if(n==1)cout << ans[1][0];
    else{
        for(int i=0;i<2;i++){
            for(int j=0;j<n-1;j++){
                if(i==0)ans[i][j+1]=ans[i][j]+a[i][j+1];
                else ans[i][j+1]=max(ans[i-1][j+1],ans[i][j])+a[i][j+1];
            }
        }
        cout << ans[1][n-1];
    }
}


Measured memory_bytes: 3628
#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 pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[101];
int col[8];
int main(){
    int n,ai;
    cin>>n;
    int rcnt=0;
    rep(i,n){
        cin>>ai;
        if(ai<=399) col[0]++;
        else if(ai<=799) col[1]++;
        else if(ai<=1199) col[2]++;
        else if(ai<=1599) col[3]++;
        else if(ai<=1999) col[4]++;
        else if(ai<=2399) col[5]++;
        else if(ai<=2799) col[6]++;
        else if(ai<=3199) col[7]++;
        else rcnt++;
    }
    int cnt=0;
    rep(i,8){
        if(col[i]>=1) ++cnt;
    }
    cout<<(cnt==0?1:cnt)<<" "<<cnt+rcnt<<endl;
    return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n){
        int a;
        cin >> a;
        v[a-1] = i + 1;
    }

    REP(i, n){
        cout << v[i] << " \n"[i == n-1];
    }
    return 0;
}


Measured memory_bytes: 1152
r1,c1,r2,c2 = map(int, input().split())
def find_power(n,mod=10**9+7):
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n,mod=10**9+7):
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

mod = 10**9+7
NUM = (2*10**6)+100
p_lis=find_power(NUM,mod)
ip_lis=find_inv_power(NUM,mod)

def comb(n,r,mod=10**9+7):
    if n<r:
        return 0
    elif n>=r:
        return (p_lis[n]*ip_lis[r]*ip_lis[n-r])%(mod)
def g(x,y):
    return comb(x+y+2,y+1)-1

ans=g(r2,c2) - g(r1-1,c2) - g(r2,c1-1) + g(r1-1,c1-1)
print(ans%mod)

Measured memory_bytes: 245204
<?php

while (true) {
    fscanf(STDIN, "%d %s %d", $a, $op, $b);
    if ('?' === $op) break;

    $r = 0;
    switch ($op) {
    case '+':
        $r = $a + $b;
        break;
    case '-':
        $r = $a - $b;
        break;
    case '*':
        $r = $a * $b;
        break;
    case '/':
        $r = floor($a / $b);
        break;
    }

    echo "$r\n";
}

Measured memory_bytes: 6568
import sys

l, r = map(int, input().split())

if 2019 <= r - l:
    print(0)
    sys.exit()

ans = 2019
for i in range(l, r):
    for j in range(i + 1, r + 1):
        i %= 2019
        j %= 2019
        ans = min(ans, (i * j) % 2019)

print(ans)

Measured memory_bytes: 3060
import sys

def parse(inp):
    n=int(next(inp))
    s=list(next(inp))[:-1]
    k=int(next(inp))    
    return n,s,k
  
def main(inp):
    n,s,k=inp
    
    keep=s[k-1]
    
    ans=""
    for i in range(n):
        if(s[i]==keep): ans+=s[i]
        else: ans+="*"
            
    print(ans)
    
main(parse(sys.stdin))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a[3][3];
	bool mark[3][3];
	memset(mark,0,sizeof(mark));
	int n;
	int b[10];
	rep(i,3) rep(j,3) cin>>a[i][j];
	cin>>n;
	rep(i,n) cin>>b[i];
	rep(i,n) rep(j,3) rep(k,3)
	{
		if (b[i]==a[j][k])
		{
			mark[j][k]=1;
			break;
			break;
		}
	}
	rep(i,3)
	{
		if (mark[i][0]==1&&mark[i][1]==1&&mark[i][2]==1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	rep(i,3)
	{
		if (mark[0][i]==1&&mark[1][i]==1&&mark[2][i]==1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	if (mark[0][0]==1&&mark[1][1]==1&&mark[2][2]==1)
	{
		cout<<"Yes";
		return 0;
	}
	if (mark[0][2]==1&&mark[1][1]==1&&mark[2][0]==1)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int n, R[200000], max, key, i, l, key2;
   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
      scanf("%d", &R[i]);
   }
   max = R[1] - R[0]; /*printf("\n%d\n", max);*/
   for ( l = 1; l < n; l++ ) {
      key = R[l] - R[0];
      if ( max < key ) { max = key; /*printf("%d\n", key);*/ }
   }
   key2 = 0;
   for ( i = 1; i < n; i++ ) {
      if ( R[i] < R[key2] ) {
         for ( l = 1; l < n - i; l++ ) {
            key = R[i + l] - R[i];
            if ( max < key ) { max = key; /*printf("%d\n", key);*/ }
            key2 = i;
         }
      }
   }
   printf("%d\n", max);
   return 0;
}

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

namespace AtCoder
{
    class AtCoderrrrrr
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];
            int C = s[2];
            if (A == B && B ==C)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int g[10][10];

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

    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a][b]=1;
        g[b][a]=1;
    }

    vector<int> ord(n);
    rep(i,n) ord[i]=i;
    int ans=0;

    do{
        if(ord[0]!=0) continue;
        bool ok=true;
        rep(i,n-1){
            if(g[ord[i+1]][ord[i]]==0){
                ok=false;
                break;
            }
        }
        if(ok) ans++;

    }while(next_permutation(all(ord)));

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
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;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    while(true){
        ll H,W;cin>>H>>W;
        if(H+W==0)break;
        rep(i,H){
            rep(j,W)cout<<"#";
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,a[22],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<n-1;i++)
	{
		int b[3];
		b[0]=a[i];
		b[1]=a[i-1];
		b[2]=a[i+1];
		sort(b,b+3);
		if(b[1]==a[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int h = 0;
    int w = 0;
    int isfinish = 0;

    while (isfinish != 1) {
        scanf("%d %d", &h, &w);

        if (h == 0 && w == 0) {
            break;
        } else {
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
                        printf("#");
                    } else {
                        printf(".");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2084
import itertools
H,W,K=map(int,input().split())
c = [list(input()) for _ in range(H)]
#print(c)
h=list(itertools.product(range(2), repeat = H))
w=list(itertools.product(range(2), repeat = W))
a= [[0 for i in range(len(w))] for j in range(len(h))] ##掛け算で書いてはいけない
ans= [[0 for i in range(len(w))] for j in range(len(h))]
#print(w)
#print(a)

for i in range(len(h)):
    for j in range(len(w)):
        cnt=0
        for ii in range(H):
            for jj in range(W):
                #print(i,j,ii,jj)
                if h[i][ii] == 1 and w[j][jj] == 1:
                    if c[ii][jj] == '#':
                        cnt+=1
        a[i][j] = cnt
        if cnt == K:
            ans[0][0] += 1

sum=0
for i in range(len(h)):
    for j in range(len(w)):
        sum+=ans[i][j]
print(sum)

Measured memory_bytes: 9084
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);

       int n=scan.nextInt();

        int ans=1;
        while(true){
            ans*=2;
            if(ans>n){
                break;
            }


        }
        System.out.println(ans/2);

    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	string s; cin >> s;
	set<char> st;
	for(auto u : s) {
		st.insert(u);
	}
	if(st.size() == 26) {
		printf("None\n");
	}else{
		for(auto u : "abcdefghijklmnopqrstuvwxyz") {
			if(st.count(u) == 0) {
				cout << u << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 512
#
K = int(input())
A = list(map(int, input().split()))

#
if A[-1]!=2:
    print(-1)
    exit()
if K>1 and A[-2]!=2 and A[-2]!=3:
    print(-1)
    exit()

#
min_n = 2
max_n = 3
for i in A[::-1][1:]:
    a = (min_n - 1)//i
    b = max_n//i
    if a==b:
        print(-1)
        exit()

    if min_n%i==0:
        pass
    else:
        min_n = min_n + (i - min_n%i)
    max_n = max_n - max_n%i + i - 1
    #print(min_n, max_n)

#
print(min_n, max_n)


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

int main() {
    string str;
    cin >> str;
    int count = str.length();
    int omitCount = count - 2;
    string omitString = str[0] + to_string(omitCount) + str[count - 1];
    cout << omitString << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Card{
    public String suit;
    public int value;
    public int index;
}

public class Main{
    public static void main(String[] args){
	int i, q;
	
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
    	Card[] A = new Card[n];

	for(i=0; i<n; i++){
	    A[i] = new Card();
	}

	for(i=0; i<n; i++){
	    A[i].suit = s.next();
	    A[i].value = s.nextInt();
	    A[i].index = i; 
	}

	quickSort(A, 0, n-1);

	if(isStable(A) == true){
	    System.out.print("Stable\n");
	}else{
	    System.out.print("Not stable\n");
	}
	for(i=0; i<n; i++){
	    System.out.printf("%s %d\n", A[i].suit, A[i].value);
	    
	}
    }

    public static void quickSort(Card[] A, int p, int r){
	int q;
	if(p < r){
	    q = partition(A, p, r);
	    quickSort(A, p, q - 1);
	    quickSort(A, q + 1, r); 
	}
    }
    
    public static int partition(Card[] A, int p, int r){
	int x, i, j;
	Card tmp;
	x = A[r].value;
	i = p-1;
	for(j=p; j<r; j++){
	    if(A[j].value<=x){
		i++;
		tmp = A[i]; A[i] = A[j]; A[j] = tmp;
	    }
	}
	tmp = A[i+1]; A[i+1] = A[r]; A[r] = tmp;
	return i+1;
    }
    
    static boolean isStable(Card[] A){
	for(int i = 0; i < A.length; i++){
	    for(int j = i + 1; j < A.length; j++){
		if(A[i].value == A[j].value && A[i].index > A[j].index)
		    return false;
	    }
	}
    return true;
    }	    
}

Measured memory_bytes: 130964
Flag = True
data = []
while Flag:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        Flag = False
    else:
      data.append((H, W))

for (H, W) in data:
    for i in range(H):
        if W % 2 == 0:
            if i % 2 == 0:
                print('#.' * int(W/2))
            else:
                print('.#' * int(W/2))
        else:
            if i % 2 == 0:
                s = '#.' * int((W+1)/2)
                print(s[:-1])
            else:
                s = '.#' * int((W+1)/2)
                print(s[:-1])
    print('\n', end="")


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int div2 (int a) {
	int cnt = 0;
	while (a % 2 == 0)
	{
		cnt++;
		a /= 2;
	}
	return cnt;
}
 
int main() {
	int n;
	cin >> n;
	ll pi = 1;
	int cnt = 0;
	rep(i, n) {
		int a; cin >> a;
		cnt += div2(a);
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program{
	static int ca1(long[] a,long[] b){
		if((b[0]+b[1]+b[2])>(a[0]+a[1]+a[2])){return 1;}
		else if((b[0]+b[1]+b[2])<(a[0]+a[1]+a[2])){return -1;}
		else{return 0;}
	}
	static int ca2(long[] a,long[] b){
		if((-b[0]+b[1]+b[2])>(-a[0]+a[1]+a[2])){return 1;}
		else if((-b[0]+b[1]+b[2])<(-a[0]+a[1]+a[2])){return -1;}
		else{return 0;}
	}
	static int ca3(long[] a,long[] b){
		if((b[0]-b[1]+b[2])>(a[0]-a[1]+a[2])){return 1;}
		else if((b[0]-b[1]+b[2])<(a[0]-a[1]+a[2])){return -1;}
		else{return 0;}
	}
	static int ca4(long[] a,long[] b){
		if((b[0]+b[1]-b[2])>(a[0]+a[1]-a[2])){return 1;}
		else if((b[0]+b[1]-b[2])<(a[0]+a[1]-a[2])){return -1;}
		else{return 0;}
	}
	static void Main(string[] args){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[][] arr=new long[s[0]][];
		long ans=0;
		long c=0;
		
		for(int i=0;i<s[0];i++){
			long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			arr[i] = new long[3];
			for (int j=0;j<3;j++){arr[i][j]=q[j];}
		}

		Array.Sort(arr,ca1);
		for(int i=0;i<s[1];i++){c+=arr[i][0]+arr[i][1]+arr[i][2];}if(ans<c){ans=c;}c=0;
		for(int i=s[0]-1;i>=s[0]-s[1];i--){c+=arr[i][0]+arr[i][1]+arr[i][2];}c=System.Math.Abs(c);if(ans<c){ans=c;}c=0;
		
		Array.Sort(arr,ca2);
		for(int i=0;i<s[1];i++){c+=-arr[i][0]+arr[i][1]+arr[i][2];}if(ans<c){ans=c;}c=0;
		for(int i=s[0]-1;i>=s[0]-s[1];i--){c+=-arr[i][0]+arr[i][1]+arr[i][2];}c=System.Math.Abs(c);if(ans<c){ans=c;}c=0;

		Array.Sort(arr,ca3);
		for(int i=0;i<s[1];i++){c+=arr[i][0]-arr[i][1]+arr[i][2];}if(ans<c){ans=c;}c=0;
		for(int i=s[0]-1;i>=s[0]-s[1];i--){c+=arr[i][0]-arr[i][1]+arr[i][2];}c=System.Math.Abs(c);if(ans<c){ans=c;}c=0;

		Array.Sort(arr,ca4);
		for(int i=0;i<s[1];i++){c+=arr[i][0]+arr[i][1]-arr[i][2];}if(ans<c){ans=c;}c=0;
		for(int i=s[0]-1;i>=s[0]-s[1];i--){c+=arr[i][0]+arr[i][1]-arr[i][2];}c=System.Math.Abs(c);if(ans<c){ans=c;}c=0;
		
		Console.WriteLine(ans);
		
	}
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll n; cin >> n;
  ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
  ll m = min({a,b,c,d,e});
  COUT(n%m ? n/m+1+4 : n/m+4);
  return 0;
}

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    int a, b, c; cin >> a >> b >> c; cout << (a + b + c > 21 ? "bust" : "win" );
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]
c = 0
c2 = 0
for n in a:
    if n % 4 == 0:
        c += 1
    elif n % 4 == 2:
        c2 += 1
ans = 'No'
if c >= N//2:
    ans = 'Yes'
if N-c*2 <= c2:
    ans = 'Yes'
print(ans)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, n;
  cin >> h >> w >> n;
  auto chk = [&](auto s) {
    while (true) {
      for (int j = 0; j < w; ++j) {
        vector<char> v;
        for (int i = h; i--; ) {
          if (s[i][j] != '.') {
            v.push_back(s[i][j]);
            s[i][j] = '.';
          }
        }
        for (int i = 0; i < (int)v.size(); ++i) {
          s[h - i - 1][j] = v[i];
        }
      }
      vector<vector<bool>> b(h, vector<bool>(w));
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          if (s[i][j] != '.') {
            int li = i, ri = i;
            while (li and s[li - 1][j] == s[i][j]) {
              --li;
            }
            while (ri + 1 < h and s[ri + 1][j] == s[i][j]) {
              ++ri;
            }
            if (ri - li + 1 >= n) {
              b[i][j] = true;
            }
            int lj = j, rj = j;
            while (lj and s[i][lj - 1] == s[i][j]) {
              --lj;
            }
            while (rj + 1 < w and s[i][rj + 1] == s[i][j]) {
              ++rj;
            }
            if (rj - lj + 1 >= n) {
              b[i][j] = true;
            }
          }
        }
      }
      bool any = false;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          if (b[i][j]) {
            s[i][j] = '.';
            any = true;
          }
        }
      }
      if (not any) {
        break;
      }
    }
    for (auto e : s) {
      if (count(begin(e), end(e), '.') < w) {
        return false;
      }
    }
    return true;
  };
  vector<string> s(h);
  for (auto&& e : s) {
    cin >> e;
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w - 1; ++j) {
      swap(s[i][j], s[i][j + 1]);
      if (chk(s)) {
        cout << "YES\n";
        exit(0);
      }
      swap(s[i][j], s[i][j + 1]);
    }
  }
  cout << "NO\n";
}



Measured memory_bytes: 3240
#include<stdio.h>
int main(void) {
    int n;
    scanf("%d",&n);
    int i = 0,j;
    for(j = 1; j <= n && j < 10; j++) {
        i ++;
    }
    for(j = 100; j <= n && j < 1000; j++) {
        i++;
    }
    for(j = 10000; j <= n && j < 100000; j++) {
        i++;
    }
    printf("%d\n",i);
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int now = 1;
	int cnt = 0;
	rep(i, n) {
		if (a[i] == now) now++;
		else cnt++;
	}
	if (now == 1) cout << -1 << endl;
	else cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

set<int> st[3];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int s, c;
        cin >> s >> c;
        s--;
        st[s].insert(c);
    }
    rep(i, N) {
        if(st[i].size() > 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    string A = "";
    rep(i, N) {
        int num = 0;
        if(st[i].size() == 1) {
            num = *st[i].begin();
            if(i == 0 && N != 1 && num == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
        if(i == 0 && N != 1 && num == 0) num = 1;
        //cout << num;
        A += to_string(num);
    }
    cout << A << endl;

    return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>
int main(void){
    int H,W,i,j,l;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
            for(i=0;i<H;i++){
                    if(i==0||i==H-1){
                        for(l=0;l<W;l++)
                        printf("#");
                        printf("\n");
                    }else{
                        for(j=0;j<W;j++){
                            if(j==0||j==W-1)
                                printf("#");
                            else
                                printf(".");
                        }
                        printf("\n");
                    }
            }

        printf("\n");
    }



    return 0;
}

Measured memory_bytes: 572
//----------------------Shanu Garg here---------------------
//-------------Search on youtube : Shanu Garg---------------
//-Studying at National Institute of Technology Delhi(NITD)-
//---------------------From Delhi, India--------------------

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

#define f(i,n) for(auto i=0;i<n;i++)
#define fr(i,n) for(auto i=n-1;i>=0;i--)
#define fs(i,a,b,c) for(auto i=a;i!=b;i+=c)
#define fl(i,x) for(auto i : x)
#define nl cout<<"\n";
#define chk(x) cout<<#x<<" : "<<x, nl
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pr pair<ll, ll>
#define vii vector<pair<int, int>>
#define vll vector<pr>
#define vl vector<ll>
#define m(a,b) map<a, b>
#define ci m(char, ll)
#define ii m(ll, ll)
#define mid(a,b) ((a+b)/2)
#define pb push_back
#define LCM(a,b) ((a*b)/__gcd(a, b))
const int INF = 0x3f3f3f3f, mod = 1e9 + 7;

class triplet{ll f, s, t;};

vl in(ll n){vl v;ll x;
    f(i,n)
    cin>>x, v.pb(x%mod);
    return v;}
void out(vl v){fl(i,v)cout<<i;}
void out(vl v, char ch){
    fl(i,v)
    cout<<i<<ch;}

void solve(){
    ll N, prev=0;
    cin>>N;
    vl v = in(N);
    fl(i, v)
    if(i == prev+1)
    prev = i;

    if(prev==0)
    cout<<"-1";
    else
    {
        cout<<N-prev;
    }
    
}

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

Measured memory_bytes: 5268
def gcd_(x,y):
    k = x % y
    if k == 0:
        return y
    else:
        return gcd_(y,k)

def gcd(x,y):
    if x < y:
        _ = x
        x = y
        y = _
    return gcd_(x,y)

N = int(input())
AList = list(map(int,input().split()))
Lgcd = [0] * N 
Rgcd = [0] * N

for i in range(N):
    if i == 0:
        Lgcd[i] = AList[i]
    else:
        Lgcd[i] = gcd(Lgcd[i-1],AList[i])
        
for i in range(N):
    j = N-1-i
    if i == 0:
        Rgcd[j] = AList[j]
    else:
        Rgcd[j] = gcd(Rgcd[j+1],AList[j])

max1 = 0
for i in range(N):
    if i == 0:
        gcd1 = Rgcd[1]
    elif i == N-1:
        gcd1 = Lgcd[N-2]
    else:
        gcd1 = gcd(Lgcd[i-1], Rgcd[i+1])
    if max1 < gcd1:
        max1 = gcd1

print(max1)


Measured memory_bytes: 14436
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b){
        for(int i=0;i<a;i++){
            printf("%d",b);
        }
    }
    else{
        for(int i=0;i<b;i++){
            printf("%d",a);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    a[0]=toupper(a[0]);
    b[0]=toupper(b[0]);
    c[0]=toupper(c[0]);
    cout << a[0]<<b[0]<<c[0]<< endl;
 }

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template <class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template <class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;


ll solve(int N, ll K, vll& a) {
    vvi cnt(40, vi(2, 0));
    rep(i,N){
        ll ai = a[i];
        for (ll i=0,b=1; i<40; ++i,b<<=1){
            if (ai&b) cnt[39-i][1]++;
            else cnt[39-i][0]++;
        }
    }
    vi ku(40,0);
    for (ll i=0,b=1; i<40; ++i,b<<=1){
        if(K&b) ku[39-i]=1;
    }

    vector<vll> dp(41, vll(2, -1));
    dp[0][0] = 0;

    rep(i,40){
        rep(j,2){
            if (dp[i][j] == -1) continue;

            int x = j ? 1 : ku[i];
            for (int d=0; d<=x; ++d) {
                amax(dp[i+1][j || d<x], dp[i][j]*2 + cnt[i][1-d]);
            }
        }
    }
    return max(dp[40][0], dp[40][1]);
}

int main() {
    int N; ll K; scanf("%d%lld",&N,&K);
    vll a(N); rep(i,N) scanf("%lld", &a[i]);
    cout << solve(N,K,a) << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
 *  Created on: 29 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define ld   long double

#define all(c)   c.begin(), c.end()
#define rall(c)  c.rbegin(), c.rend()
#define stp(n)   cout << fixed << setprecision(n);
#define iq(v)    v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)    s.size()
#define endl     '\n'

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	string a, b; cin >> a >> b;
	ll ans = LLONG_MAX;
	for (int i = 0; i <= sz(a) - sz(b); i++)
	{
		ll x = 0;
		for (int u = 0; u < sz(b); u++)
		{
			if (a[i + u] != b[u])x++;
		}
		ans = min(x, ans);
	}
	cout << ans;
}

Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

manzoku=0;

for i in range(len(a)):
	manzoku+=b[a[i]-1]
	if i+1<n and a[i+1]-a[i]==1:
		manzoku+=c[a[i]-1]
print(manzoku)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    cin >> a >> b >> n;

    ll x = n;
    if(x >= b){
        cout << (a*(b-1))/b << endl;
    }else{
        cout << (a*x)/b << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <queue>

using namespace std;

#define MAX 110
int num;
int matrix[MAX][MAX];
int dst[MAX];

void input(){
    for(int i=0;i<MAX;i++){
        dst[i] = -1;
        for(int j=0;j<MAX;j++){
            matrix[i][j] = 0;
        }
    }
    for(int i=1;i<=num;i++){
        int v; cin >> v;
        int tmp; cin >>tmp;
        for(int j=0;j<tmp;j++){
            int vi; cin >> vi;
            matrix[v-1][vi-1] = 1;
        }
    }
}

void bfs(){
    queue<int> Q;
    Q.push(0);
    dst[0] = 0;
    while(Q.size() != 0){
        int cur = Q.front();
        for(int i=0;i<num;i++){
            if(matrix[cur][i]==1){
                if(dst[i]==-1){
                    Q.push(i);
                    dst[i] = dst[cur] + 1;
                }
            }
        }
        Q.pop();
    }
    for(int i=0;i<num;i++){
        cout << i+1 << " " <<  dst[i] << endl;
    }
}

int main(){
    cin >> num;
    input();
    bfs();
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    ll A = 0LL;
    ll a[N];
    REP(i,N){
        cin>>a[i];
        A = (A^a[i]);
    }
    REP(i,N){
        ll k = A^a[i];
        cout << (i?" ":"") << k;
    }
    cout << "\n";
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=2305843009213693951;//巨大な定数
const int dx[]={0,1,0,-1};//x方向のベクトル
const int dy[]={1,0,-1,0};//y方向のベクトル

int main(){
    //入力
    ll h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    vector<vector<char>> S(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>S[i][j];
        }
    }

    //1-indexedなので0-indexedに直す
    ch--;
    cw--;
    dh--;
    dw--;

    //BFS用のqueue
    //HとWには移動1で行けるH座標とW座標
    //H2とW2には移動2で行けるH座標とW座標
    queue<ll> H,H2,W,W2;

    //初期地点をH,Wに追加
    H.push(ch);
    W.push(cw);

    //最低何回の魔法でたどり着けるかを記録する
    //巨大な数INFで初期化する
    vector<vector<ll>> T(h,vector<ll>(w,INF));

    //初期地点は0回の魔法でたどり着く
    T[ch][cw]=0;

    //BFSをする
    while(!H.empty()){
        while(!H.empty()){
            //現在の座標
            ll nh=H.front();
            ll nw=W.front();

            //queueから削除
            H.pop();
            W.pop();

            //移動A
            for(int i=0;i<4;i++){
                //移動先の座標
                ll th=nh+dx[i];
                ll tw=nw+dy[i];

                //範囲外になってないかチェック
                if(th>=h||th<0||tw>=w||tw<0){
                    continue;
                }

                //壁かチェック
                if(S[th][tw]=='#'){
                    continue;
                }

                //魔法の回数が多い場合更新
                if(T[th][tw]>T[nh][nw]){
                    T[th][tw]=T[nh][nw];
                    H.push(th);
                    W.push(tw);
                }
            }

            //移動B
            for(int i=-2;i<=2;i++){
                for(int j=-2;j<=2;j++){
                    //移動先の座標
                    ll th=nh+i;
                    ll tw=nw+j;

                    //範囲外になってないかチェック
                    if(th>=h||th<0||tw>=w||tw<0){
                        continue;
                    }

                    //移動先が壁かチェック
                    if(S[th][tw]=='#'){
                        continue;
                    }

                    //INFなら更新
                    if(T[th][tw]==INF){
                        T[th][tw]=T[nh][nw]+1;
                        H2.push(th);
                        W2.push(tw);
                    }
                }
            }
        }
        //移動1が終わったので、移動1から1回の魔法で行ける移動2を調べる
        swap(H,H2);
        swap(W,W2);
    }

    //ゴールに到達出来ない場合
    if(T[dh][dw]==INF){
        cout<<-1<<endl;
    }

    //到達できる場合
    else{
        cout<<T[dh][dw]<<endl;
    }
}

Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
typedef long  long LL;
LL a,b,c;
int main()
{
    cin >> a >> b >> c;
    if(a + b > c){
        cout << "No";
        return 0;
    }
    if(4 * a * b < (c - a - b) * (c - a - b)){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int a;cin>>a;
  string s;cin>>s;
  if (a>=3200){
    cout << s << endl;
  }
  else{
    cout << "red" << endl;
  }
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int n = Integer.parseInt(br.readLine());
			int k = Integer.parseInt(br.readLine());
			int x = Integer.parseInt(br.readLine());
			int y = Integer.parseInt(br.readLine());

			System.out.println(n-k>0?x*k+y*(n-k):x*n);

		}
	}
}


Measured memory_bytes: 25368
n=input()
n=int(n)
for i in range(n):
    a,b,c=map(int,input().split())
    if a**2+b**2==c**2 or a**2+c**2==b**2 or b**2+c**2==a**2:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N = 105;
const int MOD = 1000000007;

int n,m,h[N],w[N];
LL dp[N][N];

int pow_(int x,int y) {///快速幂求 x的y次方
    int ans = 1;
    if(y > 0) {
        while(y) {
            if(y % 2)ans = (LL)ans * x % MOD;
            x = (LL)x * x % MOD;
            y /= 2;
        }
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&h[i]);
        w[++ m] = h[i];
    }
    sort(w + 1,w + m + 1);///高度排序
    m = unique(w + 1,w + m + 1) - w - 1;///离散化 m是离散化后的长度
    for(int i = 1;i <= n;i ++) {
        h[i] = lower_bound(w + 1,w + m + 1,h[i]) - w;
    }
    dp[0][0]=1;
    for(int i = 1;i <= n;i ++) {
        for(int j = h[i] + 1;j <= h[i - 1];j ++)
            (dp[i][0] += dp[i - 1][j] * 2 % MOD) %= MOD;
            
        (dp[i][0] += dp[i - 1][0] * 2 % MOD) %= MOD;///交叉或者不交叉
        
        int d = pow_(2,w[h[i]] - w[h[i-1]]);
        for(int j = 1;j <= h[i];j ++) {
            dp[i][j] = dp[i - 1][j] * d % MOD;
        }
        
        for(int j = h[i - 1] + 1;j <= h[i];j ++) {///比前一列高出的部分
            if(j > 1)(dp[i][j] += dp[i - 1][0] * (pow_(2,w[j] - w[j - 1]) - 1) % MOD * 2 % MOD * pow_(2,w[h[i]] - w[j]) % MOD) %= MOD;
            else (dp[i][1] += dp[i - 1][0] * (pow_(2,w[1]) - 2) % MOD * pow_(2,w[h[i]] - w[1]) % MOD) %= MOD;///上一列中无重复的乘上化不超过上一列高度中有重复的
        }
    }
    LL ans = 0;
    for(int i = 0;i <= m;i++)
        (ans += dp[n][i]) %= MOD;
    printf("%lld",ans);
    return 0;
}


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

int main(){
  //整数の時はint
  int a,b,m;
  double c;
  //文字の時はstring
  //string a;
  const double PI=3.14159265358979323846;
  cin>>c;
  cout<<c*PI*2.0<<endl;

 
  return 0;
}



Measured memory_bytes: 3748