akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
//cout << "Yes" << endl;
//cout << "No" << endl;
int seiyaku_check(long i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
	}
}

int main(){
	
	string a,b;
	
	cin >> a >> b;
	
	seiyaku_check(a.length(),1,100);
	seiyaku_check(b.length(),1,100);
	
	cout << b << a << endl;
	
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;




long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N;
	cin>>N;
	vector<long long>v(N);
	long long rednum=0;
	set<long long>set;
	for(int i=0;i<N;i++){
		cin>>v[i];
		if(v[i]>=3200)rednum++;
		else set.insert(v[i]/400);
	}
	cout<<max(1LL,(long long)set.size())<<endl;
	cout<<(long long)set.size()+rednum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B, C, D; cin >> A >> B >> C >> D;

	bool T[101], S[101];
	rep(i, 0, 101) {
		S[i] = false;
		T[i] = false;
	}

	rep(i, 0, 101) {
		if (A <= i && i <= B) S[i] = true;
		if (C <= i && i <= D) T[i] = true;
	}

	int time = 0;
	rep(i, 0, 101) {
		if (T[i] && S[i])time++;
	}

	cout << ((time > 0) ? time - 1 : time) << endl;
	return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var L = one[2];
  var kyori = new Array(N);
  var max = Math.pow(10,15);
  for(var i = 0; i < N; i++){
    kyori[i] = new Array(N).fill(max);
    kyori[i][i] = 0;
  }
  var list = new Array(M);
  for(var i = 0; i < M; i++){
    list[i] = nextIntArray();
    kyori[list[i][0] - 1][list[i][1] - 1] = list[i][2];
    kyori[list[i][1] - 1][list[i][0] - 1] = list[i][2];
  }
  for(var k = 0; k < N; k++){
    for(var i = 0; i < N; i++){
      for(var j = 0; j < N; j++){
        if(kyori[i][j] > kyori[i][k] + kyori[k][j]){
           kyori[i][j] = kyori[i][k] + kyori[k][j];
        }
      }
    }
  }
  var count = new Array(N);
  for(var i = 0; i < N; i++){
    count[i] = new Array(N).fill(max);
    for(var j = 0; j < N; j++){
      if(kyori[i][j] <= L){
        count[i][j] = 1;
      }else{
        count[i][j] = max;
      }
    }
    count[i][i] = 0;
  }
  for(var k = 0; k < N; k++){
    for(var i = 0; i < N; i++){
      for(var j = 0; j < N; j++){
        if(count[i][j] > count[i][k] + count[k][j]){
           count[i][j] = count[i][k] + count[k][j];
        }
      }
    }
  }
  //myerr(kyori);
  //myerr(count);
  var Q = nextInt();
  var output = new Array(Q);
  for(var i = 0; i < Q; i++){
    var query = nextIntArray();
    query[0]--;
    query[1]--;
    var getCount = count[query[0]][query[1]];
    if(getCount >= max){
      getCount = 0;
    }
    output[i] = getCount - 1;
  }
  myout(myconv(output,9));
}

Measured memory_bytes: 53484
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,a,b;cin>>n>>a>>b;
    vll v(n);rep(i,n)cin>>v[i];
    sort(all(v));reverse(all(v));
    bool only=true;int last=0;
    ll sum=v[0];
    rep2(i,1,a){
        sum+=v[i];
        if(v[i]!=v[i-1]){
            only=false;
            last=i;
        }
    }
    vvll dp(n+1,vll(n+1));//dp[i][j]=iCj
    rep(i,n+1)dp[i][0]=(ll)1;
    rep2(i,1,n+1)rep2(j,1,n+1)dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
    int res=(ll)0;ll ans=(ll)0;
    if(only){
        rep(i,n)if(v[i]==v[0])res++;
        rep2(i,a,min(b,res)+1)ans+=dp[res][i];
    }
    else{
        rep(i,n)if(v[i]==v[a-1])res++;
        ans=dp[res][a-last];
        //cout<<a-last<<" "<<res<<endl;
    }
    decp(10);
    double av=(double)sum/(double)a;
    cout<<av<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 3824
#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

bool isPrime(int z){
    int S=sqrt(z);
    int f=0;
    for (int p = 2; p <= S; p++) {
        if(z%p==0){return false;}
    }
    if(f==0){
        return true;
    }
    return false;
}

int main()
{   int n, i, count;
    while(true){
        if(!(cin >> n))exit(0);
        int x[n];
        count = 0;
        for(i=0;i<n;i++)cin>>x[i];
        for(i=0;i<n;i++){
            count += isPrime(x[i]);
        }
        cout << count << endl;
    }    
    return 0;
}



Measured memory_bytes: 3108
from collections import Counter
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

L.sort(key=lambda x: x[0])

ans = []
for i in range(M):
    if (L[i][0] == 1):
        ans.append(L[i][1])

    if (L[i][1] == N):
        ans.append(L[i][0])

c = Counter(ans)
for i, v in c.items():
    if (v >= 2):
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


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

namespace _0625
{
	class Program
	{
		static void Main(string[] args)
		{
			long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long[] dp = new long[x[0] + 1];
			for (int i = 1; i <= x[0]; i++) dp[i] = long.MaxValue;
			long[] oranges = new long[x[0]];
			for (int i = 0; i < x[0]; i++) oranges[i] = long.Parse(Console.ReadLine());
			for (int i = 1; i <= x[0]; i++)
			{
				long min = long.MaxValue; long max = 0;
				for (int j = 1; j <= Math.Min(i, x[1]); j++)
				{
					min = Math.Min(min, oranges[i - j]); max = Math.Max(max, oranges[i - j]);
					dp[i] = Math.Min(dp[i], dp[i - j] + x[2] + j * (max - min));
				}
			}
			Console.WriteLine(dp[x[0]]);
		}
	}
}


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

int main()
{
    int a,b,c,x,sum=0;
    cin >> a >> b >> c >> x;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if((i*500+j*100+k*50) == x){
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.awt.geom.*;
import java.util.*;

public class Main{
	
	public class Circle{
		Point2D p;
		double r;
		public Circle(Point2D p, double r) {
			this.p = p; this.r = r;
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Circle [] cs = new Circle[n];
			for(int i = 0; i < n; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				int r = sc.nextInt();
				cs[i] = new Circle(new Point2D.Double(x, y), r);
			}
			int m = sc.nextInt();
			while(m-- > 0){
				int x1 = sc.nextInt();
				int y1 = sc.nextInt();
				int x2 = sc.nextInt();
				int y2 = sc.nextInt();
				boolean issafe = false;
				for(int i = 0; i < n; i++){
					boolean in1 = isin(x1,y1, cs[i]);
					boolean in2 = isin(x2,y2,cs[i]);
					if(in1 && in2){
						issafe = false;
					}
					else if(in1 || in2){
						issafe = true;
						break;
					}
					else{
						Line2D l = new Line2D.Double(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
						double dis = l.ptSegDist(cs[i].p);
						if(dis <= cs[i].r){
							issafe = true;
							break;
						}
						else{
							issafe = false;
						}
					}
				}
				if(issafe){
					System.out.println("Safe");
				}
				else{
					System.out.println("Danger");
				}
			}
		}
	}
	
	private boolean isin(int x1, int y1, Circle c) {
		double dis = Point2D.distance(x1, y1, c.p.getX(), c.p.getY());
		if(dis <= c.r){
			return true;
		}
		return false;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 25896
from math import atan
from math import pi

a, b, x = map(int, input().split())

if a * a * b / 2 <= x:
    ans = atan((2 * b) / a - 2 * x / (a ** 3))
    ans = ans * 180 / pi
else:
    ans = atan(2 * x / (a * (b ** (2))))
    ans = ans * 180 / pi
    ans = 90 - ans
print(ans)


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

int main() {
	int n,m;
	cin >> n;
	int t[n];
	for(int i=0;i<n;i++){
		cin >> t[i];
	}
	cin >> m;
	int p[m],x[m];
	for(int i=0;i<m;i++){
		cin >> p[i] >> x[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		sum=sum+t[i];
	}
//	cout << sum << endl;
	for(int i=0;i<m;i++){
		cout << sum-(t[p[i]-1]-x[i]) << endl;
	}
	
	
	
	
	
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  string a, s, c;
  cin >> a >> s >> c;
  cout << "A" << s[0] << "C" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int c[]=new int[26];
		int s[][] = new int[D][26];
		for (int i = 0; i < 26; i++) {
			c[i]=sc.nextInt();
		}
		for (int i = 0; i < D; i++) {
			for (int j = 0; j < 26; j++) {
				s[i][j]=sc.nextInt();
			}
		}
		int mannzokudo = 0;
		int last[]=new int[26];
		for (int i = 0; i <26; i++) {
			last[i]=0;
		}
		for (int d = 1; d <D+1; d++) {
			int test = 0;
			for(int t=0;t<26;t++){
				int mannzokudotest=0;
				int lasttest[]=last.clone();
				mannzokudotest=mannzokudotest+s[d-1][t];
				lasttest[t]=d;
				for (int j = 0; j < 26; j++) {
					mannzokudotest=mannzokudotest-c[j]*(d-last[j]);
				}
				if(t==0){mannzokudo=mannzokudotest;}
				if(mannzokudotest>mannzokudo){
					mannzokudo=mannzokudotest;
					test=t;}
				lasttest=last;
				}
			System.out.println(""+(test+1));
			last[test]=d;
			mannzokudo=0;
		}
	}
}

Measured memory_bytes: 49732
# -*- coding: utf-8 -*-
"""
A - CF
https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_a

"""
import sys


import re

def solve(s):
    if re.search(r'C.*F', s):
        return 'Yes'
    return 'No'


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

ans_list = [1]
history_list = [0 for _ in range(N)]
before_town = 1
loop_start_town = 10 ** 10
for i in range(N):
    now_town = A_list[before_town - 1]
    if history_list[now_town - 1] == 1:
        break
    ans_list.append(now_town)
    before_town = now_town

if len(ans_list) > K:
    print(ans_list[K])
else:
    loop_start_idx = ans_list.index(A_list[ans_list[-1] - 1])
    loop_len = len(ans_list)
    ans_list = ans_list[loop_start_idx:]
    mod_num = (K - loop_len) % (loop_len - loop_start_idx)
    print(ans_list[mod_num])

Measured memory_bytes: 32376
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//詰みの状態
//abab ac aba
//両端違うのは文字列の長さが偶数、両端同じパターンは奇数

//A,Bが交互に-1ずつしていくので同じ人間がずっと同じ偶奇がずっと同じ

int main() {
	string s; cin >> s;
	if (s[0] == s[s.length() - 1]) {
		if (s.length() % 2 == 1) puts("Second");
		else puts("First");
	}
	else {
		if (s.length() % 2 == 0) puts("Second");
		else puts("First");
	}
	return 0;
	return 0;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun pow(a: Int, p: Int): Long = pow(a.toLong(), p)
    fun pow(a: Long, p: Int): Long = when {
        p == 0 -> 1L
        p % 2 == 1 -> a * pow(a, p - 1)
        else -> {
            val half = pow(a, p / 2)
            half * half
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        pw.println(1900 * pow(2, M) * M + 100 * pow(2, M) * (N - M))
    }
}


Measured memory_bytes: 31264
// Problem : C - gacha
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define pb push_back
#define vi vector<int>


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	map<string,int>m;
	string s;
	while(n--)
	{
		cin>>s;
		m[s]++;
	}
	cout<<m.size()<<"\n";
   	return 0;
}



Measured memory_bytes: 19288
N = int(input())
bucket = [[0] * 10 for _ in range(10)]

for n in range(1, N + 1):
    n = str(n)
    bucket[int(n[0])][int(n[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += bucket[i][j] * bucket[j][i]

print(ans)

Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int maxn= 1e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;

int a[200];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int minnum=999999,maxnum=0;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
        minnum=min(minnum,a[i]);
        maxnum=max(maxnum,a[i]);
    }
    ll cnt=1e18;
    for(int i=minnum;i<=maxnum;i++)
    {
        ll ans=0;
        for(int j=1;j<=n;j++)
        {
            ans+=(i-a[j])*(i-a[j]);
        }
        if(ans<cnt)
        {
            cnt=ans;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<climits>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 405
#define Inf 1000000000005

int n;
ll arr[MAX];
ll dp[MAX][MAX]={0};

ll solve(){
    for(int d=1; d<n; d++){
        int i=0, j=d;
        while(j<n){
            ll ans = LLONG_MAX;
            for(int k=i; k<j; k++){
                ans = min(ans, dp[i][k]+dp[k+1][j]+(arr[j]-(i>0?arr[i-1]:0)));
            }
            dp[i][j]=ans;
            i++;
            j++;
        }
    }
    return dp[0][n-1];
}

int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(i>0) arr[i] += arr[i-1];
    }
    cout<<solve()<<endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;


void solve(long long N, ll K, vector<long long> h){
    vector<ll> dp(N+K+100, INF);

    // initial point
    dp[0] = 0;

    if (K >= N) {
        K = N;
    }
    for (ll i = 0; i < N; ++i) {
        for (ll k = 1; k <= K; ++k) {
            chmin(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << dp[N-1] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    vector<long long> h(N);
    for(ll i = 0 ; i < N ; i++){
        cin >> h[i];
    }
    solve(N, K, move(h));
}


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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, a, b;
  cin >> k >> a >> b;
  if (k <= a || a + 2 >= b) {
    cout << k + 1 << '\n';
    return 0;
  }
  ll ans = a + (k - a + 1) / 2 * (b - a);
  if ((k - a + 1) % 2 == 1) ans++;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3588
# AGC 011 B - Colorful Creatures
from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[0]+a
b=list(accumulate(a))
# print('a:',a)
# print('b:',b)
cnt=0
for i in range(n-1):
    if a[i+1]>2*b[i]:
        cnt=i+1
print(n-cnt)

Measured memory_bytes: 14428
# coding: utf-8
while True:
    line = input().rstrip().split()
    a = int(line[0])
    op = line[1]
    b = int(line[2])
    if op == '?':
        break
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)


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

using namespace std;

string a = "abc";
int cnt[150];
main ()
{
    string s;
    cin >> s;
    int n = s.size();
    s = ' ' + s;
    string ans = s;
    for( int i = 1; i <= n; i++ )
    {
        cnt[s[i]]++;
    }
    if( abs(cnt['a'] - cnt['b'] ) > 1 || abs( cnt['c'] - cnt['b'] ) > 1 || abs( cnt['a'] - cnt['c']) > 1 )
    {
        puts("NO");
        return 0;
    }
    puts("YES");
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   if(s[3]==s[2]&&s[4]==s[5]) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

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

	if (A*B % 2 == 0)printf("Even");
	else printf("Odd");





}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a;
    cin>>a;
    int tp=a/100;
    int op=a%100;
    if(tp<=12&&tp>=1)
    {
        if(op<=12&&op>=1)
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        else
        {
            cout<<"MMYY"<<endl;
        }
    }
    else
    {
        if(op<=12&&op>=1)
        {
            cout<<"YYMM"<<endl;
        }
        else
        {
            cout<<"NA"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N;
vector<ll> A, B;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N + 1);
  for (int i = 0; i < N + 1; i++) {
    cin >> A[i];
  }
  B.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  ll ans = 0;
  ll r = 0;
  for (int i = 0; i < N; i++) {
    ll a = A[i];
    ll b = B[i];
    ans += min(r, a);
    a -= r;
    if (a > 0) {
      ans += min(b, a);
      b -= a;
      if (b > 0) {
        r = b;
      } else {
        r = 0;
      }
    } else {
      r = b;
    }
  }
  ans += min(r, A[N]);

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

Measured memory_bytes: 1792
#include <set>
#include <map>
#include <list>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int maxn = 1e6 + 7;
const LL INF = 1e18;

int main() {
    int n,m;
    cin >> n >> m;
    if(n < m) {
        for(int i = 1 ; i <= m ; i++) cout << n;
        cout << endl;
    } else {
        for(int i = 1 ; i <= n ; i++) cout << m;
        cout << endl;
    }
    return 0;
}


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

  while (true) {
    int n, m;
    cin >> m >> n;
    if (n == 0)
      break;
    b = bitset<8000000>(0);
    int c = 0;
    for (ll i = m; true; i++) {
      if (!b[i]) {
        c++;
        if (c > n) {
          cout << i << endl;
          break;
        }
        for (ll j = 1; j * i < 8000000; j++) {
          b[i * j] = true;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 5084
#include <cstdio>
#include <algorithm>
#define N 100003
#define IL inline
#define REP(a,b,c) for(a=b;a<=c;a++)
using namespace std;
int n,a[N];
IL int rd(){
	int res=0;char c;while((c=getchar())<'0'||c>'9');
	while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res;
}
IL bool cmp(int a,int b){return a>b;}
int main(){
  n=rd();int i,l,r;REP(i,1,n)a[i]=rd();sort(a+1,a+1+n,cmp);
	l=2,r=n+1;while(l!=r)i=(l+r-1)>>1,i>a[i]?r=i:l=i+1;
	bool res=1;for(l=r;a[l]==r-1;l++)res^=1;
	res&=(a[r-1]-r+2)&1;printf(res?"Second":"First");
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

struct UnionFind {
	vi root;
	vi sizes;

	UnionFind(int max) : root(max), sizes(max, 1) {
		REP(i, max) {
			root[i] = i;
		}
	}

	int find(int x) {
		if (x == root[x]) return x;

		return root[x] = find(root[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		assert(sizes[x]);
		assert(sizes[y]);

		if (x == y)return;

		if (sizes[x] < sizes[y]) swap(x, y);

		root[y] = x;
		sizes[x] += sizes[y];

		sizes[y] = -1;
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return sizes[find(x)];
	}

};


void solve(long long N, long long K, long long L, vector<long long> p, vector<long long> q, vector<long long> r, vector<long long> s){
	UnionFind uf_k(N + 1000);
  UnionFind uf_l(N + 1000);
  map<string,int> count;
  
  REP(i,K){
    uf_k.unite(p[i], q[i]);
  }
  
  REP(i,L){
    uf_l.unite(r[i], s[i]);
  }
  
  REP(i,N){
    string key = to_string(uf_k.find(i));
    key += " "+to_string(uf_l.find(i));
    count[key]++;
  }
  
  REP(i,N){
    string key = to_string(uf_k.find(i));
    key += " "+to_string(uf_l.find(i));
    cout << count[key];
    if(i != N-1) cout << " ";
  }
  
  cout << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long K;
	long long L;
	long long N;
	cin >> N;
	cin >> K;
	vector<long long> p(K-1+1);
	vector<long long> q(K-1+1);
	cin >> L;
	vector<long long> r(L-1+1);
	vector<long long> s(L-1+1);
	for(int i = 0 ; i <= K-1 ; i++){
		cin >> p[i];p[i]--;
		cin >> q[i];q[i]--;
	}
	for(int i = 0 ; i <= L-1 ; i++){
		cin >> r[i];r[i]--;
		cin >> s[i];s[i]--;
	}
	solve(N, K, L, p, q, r, s);
	return 0;
}


Measured memory_bytes: 29696
#include <stdio.h>

int main() {
	double x1, x2, x3, x4, y1, y2, y3, y4;
	int n;

	int i;


	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);

		if((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3))
			printf("NO\n");
		else
			printf("YES\n");
	}

	return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par;
    UnionFind(int size) : par(size, -1) {}
    bool unionSet(int x, int y) {
        x = root(x);
        y = root(y);
        if(x != y) {
            if(par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
        }
        return x != y;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    int size(int x) { return -par[root(x)]; }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, M;
    cin >> N >> M;
    pair<int, int> Edges[M];
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Edges[i] = make_pair(a, b);
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        UnionFind UF(N);
        for(int j = 0; j < M; j++) {
            if(i == j)
                continue;
            int a, b;
            tie(a, b) = Edges[j];
            UF.unionSet(a, b);
        }
        bool isok = true;
        for(int j = 0; j < N; j++) {
            for(int k = j + 1; k < N; k++) {
                isok &= UF.same(j, k);
            }
        }
        ans += !isok;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
X, K, D = gets.chomp.split(' ').map(&:to_i)
X = X.abs

if X/D > K
  ans = X - D * K 
elsif (K - X/D) % 2 == 0
  ans = X - X/D*D
else
  ans = (X - X/D*D - D) * -1
end

puts ans

Measured memory_bytes: 14308
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), res(n);
  ll ans1 = 0;
  ll ans2 = 0;
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  res[0] = -1;
  res[n - 1] = -1;
  if(n % 2 == 0)res[n-1] = 1;
  int plus = 1;
  for (int i = 1; i < n - 1; i++){
    if(plus)res[i] = 2;
    else res[i] = -2;
    plus = plus ^ 1;
  }
  sort(ALL(res));
  rep(i, n){
    ans1 += a[i] * res[i];
  }
  rep(i, n){
    ans2 += -1 * a[i] * res[n - 1 - i];
  }
  cout << max(ans1, ans2) << endl;
}

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

// why am I so weak

void print(char ch, string s) {
	printf("%c %s\n", ch, s.c_str());
	fflush(stdout);
}
void print(char ch, long long x) {
	printf("%c %lld\n", ch, x);
	fflush(stdout);
}
int main() {
	print('?', "100000000000");

	{
		char wtf;
		scanf("\n%c", &wtf);

		if (wtf == 'Y') {
			long long res = 2;

			while (true) {
				print('?', 1ll * res);

				char ch;
				scanf("\n%c", &ch);

				if (ch == 'Y') {
					print('!', 1ll * res / 2);
					return 0;
				}

				res *= 10;
			}
		}
	}

	long long s = 1;

	while (true) {
		print('?', s);

		char ch;
		scanf("\n%c", &ch);

		if (ch == 'N') break;

		s *= 10;
	}

	long long lb = s / 10, ub = s;

	while (ub - lb > 1) {
		long long mid = (ub + lb) >> 1;

		print('?', mid * 10);

		char ch;
		scanf("\n%c", &ch);

		if (ch == 'Y') {
			ub = mid;
		} else lb = mid;
	}

	print('!', ub);

	return 0;
}


Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
    char *T;
    T = (char *)malloc(sizeof(char)*200000);

    scanf("%s",T);
    //printf("%s\n",T);

    int i = 0;
    /*
    int pd = 0;
    while(T[i]!='0'){
        if(T[i]=='D'||){
            pd++;
            if(i-1<0){
                if(T[i-1]=='P')pd++;
            }
        }
    }
    */
       //printf("%d\n",pd);

    while(T[i]!='\0'){
        if(T[i]=='?')T[i]='D';
        i++;
    }
    
    printf("%s\n",T);

    return 0;
}

Measured memory_bytes: 1852
from itertools import product as p

N = int(input())
*V, = map(int, input().split())
*C, = map(int, input().split())

ans = -10**12
for i in p(range(2), repeat=N):
    X, Y = 0, 0
    for j, k in enumerate(i):
        if k==1:
            X += V[j]
            Y += C[j]
    ans = max(ans, X-Y)
print(ans)

Measured memory_bytes: 73284
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

ans = 0
now = -1

li.sort(key = lambda x:x[1])

for i in range(m):
    if li[i][0] <= now and li[i][1] > now:
        pass
    else:
        ans += 1
        now = li[i][1] - 1

print(ans)


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

using namespace std;

int main() {
  int N, C, K, T, t, c{}, ans{};
  cin >> N >> C >> K;
  priority_queue<int, vector<int>, greater<int>> q;
  while(cin >> T) q.push(T);
  t = -K;
  while(!q.empty()) {
    int x = q.top();
    q.pop();
    if (x > t+K || c == C) {
      ++ans;
      t = x;
      c = 0;
    }
    ++c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3844
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read4();
      Read2();
for(int i=0;i<N;i++){
if(s[i]>=K)result++;


}
        

        Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}

Measured memory_bytes: 16736
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef pair<string, int> psi;

bool check(string worm) {
    for (int i = 1; i < worm.size(); i++) {
        if (worm[i] != worm[i-1]) return false;
    }
    return true;
}

char change_color(char a, char b) {
    char c;
    if (a == 'r') {
        if (b == 'g') c = 'b';
        else c = 'g';
    }
    if (a == 'g') {
        if (b == 'r') c = 'b';
        else c = 'r';
    }
    if (a == 'b') {
        if (b == 'r') c = 'g';
        else c = 'r';
    }
    return c;
}

int solve(string worm) {
    int ans = -1;
    map<string, int> memo;
    queue<psi> Q;

    Q.push(make_pair(worm, 0));
    while(!Q.empty()) {
        psi now = Q.front(); Q.pop();
        if (check(now.first)) {
            return now.second;
        }
        if (memo[now.first]) continue;
        memo[now.first] = now.second;

        for (int i = 1; i < now.first.size(); i++) {
            if (now.first[i] == now.first[i-1]) continue;
            char color = change_color(now.first[i-1], now.first[i]);
            string next = now.first;
            next[i-1] = next[i] = color;

            Q.push(make_pair(next, now.second + 1));
        }
    }
    return ans;
}


int main() {
    string worm;
    while(cin >> worm) {
        if (worm == "0") break;
        int ans = solve(worm);
        if (ans == -1)
            cout << "NA" << endl;
        else
            cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 5204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        v: [chars; h]
    }
    let mut g: Vec<Vec<usize>> = vec![Vec::new(); h * w];
    for i in 0..h {
        for j in 0..w - 1 {
            if v[i][j] != v[i][j + 1] {
                g[w * i + j].push(w * i + j + 1);
                g[w * i + j + 1].push(w * i + j);
            }
        }
    }
    for i in 0..h - 1 {
        for j in 0..w {
            if v[i][j] != v[i + 1][j] {
                g[w * i + j].push(w * i + j + w);
                g[w * i + j + w].push(w * i + j);
            }
        }
    }
    let mut done = vec![false; h * w];
    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            let n = w * i + j;
            if done[n] {
                continue;
            }
            done[n] = true;
            let (bc, wc) = dfs(&g, n, 0, &mut done);
            ans += bc * wc;
        }
    }
    println!("{}", ans);
}

fn dfs(g: &Vec<Vec<usize>>, r: usize, t: usize, mem: &mut Vec<bool>) -> (usize, usize) {
    let mut bc = 0;
    let mut wc = 0;
    if t == 0 {
        bc += 1;
    } else {
        wc += 1;
    }
    for &c in g[r].iter().clone() {
        if mem[c] {
            continue;
        }
        mem[c] = true;
        let (bt, wt) = if t == 0 {
            dfs(g, c, 1, mem)
        } else {
            dfs(g, c, 0, mem)
        };
        bc += bt;
        wc += wt;
    }
    (bc, wc)
}


Measured memory_bytes: 29564
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int n;

    scanf("%d",&n);
    int sum=1;
    for(int i=0; i<n; i++)
    {
        int a;
        scanf("%d",&a);
        if(a%2==0)
            sum*=2;
    }
    printf("%d\n",(int)pow(3,n)-sum);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int x,y,z;
  int temp1,temp2;
  scanf("%d%d%d",&x,&y,&z);
  temp1 = x;
  x = y;
  y= temp1;
  
  temp2 = x;
  x = z;
  z = temp2;
  printf("%d %d %d",x,y,z);
  
  return 0;
}

Measured memory_bytes: 1732
X = int(input())

if X>=400 and X<=599:
    print('8')
elif X>=600 and X<=799:
    print('7')
elif X>=800 and X<=999:
    print('6')
elif X>=1000 and X<=1199:
    print('5')
elif X>=1200 and X<=1399:
    print('4')
elif X>=1400 and X<=1599:
    print('3')
elif X>=1600 and X<=1799:
    print('2')
elif X>=1800 and X<=1999:
    print('1')

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

int main() {
int a, b, c, d;
  cin >>a >>b >>c >>d;
if (a+b==c+d){
  cout << "Balanced";
}
  else if(a+b>=c+d){
  cout << "Left";
}
   else if(c+d>=a+b){
  cout << "Right";
}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,k;
char s[11][1010];
int cnt[11];
int solve(int x)
{
	int ans=0;
	for(int i=1;i<n;i++)
		if(x&(1<<(i-1)))ans++;
	memset(cnt,0,sizeof(cnt));
	for(int j=0;j<m;j++)
	{
		int num=0;
		cnt[num]+=s[0][j]-'0';
		for(int i=1;i<n;i++)
		{
			if(x&(1<<(i-1)))num++;
			cnt[num]+=s[i][j]-'0';
		}
		bool flag=false;
		for(int i=0;i<=num;i++)
			if(cnt[i]>k)flag=true;
		if(flag){
			ans++;
			memset(cnt,0,sizeof(cnt));
			num=0;cnt[num]+=s[0][j]-'0';
			for(int i=1;i<n;i++)
			{
				if(x&(1<<(i-1)))num++;
				cnt[num]+=s[i][j]-'0';
			}
			for(int i=0;i<=num;i++)
				if(cnt[i]>k)return 1e9;
		}
	}
	return ans;
}
int main()
{
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	int ans=1e9;
	for(int x=0;x<(1<<(n-1));x++)
		ans=min(ans,solve(x));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
N = int(input())
A = [int(input()) for i in range(N)]
A = [-a for a in A]

X = []
for a in A:
    i = bisect_right(X, a)
    if i == len(X):
        X.append(a)
    else:
        X[i] = a


print(len(X))


Measured memory_bytes: 11052
#include<iostream>
#include<fstream>

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  int N;
  std::string S, tmp_str;
  std::cin >> N;
  std::cin >> S;
  int cnt = 0;

  for(int i = 0; i < N-2; i++){
    tmp_str = S.substr(i, 3);
    //std::cout << tmp_str << std::endl;
    if(tmp_str == "ABC"){
      cnt++;
    }

  }
  std::cout << cnt << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
	int s[1];
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		s[0] = 1;
	}
	else {
		if (a == b) {
			s[0] = 2;
		}
		if (b == c) {
			s[0] = 2;
		}
		if (a==c){
			s[0] = 2;
		}
		if (a != b && a != c && b != c) {
			s[0] = 3;
		}
	}
	cout << s[0] << endl;
	return 0;
}


Measured memory_bytes: 256
import math
l,r=map(int,input().split())

t=r
c=0
while(t!=0):
    c+=1
    t//=2
LIST=[0]*c

if(c==0):
    print(0)
    exit()

l=l-1

t1=math.ceil(l/2)
t2=math.ceil(r/2)
LIST[-1]=((t2-t1)%2)*(2**(0))

for i in range(2,c+1):
    k=(l-(l//2**i)*(2**i))+1
    t1=max(k-((2**i)//2),0)

    k=(r-(r//2**i)*(2**i))+1
    t2=max(k-((2**i)//2),0)
 
    LIST[-i]=((t2-t1)%2)*(2**(i-1))

print(sum(LIST))

Measured memory_bytes: 3064
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64 c:i64 d:i64));
    if (a - c).abs() <= d || ((a - b).abs() <= d && (c - b).abs() <= d) {
        "Yes"
    } else {
        "No"
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4 7 9 3" => "Yes",
    test2: "100 10 1 2" => "No",
    test3: "10 10 10 1" => "Yes",
    test4: "1 100 2 10" => "Yes",
}


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

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int x, res = 0;
    cin >> x;   
    int y = x / 500;
    res += 1000 * y;
    x -= 500 * y;
    y = x / 5;
    res += 5 * y;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3584
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in reversed(range(a + 1)):
    for j in reversed(range(b + 1)):
        for k in reversed(range(c + 1)):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1

print(ans)

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

int main()
{
  int n, ans{0};
  string a, b, c;
  cin >> n >> a >> b >> c;
  for (auto i = 0; i < n; i++) {
    set<char> s{a[i], b[i], c[i]};
    ans += s.size() - 1;
  }
  cout << ans << endl;
}


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

int *a, n;
long long ans = 0;

int main() {
  scanf("%d", &n);
  n *= 3;
  a = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  std::sort(a, a + n);
  for (int i = 0, j = n - 2; i < n / 3; ++i, j -= 2) {
    ans += a[j];
  }
  printf("%lld\n", ans);
  return 0;
}

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

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

    vector<int> cnt(1e5 + 2, 0);
    int ai;
    for (int i = 0; i < N; i++)
    {
        cin >> ai;
        cnt.at(ai) += 1;
        cnt.at(ai + 1) += 1;
        cnt.at(ai + 2) += 1;
    }
    int res = 0;
    for (int i = 0; i < 1e5 + 2; i++)
    {
        res = max(res, cnt.at(i));
    }
    cout << res << endl;
}

Measured memory_bytes: 640
// keyence2020_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    
    vector<pll> vec(N);
    rep(i, N) {
        ll f, s;
        cin >> f >> s;
        vec[i].first = f+s;  // アームの終端
        vec[i].second = f-s;
    }
    sort(vec.begin(), vec.end());
    
    // calculation
    ll res = 0, last = -INF;
    rep(i, N) {
        if (last <= vec[i].second) {
            res++;
            last = vec[i].first;
        }
    }
    
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 1792