akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"

using namespace std;

int main()
{
  int a, b;
  std::cin >> a >> b;
  bool check = true;
  char s[15];
  for (int i = 0; i < a + b + 1; i++)
  {
    std::cin >> s[i];
    if (i == a)
    {
      if (s[i] != '-')
      {
        check = false;
      }
    }
    else
    {
      if (s[i] < '0' || s[i] > '9')
      {
        check = false;
      }
    }
  }
  std::cout << (check ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

namespace fastinput
{
	/** Interface */

	inline int readChar();
	template <class T = int> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(int x);
	inline void writeWord(const char *s);

	/** Read */

	static const int buf_size = 16384;

	inline int getChar() {
		static char buf[buf_size];
		static int len = 0, pos = 0;
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline int readChar() {
		int c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		int s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static int write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(int x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		int n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

int main()
{
	long long a, b, c;
	a = readInt();
	b = readInt();
	c = readInt();
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else
	{
		cout << min(a * b, min(b * c, c * a)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* Atcoder TASK_NAME
 * See tasks at: https://atcoder.jp/contests/abc177/tasks/abc177_a
 */

#include <bits/stdc++.h>
#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    
    if (s * t >= d)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <cmath>
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << ((a + 9) / 10 * 10
        + (b + 9) / 10 * 10
        + (c + 9) / 10 * 10
        + (d + 9) / 10 * 10
        + (e + 9) / 10 * 10
        + min(a % 10 > 0 ? a % 10 : 10,
            min(b % 10 > 0 ? b % 10 : 10,
            min(c % 10 > 0 ? c % 10 : 10,
            min(d % 10 > 0 ? d % 10 : 10,
                e % 10 > 0 ? e % 10 : 10))))
        - 10) << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse = True)

l = []
tmp = 0
for i in range(n-1):
    if A[i] == A[i+1]:
        l.append(A[i])
        tmp = i+1
        break

for i in range(tmp+1, n-1):
    if A[i] == A[i+1]:
        l.append(A[i])
        break

print(l[0] * l[1] if len(l) == 2 else 0)


Measured memory_bytes: 20008
#include <bits/stdc++.h>
using namespace std; 
int main(){
    long long n,i;
    cin >> n;
 
    long long k = 0;
    for(i=0;i<n;i++)
    {
        k = k*10+7;
        k %= n;
        if(k==0)
        {
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 ;
    return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> ans;
  if (ans == 5 || ans == 3 || ans == 7)
    YES();
  else
    NO();
  return 0;
}


Measured memory_bytes: 3612
N=int(input())
nums=list(map(int,input().split()))

for i in range(0,N):
  key = nums[i]
  j= i-1
  while j >= 0 and nums[j] > key:
    nums[j+1] = nums[j]
    j = j-1
  nums[j+1] = key
  print(" ".join(map(str,nums)))


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

int main() {
	// your code goes here
	int m,d,x,y,i,j,ans=0;
	cin >> m >> d;
	for(i=1;i<=m;i++){
		for(j=1;j<=d;j++){
			x=j%10;
			y=(j-x)/10;
			if(x>=2&&y>=2&&x*y==i) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	int n;
	char aa;
	char a = 'A';
	char s[10001];
	scanf("%d", &n);
	scanf("%s", &s);
	int l = strlen(s);
	for (int i=0; i<l; i++) {
		aa = s[i] + n;
		if (aa >= 91) {
			aa -= 26;
		}
		s[i] = aa;
		
	}
	printf("%s", s);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var W int
	var H int
	var x int
	var y int
	var r int

	fmt.Scan(&W, &H, &x, &y, &r)

	if (x-r) < 0 || (x+r) > W || (y-r) < 0 || (y+r) > H {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}

}


Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){

       string s,t;
        cin>>s>>t;

        int count = 0;

         for(int i=0;i<s.length();i++){

             if(s[i]!=t[i]){
                count++;
                break;
             }
         }
          if(count==0)
           cout<<"Yes";

           else
           cout<<"No";
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n;
ll a[100010], d[100010], x;
ll s, y;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld", a + i);
		s += a[i];
	}
	for(int i = 0; i < n; i++){
		d[i] = a[i] - a[(i + n - 1) % n];
		int t = d[i];
		t %= n; if(t < 0) t += n;
		if(i == 0) x = t;
		else if(x != t){
			puts("NO");
			return 0;
		}
	}
	if(s % (1LL * n * (n + 1) / 2)){
		puts("NO");
		return 0;
	}
	y = s / (1LL * n * (n + 1) / 2);
	for(int i = 0; i < n; i++) d[i] -= y;
	ll q = 0;
	for(int i = 0; i < n; i++){
		if(d[i] > 0 || (d[i] % n) != 0){
			puts("NO");
			return 0;
		}
		q -= (d[i] / n);
	}
	if(q != y) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h> 
#define int long long
using namespace std;
int solve2(vector<int>& weights, vector<int>& value,int N, int W){
	vector<vector<int>> dp(N+1,vector<int>(W+1,0));
	for (int i=1;i<=N;i++){
		for (int j=1;j<=W;j++){
			if (weights[i-1]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],value[i-1]+dp[i-1][j-weights[i-1]]);
		}
	}
	return dp[N][W];
}
int solve(vector<int>& weights, vector<int>& value,int N, int W, vector<vector<int>>& dp){
	if (N<=0||W<=0) return 0;
	if (dp[N][W]!=-1) return dp[N][W];
	if (weights[N-1]>W) return dp[N][W]=solve(weights,value,N-1,W,dp);
	return dp[N][W]=max(solve(weights,value,N-1,W,dp),
		value[N-1]+solve(weights,value,N-1,W-weights[N-1],dp));
}
signed main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
	int N,W;
    cin>>N>>W;
    vector<int> weights(N);
    vector<int> value(N);
    for (int i=0;i<N;i++){
    	cin>>weights[i]>>value[i];
    }
    // vector<vector<int>> dp(N+1,vector<int>(W+1,-1));
	cout<< solve2(weights,value,N,W)<<endl;
    return 0; 
}


Measured memory_bytes: 83164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define ll long long
#define N 410
using namespace std;
struct node{
	int a,b,c,d;
	node(int A=0,int B=0,int C=0,int D=0):a(A),b(B),c(C),d(D){}
	void rotate(){int t=a;a=b,b=c,c=d,d=t;}
	bool operator<(const node u)const
	{
		if(a!=u.a) return a<u.a;
		if(b!=u.b) return b<u.b;
		if(c!=u.c) return c<u.c;
		return d<u.d;
	}
	node operator <<(const int a)const{node p=*this;for(int i=1;i<=a%4;i++){int swp=p.a;p.a=p.b;p.b=p.c;p.c=p.d;p.d=swp;}return p;}
	void operator <<=(const int a){*this=(*this)<<a;}
}p[N];
node operator |(const node a,const node b)
{
	return node(a.b,a.a,b.a,b.d);
}
map<node,int>mp;
void insert(node a)
{
	mp[a]++;mp[a<<1]++;
	mp[a<<2]++;mp[a<<3]++;
}
void del(node a){mp[a]--;mp[a<<1]--;mp[a<<2]--;mp[a<<3]--;}
node np[4],s1,s2;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&p[i].a,&p[i].b,&p[i].c,&p[i].d);
		insert(p[i]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		del(p[i]);
		for(int j=i+1;j<=n;j++)
		{
			del(p[j]);
			for(int k=0;k<4;++k)
			{
				p[j]<<=1;s1=p[i],s2=p[j];
				for(int l=0;l<4;l++)
				{
					np[l]=s1|s2;
					s1<<=1,s2<<=3;
				}
				if(mp.count(np[0]) && mp.count(np[1]) && mp.count(np[2]) && mp.count(np[3]))
				{
					long long sum=1ll;
					for(int l=0;l<4;l++)
					sum*=mp[np[l]],del(np[l]);
					for(int l=0;l<4;l++)
					insert(np[l]);
					ans+=sum;
				}
			}
			insert(p[j]);
		}
	}
	printf("%lld",ans);
	return 0;
}


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

int main()
{
   string a, op, b;
   cin >> a >> op >> b;
   int A = 0, B = 0;

   for(int i = 0; i < a.size(); ++i)
   {
       A = (A * 10) + (a[i] - 48);
   }

   for(int i = 0; i < b.size(); ++i)
   {
       B = (B*10) + (b[i] - 48);
   }

   if(op == "+")cout << A + B << endl;
   else cout << A - B << endl;

   return 0;
}


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

#define QLEN 60000

typedef struct {
  char name[11];
  int time;
} process;

int main()
{
  int d, i, n, q, sp, head, time;
  char buf[32], *p;
  fgets(buf, 32, stdin);
  for (p=buf, n=0; *p!=' '; p++)   n = n * 10 + *p - '0';
  for (p++,q=0; *p!='\n'; p++)   q = q * 10 + *p - '0';
  process *proc = (process*)malloc(sizeof(process)*QLEN);
  for (sp=0; sp<n; sp++) {
    fgets(buf, 32, stdin);
    for (p=buf, i=0; *p!=' '; p++,i++)  proc[sp].name[i] = *p;
    proc[sp].name[i]=0;
    for (p++,proc[sp].time=0; *p!='\n'; p++)
      proc[sp].time = proc[sp].time * 10 + *p - '0';
  }
  time = head = 0;
  buf[31] = 0;
  buf[30] = '\n';
  while ((sp-head+QLEN)%QLEN>0) {
    process p = proc[head++%QLEN];
    if (p.time-q<=0) {
      time += p.time;
      fputs(p.name, stdout);
      d = time;
      for (i=30; d>0; buf[--i]='0'+d%10,d/=10);
      buf[--i] = ' ';
      fputs(buf+i, stdout);
    } else {
      p.time -= q;
      time += q;
      proc[sp++%QLEN] = p;
    }
  }

  return 0;
}



Measured memory_bytes: 2552
def slv():
    import sys
    input = sys.stdin.readline
    N, M, L = list(map(int, input().rstrip('\n').split()))
    INF = 10**11
    g = [[INF]*(N) for _ in range(N)]
    gg = [[INF]*(N) for _ in range(N)]

    for i in range(N):
        g[i][i] = 0
    for _ in range(M):
        a, b, c = list(map(int, input().rstrip('\n').split()))
        if c <= L:
            g[a-1][b-1] = c
            g[b-1][a-1] = c
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                g[i][j] = min(g[i][j], g[i][k] + g[k][j])
    
    for u in range(N):
        for v in range(N):
            if g[u][v] <= L:
                gg[u][v] = 1
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                gg[i][j] = min(gg[i][j], gg[i][k] + gg[k][j])

    Q = int(input())
    for _ in range(Q):
        s, t = list(map(int, input().rstrip('\n').split()))
        c = gg[s-1][t-1]
        if c != INF:
            print(c-1)
        else:
            print(-1)



def main():
    slv()

if __name__ == '__main__':
    main()


Measured memory_bytes: 57436
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W;//風呂敷の容量
int N;//お宝の数
int dp[1010][1010];//dp[i][j]品物i番目までで重さがj以下の最大の価値
int dpW[1010][1010];
int Wt[1010];
int Vt[1010];
int ansW;
int main()
{
  int k = 1;
  while(cin>>W,W){
    cin >>N;
    for(int i = 0;i <N;i++){
      int w,v;
      scanf("%d,%d",&v,&w);
      Vt[i] = v;
      Wt[i] = w;
    }
    for(int i = 0;i <N;i++){
      for(int j = 0;j <W;j++){
	dp[i][j] = 0;
      }
    }
    for(int i = 0;i <N;i++){
      for(int j = 0;j <= W;j++){
	if(j-Wt[i]>=0){
	  dp[i+1][j] =max(dp[i][j],dp[i][j-Wt[i]]+Vt[i]);
	}else{
	  dp[i+1][j] =dp[i][j];
	}
      }
  }
    ansW = 1;
    for(int j = 1;j <=W;j++){
      if(dp[N][ansW] <dp[N][j]){
	ansW =j;
      }
    }
    printf("Case %d:\n",k);
    k++;
    cout <<dp[N][W]<<endl;
    cout <<ansW<<endl;
  }
  return 0;
}

Measured memory_bytes: 7184
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    if N==M:
        print("Yes")
    else:
        print("No")


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;


public class Main {
	
	double EPS = 1e-6;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			
			P[] ps = new P[n];
			
			for(int i=0;i<n;i++) {
				String[] str = sc.next().split(",");
				ps[i] = new P(Double.parseDouble(str[0]), Double.parseDouble(str[1]));
			}
			
			int max = 1;
			for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {
				ArrayList<P> cs = cross(ps[i], ps[j]);
				if(cs.isEmpty()) continue;
				
				for(P c: cs) {
					debug("",c.x, c.y);
					int cnt = 0;
					for(int k=0;k<n;k++)  {
//						debug(k, c.abs(ps[k]));
						if( 1.0 + EPS > c.abs(ps[k])  ) cnt++;
					}
					max = max(cnt, max);
				}
				
				
			}
			
			System.out.println(max);
		}
		
	}
	
	ArrayList<P> cross(P p1, P p2) {
		ArrayList<P> ret = new ArrayList<P>();
		debug(p1.x, p1.y, p2.x, p2.y);
		
		if( abs ( 4.0 - abs( p1.abs(p2) ) ) < EPS ) {
			P c = p1.add(p2).mult(0.5);
			ret.add(c);
		}
		else if( 4.0 - EPS > abs(p1.abs(p2)) ) {
			P p3 = p1.add(p2.mult(-1.0));
			P c = p2.add(p3.mult(0.5));
			debug(p3.x, p3.y);
			
			P un1 = new P(p3.y, -p3.x).mult(1.0/sqrt(p3.abs()));
			P un2 = new P(-p3.y, p3.x).mult(1.0/sqrt(p3.abs()));
			
			debug(" ", un1.x, un1.y);
			
			double dist = sqrt( 1.0 - p3.mult(0.5).abs() );
			
			P c1 = c.add(un1.mult(dist));
			P c2 = c.add(un2.mult(dist));
			
			ret.add(c1); ret.add(c2);
		}
		
		return ret;
	}
	
	class P {
		double x, y;
		P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		
		P add(P p) {
			return new P(x+p.x, y+p.y);
		}
		
		P mult(double k) {
			return new P(x * k, y * k);
		}
		
		double dot(P p) {	//内積
			return x*p.x + y*p.y;
	}
	
		double det(P p) {	//外積
			return x*p.y - y*p.x;
		}
		
		double abs(P p) {
			return (x-p.x) * (x-p.x) + (y-p.y) * (y-p.y);
		}
		
		double abs() {
			return x * x + y * y;
		}
	}

	void debug(Object... os) {
//		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 27516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll GCD(ll a, ll b) { return (b == 0)? a: GCD(b, a % b); }

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

  ll N; cin >> N;
  map<pair<ll, ll>, pair<ll, ll>> cnt;

  ll cnt00 = 0;
  for (ll i = 0; i < N; i++) {
    ll A, B; cin >> A >> B;
    if (A == 0 && B == 0) {
      cnt00++;
      continue;
    }

    ll g = GCD(abs(A), abs(B));
    A /= g, B /= g;
    if (A == 0) {
      cnt[{0, 0}].first++;
    } else if (B == 0) {
      cnt[{0, 0}].second++;
    } else {
      if (A < 0) {
        A = -A, B = -B;
      }
      if (B > 0) cnt[{A, B}].first++;
      else cnt[{-B, A}].second++;
    }
  }

  ll MOD = 1e9 + 7;
  vector<ll> pow2(200200, 0);
  pow2[0] = 1;
  for (ll i = 1; i < 200200; i++) {
    pow2[i] = (pow2[i - 1] * 2) % MOD;
  }

  ll ans = 1;
  for (auto p: cnt) {
    ans = (ans * (pow2[p.second.first] + pow2[p.second.second] - 1) % MOD) % MOD;
  }
  ans = (ans + cnt00 - 1 + MOD) % MOD;

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 20264
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    for(;;){
        scanf("%d%d",&n,&k);
        if(n==0&&k==0)break;
        vector<int> ns(k);
        for(int i=0;i<k;i++){
            scanf("%d",&ns[i]);
        }
        sort(ns.begin(),ns.end());
        vector<pair<int,int> > rens;
        int st=0;
        bool isc=false;
        if(ns[0]==0){
            st=1;
            isc=true;
        }
        for(int i=st+1;i<k;i++){
            if(ns[i]!=ns[i-1]+1){
                rens.push_back(make_pair(ns[st],ns[i-1]));
                st=i;
            }
        }
        rens.push_back(make_pair(ns[st],ns[k-1]));
        int ma=0;
        if(isc){
            for(int i=1;i<rens.size();i++){
                if(rens[i-1].second+2==rens[i].first){
                    ma=max(ma,rens[i].second-rens[i-1].first+1);
                }else ma=max(ma,rens[i].second-rens[i].first+1);
            }
        }else{
            for(int i=0;i<rens.size();i++){
                ma=max(ma,rens[i].second-rens[i].first+1);
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll N, M, P;
	cin >> N >> M >> P;
	int a[5010], b[5010];
	ll c[5010];
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		c[i] = -(c[i] - P);
	}
	ll dist[2510];
	for (int i = 0; i < N; ++i) {
		dist[i] = INF;
	}
	dist[0] = 0;
	for (int loop = 0; loop < N - 1; ++loop) {
		for (int i = 0; i < M; ++i) {
			if (dist[a[i]] == INF)continue;
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
			}
		}
	}
	ll ans = dist[N - 1];
	bool negative[2510];
	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}
	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			if (dist[a[i]] == INF)continue;//関係にない負閉路は無視
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
				negative[b[i]] = true;
			}
			if (negative[a[i]] == true) {
				negative[b[i]] = true;
			}
		}
	}
	if (negative[N - 1]) {
		cout << "-1" << endl;
	}
	else {
		if (ans > 0) {
			cout << 0 << endl;
		}
		else {
			cout << -ans << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

const int INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> a(n);
    int X1, Y1, X2, Y2;
    cin >> X1 >> Y1 >> X2 >> Y2;
    X1--, Y1--, X2--, Y2--;
    forn(i, n) cin >> a[i];
    queue<pii> q;
    q.push({X1, Y1});
    vector<vi> d(n, vi(m, -1));
    d[X1][Y1] = 0;
    vector<vi> lr(n), lc(m);
    vector<set<int>> r(n), c(m);
    forn(i, n) {
        forn(j, m) {
            if (a[i][j] == '@') {
                lr[i].pb(j);
                lc[j].pb(i);
            } else {
                r[i].insert(j);
                c[j].insert(i);
            }
        }
    }
    forn(i, n) r[i].insert(INF);
    forn(i, m) c[i].insert(INF);
    r[X1].erase(Y1);
    c[Y1].erase(X1);
    while (!q.empty()) {
        int x = q.front().fst, y = q.front().snd;
        q.pop();
        int y1 = max(0, y - k), y2 = min(m - 1, y + k);
        if (!lr[x].empty()) {
            auto ub = upper_bound(all(lr[x]), y);
            if (lr[x].back() >= y) y2 = min(y2, *ub - 1);
            if (lr[x][0] <= y) y1 = max(y1, 1 + *(--ub));
        }
        while (!r[x].empty()) {
            int Y = *r[x].lower_bound(y1);
            if (Y > y2) break;
            r[x].erase(Y);
            c[Y].erase(x);
            q.push({x, Y});
            d[x][Y] = 1 + d[x][y];
        }
        int x1 = max(0, x - k), x2 = min(n - 1, x + k);
        if (!lc[y].empty()){
            auto ub = upper_bound(all(lc[y]), x);
            if (lc[y].back() >= x) x2 = min(x2, *ub - 1);
            if (lc[y][0] <= x) x1 = max(x1, 1 + *(--ub));
        }
        while (!c[y].empty()){
            int X = *c[y].lower_bound(x1);
            if (X > x2) break;
            c[y].erase(X);
            r[X].erase(y);
            q.push({X, y});
            d[X][y] = 1 + d[x][y];
        }
        if (d[X2][Y2] != -1) break;
    }
    cout << d[X2][Y2] << '\n';
    return 0;
}

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

using namespace std;
using ll = long long;
using Lll = list<ll>;
using Vll = vector<ll>;

#define rep(a,x,i,f) for(ll a = i; a < f; a+=x )
#define repR(a,x,i,f) for(ll a = i; a > f; a-=x )

ll ms = 1123456789;

ll frog(Vll& s, Vll& ci, int cur,int k)
{
  ll p,min = ms;

  if(cur < 2)
  {
    return ci[cur];
  }

  rep(i,1,1,k+1)
  {
    if(cur - i < 0) break;
    p = abs(s[cur] - s[cur-i]) + (ci[cur-i] != -1 ? ci[cur-i] : frog(s,ci,cur-i,k));
    min = p < min ? p : min;
  }
  
  ci[cur] = min;

  return ci[cur];
}

int main() 
{
  ll n,m,k;
  cin >> n >> k;
  Vll s(n);
  Vll ci(n,-1);

  rep(i,1,0,n)
    cin >> s[i];

  ci[0] = 0;
  ci[1] = abs(s[0] - s[1]);

  m = frog(s,ci,n-1,k);

  cout << m << endl;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,j,count=0,z=0,a=1;
    cin>>n;
    for(int i=1; i<=n; i++){
        j=i;
        count = 0;
        while(j%2 == 0){
            count++;
            j=j/2;
        }
        if(z < count){
            z=count;
            a=i;
        }
    }
    cout<<a<<endl;
}


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


int main(void){
    int max=999999999;
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
if(abs(a+b-(c+d))<=max){max=abs(a+b-(c+d));}
if(abs(a+c-(b+d))<=max){max=abs(a+c-(b+d));}
if(abs(a+d-(c+b))<=max){max=abs(a+d-(c+b));}
if(abs(c+b-(a+d))<=max){max=abs(c+b-(a+d));}
printf("%d\n",max);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int N, L; cin >>N>>L;
  vi apples(N);
  int mn=1e9;
  rep(i,N) {
    int x = L+i;
    int dif = abs(x-0);
    if (dif<abs(mn-0)) 
      mn = x;
  }
  int aji = L*N+N*(N-1)/2;
  cout << aji - mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int a, b, c;
	cin >> a >> b >> c;

	int ans = 0;
	if (a == b && b == c) ans = 1;
	else if (a == b || b == c || c == a) ans = 2;
	else ans = 3;

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, Y;
  cin >> n >> Y;
  int total = n * 10000;
  // cout << total << endl;
  int x = n, y = 0, z = 0;
  bool flag = false;
  for (int i = 0; i <= n; i++) {       // 5000円のループ
    for (int j = 0; j <= n - i; j++) { // 1000円のループ
      total = total - 5000 * i - 9000 * j;
      // cout << total << endl;
      if (total == Y) {
        flag = true;
        y = i;
        z = j;
        x = n - y - z;
        break;
      }
      if (total < 0) {
        break;
      }
      total = n * 10000;
    }
    if (flag) {
      break;
    }
    total = n * 10000;
  }
  if (flag) {
    cout << x << " " << y << " " << z << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
from bisect import bisect_left

icase=0
if icase==0:
    n=int(input())
    a=list(map(int,input().split()))
elif icase==1:
    n=4
    a=[2,5,4,6]
elif icase==2:
    n=9
    a=[0,0,0,0,0,0,0,0,0]
elif icase==3:
    n=19
    a=[885,8,1,128,83,32,256,206,639,16,4,128,689,32,8,64,885,969,1]

amax=max(a)
k=len(bin(amax))-2

cc=[[0]*k for i in range(n)]
for i in range(n):
    ai=bin(a[i])[2:]
#    print(ai)
    kd=k-len(ai)
    for j in range(len(ai)):
        cc[i][kd+j]=int(ai[j])
#print(cc)    
cc2=[[0]*(n+1) for i in range(k)]
for i in range(n):
    for j in range(k):
        cc2[j][i+1]=cc2[j][i]+cc[i][j]
#print(cc2)

icnt=0
for i in range(n):
#    print(i,"-------------")
    cmin=n+1
    for j in range(k):
#    ileft=bisect_left(cc2[j],cc2[j][i]+1,i)
        iright=bisect_right(cc2[j],cc2[j][i]+1,i+1)-(i+1)
        cmin=min(cmin,iright)
#        print(cc2[j])
#        print("j:",j,"v:",cc2[j][i]+1,"i:",i,"ir:",iright,"cmin:",cmin)
    icnt+=cmin
print(icnt)

Measured memory_bytes: 165428
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(0);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a; cin >> a;
    string b; cin >> b;
    ll b_num = (b[0]-'0')*100 + (b[2]-'0')*10+(b[3]-'0')*1;
    ll ans = a*b_num/100;
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){
ll mod = 1000000007;
ll N,M; cin >> N >> M;
vl dp(N+2,0);
rep(i,M){
    ll a; cin >> a;
    dp[a] = -1;
}
dp[N] = 1;
for(int i = N - 1; i >= 0; i--){
    if(dp[i] != -1){
        dp[i] = dp[i+1] + dp[i+2];
        dp[i] %= mod;
    }
    else{
        dp[i] = 0;
    }
}
    cout << dp[0] << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

vector<ll> p,c;

//dp
vector<vector<ll>> table;

ll alpha(ll i,ll k){
  if(k==p[i]) return c[i];
  else return 0;
}

ll dp(ll i,ll j){
  if(i<=0||j<=0) return 0;
  if(table[i][j]>-INF) return table[i][j];
  
  ll ret=-INF+1;
  rep(k,p[i]+1){
    if(j-k<0) break;
    chmax(ret,dp(i-1,j-k)+i*k+alpha(i,k));
  }
  
  return table[i][j]=ret;
}

int main()
{
  ll D,G; cin>>D>>G; G/=100;
  ll P=0;
  p=vector<ll>(D+1),c=vector<ll>(D+1); rep(i,D) {cin>>p[i+1]>>c[i+1]; P+=p[i+1],c[i+1]/=100;}
  
  //dp
  table=vector<vector<ll>>(D+1,vector<ll>(P+1,-INF));
  /*
  rep(i,D+1){
    rep(j,P+1){
      if(j!=0) cout<<" ";
      cout<<dp(i,j);
    }
    cout<<endl;
  }
  */
  rep(i,P+1){
    if(dp(D,i)>=G){cout<<i<<endl; return 0;}
  }
  
  
  
  return 0;
}


Measured memory_bytes: 3724
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i>n-1:
            break
        if s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:
            ans-=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <map>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

map<vector<int>, int> mem;

int solve(const vector<int>& v) {
  if (v.empty()) return 0;
  if (mem.count(v)) return mem[v];
  int res = v.size();
  for (int i : range((int)v.size() - 1)) if (i % 4 != 3 && v[i] == v[i + 1]) {
    vector<int> vv;
    for (int j : range(v.size())) if (j != i && j != i + 1) vv.emplace_back(v[j]);
    is_min(res, solve(vv));
  }
  for (int i : range((int)v.size() - 4)) if (v[i] == v[i + 4]) {
    vector<int> vv;
    for (int j : range(v.size())) if (j != i && j != i + 4) vv.emplace_back(v[j]);
    is_min(res, solve(vv));
  }
  for (int i : range((int)v.size() - 5)) if (i % 4 != 3 && v[i] == v[i + 5]) {
    vector<int> vv;
    for (int j : range(v.size())) if (j != i && j != i + 5) vv.emplace_back(v[j]);
    is_min(res, solve(vv));
  }
  for (int i : range((int)v.size() - 3)) if (i % 4 != 0 && v[i] == v[i + 3]) {
    vector<int> vv;
    for (int j : range(v.size())) if (j != i && j != i + 3) vv.emplace_back(v[j]);
    is_min(res, solve(vv));
  }
  return mem[v] = res;
}


int main() {
  int t;
  cin >> t;
  for (int _ : range(t)) {
    vector<int> v;
    for (int i : range(20)) {
      int c;
      cin >> c;
      v.emplace_back(c);
    }
    cout << solve(v) << endl;
  }
}

Measured memory_bytes: 1640
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();

        if(n>=10) System.out.println(r);
        else {
            r+=100*(10-n);
            System.out.println(r);
        }

    }

}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
    int n,q;
    cin >> n >> q;
    vector<array<ll,3>> events;
    rep(i,n){
        ll s,t,x;
        cin >> s >> t >> x;
        events.push_back({s-x,1,x});
        events.push_back({t-x,-1,x});
    }
    sort(events.begin(),events.end(),[](array<ll,3> a,array<ll,3> b){return a[0]>b[0] || (a[0]==b[0] && a[1]>b[1]);});
    set<ll> stop_coord;
    rep(i,q){
        ll d;
        cin >> d;
        while(!events.empty() && (*events.rbegin())[0]<=d){
            if( (*events.rbegin())[1] == 1 )stop_coord.emplace((*events.rbegin())[2]);
            else stop_coord.erase((*events.rbegin())[2]);
            events.pop_back();
        }
        if(stop_coord.empty())cout << "-1" << endl;
        else cout << *stop_coord.begin() << endl;
    }
    return 0;
}

Measured memory_bytes: 21864
mod = 10 ** 9 + 7


def pow(a, b, mod):
    if b == 0:
        return 1
    if b == 1:
        return a
    if b % 2 == 0:
        return (pow(a, b // 2, mod) ** 2) % mod
    else:
        return (a * pow(a, b // 2, mod) ** 2) % mod


def inv(x, mod):
    return pow(x, mod - 2, mod)


MAX = 2 * 10 ** 6 + 3
l = [1] * MAX
for i in range(1, MAX):
    l[i] = (l[i - 1] * i) % mod


def f(r, c):
    return (l[r + c] * inv(l[r], mod) * inv(l[c], mod)) % mod


def g(r, c):
    if r < 0 or c < 0:
        return 0
    ans = f(r+1, c+1) - 1 + mod
    return ans % mod


r1, c1, r2, c2 = map(int, input().split())
print(((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % mod + mod) % mod)


Measured memory_bytes: 55660
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    int cnt = 0, zero = 0, one = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '0') zero++;
        else one++;
    }
    
    cout << min(zero, one)*2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <limits.h>
#include <stack>
#include <set>
#include <map>

#define P pair
#define MP make_pair

typedef long long int llint ;

using namespace std;

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


Measured memory_bytes: 256
N,M = map(int,input().split())
P = []

Indexs = {}
Syuturyoku = []


for j in range(N):
	P.append([0])


for i in range(M):
	p,y = map(int,input().split())

	P[p-1].append(y)
	Indexs[y] = i
	Syuturyoku.append(0)

for i in range(len(P)):
	P[i].sort()
	# P[i] = list(map(str,P[i]))


for i in range(N):
	if (len(P[i]) > 1):
		for j in range(len(P[i])-1):
			atai = P[i][j+1]
			si = i+1
			# si = str(si)
			x = j+1
			# x = str(x)
			# bangou = list(map(str,si))
			# bangou_len = int(len(bangou))
			# bangou_ushiro = list(map(str,x))
			# bangou_ushiro_len = int(len(bangou_ushiro))
			# if(len(bangou)<6):
			# 	for zero in range(6-bangou_len):
			# 		bangou.insert(0,'0')
			# if(len(bangou_ushiro)<6):
			# 	for zero in range(6-bangou_ushiro_len):
			# 		bangou_ushiro.insert(0,'0')

			# mojiretsu = ''
			# for k in bangou:
			# 	mojiretsu += k
			# mojiretsu2 = ''
			# for k2 in bangou_ushiro:
			# 	mojiretsu2 += k2

			a = Indexs[atai]
			Syuturyoku[a] = (si, x)

for i in range(M):
	print('{0:06}{1:06}'.format(Syuturyoku[i][0], Syuturyoku[i][1]))


Measured memory_bytes: 42136
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		if (D == 25) {
			System.out.println("Christmas");
		} else if (D == 24) {
			System.out.println("Christmas Eve");
		} else if (D == 23) {
			System.out.println("Christmas Eve Eve");
		} else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
	
}

Measured memory_bytes: 21332
#include <iostream>

using namespace std;

int main(void) {
    int N, Y;
    cin >> N >> Y;
    for(int x=0; x<=N; x++) {
        for(int y=0; x+y<=N; y++) {
            int z = N - x - y;
            if(10000*x + 5000*y + 1000*z == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[50];
  if(n==0){
    cout<<0;
    return 0;
  }
  while(n!=0){
    if(max(n%2,-n%2)==0)a[cnt++]=0;
    else a[cnt++]=1;
    n=-(n-max(n%2,-n%2))/2;
  }
  for(i=cnt-1;i>=0;i--)cout<<a[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}

int main(){
    int n,t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    double t_ave=0;
    double dif=0;
    double dif_min = 0;
    int idx=1;
    rep(i,n){
        t_ave = t - 0.006*h[i];
        dif = abs(t_ave - a);
        if(i==0) dif_min = dif;
        if(dif<dif_min){
            dif_min =  dif;
            idx = i+1;
        }
    }

    cout<<idx<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = input().split(' ')
NA = int(N)
K = int(K)
if NA - K > K:
  NA = NA - K*(NA//K - 1)
N1 = abs(NA-K)

while N1 < NA:
  NA = N1
  N1 = abs(N1-K)
else:
  print(NA)

Measured memory_bytes: 8924
#include <iostream> 
#include <bits/stdc++.h> 
#include <stdio.h>
typedef long long ll; 
using namespace std; 
void solve() 
{
    ll n,d; 
    cin >> n >> d; 
    ll x,y; 
    ll sum = 0;  
    int count = 0; 
    for (int i=0;i<n;i++) 
    {
        cin >> x >> y; 
        sum = (x*x + y*y); 
        if (sum<=(d*d))
        {
            count ++; 
        }
    }
    cout << count << endl; 
}
int main() 
{
    solve() ; 
    return 0; 
}


Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main(){
  int A[50];
  int N;
  int m = 0;
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i){
    if(A[i]!=i+1){
      m += 1;
        }
    }
  if(m == 0){
    cout << "YES";
    }
  else if(m ==2){
      cout << "YES";
    }
  else{
    cout << "NO";
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
		else if(a>b){
		printf("a > b\n");
	}
		else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+3;
ll k[maxn];
int main()
{
    ll n,sum=1,flag=0,zero=0;
    cin>>n;
    for(ll i=0; i<n; i++)
    {
        cin>>k[i];
        if(k[i]==0)
            zero=1;
    }
    if(zero)
        cout<<0;
    else
    {
        for(ll i=0; i<n; i++)
        {
            if(sum*k[i]>1000000000000000000)
            {
                flag=1;
                break;
            }
            sum*=k[i];
        }
        if(flag)
            cout<<-1;
        else
            cout<<(sum>0?sum:-1);
    }
    return 0;
}
/*
2
1000000000000000000 1000000000000000000

*/


Measured memory_bytes: 4404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int N,T;
  cin >> N >> T;
  vector<pii> route;
  for(int i = 0; i < N; i++){
    int c,t;
    cin >> c >> t;
    route.push_back(make_pair(c, t));
  }
  sort(route.begin(), route.end());
  for(int i = 0; i < N; i++){
    if(route[i].second <= T){
      cout << route[i].first << endl;
      return 0;
    }
  }
  cout << "TLE" << endl;

  return 0;
}

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

int main()
{
  long long int n=0;
  long long int wt=0;
  cin>>n;
  cin>>wt;
  vector<long long int> weight(n,0);
  vector<long long int> price(n,0);
  for(int i=0;i<n;i++)
  {
      cin>>weight[i];
      cin>>price[i];
  }
  vector<long long int> temp(wt+1,0);
  vector<vector<long long int>> dp(n+1,temp);
  
  for(long long int i=0;i<=n;i++)
   {
       for(long long int j=0;j<=wt;j++)
       {
           if(i==0 or j==0)
           dp[i][j]=0;
           else if(weight[i-1]<=j)
           {
               dp[i][j]=max(dp[i-1][j],price[i-1]+dp[i-1][j-weight[i-1]]);
           }
           else
           dp[i][j]=dp[i-1][j];
           
       }
   }
   cout<<dp[n][wt];
}

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

typedef long long ll;
ll h,w, Min = 1e18;

int main(){
    scanf("%lld%lld",&h,&w);
    if(h % 3 == 0 || w % 3 == 0) printf("0\n");
    else{
        for(ll i = 1; i < w; i++){
            ll One = i * h;
            ll w1 = w - i;
            ll Two = h / 2 * w1;
            ll San = (h - h / 2) * w1;
            Min = min(Min, max(One, max(Two, San)) - min(One, min(Two,San)) );
        }
        Min = min(Min, w);
        
        for(ll i = 1; i < h; i++){
            ll One = i * w;
            ll h1 = h - i;
            ll Two = w / 2 * h1;
            ll San = (w - w / 2) * h1;
            Min = min(Min, max(One, max(Two, San)) - min(One, min(Two,San)) );
        }
        Min = min(Min,h);
        printf("%lld\n",Min);
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int right = 0;

    rep(left, s.size())
    {

            while (right < s.size() && (s[right] == 'A'||s[right] == 'T'||s[right] == 'G'||s[right] == 'C'))
            {
            right++;
            }
        
        ans = max(ans, right-left);
        if(left==right){
            right++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256