akhauriyash/Code-Regression huggingface dataset:
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=1e5+15;
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

vector<int>adj[N];
int d[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int h[N];

int main()
{
    Nitroboost;
    int n;
    cin>>n;
    for(int i=1;i*i<=n;i++)
        for(int j=1;j*j<=n;j++)
            for(int k=1;k*k<=n;k++)
            {
                h[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
            
    for(int i=1;i<=n;i++)
        cout<<h[i]<<"\n";
}

Measured memory_bytes: 6080
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int j1=1,o2=1,i3=1;
    int cur=-1,ans=0;
    char p[]="JOI";
    for(int i=0;i<=s.size();++i){
        if(p[cur]==s[i]){
            if(cur==0) ++j1;
            else if(cur==1) ++o2;
            else ++i3;continue;
        }
        else if(cur+1==3){
            j1=min(j1,i3);
            if(o2<=j1) ans=max(ans,o2);
            cur=-1;
        }
        if(p[cur+1]==s[i]){
            ++cur;
            if(cur==0) j1=o2=i3=1;
        }
        else{
            cur=-1;j1=o2=i3=1;
            if(p[cur+1]==s[i]) ++cur;}
    }
    cout<<ans<<endl;
    return 0;
}

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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

set<string>a;
int main() {
	int n = read(); int x = read();
	int ans = abs(read() - x);	
	for (int i = 2; i <= n; ++i) {
		ans = __gcd(ans, abs(read() - x));
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int X, A, B;
    cin >> X >> A >> B;
    int ans = (X - A) % B;
    cout << ans << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  long long int S=0LL;
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
    if(i%3!=0 && i%5!=0)
      S+=(long long int)i;
  printf("%lld\n",S);
  return 0;
}

Measured memory_bytes: 1672
<?php
    $math_ary = array();
    $tmp;
    while($line = trim(fgets(STDIN))){
        $math_ary[] = $line;
    }
    for($i = 0;$i < count($math_ary)-1;$i++){
        for($j = $i;$j < count($math_ary);$j++){
            if($math_ary[$i] < $math_ary[$j]){
                $tmp = $math_ary[$i];
                $math_ary[$i] = $math_ary[$j];
                $math_ary[$j] = $tmp;
            }
        }
    }
    for($i = 0;$i < 3;$i++){
        echo $math_ary[$i]."\n";
    }


Measured memory_bytes: 9252
#include<stdio.h>
#define M 2000000

int H;

void MH(int *A,int i){
  int work;
  int l,r,b;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) b = l;
  else b = i;
  if(r <= H && A[r] > A[b]) b = r;

  if(b != i){
    work = A[i];
    A[i] = A[b];
    A[b] = work;    
    MH(A,b);
  }
}

int main(){
  int A[M+1],i;
  scanf("%d",&H);

  for(i = 1; i <= H; i++) scanf("%d",&A[i]);
  for(i = H/2;i >= 1; i--) MH(A,i);
  for(i = 1; i <= H; i++) printf(" %d",A[i]);
  printf("\n");

  return 0;
}
  
  



Measured memory_bytes: 3688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        arr[0] = Integer.MAX_VALUE;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (arr[max] >= x) {
                max++;
                arr[max] = x;
               continue;
            }
            int left = 0;
            int right = max;
            while (right - left > 1) {
                int m = (left + right) / 2;
                if (arr[m] < x) {
                    right = m;
                } else {
                    left = m;
                }
            }
            arr[right] = x;
        }
        System.out.println(max);
        
    }
}

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

int main(void){
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        if(i % 2 == 0){
            if(S[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
ans=0
for i in range(1,n+1):
    x=n//i
    ans+=(i+x*i)*x//2
print(ans)

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

std::vector<int> split (int x) {
  if (x == 0) return {0};
  std::vector<int> ans;
  while (x) ans.push_back (x%10), x/=10;
  std::reverse (ans.begin(), ans.end());
  return ans;
}

int main () {
  int n, m; std::cin >> n >> m;
  std::vector <std::pair<int,int>> condition (m);
  for (int i = 0; i < m; ++i)
    std::cin >> condition[i].first >> condition[i].second;
  for (int ans = 0; ans <= 999; ++ans) {
    auto res = split (ans);
    if (res.size() != n) continue;
    bool flag = true;
    for (int i = 0; i < m; ++i)
      if (res[condition[i].first-1] != condition[i].second)
        flag = false;
    if (!flag) continue;
    std::cout << ans << "\n";
    return 0;
  }
  std::cout << -1 << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll a(N);
    for(ll i=0;i<N;i++)cin>>a[i];
    ll ans=0;
    vll count(100001,0);
    for(ll i=0;i<N;i++){
        if(a[i]<100001)count[a[i]]++;
        else ans++;
    }
    
    for(ll i=1;i<100001;i++){
        if(count[i]>=i) ans+=count[i]-i;
        else ans+=count[i];
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;

const int N = 1e5 + 7 ; 
int n; 

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        map<string , int > mp ; 

        cin >> n ; 
        for(int i = 0 ;i < n;i++){
                string s ; 
                cin >> s; 
                mp[s] ++ ; 
        }

        cout<< "AC x " << mp["AC"] <<"\n" ; 
        cout<< "WA x " << mp["WA"] <<"\n" ; 
        cout<<"TLE x " << mp["TLE"] <<"\n" ; 
        cout<<"RE x " << mp["RE"] <<"\n"; 

        return 0;
}

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

int main()
{
  long long x, k, d;
  cin >> x >> k >> d;
  long long candidate1 = x % d;
  long long candidate2;
  if (candidate1 < 0) {
    candidate2 = candidate1 + d;
  } else {
    candidate2 = candidate1 - d;
  }
  long long rest = k - abs(x - candidate1) / d;
  if (rest <= 0) {
    cout << abs(x) - d * k << '\n';
  } else if (rest % 2 == 0) {
    cout << abs(candidate1) << '\n';
  } else {
    cout << abs(candidate2) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);

  if (A >= 13)
  {
    printf("%d\n", B);
  }
  else if (A >= 6)
  {
    printf("%d\n", B / 2);
  }
  else
  {
    printf("%d\n", 0);
  }

  return 0;
}

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


int main() {
	// your code goes here
	long long n,w,i,j,x,y;
	cin>>n>>w;
	vector<pair<long long,long long>> vec;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		vec.push_back({x,y});
	}
	long long currVal=0,currWt=0;
	long long dp[n+1][w+1];
	for(i=0;i<=n;i++)
		dp[i][0]=0;
	for(j=0;j<=w;j++)
		dp[0][j]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(vec[i-1].first<=j)
			{
				dp[i][j]=max(vec[i-1].second+dp[i-1][j-vec[i-1].first],dp[i-1][j]);
			}
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	
	cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"YES"<<endl;}else cout<<"NO"<<endl;//条件によってYes、Noを出力する
bool isK(string t){
    int n = t.length();
    for(int i=0;i<n;i++){
        if(t[i]!=t[n-1-i]){
            return false;
        }
    }
    return true;
}

int main(){
    string s;
    cin>>s;
    int n= s.length();
    string t = "";
    vector<int> lo;
    rep(i,n){
        if(s[i]!='x'){
            t += s[i];
            lo.push_back(i);
        }
    }
    if(t==""){
        cout<<0<<endl;
        return 0;
    }
    if(!isK(t)){
        cout<<-1<<endl;
        return 0;
    }
    int tn = t.length();
    //cout<<tn<<endl;
    //cout<<lo[tn/2]<<endl;//tnが奇数の時、真ん中の文字がsで出てくる場所
    //tnが偶数の時はlo[tn/2]とlo[tn/2-1]
    int ans=0;
        int l = lo[tn/2];
        if(tn%2==0){
            l = lo[tn/2-1];
        }
        int r = lo[tn/2];
        while(l>=0 || r<=n-1){
            if(l<0){
                r++;
                ans++;
            }
            else if(r>=n){
                l--;
                ans++;
            }
            else if(s[l]!=s[r]){
                if(s[l]=='x'){
                    l--;
                }
                if(s[r]=='x'){
                    r++;
                }
                ans++;
            }
            else if(s[l]==s[r]){
                r++;
                l--;
            }
        }
        cout<<ans<<endl;

}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  int cnt = 0; int ans;
  for(int i=a;i>0;i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      //cout << cnt << "," << i << endl;
    }
    if(k==cnt){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

const ll SIZE = 1e5+10;

ll x,y,z;

int main(){
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n, k;
  int ans=1;
  cin >> n >> k;
  for(int i=0; i<n; i++){
    if(i==0)ans*=k;
    else{ans*=k-1;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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 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 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, W;
vector<int> w, v;
ll dp[105][100005];

inline void solve(){

    cin >> n >> W;
    w.resize(n);
    v.resize(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    

    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= W; j++) {
            dp[i+1][j] = dp[i][j];
            if(j-w[i]>=0)
                chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }

    cout << dp[n][W] << endl;
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int MAX=510000;
const int MOD=998244353;
long long fac[MAX],inv[MAX],finv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=inv[i]*finv[i-1]%MOD;
    }
}
long long COM(int n,int r){
    if(n<r) return 0;
    if(r==0) return 1;
    return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}
long long modpow(long long a,long long b,long long p){
    if(b==0) return 1;
    else if(b%2==0) return modpow(a,b/2,p)*modpow(a,b/2,p)%p;
    return (modpow(a,(b-1)/2,p)*modpow(a,(b-1)/2,p)%p)*a%p;
}
int main(){
    COMinit();
    long long n,m,k;
    cin>>n>>m>>k;
    long long ans=0;
    rep(i,k+1){
        ans+=(m*modpow(m-1,n-i-1,MOD)%MOD)*COM(n-1,i)%MOD;
    }
    ans%=MOD;
    cout<<ans;
}

Measured memory_bytes: 15592
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if (A <= 9 && B <= 9)
    {
        cout << A * B << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		int max = 0;
		int tmp = 0;
		for(int i=0; i<S.Length; i++)
        {
            if(S[i] == 'R')
            {
				tmp++;
				if(max < tmp)
                {
					max = tmp;
                }
            }
            else
            {
				tmp = 0;
            }
        }
		Console.WriteLine(max);
	}
}

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

int main(){
  int N, M, P;
  cin >> N >> M;
  P = 0;
  vector<int> vec(M);
  for (int i = 0; i < M; i++){
    cin >> vec.at(i);
    P = P + vec.at(i);
  }
  if (P > N){
    cout << -1 << endl;
  }
  else{
    cout << N - P << endl;
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
long long int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll ans=0;
    ll n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    int k=60;
    ll temp=1;
    while(k--){
        ll e=0;ll r=0;
        for(int i=0;i<n;i++){
            if(a[i]%2)e++;
            else r++;
            a[i]=a[i]/2;
        }
        ll t=e*r;t%=p;
        ans=ans+(temp*(t))%p;
        temp=2*temp;
        temp%=p;
        ans%=p;
    }
    cout<<ans;
    return 0;
}   

Measured memory_bytes: 2560
import sys

ptn00 = [['00', '01', '11', '10'], ['10', '11', '01', '00']]
ptn11 = [['00', '01', '11', '10'], ['10', '00', '01', '11']]
ptnEven = ['01', '10']

# [00…0]（全ての桁が0）から[1…10…0]（先頭のnumDiff桁が1）まで、
# ちょうど1ビットずつ変化するパターン（重複なし）を生成する
def dfs(digit, ptnNow, parity, isLast):
    if digit == maxDigit:
        if N % 2:
            ptns.append(ptnNow)
        else:
            # Nが偶数の場合、長さを調整する
            ptns.append(ptnNow+ptnEven[parity][0])
            ptns.append(ptnNow+ptnEven[parity][1])
        return

    if digit <= numDiff//2 and parity and isLast:
        # [11]になるビットの場合、最後だけ基本パターンから逸脱する
        for v, p in enumerate(ptn11[1]):
            dfs(digit+1, ptnNow+p, v%2, isLast if v == 3 else 0)
    else:
        # [00]になる2ビットの場合
        for v, p in enumerate(ptn00[parity]):
            dfs(digit+1, ptnNow+p, v%2, isLast if v == 3 else 0)


N, A, B = map(int, input().split())

binA, binB = bin(A)[2:].zfill(N), bin(B)[2:].zfill(N)
numDiff = sum([Ai != Bi for Ai, Bi in zip(binA, binB)])

if numDiff % 2 == 0:
    print('NO')
    sys.exit()

numSame = N - numDiff
maxDigit = 1 + numDiff//2 + numSame//2

ptns = []
dfs(1, '0', 0, False)
dfs(1, '1', 1, True)

# A→Bでの変化有無に応じて、各ビットを並べ替える
conv2digitPtns = []
digitDiff, digitSame = 0, numDiff
for i, (Ai, Bi) in enumerate(zip(binA, binB)):
    if Ai == Bi:
        conv2digitPtns.append(digitSame)
        digitSame += 1
    else:
        conv2digitPtns.append(digitDiff)
        digitDiff += 1

anss = []
for ptn in ptns:
    ans = ''
    for c in conv2digitPtns:
        ans += ptn[c]
    ans = int(ans, 2) ^ A
    anss.append(ans)

print('YES')
print(' '.join(map(str, anss)))


Measured memory_bytes: 27824
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    int n;
    int first=INF;
    int second=INF-1;

    cin>>n;
    vector<int> a(n),b(n);
    FOR(i,0,n-1){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    first=b[n-1];
    second=b[n-2];
    FOR(i,0,n-1){
        if(a[i]==first){
            cout<<second<<endl;
        }else{
            cout<<first<<endl;
        }
    }
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a != c)
        cout << 1 << '\n';
    else 
        cout << 0 << '\n';

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if(s.size() == 3)
		cout << s[2] << s[1] << s[0] << endl;
	else
		cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int N=700;
int n,m,cnt1,cnt2;
int d[N+10][N+10],vis[N+10],f[N+10],g[N+10];
bool dfs(int x,int kx) {
    if (vis[x]&&vis[x]!=kx) return 0;
    if (vis[x]) return 1;
    vis[x]=kx;
    if (kx==1) cnt1++;
    else cnt2++;
    for (int i=1;i<=n;i++)
        if (!d[x][i])
            if (!dfs(i,((kx-1)^1)+1)) return 0;
    return 1;
}
void work(int cnt1,int cnt2) {
    for (int i=0;i<=n;i++) g[i]=0;
    for (int i=0;i<=n;i++)
        if (f[i]) g[i+cnt1]=g[i+cnt2]=1;
    for (int i=0;i<=n;i++) f[i]=g[i];
}
int main() {
    f[0]=1;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        d[u][v]=d[v][u]=1;
    }
    for (int i=1;i<=n;i++) d[i][i]=1;
    memset(vis,0,sizeof(vis));
    for (int i=1;i<=n;i++)
        if (!vis[i]) {
            cnt1=cnt2=0;
            if (!dfs(i,1)) {
                printf("-1\n");
                return 0;
            }
            work(cnt1,cnt2);
        }
    int ans=1e9;
    for (int i=0;i<=n;i++)
        if (f[i]) ans=min(ans,(i-1)*i/2+(n-i)*(n-i-1)/2);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2176
from itertools import product

class FloydWarshall:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self):
        INF = float('inf')
        self.dist = [[INF] * self.N for _ in range(self.N)] # dist[s][t]: the distance of vertex t from s
        self.prev = [[-1] * self.N for _ in range(self.N)] # prev[s][t]: the previous vertex of vertex t on a shortest path from s
        # initialize
        for v in range(self.N):
            self.dist[v][v] = 0; self.prev[v][v] = -1
            for u, c in self.E[v]: self.dist[v][u] = c; self.prev[v][u] = v
        # update
        for k in range(self.N):        
            for i, j in product(range(self.N), repeat=2):
                temp = self.dist[i][k] + self.dist[k][j]
                if self.dist[i][j] > temp: self.dist[i][j] = temp; self.prev[i][j] = self.prev[k][j]
        for v in range(self.N):
            if self.dist[v][v] < 0: return None # There exists a negative cycle
        return self.dist
    
    def shortest_path(self, s, t):
        P = []
        prev_s = self.prev[s]
        while True:
            P.append(t)
            t = prev_s[t]
            if t == -1: break
            elif t == P[0]: P.append(t); break
        return P[::-1]

INF = float('inf')
N, M = map(int, input().split())
fw = FloydWarshall(N)
for _ in range(M):
    a, b, c = map(int, input().split())
    fw.add_edge(a, b, c)
dist = fw.distance()
if dist is None: print('NEGATIVE CYCLE')
else:
    for dst in dist: print(*[d if d != INF else 'INF' for d in dst])


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

int main()
{
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	ans=max(ans,a*2-1);
	ans=max(ans,b*2-1);
	ans=max(ans,a+b);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

template <typename T>
struct Vec2;

template <typename T>
T SqrMagnitude(const Vec2<T>& v);

template <typename T>
T Magnitude(const Vec2<T>& v);

template <typename T>
T Dot(const Vec2<T>& v1, const Vec2<T>& v2);


template <typename T>
struct Vec2 {
    T x, y;
    Vec2() = default;
    Vec2(T in_x, T in_y)
        : x {in_x}, y {in_y} {};
    Vec2(const Vec2&) = default;
    Vec2(Vec2&&) = default;

    Vec2 normalized() const{
        T mag = Magnitude(*this);
        return {x / mag, y / mag};
    }

    Vec2 normalize() {
        T mag = Magnitude(*this);
        return {x /= mag, y /= mag};
    }

    Vec2 operator-() {
        return {-x, -y};
    }

    Vec2 operator+(const Vec2& rhs) const{
        return {x + rhs.x, y + rhs.y};
    }

    Vec2 operator-(const Vec2& rhs) const{
        return {x - rhs.x, y - rhs.y};
    }

    Vec2 operator*(T rhs) const{
        return {x * rhs, y * rhs};
    }

    Vec2 operator/(T rhs) const{
        return {x / rhs, y / rhs};
    }

    Vec2& operator+=(const Vec2& rhs) {
        x += rhs.x;
        y += rhs.y;
        return *this;
    }

    Vec2& operator-=(const Vec2& rhs) {
        x -= rhs.x;
        y -= rhs.y;
        return *this;
    }

    Vec2& operator*=(T rhs) {
        x *= rhs;
        y *= rhs;
        return *this;
    }

    Vec2& operator/=(T rhs) {
        x /= rhs;
        y /= rhs;
        return *this;
    }
};

template <typename T>
inline Vec2<T> operator*(T s, const Vec2<T>& v) {
    return {s * v.x, s * v.y};
}


template <typename T>
inline T SqrMagnitude(const Vec2<T>& v) {
    return Dot(v, v);
}

template <typename T>
inline T Magnitude(const Vec2<T>& v) {
    return sqrt(SqrMagnitude(v));
}

template <typename T>
inline T Dot(const Vec2<T>& v1, const Vec2<T>& v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

template <typename T>
inline T Cross(const Vec2<T>& v1, const Vec2<T>& v2) {
    return v1.x * v2.y - v1.y *v2.x;
}

int main() {
    constexpr long double tolerance = 1e-10;
    using ld = long double;

    Vec2<ld> p0, p1, p2;

    cin >> p0.x >> p0.y >> p1.x >> p1.y;

    int n;
    cin >> n;

    auto p_01 = p1 - p0;

    for(int i = 0; i < n && cin >> p2.x >> p2.y; ++i) {
        auto p_02 = p2 - p0;        

        auto cross = Cross(p_01, p_02);

        if(cross > 0) {
            cout << "COUNTER_CLOCKWISE" << endl;
        }
        else if(cross < 0){
            cout << "CLOCKWISE" << endl;
        }
        else {
            auto dot {Dot(p_01, p_02)};
            if(dot >= 0.0) {
                cout << (dot >  Dot(p_01, p_01) ? "ONLINE_FRONT" : "ON_SEGMENT") << endl;
            }
            else {
                cout << "ONLINE_BACK" << endl;
            }
            
        }
    }

    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

int main(){
  int N;cin>>N;
  vector<int> x(N),y(N),h(N);
  int x0,y0,h0=-1;
  Rep(i,N){
    cin>>x[i]>>y[i]>>h[i];
    if(h0==-1&&h[i]>0){
      x0=x[i];y0=y[i];h0=h[i];
    }
  }
  Rep(ax,101){
    Rep(ay,101){
      bool f=true;
      int H=h0+abs(ax-x0)+abs(ay-y0);
      Rep(i,N){
        int H0=max(0,H-abs(ax-x[i])-abs(ay-y[i]));
        if(H0!=h[i])f=false;
      }
      if(f){
        cout<<ax<<" "<<ay<<" "<<H;
        return 0;
      }
    }
  }
  
  return 0;
}

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

int main(){
    int a,b;
    char op;
    
    cin>>a>>op>>b;
    while(op!='?'){
         int c;
         if(op=='+') c=a+b;
         if(op=='-') c=a-b;
         if(op=='*') c=a*b;
         if(op=='/') c=a/b;
         cout << c << endl;
         cin >> a >> op >> b;
    }
    
}


Measured memory_bytes: 3108
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k; cin>>n>>k;
    ll arr[n+2];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    vector<ll> v;
    int vis[n+2]={0};
    int node=1;
    k++;
    while(1)
    {
        vis[node]=1;
        v.push_back(node);
        node=arr[node];
        if(vis[node]==1)
        {
            if(v.size()>=k){
                cout<<v[k-1]; return 0;
            }
            int idx=1;
            for(int i=v.size()-1;i>=0;i--)
            {
                if(v[i]==node) {
                    
                    k-=i;
                    ll sz=v.size()-i;
                    k--;
                    k%=sz;
                    cout<<v[i+k];
                    return 0;
                }
            }
            break;
        }
    }
}

Measured memory_bytes: 7648
INF = 10 ** 9 + 7
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
dp = [INF] * (H + 1)
dp[0] = 0

for i in range(N):
    for j in range(H):
        if dp[j] == INF: continue
        if j + ab[i][0] <= H:
            dp[j + ab[i][0]] = min(dp[j + ab[i][0]], dp[j] + ab[i][1])
        else:
            dp[H] = min(dp[H], dp[j] + ab[i][1])

print(dp[H])

Measured memory_bytes: 68840
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int wg;
int ryo[]={200,300,500,1000,1200,1500};
int plc[]={380,550,850,0,0,0};	

	plc[3]=380*5*0.8; plc[4]=550*4*0.85; plc[5]=850*3*0.88;
	rep(i,6) ryo[i] /= 100;

	while(cin >> wg ){
		if(wg==0 || cin.eof()) break;
		wg /= 100;
		vector<int>dp(wg+1,1<<22);
		dp[0]=0;
	rep(i,6) for(int j=0;j+ryo[i]<=wg; j++){
		dp[j+ryo[i]] = min( dp[j+ryo[i]] , dp[j]+plc[i] );
	}
	cout << dp[wg] << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1196
/* nuttela - Soham Chakrabarti */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define FR(i,j,k) for(int i=j;i<k;i++)
#define FRR(i,j,k) for(int i=j;i>=k;--i)
#define ff first
#define ss second
#define Judge
 
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll,ll> pii;
 
const int N = 1e5 + 5;
const int M = 1e5 + 5;
const int inf = INT_MAX;
const int MOD = 1e9 + 7;

int32_t main() {

    IO;
    #ifndef Judge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    // int t;
    // cin>>t;
    // while(t--) {
    string s;
    cin >> s;
    if(s == "ARC") 
        cout << "ABC\n";
    else 
        cout << "ARC\n";
    // }   
    return 0;
}


Measured memory_bytes: 3564
N, K = map(int,input().split())
P = list(map(int,input().split()))
prob = [0 for _ in range(N)]
for i in range(N):
    prob[i] = (P[i]+1)/2
m = sum(prob[:K])
a = sum(prob[:K])
for j in range(1,N-K+1):
    a = a - prob[j-1] + prob[j+K-1]
    if a > m:
        m = a
print(m)

Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int main(){
    int n;cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;++i){
        cin>>p[i];p[i]--;
    }
    vector<int> q(n);
    for(int i=0;i<n;++i){
        q[p[i]]=i;
    }
    int ans=0;
    int right=0;
    for(int left=0;left<n;++left){
        while(right<n-1&&q[right]<q[right+1]) right++;
        ans=max(ans,right-left+1);
        if(right==left) right++;
    }
    ans=n-ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4848
#include <stdio.h>
int main(void){
    int w, a, b, move=0;
    scanf("%d%d%d", &w, &a, &b);
    if(a<b) move=b-(a+w);
    else move=a-(b+w);
    printf("%d", move<0 ? 0:move);
    return 0;
}

Measured memory_bytes: 1700
Parent = 0
Lchild = 1
Rchild = 2

def depth(n):
    if n == -1: return -1
    return depth(parent(n)) + 1

def height(n):
    c1, c2 = childs(n)
    if (c1, c2) == (-1, -1): return 0
    return max(height(c1), height(c2)) + 1

def parent(n):
    return node[n][Parent]

def childs(n):
    return node[n][Lchild:Rchild+1]

def sibling(n):
    c1, c2 = childs(parent(n))
    if c1 == n: return c2
    elif c2 == n: return c1
    return -1

def degree(n):
    return 2 - childs(n).count(-1)

def nt(n):
    if parent(n) == -1:
        return 'root'
    elif degree(n) == 0:
        return 'leaf'
    else:
        return 'internal node'
    return

n = int(input())
node = [[-1, -1, -1] for i in range(n)]
for i in range(n):
    tmp = map(int, raw_input().split())
    j = tmp[0]
    e1, e2 = tmp[1:]
    if e1 != -1:
        node[j][Lchild] = e1
        node[e1][Parent] = j
    if e2 != -1:
        node[j][Rchild] = e2
        node[e2][Parent] = j

for i in range(n):
    msg = 'node {0}: parent = {1}, sibling = {2}, degree = {3}, '+\
          'depth = {4}, height = {5}, {6}'''
    c1 = parent(i)
    c2 = sibling(i)
    c3 = degree(i)
    c4 = depth(i)
    c5 = height(i)
    c6 = nt(i)
    print msg.format(i, c1, c2, c3, c4, c5, c6)

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll s,mod=1e9+7,ans=0;cin>>s;
  ll lim=s/3;
  vector<lvector> v(s+1,lvector(s+1,0));
  rep(i,s+1) {v[i][0]=1;v[i][i]=1;}
  for(ll j=1;j<s+1;++j)
  for(ll k=1;k<j;++k) v[j][k]=(v[j-1][k-1]+v[j-1][k])%mod;
  for(ll len=1;len<=lim;++len) {
    ll rem=s-3*len;
    ans=(ans+v[rem+len-1][len-1])%mod;
  }
  print(ans);
  return 0;
}


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

int main() {
  int64_t N;
  cin >> N;
  
  int64_t l0 = 2;
  int64_t l1 = 1;
  
  int64_t ln = l1;
  int64_t lnpre1 = l1;
  int64_t lnpre2 = l0;



  
  for ( int64_t i = 0; i < N + 1 ; i++){
    if( i == 0) ln = 2;
    else if ( i == 1) ln = 1;
    else{
   		ln = lnpre1 + lnpre2;
    	lnpre2 = lnpre1;
    	lnpre1 = ln;
    }
// printf("i= %lld : ln = %lld\n",i,ln);

    
  }
  
  //cout << ln << endl;
    printf("%lld\n",ln);
}




Measured memory_bytes: 256
void main()
{
    string[] tmp = readln.split;
    long n = tmp[0].to!long, k = tmp[1].to!long;
    long[] d = readln.split.to!(long[]);

    bool[] ok = new bool[10];
    ok[] = true;
    foreach (x; d)
    {
        ok[x] = false;
    }
    long okmin = ok.countUntil(true);

    long len = tmp[0].length;
    long[] money = new long[len+1];
    foreach_reverse (i; 1 .. len+1)
    {
        money[i] += n % 10;
        money[i-1] += money[i] / 10;
        money[i] %= 10;
        n /= 10;

        bool up;
        while (!ok[money[i]])
        {
            up = true;
            if (money[i] == 9)
            {
                ++money[i-1];
                money[i] = 0;
            }
            else
            {
                ++money[i];
            }
        }
        if (up) money[i+1..$] = okmin;
    }

    if (money[0] == 0)
    {
        money = money[1..$];
    }
    else
    {
        while (!ok[money[0]])
        {
            ++money[0];
        }
        money[1..$] = okmin;
    }

    foreach (i, x; money)
    {
        x.write;
    }
    writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
n  = int(input())
a = list(map(int, input().split()))
total = sum(a)

def rain(i):
  rainfall = (total/2 - sum(a[:i-2:-2]) - sum(a[i+1::2])) * 2
  return int(rainfall)

i = 0
a.insert(0, a[n-1])
del a[n]
i += 1
r = []
r.append(rain(i))
a.append(a[0])
del a[0]

for i in range(1, n):
  rainfall = a[i-1] * 2 - r[i-1]
  r.append(rainfall)

for i in range(n):
  print(r[i])

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

const int N = 2e5 + 9, P = 1e9 + 7;

int n, x[N], y[N];
/*using pii = pair<int, int>;
using ull = unsigned long long;
struct Hash {
	ull operator () (const pii &pi) const {
		return (ull)pi.first << 31 | pi.second;
	}
};
unordered_map<pii, int, Hash>T;*/
vector<int>V[N];
int dep[N], ss[N], h[N], t, es, ns, ans, f[N], fac[N], fac_rev[N], s[N], sum, tmp, A, B;
bool vis[N], o;

void Dfs (int x, int d, int y) {
	vis[x] ^= 1;
	ss[dep[x] = d] = x;
	++ns;
	for (auto v : V[x]) if (v != y) {
		++es;
		if (!vis[v]) Dfs(v, d + 1, x); else if (o) { o = 0; for (int i = dep[v]; i <= d; ++i) h[++t] = ss[i]; }
	}
}

void Dfs2 (int x, int y) {
	f[x] = 1; s[x] = 0;
	for (auto v : V[x]) if (v != y && (v != A || x != B) && (v != B || x != A)) {
		Dfs2(v, x);
		if (v < y) {
			f[x] = 1ll * f[x] * fac_rev[s[v]] % P * f[v] % P;
			s[x] += s[v];
		} else {
			sum = 1ll * sum * f[v] % P * fac_rev[s[v]] % P;
		}
	}
	f[x] = 1ll * f[x] * fac[s[x]] % P; ++s[x];
	if ((x == A && y == B) || (x == B && y == A)) sum = 1ll * sum * f[x] % P * fac_rev[s[x]] % P;
}

int qp (int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; }

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= (n << 1); ++i) scanf("%d%d", &x[i], &y[i]), y[i] += n, V[x[i]].emplace_back(y[i]), V[y[i]].emplace_back(x[i]);
	fac[0] = 1; for (int i = 1; i <= (n << 1); ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	fac_rev[n << 1] = qp(fac[n << 1], P - 2);
	for (int i = (n << 1) - 1; ~i; --i) fac_rev[i] = 1ll * fac_rev[i + 1] * (i + 1) % P;
	ans = fac[n << 1];
	for (int i = 1; i <= n; ++i) if (!vis[i]) {
		o = 1; t = es = ns = tmp = 0;
		Dfs(i, 0, 0);
		if (es != ns + 1) puts("0"), exit(0);
		A = h[1]; B = h[t];
		for (int i = 1; i < t; ++i) if (h[i] + h[i + 1] > A + B) A = h[i], B = h[i + 1];
		sum = 1; Dfs2(A, B); tmp = (tmp + sum) % P;
		sum = 1; Dfs2(B, A); tmp = (tmp + sum) % P;
		ans = 1ll * ans * tmp % P;
//		for (int i = 1; i <= t; ++i) printf("%d%c", h[i], i == t ? '\n' : ' ');
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 22528
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

#define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

ll N;
ll A[MAX];

signed main() {
	cin >> N;
	rep(i, N) cin >> A[i];
	ll cnt = 0;
	ll max_v = 0;
	rep(i, N) {
		ll tmp = A[i] / (max_v + 1);
		if (A[i] % (max_v + 1) == 0) tmp--;
		dump(tmp);
		cnt += tmp;
		if (max_v == 0) max_v = 1;
		if (tmp == 0) max_v = max(max_v, A[i]);
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
	string N;
	cin >> N;
	if (N.find('7') != std::string::npos) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> t(s.size());
    for (int i=0;i<s.size();i++) {
        t[i]=s[i]-'A';
        t[i]+=n;
        t[i]=t[i]%26;
        s[i]=t[i]+'A';
    }
    cout << s << endl;
}

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

int main() {
    bool cards[4][14];
    int n, rank;
    char suit;

    for(int s = 0; s < 4; s++)
        for(int r = 1; r <= 13; r++)
            cards[s][r] = 0;

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> suit >> rank;
        if(suit == 'S')cards[0][rank] = 1;
        if(suit == 'H')cards[1][rank] = 1;
        if(suit == 'C')cards[2][rank] = 1;
        if(suit == 'D')cards[3][rank] = 1;
    }

    for(int s = 0; s < 4; s++ ) {
        for(int r = 1; r <= 13; r++) {
            if(cards[s][r])continue;
            if(s == 0)suit = 'S';
            if(s == 1)suit = 'H';
            if(s == 2)suit = 'C';
            if(s == 3)suit = 'D';
            cout << suit << " " << r << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((B - A) == (C - B)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3564
a, b, c, x, y = gets.split.map(&:to_i)
reasonable = (a + b) >= c * 2 ? true : false
cost = 0
if reasonable
  min = [x, y].min
  cost += c * min * 2
  x -= min
  y -= min
end
cost += [a, c * 2].min * x + [b, c * 2].min * y
puts cost

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second

int n,m, P[N], wa[N],s,ss,p;
char su[5];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
    {
        scanf("%d %s",&p, su);
        if(su[0]=='W' && !P[p]) wa[p]++;
        if(su[0]=='A' && !P[p])
        {
            ss += wa[p];
            P[p]=1;
            s++;
        }
    }
    printf("%d %d",s,ss);
    return 0;
}

Measured memory_bytes: 1024
s,*X=$<.map{_1.split.map &:to_i}
A,B=X.transpose.map{|x|c=x.tally;d=c.map{_2}.max;c.filter{_2==d}}
Y=X.tally
p A.all?{|a,c|B.all?{s=c+_2;Y[[a,_1]]}}?s-1:s

Measured memory_bytes: 112428
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int a, b;
  cin >> a >> b;

  int ans = max(0, a - (2 * b));

  cout << ans << endl;

  return 0;
}


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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define hell (ll)(1e9+7)

using namespace std;

void solve()
{
    ll n,m;
    cin>>n>>m;
    string p[n];
    rep(i,0,n)
        cin>>p[i];
    ll dp[n][m];
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if(i==0&&j==0)
                dp[i][j]=1;
            else if(i==0)
                dp[i][j]=p[i][j]=='.'?dp[i][j-1]:0;
            else if(j==0)
                dp[i][j]=p[i][j]=='.'?dp[i-1][j]:0;
            else
                dp[i][j]=p[i][j]=='.'?dp[i-1][j]+dp[i][j-1]:0;
            dp[i][j]%=hell;
        }
    }
    cout<<dp[n-1][m-1];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 9088
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if i%2 == 0 and j%2 ==0:
                print('#',end ='')
            elif i%2 == 1 and j%2 ==1:
                print('#',end ='')
            else:
                print('.',end ='')
           
        print()
    print()


Measured memory_bytes: 7004
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define int long long


signed main(){

    int N, MAX;
    cin >> N >> MAX;
    vector<pair<int,int> > A(N);
    set<int> st;
    for(int i=0;i<N;i++){
        cin >> A[i].first >> A[i].second;
        st.insert(A[i].second);
        st.insert(A[i].first);
    }
    
    sort(A.begin(), A.end());


    int cur = 0;
    int ncur = 0;
    int X = 1;
    for(int i=0;i<N;i++){
        if(cur < A[i].first){
            cur = ncur;
            if(cur == MAX)break;
            X++;
        }
        ncur = max(A[i].second, ncur);
    }

   

    vector<pair<int,int> > R = A;
    vector<pair<int,int> > L = A;
    for(int i=0;i<N;i++){
        swap(R[i].first, R[i].second);
    }
    sort(R.begin(), R.end());
    sort(L.begin(), L.end());
    int Y = 0;
    for(int i = 0;i <= N; i++){
        int l;
        if(i < N)l = L[i].first;
        else l = MAX;
        if(l > 0){
            int t = upper_bound(R.begin(), R.end(), make_pair(l, (int)-1)) - R.begin();
            Y = max(Y, N - i + t);
        }

    }
    cout << X << " " << Y + 1 << endl;
    return 0;
}


Measured memory_bytes: 30008
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

A2=[0]+list(accumulate(A, max))+[0]
# A3=[0]+list(accumulate(A[::-1], max))[::-1]+[0]
A3=[0]*(N+2)
A3[N]=A[-1]
for i in range(N-2, -1, -1):
    A3[i+1]=max(A3[i+2], A[i])

for i in range(1, N+1):
    print(max(A2[i-1], A3[i+1]))


Measured memory_bytes: 15728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int a;
  int x,y;
  scanf("%d",&a);
  x=a/2;
  y=(a+1)/2;
  printf("%d\n",x*y);
  return 0;
}


Measured memory_bytes: 128
# AOJ 0409
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0409

xx, yy = list(map(int, input().split()))

fib = [1, 1]
a = 0
while a < 10000000:
    a = fib[-1] + fib[-2]
    fib += [a]

area = [[0, 0, 1]]
x, y = 0, 0
f1 = 0
f2 = 1
for n in range(1, len(fib)):
    a = fib[n]
    if n % 4 == 1:
        area += [[x + f2, y + f1, a]]
    elif n % 4 == 2:
        area += [[x - f1, y + a, a]]
    elif n % 4 == 3:
        area += [[x - a, y, a]]
    elif n % 4 == 0:
        area += [[x, y - f2, a]]
    f1 = f2
    f2 = a
    x, y = area[-1][0:2]

for n, floor in enumerate(area):
    x, y, a = floor
    if x <= xx < x + a and y - a < yy <= y:
        print(n % 3 + 1)
        break



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b=0,c=100000,cos=0,k=100000000;
  int s[105];
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>s[i];
    b=max(b,s[i]);
    c=min(c,s[i]);
  }
  for(int i=c;i<=b;i++){
    for(int j=0;j<a;j++){
      int g=s[j]-i;
      cos+=g*g;
    }
    k=min(k,cos);
    cos=0;
  }
  cout<<k<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k, sum int
	fmt.Scan(&n, &k)
	for i := 1; i <= n; i += 2 {
		sum++
	}
	if sum >= k {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512