akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <stack>
#include <queue>

using namespace std;

struct Area {
    int s;
    int e;
    int area;
    Area(int _s, int _e) : s(_s), e(_e), area(_e - _s) {}
};

stack<int> stk;
queue<Area> areas;

int main()
{
    int ch;
    int sum = 0;
    int current_point = 0;
    while ((ch = getchar()) && ch != '\n' && ch != EOF)
    {
        switch (ch)
        {
            case '\\':
                stk.push(current_point);
                break;
            case '/':
                if (!stk.empty())
                {
                    int p = stk.top();
                    stk.pop();
                    Area area(p, current_point);
                    sum += area.area;
                    int size = areas.size();
                    while (size-- > 0)
                    {
                        Area a = areas.front();
                        areas.pop();
                        if (area.s < a.s && a.e < area.e)
                            area.area += a.area;
                        else
                            areas.push(a);
                    }
                    areas.push(area);
                }
                break;
        }
        current_point++;
    }

    printf("%d\n", sum);
    printf("%d", areas.size());
    while (!areas.empty())
    {
        Area a = areas.front();
        areas.pop();
        printf(" %d", a.area);
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 1080
using System;
using System.Linq;

namespace AGC35A
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = CIN.Long();
            long[] A = CIN.LongArray();

            if (N % 3 != 0)
            {
                for (int i = 0; i < N; i++)
                {
                    if (A[i] != 0)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }

                Console.WriteLine("Yes");
                return;
            }

            long[] bits = new long[33];
            for (int i = 0; i < N; i++)
            {
                long p = 1;
                for (int j = 0; j < 33; j++)
                {
                    bits[j] += (A[i] / p) % 2;
                    p *= 2;
                }
            }

            for (int i = 0; i < 33; i++)
            {
                if (bits[i] != N / 3 * 2 && bits[i] != 0)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 21344
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c;
 cin >> a>> b>> c;
 int ans = min(min(a+b,b+c),a+c);
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void solve(){
    string s;
    int k;
    cin>>k>>s;
    if(s.length()<=k)
        cout<<s;
    else{
        for(int i=0;i<k;i++)
            cout<<s[i];
            cout<<"...";
    }
    }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();

}



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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  int count;
  vector<vector<int>> data(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++){cin >> data.at(i).at(j);}}
  for (int i = 0; i < N-2; i++)
  {
    if (data.at(i).at(0) == data.at(i).at(1) && data.at(i+1).at(0) == data.at(i+1).at(1) && data.at(i+2).at(0) == data.at(i+2).at(1))
    {
      cout << "Yes" << endl;
      break;
    } 
    if (i == N-3) {cout << "No" << endl;}
  }

}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
    int x,y;
    int a[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
    scanf("%d %d",&x,&y);
    if(a[x-1] == a[y-1]){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N;
  cin >> N;
  
  ll i;
  pair<pair<string, ll>, ll> res[111];
  
  for(i=0; i<N; i++) {
    cin >> res[i].ft.ft >> res[i].ft.sc;
    res[i].ft.sc*=-1;
    res[i].sc=i+1;
  }
  sort(res, res+N);
  
  for(i=0; i<N; i++) {
    pt(res[i].sc);
  }
  
}












Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    double ans = 0.0;
    REP(i, n) {
        double a; cin >> a;
        ans += 1.0/a;
    }
    cout << fixed << setprecision(12) << 1.0/ans << '\n';
    return 0;
}


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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    getline(cin,s);
    for (int i = 0; i < s.size(); i++){
        char c,c1;
        c=s[i];
        if(isalpha(c)){
            if(islower(c))c1=toupper(c);
            else c1=tolower(c);
        }else c1=c;
        printf("%c",c1);
    }
    printf("\n");
}


Measured memory_bytes: 3196
#include <stdio.h>
 

#define Max 1000
#define Inf 100000

int n, M[Max][Max];
int d[Max];
int Q[Max];
int tail=0;
int head=0;
 

void enq(int x) {
  Q[tail++] = x;
}
 

int deq() {
  return Q[head++];
}
 

void bfs(int s) {
  int i,u,v;
  enq(s);
  for(i=1;i<=n;i++){
    d[i] = Inf;
    d[s] = 0;
  }
  while(head != tail){
    u = deq();
    for(v=1;v<=n;v++){
      if(M[u][v] == 0){
    continue;
      }
      if(d[v] != 100000){
    continue;
      }
      d[v] = d[u] +1;
      enq(v);
    }
  }
}
 

int main() {
  int i,j,u,k,v;
 
  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++)
    for(j = 0 ; j < n ; j++)
      M[i][j] = 0;
 
  for(i = 1 ; i <= n ; i++){
    scanf("%d %d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      M[u][v] = 1;
    }
  }
 
  bfs(1);
   
  for(i=1;i<=n;i++){
    if(d[i] == Inf){
      d[i] = -1;
    }
    printf("%d %d\n",i,d[i]);
  }
 
  return 0;
}

Measured memory_bytes: 992
import org.w3c.dom.ls.LSOutput;
import java.util.*;
public class Main {
    static boolean visited[] = new boolean[1002];
    static boolean counted[] = new boolean[1002];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n-=400;
        System.out.println(8-n/200);
    }
}






Measured memory_bytes: 35556
n = int(input())
tasks = []

for _ in range(n):
    c,d = map(int,input().split())
    tasks.append([d,c])
tasks.sort()
maxday = tasks[-1][0]
worked = 0
for i in range(n):
    day = tasks[i][0]
    cost = tasks[i][1]
    if day - worked < cost :
        print("No")
        exit()
    else:
        worked += cost
print("Yes")

Measured memory_bytes: 35944
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();

    ll int n,m,a,b,res,ara[sz];
    for(int i=1;i<=5;i++)
    {
        cin>>a;
        if(a==0)res=i;
    }
    cout<<res<<endl;



}



Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {

        solve();
    }

    private static void solve() {

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

        int result = (n * (n - 1)) / 2 + m * (m - 1) / 2;

        System.out.println(result);

    }
}

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

int n, c, mx;
string a;
int main()
{
    int i;
    cin >> n >> a;
    for (i = 0; i < a.size(); i++) {
        if (a[i] == 'I') c++;
        else c--;
        mx = max(mx, c);
    }
    cout << mx << endl;
    return 0;
}


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

int main() {
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2]) {
        cout << "Yes" << endl;
    } else if (n[1] == n[2] && n[2] == n[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    vector<double> e(n);
    rep(i, n) {
        double p;
        cin >> p;
        e[i] = 1.0 + 0.5*(p-1);
    }

    double res = 0.0;
    rep(i, k) res += e[i];

    double sum = res;
    rep(i, n-k){
        sum -= e[i];
        sum += e[k+i];

        res = max(res, sum);
    }

    printf("%.19f\n", res);

    return 0;
}

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



void solve(){
  int k;
  cin >> k;
  const int n=k;
  int h[n];
  for(int i=0; i<n; i++) cin >> h[i];
  int count =0;
  
  for(int i=0;i<n; i++){
    bool b=true;
    for(int j=0; j<i; j++){
       if(h[j]>h[i]) b=false;
    }
    if(b) count++;
  }
  cout << count << endl;
}

int main(){
  solve();
  return 0;
}
  


Measured memory_bytes: 256
using System;
using System.Numerics;

namespace d
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = BigInteger.Parse(Console.ReadLine());
            Console.WriteLine(recFunc(h));
        }

        static BigInteger recFunc(BigInteger h){
            if(h == 1){
                return 1;
            }
            return recFunc(h / 2) * 2 + 1;
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

bool does_win(std::string str, char c){
	if(str[0] == c && str[1] == c && str[2] == c){
		return true;
	}
	if(str[3] == c && str[4] == c && str[5] == c){
		return true;
	}
	if(str[6] == c && str[7] == c && str[8] == c){
		return true;
	}
	if(str[0] == c && str[3] == c && str[6] == c){
		return true;
	}
	if(str[1] == c && str[4] == c && str[7] == c){
		return true;
	}
	if(str[2] == c && str[5] == c && str[8] == c){
		return true;
	}
	if(str[0] == c && str[4] == c && str[8] == c){
		return true;
	}
	if(str[2] == c && str[4] == c && str[6] == c){
		return true;
	}
	return false;
}

int main(int argc, char **argv){
	std::string str;


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(std::getline(ifs, str)){
#else
	while(std::getline(std::cin, str)){
#endif
		if(does_win(str, 'o')){
			std::cout << "o" << std::endl;
		}
		else if(does_win(str, 'x')){
			std::cout << "x" << std::endl;
		}
		else{
			std::cout << "d" << std::endl;
		}

	}
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef  long long 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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int a[3];
    bool yes=false;
    rep(i,3)cin>>a[i];
    rep(i,3){
        rep(j,3){
            if(i==j)continue;
            if(a[i]==a[j]){
                if(a[3-(i+j)]!=a[i])yes=true;
            }
        }
    }
    if(yes)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream> 
using namespace std;
int main(){
  int n,x;cin>>n>>x;
  int sm = 1;
  int subbb = 0;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    subbb += tmp;
    if(subbb<=x)sm++;
  }
  cout << sm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair <int,int> P;
const ll MAX_N = 100000;
int main() {
//input
ll n;
int P[200000];
int count = 0;
scanf("%lld",&n);
rep(i,n)scanf("%d",&P[i]);
bool flg =false;
int j =0;
//compute
rep(i,n){
    while(j<i){
       if(P[i]>P[j]){
           flg =true;
           break;
       }
       j++;
    }
    if(!flg)count ++;
    flg = false;
}
//output
printf("%d",count);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'
#define pi 3.14159265
int mod=10;
int p(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
            res*=a;
        res%=mod;
        a*=a;
        a%=mod;
        b/=2;
    }
    return res; 
}
int32_t main()
{
    IOS;
    string s;
    cin>>s;
    set<char> c;
    for(int i=0;i<4;i++)
        c.insert(s[i]);
    if(c.size()==2)
        cout<<"Yes";
    else
        cout<<"No";
}   

Measured memory_bytes: 256
from collections import deque
a = deque(list(input()))
b = deque(list(input()))
c = deque(list(input()))
key = 'a'
while len(a) != 0 or len(b) != 0 or len(c) != 0:
    if key == 'a':
        tmp = a.popleft()
    elif key == 'b':
        tmp = b.popleft()
    elif key == 'c':
        tmp = c.popleft()
    key = tmp
    if len(a) == 0 and key == 'a':
        ans = 'A'
        break
    elif len(b) == 0 and key == 'b':
        ans = 'B'
        break
    elif len(c) == 0 and key == 'c':
        ans = 'C'
        break

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<58;

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    
    vector<long long> s(a+2);
    vector<long long> t(b+2);
    
    s[0] = -INF;
    s[a+1] = INF;
    
    t[0] = -INF;
    t[b+1] = INF;
    
    for (int i = 1; i <= a; i++) cin >> s[i];
    for (int i = 1; i <= b; i++) cin >> t[i];
    
    
   
    
    for (int i = 0; i < q; i++){
        long long ans = INF;
        long long x;
        cin >> x;
        
        //　神社の右端
        int rightJinja = lower_bound(s.begin(),s.end(),x) - s.begin();
        int leftJinja = rightJinja-1;
        
        // 寺の右端
        int rightTera = lower_bound(t.begin(),t.end(),x) - t.begin();
        int leftTera = rightTera-1;
        
        
        for (int j = leftJinja; j <= rightJinja; j++){
            for (int k = leftTera; k <= rightTera; k++){
                long long dist1 = abs(s[j] - x) + abs(s[j]-t[k]);
                long long dist2 = abs(t[k]-x) + abs(t[k]-s[j]);
                
                ans = min(ans,dist1);
                ans = min(ans, dist2);
                
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
# AOJ 0270: Modular Query
# Python3 2018.6.26 bal4u

N, Q = map(int, input().split())
tbl = [0]*300005
nmax, tbl[0] = 0, 1
c = list(map(int, input().split()))
for k in c:
	tbl[k] = 1
	if k > nmax: nmax = k
	tbl[k & 1] = 1
	tbl[k & 3] = 1
	tbl[k & 7] = 1
for i in range(Q):
	q = int(input())
	if q > nmax: print(nmax)
	else:
		f = 0
		for k in range(q-1, -1, -1):
			for i in range(k, nmax+1, q):
				if tbl[i]:
					print(k)
					f = 1
					break
			if f: break


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

int main() {
    int h, w;
    while(1) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        } else {
            for (int i = 0; i < h; i++) {
                if (i % 2) {
                    for (int j = 0; j < w / 2; j++) {
                        cout << ".#";
                        
                    }
                    if (w % 2) cout << ".";
                } else {
                    for (int j = 0; j < w / 2; j++) {
                        cout << "#.";
                        
                    }
                    if (w % 2) cout << "#";
                }
                cout << endl;
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    VI v;
    cin >> n;
    REP(i, n){
        int a;
        cin >> a;
        v.push_back(a);
    }

    if(n % 2 == 0){
        for(int i = n - 1; i > 0; i -= 2){
            cout << v[i] << " ";
        }
        for(int i = 0; i < n - 1; i += 2){
            cout << v[i] << " ";
        }
    }else{
        for(int i = n - 1; i >= 0; i -= 2){
            cout << v[i] << " ";
        }
        for(int i = 1; i < n - 1; i += 2){
            cout << v[i] << " ";
        }
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string a,s,c;
    cin >> a >> s >> c;

    cout << "A" << s[0] << "C" << endl; 

    return 0;
}


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

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,K=mi()
    
    n = N//K
    ans = INF
    for m in [n-1,n,n+1]:
        ans = min(ans,abs(N-K*m))
    print(ans)

if __name__ == "__main__":
    main()

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

int allocate(int n, int w[], int k, int p) {
	int load = 0;
	int cnt = 1;
	for (int i = 0; i < n; i++) {
		if (load + w[i] > p) {
			cnt ++;
			if (cnt > k) return -1;
			load = 0;
		}
		load += w[i];
	}
	return 0;
}

int main() {
	int n,k,w[100000], j, m;
	cin >> n >> k;
	m = (1<<30) * -1;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		m = max(m, w[i]);
		j += w[i];
	}

	int i = m;
	while (i <= j) {
		int guess = i + (j - i) / 2;
		if (allocate(n, w, k, guess) < 0) {
			i = guess + 1;
		} else {
			j = guess - 1;
		}
	}
	cout << i << endl;
	return 0;
}



Measured memory_bytes: 3496
"""
Bit全探索していく
"""
s = list(input())


for i in range(2**3):
    para = ["+","+","+"]
    ans = []
    for j in range(3):
        if (i >> j) & 1 :
            pass
        else : para[j] = "-"
    for i in range(4):
        ans.append(s[i])
        if i <=2 :
            ans.append(para[i])
    a = "".join(ans)
    if eval(a) == 7 :
        print(a+"=7")
        break
    else : pass
    

Measured memory_bytes: 3064
function Main(input) {
	var array = input.split('\n');
	var h = array[0].split(' ')[0]*1
	var w = array[0].split(' ')[1]*1
	array = array.filter((elm,i)=>i>=1);

	if(!input.match(/(\.)/g)){
		//爆弾しかない
		console.log(array.join('\n'));
		
	}else if(input.match(/(\.)/g).length==w*h){
		//爆弾がない
		console.log(array.join('\n').replace(/./g,'0'));

	}else{
		for(var i=0;i<array.length;i++){
			for(var j=0;j<array[i].length;j++){
				if(array[i][j]!='.') continue;
				u = !array[i-1]? null : array[i-1][j], //上
				d = !array[i+1]? null : array[i+1][j], //下
				r = j==w ? null : array[i][j+1], //右
				l = j==0 ? null : array[i][j-1], //左
				ur = !(u && r) ? null : array[i-1][j+1], //右上
				ul = !(u && l) ? null : array[i-1][j-1], //左上
				dr = !(d && r) ? null : array[i+1][j+1], //右下
				dl = !(d && l) ? null : array[i+1][j-1]; //左下
				var num = (u+r+d+l+ur+ul+dr+dl).match(/#/g);
				num = !num ? 0 : num.length;
				array[i] = array[i].replace('.', num);
			};
		}
		console.log(array.join('\n'));
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8012
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
struct bimatch{
	int n;
	vector<vector<int> >G;
	vector<int>match;
	vector<bool>used;
	bimatch(int _n=0):n(_n),G(n),match(n),used(n){}
	void add_edge(int u,int v)
	{
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bool dfs(int v)
	{
		used[v]=true;
		for(int u:G[v])
		
		{
			int w=match[u];
			if(w<0||!used[w]&&dfs(w))
			{
				match[v]=u;
				match[u]=v;
				return true;
			}
		}
		return false;
	}
	int count()
	{
		int ans=0;
		fill(match.begin(),match.end(),-1);
		for(int v=0;v<n;v++)
		{
			if(match[v]<0)
			{
				fill(used.begin(),used.end(),false);
				if(dfs(v))ans++;
			}
		}
		return ans;
	}
};
int X,Y,E;
main()
{
	cin>>X>>Y>>E;
	bimatch P(X+Y);
	for(int i=0;i<E;i++)
	{
		int x,y;cin>>x>>y;
		P.add_edge(x,X+y);
	}
	cout<<P.count()<<endl;
}


Measured memory_bytes: 3276
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]

cost = [99999]*10
cost[1] = 0

def f(n):
    for i in range(10):
        flag = False
        cc = C[i][n]+cost[n]
        if cc < cost[i]:
            flag = True
            cost[i] = cc
            f(i)

f(1)

ans = 0
for _ in range(H):
    for n in map(int, input().split()):
        if n < 0:
            continue
        ans += cost[n]

print(ans)

Measured memory_bytes: 9116
# %% constants
# ------------

# %% body
# -------

function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))

    # handle IO and solve
    X, = readnum()
    println(solve(X))
end

function solve(X)
    if 400 ≤ X ≤ 599
        8
    elseif 600 ≤ X ≤ 799
        7
    elseif 800 ≤ X ≤ 999
        6
    elseif 1000 ≤ X ≤ 1199
        5
    elseif 1200 ≤ X ≤ 1399
        4
    elseif 1400 ≤ X ≤ 1599
        3
    elseif 1600 ≤ X ≤ 1799
        2
    elseif 1800 ≤ X ≤ 1999
        1
    else
        nothing
    end
end

@static if @isdefined(Juno)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


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

using namespace std;

struct Point{int x, y;};

int main()
{
    int N;
    cin >> N;
    Point a0;
    a0.x = 0;
    a0.y = 0;
    int t0 = 0;
    Point x;
    int i;
    for( i = 0;i<N;i++)
    {

        int t;
        cin >> t>>x.x>>x.y;
        int dt = t - t0;
        int dl = x.x +x.y-a0.x-a0.y;
        if(dl > dt)
        {
            cout << "No"<< endl;
            break;
        }
        if((dt-dl)%2 != 0)
        {
            cout <<"No"<<endl;
            break;
        }
        t0 = t;
        a0 = x;
    }
    if(i == N)
        cout <<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
m = n//2
INF = 10**18
dp = [defaultdict(lambda: -INF)for _ in range(n+2)]
for i, a in enumerate(map(int, input().split()), 2):
    for j in range(max(1, i//2-1), -(-i//2)+1):
        if j-1 == 0:
            dp[i-2][j-1] = 0
        dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+a)

print(dp[n+1][m])


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

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

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }

} 

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

class aizu_judge
{
    static void Main(string[] args)
    {
        while(true)
        {
            int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();


            if (num[0] + num[1] == 0)
                break;

            for (int i = 1; i <= num[0]; i++)
            {
                StringBuilder sb = new StringBuilder();
                for(int j = 1; j <= num[1]; j++)
                {
                    sb.Append((i + j) % 2 == 0 ? "#" : ".");
                }
                Console.WriteLine(sb.ToString());
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9388
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[5000];
        for (int i = 0 ; i < 5000 ; i++) {
            a[i] = i * (i + 1) / 2;
        }

        List<Integer> ans = new ArrayList<>();
        while (n > 0) {
            int i = 0;
            while (a[i] < n) {
                i++;
            }
            ans.add(i);
            n -= i;
        }
        for (int i = ans.size() - 1 ; i >= 0 ; i--) {
            System.out.println(ans.get(i));
        }



    }

    static void searchNum(int n, int[] a, List<Integer> ans) {
        int i = 0;
        while (a[i] <= n) {
            i++;
        }
        ans.add(i);
        n -= i;
    }

}

Measured memory_bytes: 22984
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Water Bottle
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const double PI = acos(-1.0);

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int aa = a * a;
  double s = (double)x / a;

  double th;
  if (a * b >= s * 2) {
    double y = s * 2 / b;
    th = atan2(y, b);
  }
  else {
    double y = b * 2 - s * 2 / a;
    th = atan2(a, y);
  }

  printf("%.10lf\n", 90.0 - th * 180 / PI);
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = list(map(int, list(input())))
S.reverse()

ans = []

i=0
while i < N:
  max = 0
  for j in range(1, M+1):
    if i + j < N+1:
      if S[i+j] == 0:
        max = j
  if max == 0:
    print(-1)
    exit()
  ans.insert(0, max)
  i += max
for i in ans:
  print(i,end=" ")

Measured memory_bytes: 89404
s = int(input())

a = list(map(int, input().split()))

count = 0
box = []


for i in range(s-1):
    if a[i] >= a[i+1]:
        count += 1
    else:
        count = 0
        
    box.append(count)
    
print(max(box)) if s >=2 else print(0)

Measured memory_bytes: 14224
#include<iostream>
#include<set>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
 
using namespace std;
 
inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
 
const int N=500009;
const int K=25;  

int n,k,ind[N];
int p[N],q[N];
int ch[N*K][2],cnt[N*K],tot;
set<int> f,b;
vector<int> g[N];
 
typedef set<int>::iterator it;
 
inline void add(int x,int v)
{
	int now=0;
	cnt[now]+=v;
	for(int i=K,nxt;i>=0;i--)
	{
		if(!ch[now][(nxt=((x>>i)&1))])
			ch[now][nxt]=++tot;
		now=ch[now][nxt];
		cnt[now]+=v;
	}
}

inline int ranks(int x)
{
	int now=0,ret=0;
	for(int i=K,nxt;i>=0;i--)
	{
		if((nxt=((x>>i)&1)) && ch[now][0])
			ret+=cnt[ch[now][0]];
		now=ch[now][nxt];
	}
	return ret+1;
}

inline int query(int kth)
{
	if(kth>cnt[0])return -1;
	int now=0,ret=0,f=0;
	for(int i=K,nxt;i>=0;i--)
	{
		if(ch[now][0] && cnt[ch[now][0]]>=kth)
			nxt=0;
		else
		{
			nxt=1;
			if(ch[now][0])
				kth-=cnt[ch[now][0]];
			ret|=(1<<i);
		}
		now=ch[now][nxt];
	}
	return ret;
}

int main()
{
	if(fopen("data.in","r"))
	{
		freopen("data.in","r",stdin);
		freopen("data.out","w",stdout);
	}

	n=read();
	k=read();
 
	for(int i=1;i<=n;i++)
		q[p[i]=read()]=i;

	memset(ch,0,sizeof(ch));
	memset(cnt,0,sizeof(cnt));
	tot=0;

	for(int i=1;i<k;i++)
		add(p[i],1);
	for(int i=1;i<=n;i++)
	{
		if(i+k-1<=n)
			add(p[i+k-1],1);
		if(i>1)
			add(p[i-1],-1);

		int las=query(ranks(p[i])+1);
		if(las!=-1)
			g[q[las]].push_back(i),ind[i]++;
	}

	memset(ch,0,sizeof(ch));
	memset(cnt,0,sizeof(cnt));
	tot=0;

	for(int i=1;i<=n;i++)
	{
		add(p[i],1);
		if(i>k)
			add(p[i-k],-1);

		int las=query(ranks(p[i])+1);
		if(las!=-1)
			g[q[las]].push_back(i),ind[i]++;
	}

/*	
	for(int i=1;i<k;i++)
		f.insert(p[i]);
	for(int i=1;i<=n;i++)
	{
		if(i+k-1<=n)
			f.insert(p[i+k-1]);
		if(i)
			f.erase(p[i-1]);
 
		b.insert(p[i]);
		if(i>k)
			b.erase(p[i-k]);
 
		it cur=f.upper_bound(p[i]);
		if(cur!=f.end())
			g[q[*cur]].push_back(i),ind[i]++,printf("1 %d:%d get %d\n",i,p[i],(*cur));
		cur=b.upper_bound(p[i]);
		if(cur!=b.end())
			g[q[*cur]].push_back(i),ind[i]++,printf("2 %d:%d get %d\n",i,p[i],(*cur));
	}
*/	

	f.clear();
	for(int i=1;i<=n;i++)
		if(!ind[i])
			f.insert(-i);
 
	int top=0;
	while(f.size())
	{
		int u=-(*f.begin());
		p[++top]=u;
		f.erase(f.begin());
		for(int i=0,ed=g[u].size();i<ed;i++)
			if(--ind[g[u][i]]==0)
				f.insert(-g[u][i]);
	}
 
	for(int i=1;i<=n;i++)
		q[p[i]]=n-i+1;
	for(int i=1;i<=n;i++)
		printf("%d\n",q[i]);
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

int N, K;
int p[1010];

int main() {
    cout << fixed << setprecision(15);
    cin >> N >> K;
    REP (i, N) cin >> p[i];
    sort(p, p+N);
    ll ans = 0;
    REP (i, K) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3652
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; print (sum [ 1 | x <- [a .. b],mod c x == 0])
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 4120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<bitset>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson i<<1,l,mid
#define rson i<<1|1,mid+1,r
#define llson j<<1,l,mid
#define rrson j<<1|1,mid+1,r
#define INF 0x7fffffff
#define maxn 110010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void radix(int *str,int *a,int *b,int n,int m)
{
    static int count[maxn];
    mem(count,0);
    for(int i=0; i<n; i++) ++count[str[a[i]]];
    for(int i=1; i<=m; i++) count[i]+=count[i-1];
    for(int i=n-1; i>=0; i--) b[--count[str[a[i]]]]=a[i];
}
void suffix(int *str,int *sa,int n,int m) //倍增算法计算出后缀数组sa
{
    static int Rk[maxn],a[maxn],b[maxn];
    for(int i=0; i<n; i++) Rk[i]=i;
    radix(str,Rk,sa,n,m);
    Rk[sa[0]]=0;
    for(int i=1; i<n; i++)
        Rk[sa[i]]=Rk[sa[i-1]]+(str[sa[i]]!=str[sa[i-1]]);
    for(int i=0; 1<<i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            a[j]=Rk[j]+1;
            b[j]=j+(1<<i)>=n?0:Rk[j+(1<<i)]+1;
            sa[j]=j;
        }
        radix(b,sa,Rk,n,n);
        radix(a,Rk,sa,n,n);
        Rk[sa[0]]=0;
        for(int j=1; j<n; j++)
            Rk[sa[j]]=Rk[sa[j-1]]+(a[sa[j-1]]!=a[sa[j]]||b[sa[j-1]]!=b[sa[j]]);
    }
}
void calcHt(int *str,int *sa,int *h,int *Rk,int n) //求出最长公共前缀数组h
{
    int k=0;
    h[0]=0;
    for(int i=0; i<n; i++) Rk[sa[i]]=i;
    for(int i=0; i<n; i++)
    {
        k=k==0?0:k-1;
        if(Rk[i])
            while(str[i+k]==str[sa[Rk[i]-1]+k]) k++;
        else k=0;
        h[Rk[i]]=k;
    }
}
int a[maxn],sa[maxn],Ht[maxn],Rk[maxn];
int v[maxn],Max[15],Min[15],r,n,len,j;
char s[10002];
bool judge(int m)
{
    mem(Max,0);mem(Min,100);
    for(int i=1; i<len; i++)
    {
        if(Ht[i]<m)
        {
            mem(Max,0);mem(Min,100);
            Max[v[sa[i]]]=sa[i];
            Min[v[sa[i]]]=sa[i];
        }
        else
        {
            Max[v[sa[i]]]=max(Max[v[sa[i]]],sa[i]);
            Min[v[sa[i]]]=min(Min[v[sa[i]]],sa[i]);
            Max[v[sa[i-1]]]=max(Max[v[sa[i-1]]],sa[i-1]);
            Min[v[sa[i-1]]]=min(Min[v[sa[i-1]]],sa[i-1]);
            for(j=1;j<=n;j++)
                if(Max[j]-Min[j]<m) break;
            if(j>n) return true;
        }
    }
    return false;
}
int binary()
{
    int ans=0,mid,l=0;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(judge(mid)) ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans;
}
int main()
{
    //freopen("1.txt","r",stdin);
    
        // scanf("%d",&n);
        len=r=j=0;
        n = 1;
        for(int i=1; i<=n; i++)
        {
            int len1;
            scanf("%d", &len1);
            scanf("%s",s);
            if(r<len1>>1) r=len1>>1;//二分上限
            for(int k=0; k<len1; k++)
                a[len+k]=s[k]+5,v[len+k]=i;//v记录在哪个串中
            a[len+len1]=++j;//字符串中间用没出现过的字符隔开
            v[len+len1]=0;
            len=len+len1+1;
        }
        len--;
        suffix(a,sa,len,256);
        calcHt(a,sa,Ht,Rk,len);
        printf("%d\n",binary());
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i]=='7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
string s;
int ope=0;
int main(void)
{
  cin >> s;
  while(int(s.size()>1))
    {
      //cout << s << endl;
      if(s[0]!=s[int(s.size()-1)] && s[0]!='x' && s[int(s.size()-1)]!='x')
	{
	  cout << -1 << endl;
	  return 0;
	}
      else
	{
	  if(s[0]!=s[int(s.size()-1)])
	    {
	      if(s[0]=='x')
		{
		  s.erase(s.begin());
		  ope++;
		}
	      else if(s[int(s.size()-1)]=='x')
		{
		  s.erase(s.begin()+int(s.size()-1));
		  ope++;
		}
	    }
	  else
	    {
	      s.erase(s.begin());
	      s.erase(s.begin()+int(s.size())-1);
	    }
	}
    }
  cout << ope << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, tmp;cin >>n;
    pair<pair<string,int>,int> cc[n];
    fo(i,n){
        cin >> cc[i].first.first ;
        cin >>tmp;
        cc[i].first.second = -tmp;
        cc[i].second = i+1;
    }
    sort(cc, cc+n);
    fo(i,n){
        cout << cc[i].second << "\n";
    }
}


Measured memory_bytes: 3520
#include "bits/stdc++.h"
#include <math.h>
using namespace std;
void solve(){
    long long x, y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << endl;
    }
    else{
        for(long long i = 1; i < y; i++){
            if(x * i % y != 0){
                cout << x * i << endl;
                break;
            }
        }
    }
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[0]/10%111==0 || A[0]%1000%111==0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> A, B;
  rep(i, N+1) { int tmp; cin >> tmp; A.push_back(tmp); }
  rep(i, N) { int tmp; cin >> tmp; B.push_back(tmp); }
  ll num = 0;
  rep(i, N) {
    if(A[i] >= B[i]) {
      A[i] -= B[i];
      num += B[i];
    } else {
      num += A[i];
      B[i] -= A[i];
      A[i] = 0;
      if(A[i+1] >= B[i]) {
        A[i+1] -= B[i];
        num += B[i];
      } else {
        num += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
#include<ctype.h>

int main(){
	int num,i;
	int counter[26]={0};
	char ch;
	int k = 26;
	
	while(scanf("%c",&ch) != EOF){
		num = -1;
		if(islower(ch)){
		num = ch -'a';
		}else if(isupper(ch)){
			num = ch -'A';
		}
		if(0<=num && num<=25){
			counter[num]++;
		}
	}
	for(i=0;i<k;i++){
		printf("%c : %d\n",'a'+i,counter[i]);
	}
}

Measured memory_bytes: 972
def bs(key):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if s[mid] == key:
            return True
        elif key < s[mid]:
            right = mid
        else:
            left = mid + 1
    return False


n = int(input())
*s, = map(int, input().split())
input()
*t, = map(int, input().split())
print(sum(bs(i) for i in t))



Measured memory_bytes: 16716
import sys
input = sys.stdin.readline
x,y,z,K=map(int,input().split())
listsa=list(map(int,input().split()))#長さはｘ
listsb=list(map(int,input().split()))#長さはy
listsc=list(map(int,input().split()))#長さはz
if x*y>3000:
    suballlist=[]
    for i in listsa:
        for j in listsb:
            suballlist.append(i+j)
    suballlist=sorted(suballlist,reverse=True)
    uselist=suballlist[:3000]
    alllist=[]
    
    for i in uselist:
        for j in listsc:
            alllist.append(i+j)
            
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])
    
elif x*y<=3000:
    alllist=[]
    for i in listsa:
        for j in listsb:
            for k in listsc:
                alllist.append(i+j+k)
                
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])


Measured memory_bytes: 163556
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
if n == 1:
    print("Hello World")
else:
    a = ni()
    b = ni()
    print(a + b)

Measured memory_bytes: 3060
n, a, b, c = [int(x) for x in input().split()]
l = [int(input()) for i in range(n)]


label = ['a', 'b', 'c', 'd']
list_init = []
for i in label:
    for j in label:
        list_init.append([i, j])

def extend(list):
    if n == 2:
        return list
    list_new = []
    for i in list[:]:
        for j in label:
            i.append(j)
            list_new.append(i[:])
            i.pop()
    if len(list_new[0]) == n:
        return list_new
    else:
        return extend(list_new[:])

list_created = extend(list_init[:])
mp = []
INF = 10 ** 9
for i in list_created:
    s = set(i)
    try: s.remove('d')
    except KeyError: pass
    if len(s) < 3:
        mp.append(INF)
        continue

    la, lb, lc = 0, 0, 0
    na, nb, nc = 0, 0, 0
    for j in range(len(i)):
        if i[j] == 'a':
            la += l[j]
            na += 1
        elif i[j] == 'b':
            lb += l[j]
            nb += 1
        elif i[j] == 'c':
            lc += l[j]
            nc += 1
    mp.append(abs(la-a) + abs(lb-b) + abs(lc-c) + 10*(na + nb + nc - 3))

print(min(mp))



Measured memory_bytes: 17596
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(line){
	before(line);
});

var log = console.log;
function before(line){
	var lines = line.split("\n");
	lines = lines.filter(function(e){
		return (e !== "");
	});
	main(lines);
}

//-----------
function main(lines){
	const tpl = lines[0].split(" ");
	const a = Number(tpl[0]);
	const b = Number(tpl[1]);
	log(a*b + " " + 2*(a+b));
}

Measured memory_bytes: 15492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int inf=1e9,N=100005,M=400005;
int ne=1,nxt[M],son[N],ed[M],di[M],d[N],q[N],ans[M>>1],an[N];
bool cmp(int a,int b){
	return d[a]<d[b];
}
void GG(){
	puts("-1"); exit(0);
}
void ae(int a,int b){
	nxt[++ne]=son[a]; son[a]=ne; ed[ne]=b;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),m=read();
	For(i,1,n)d[q[i]=i]=read();
	For(i,1,m){
		int s=read(),t=read();
		ae(s,t); ae(t,s);
	}
	sort(q+1,q+n+1,cmp);
	For(i,1,m)ans[i]=inf;
	memset(an,-1,sizeof(an));
	For(o,1,n){
		int i=q[o]; if(an[i]!=-1)continue;
		for(int j=son[i];j;j=nxt[j]){
			int t=ed[j];
			if(d[t]<d[i]){
				an[i]=an[t];
				ans[j/2]=d[i]-d[t];
				break;
			}else if(d[t]==d[i]){
				if(an[t]==-1)an[t]=0;
				an[i]=an[t]^1;
				ans[j/2]=d[i];
				break;
			}
		}
		if(an[i]==-1)GG();
	}
	For(i,1,n)if(an[i])putchar('B'); else putchar('W'); puts("");
	For(i,1,m)writeln(ans[i]);
}
/*
0 1 1 0
0 0 1 1 1 0 1 '

*/

Measured memory_bytes: 8984
#include <iostream>
using namespace std;
long long a,b,c,d,n;
int main(void){
   cin>>a>>d>>n>>b>>c>>n>>n;
   n=a%2+b%2+c%2;
   if(a*b*c){
       if(n==0||n==3)n=0;
       else n=1;
   }
   cout<<a+b+c+d-n;
}

Measured memory_bytes: 256