akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int H, W;
    int i, j, k, l;
    char S[55][55];
    int number;
    char *a;
    char tmp;
    scanf("%d %d", &H, &W);
    for (i = 0; i < H; i++){
        scanf(" %s", &S[i][0]);
    }

    for (i = 0; i < H; i++){
        for (j = 0; j < W; j++){
            if (S[i][j] == '.'){
                a = &S[i][j];
                *a = '0';
            }
        }
    }

    for (i = 0; i < H; i++){
        for (j = 0; j < W; j++){
            if (S[i][j]!='#'){
                for (k = i-1; k < i+2; k++){
                    for (l = j-1; l < j+2; l++){
                        if (k < 0 || k > H-1){
                            continue;
                        }
                        if (l < 0 || l > W-1){
                            continue;
                        }
                        if (S[k][l]=='#'){
                            S[i][j]++;
                        }
                    }
                }
            }
        }
    }

    for (i = 0; i < H; i++){
        printf("%s\n", S[i]);
    }



    

    printf("\n");

    return 0;
}

Measured memory_bytes: 128
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# 整数リストを連結表示    print(''.join(map(str, list)))

# -*- coding: utf-8 -*-

n = input()
ans = "No"

for x in n:
    if x == "7":
        ans = "Yes"

print(ans)

Measured memory_bytes: 9880
#include<stdio.h>

int main()
{
 int a,b,c;

 scanf("%d%d%d",&a,&b,&c);


 if(a==b && b==c)
 {
  printf("\n1\n");
 }

 else if(a==b && b!=c)
  {
      printf("\n2\n");
  }

 else if(b==c && c!=a)
  {
        printf("\n2\n");
  }
  
 else if(a==c && a!=b)
  {
        printf("\n2\n");
  }

 else if(a!=b && b!=c && a!=c)
  {
        printf("\n3\n");
  }

 return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a, b := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		a[i], b[i] = nextInt(), nextInt()
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		a[i] += ans
		ans += (b[i] - a[i]%b[i]) % b[i]
	}
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 5248
N = int(input())
W = [input() for i in range(N)]

if len(set(W)) != N:
  print('No')
else:
  ng = False
  for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
      ng = True
  if ng:
    print('No')
  else:
    print('Yes')


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

#define ll long long
#define INF 2147483647

int inp(){
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum;
}

int sum[2010], a[2010];

int main(){
    int n = inp();
    for(int i = 1; i <= n; i++){
        a[i] = inp();
        sum[a[i]]++;
    }
    for(int i = 1; i <= 2000; i++)
        sum[i] += sum[i - 1];
    ll ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++){
            if(i == j)
                continue;
            int r = a[i] + a[j] - 1;
            int l = abs(a[i] - a[j]) + 1;
            if(l > r)
                continue;
            ans += sum[r] - sum[l - 1];
            if(a[i] >= l && a[i] <= r)
                ans--;
            if(a[j] >= l && a[j] <= r)
                ans--;
        }
    printf("%lld\n", ans / 6);
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> T(n);
    rep(i, n) cin >> T[i];
    ll sum = 0;
    rep(i, n) sum += T[i];
    int m;
    cin >> m;
    vector<int> P(m), X(m);
    rep(i, m) cin >> P[i] >> X[i];
    for (int i = 0; i < m; i++) {
        int idx = P[i] - 1;
        cout << sum - T[idx] + X[i] << endl;
    }
    return 0;
}

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

int main() {
  int a, b;
  int c = 0;
  int p = 1;
  cin >> a >> b;
  while (p < b) {
    p += (a - 1);
    c++;
  }
  
  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
a[99][999],c;f(d,s,b,i){for(++a[d++][s];i--;)b>>i&1||f(d,s+i*d,b|1<<i,10);}main(){for(f(0,0,0,10);scanf("%d%d",a,&c)/2;)printf("%d\n",c<400?a[**a][c]:0);}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N; cin>>N;
	int ans = 0;
	rep(i,N){
		int l,r; cin>>l>>r;
		ans += (r-l+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void)
{
  int N;
  int cnt=0;
  int sum=0;
  cin>>N;
  for(int i=1; i<=N; i++)
  {
    cnt=0;
    if(i%2==1){
      for(int j=1; j<=i; j++)
      {
        if(i%j==0)cnt++;
      }
      if(cnt==8)sum++;
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll d, g; cin >> d >> g;
    vector<ll> p(d), c(d);
    REP(i, d) {
        cin >> p[i] >> c[i];
    }

    ll ans = INF;
    REP(mask, 1LL << d) {

        ll term = 0;
        ll pts = 0;
        DSRNG(i, d-1, 0) {
            if (mask & (1LL << i)) {
                term += p[i];
                pts += 100 * (i + 1) * p[i] + c[i];
            }
        }
        DSRNG(i, d-1, 0) {
            if (pts >= g) break;
            if (mask & (1LL << i)) continue;
            REP(j, p[i]-1) {
                if (pts >= g) break;
                term++;
                pts += (i + 1) * 100;
            }
        }

        if (pts >= g) {
            chmin(ans, term);
        }

    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
int n,a,b,h[100000],i,l,m,r;
long long x;
main(){
  for(scanf("%d%d%d",&n,&a,&b),a-=b;i<n;l=1,r=1e9)scanf("%d",h+i++);
  while(l<r){
    m=(l+r)/2;
    for(x=i=0;i<n;++i)h[i]>(long long)m*b?x+=(h[i]-m*b+a-1)/a:0;
    x<=m?r=m:l=m+1;
  }
  printf("%d\n",l);
}

Measured memory_bytes: 512
#include <stdio.h>

typedef struct{
	int top, front, right, left, back, bottom;
}dice_t;

void scan_dice(dice_t *storage_location){
	for(int i=0; i<6; i++){
		scanf("%d", (int*)storage_location+i);
	}
}

void roll_dice(dice_t *dice, char dir){
	int tmp;
	switch(dir){
	case 'E':
		tmp          = dice->top;
		dice->top    = dice->left;
		dice->left   = dice->bottom;
		dice->bottom = dice->right;
		dice->right  = tmp;
		break;
	case 'N':
		tmp          = dice->top;
		dice->top    = dice->front;
		dice->front  = dice->bottom;
		dice->bottom = dice->back;
		dice->back   = tmp;
		break;
	case 'S':
		tmp          = dice->top;
		dice->top    = dice->back;
		dice->back   = dice->bottom;
		dice->bottom = dice->front;
		dice->front  = tmp;
		break;
	case 'W':
		tmp          = dice->top;
		dice->top    = dice->right;
		dice->right  = dice->bottom;
		dice->bottom = dice->left;
		dice->left   = tmp;
		break;
	}
}

int main(void) {
	dice_t dice;
	char str[101];
	
	scan_dice(&dice);
	scanf("%s", str);
	
	for(int i=0;str[i]!='\0';i++){
		roll_dice(&dice, str[i]);
	}
	
	printf("%d\n", dice.top);
	return 0;
}



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

int main() {
	int n;
	cin >> n;
	string s[n * 2];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		s[i + n] = s[i];
	}
	int ans = 0;
	for (int i0 = 0; i0 < n; i0++) {
		bool b = true;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (s[i + i0][j] != s[j + i0][i]) {
					b = 0;
					i = n;
					break;
				}
			}
		}
		if (b) ans += n;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
/* winners never quit and quitters never win.
      #swap                                 */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define inf 100000000000000000
#define rk 256
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)
/*ll ncr[5001][5001];
void coeff()
{
    for(ll a=0;a<5001;a++)
    {
        for(ll b=0;b<5001;b++)
        {
            ncr[a][b]=0;
        }
        ncr[a][0]=1;
    }
    for(ll a=1;a<5001;a++)
    {
        for(ll b=1;b<=a;b++)
        {
            ncr[a][b]=(ncr[a-1][b]+ncr[a-1][b-1])%mod;
        }
    }
}*/
ll fast_exp(ll base, ll exp1) {
    ll res=1;
    while(exp1>0) {
       if(exp1&1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp1/=2;
    }
    return res%mod;
} 
ll pr[1000001]={0};
void isprime()
{
    pr[0]=1;
    pr[1]=1;
    for(ll a=2;a<1000001;a++)
    {
        if(!pr[a])
        {
            for(ll b=a*2;b<1000001;b+=a)
            {
                pr[b]=1;
            }
        }
    }
}
ll comp=1,tim=0;
struct vertex
{
    vc<ll> adj;
    ll vis=0;
    ll parent=-1;
    ll dist=0;
    ll component=0;
    ll in=0;
    ll out=0;
    ll low=0;
    ll child=0;
    ll indeg=0;
    ll outdeg=0;
    bool AP=false;
};
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n,k;
    cin>>n>>k;
    ll x[n];
    for(ll a=0;a<n;a++)
        cin>>x[a];
    ll dp[n]={0};
    dp[0]=0;
    if(n>1)
        dp[1]=llabs(x[1]-x[0]);
    for(ll a=2;a<n;a++)
    {
        ll k1=mod;
        for(ll b=a-1;b>=max(0*1LL,a-k);b--)
        {
            k1=min(dp[b]+llabs(x[a]-x[b]),k1);
        }
        dp[a]=k1;
    }
    cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main bst = new Main();
		int ops = in.nextInt();
		while (in.hasNextLine()) {
			String[] holder;
			holder = in.nextLine().split(" ");
			
			if (holder[0].equals("insert")) {
				bst.insert(bst, new Node(Integer.parseInt(holder[1])));
			}
			else if (holder[0].equals("print")) {
				bst.print();
			}
		}
		
	}
	
	Node root;
	
	public Main() {
		root = null;
	}
	
	
	public void insert(Main T, Node z) {
		Node y = null;
		Node x = T.root;
		
		while (x != null) {
			y = x;
			if (z.key < x.key) {
				x = x.left;
			}
			else {
				x = x.right;
			}
		}
		z.p = y;
		
		if (y == null) {
			T.root = z;
		}
		else if (z.key < y.key) {
			y.left = z;
		}
		else {
			y.right = z;
		}
	}
	
	public String inOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return inOrder(z.left) + " " + z.key + inOrder(z.right); 
		}
	}
	
	public String preOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return " " + z.key + preOrder(z.left) + preOrder(z.right); 
		}
	}
	
	public void print() {
		System.out.println(this.inOrder(root));
		System.out.println(this.preOrder(root));
	}
}
class Node {
	int key; // Key of the node
	Node p; // Parent of the node
	Node left; // Left child
	Node right; // Right child
	
	public Node(int val) {
		key = val;
		p = null;
		left = null;
		right = null;
	}
	
	public String toString() {
		return key + "";
	}
}




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

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

  int odd = ((n + 1) / 2);

  cout << float(odd) / float(n) << endl;
  return 0;
}

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

int main() {
	int n,l;
    bool tf=false;
    cin>>n>>l;
    int a,num;
    cin>>a;
    for(int i=1;i<n;i++){
        int b;
        cin>>b;
        if(a+b>=l){
            tf=true;
            num=i;
        }
        a=b;
    }
    if(tf){
        cout<<"Possible"<<endl;
        for(int i=1;i<num;i++){
            cout<<i<<endl;
        }
        for(int i=n-1;i>=num;i--){
            cout<<i<<endl;
        }
    }else cout<<"Impossible"<<endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <bitset>

using namespace std;

int main()
{
  string in;

  cin >> in;

  bitset<4> dir; // N S W E
  for (int i = 0; i < in.length(); ++i) {
    const char c = in[i];
    if (c == 'N') {
      dir.set(0);
    } else if (c == 'S') {
      dir.set(1);
    } else if (c == 'W') {
      dir.set(2);
    } else if (c == 'E') {
      dir.set(3);
    }
  }

  if (dir[0] && dir[1]) {
    if ((!dir[2] && dir[3]) || (dir[2] && !dir[3])) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else if (dir[2] && dir[3]) {
    if ((!dir[0] && dir[1]) || (dir[0] && !dir[1])) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, D=0;
  cin >> N;
  M = N;
  
  for(; M != 0 ; M /= 10 )
    D += M % 10;
  
  if( N % D == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 256
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

from operator import itemgetter
L.sort(key=itemgetter(1))
time = 0
ans = "Yes"
for i in range(N):
    time += L[i][0]
    if time > L[i][1]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 41308
#include<cstdio>
using namespace std;
int main(void)
{
	unsigned int i,j,k,x1,x2;
	char buf[1001];
	int a[1001][8];
	int n,x,p,sum;
	unsigned int mask[3]={4,2,1};
	
	scanf("%d",&n);
	scanf("%s",buf);
	if(buf[0]=='J')	p=mask[0];
	else if(buf[0]=='O')	p=mask[1];
	else p=mask[2];
	for(i=0;i<n;i++)	{
		for(j=0;j<8;j++)	{
			a[i][j]=0;
		}
	}
	for(j=0;j<8;j++)	{
		x1=j&4;	x2=j&p;
		if(x1==4 && x2==p)	{
				a[0][j]=1;			
			
		}
	}
	for(i=1;i<n;i++)	{
		if(buf[i]=='J')	p=4;
		else if(buf[i]=='O')	p=2;
		else p=1;	
		for(j=1;j<8;j++)	{
			for(k=1;k<8;k++)	{
				x1=j&p;	x2=j&k;
				if(x1!=0 && x2!=0)	{
					a[i][j]+=a[i-1][k];
				}
			}
			a[i][j]%=10007;
		}
	}
	sum=0;
	for(i=1;i<8;i++)	{
		sum+=a[n-1][i];
	}
	sum%=10007;
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 1056
s = list(input())
n = len(s)
ans = "No"

if n == 3:
    if s[0] == s[2]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


for i in range(1 - -(n//2)//2):
    if s[i] == s[n//2 - i - 1] == s[n//2 + i + 1] == s[n - i - 1]:
        ans = "Yes"
    else:
        print("No")
        exit()

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int

template <typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;

ll counter = 1;

ll a, b, c;

int main()
{
	cin >> n >> k;
	ans = 1;
	ans *= k;
	REP(i,n-1)
	{
		ans *= (k - 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	int a,b,m;
	cin>>a>>b>>m;
	vector<int> ref(a);
	vector<int> mi(b);
	for(int i=0; i<a; i++) cin>>ref[i];
	for(int i=0; i<b; i++) cin>>mi[i];
	int ans=INT_MAX;
	int temp= (*min_element(ref.begin(), ref.end()))+(*min_element(mi.begin(), mi.end()));
	while(m--){
	    int x,y,c;
	    cin>>x>>y>>c;
	    ans=min(ans, (ref[x-1]+mi[y-1]-c));
	}
	ans=min(ans,temp);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;

int main() {

	int64_t A, B, K;
	cin >> A >> B >> K;

	if (A >= K) {

		cout << A - K << " " << B;
		
	}
	else if (A < K && A + B >= K) {
		cout << 0 << " " << B - (K - A);
	}
	else {
		cout << 0 << " " << 0;
	}
	
	return 0;

}

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
t = [[int(x) for x in input().split()] for _ in range(q)]
add_list = [0]
for i in range(len(s)-1):
    if s[i:i+2] == "AC":
        add_list.append(add_list[i]+1)
    else:
        add_list.append(add_list[i])
for i in t:
    ans = add_list[i[1]-1] - add_list[i[0]-1]
    print(ans)

Measured memory_bytes: 24496
#include<iostream>
using namespace std;
int a[100010];
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    if(y*z>=x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

int main() {
    int n, m;
    std::vector<int> t(100000, 0);

    std::cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        std::cin >> t[i];
        sum += t[i];
    }

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


Measured memory_bytes: 640
from collections import defaultdict
from collections import deque
from sys import stdin

def sp(G,R,V):
    d = {}
    INF = float('inf')
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = deque([(R)])
    while q:
        u = q.popleft()
        for v in G[u]:
            if d[v[0]] > d[u] + v[1]:
                d[v[0]] = d[u] + v[1]
                q.append(v[0])
    return d


V, E, R = tuple(int(x) for x in stdin.readline().split(' '))
G = defaultdict(list)
for case in range(E):
    s, t, w = tuple(int(x) for x in stdin.readline().split(' '))
    G[s].append((t,w))
d = sp(G, R, V)
for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])

Measured memory_bytes: 106760
def main():
    M, K = map(int, input().split())
    N = 2**M
    if M == 1:
        if K == 0:
            print(*[0, 0, 1, 1])
        else:
            print(-1)
        return
    if K >= N:
        print(-1)
        return
    ans = [x for x in range(N) if x != K]
    ans = ans + [K] + ans[::-1] + [K]
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71024
#include<bits/stdc++.h>
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0 ; i < n ; ++i)
      cin >> a[i];

   sort(a.rbegin() , a.rend());
   long long rs = a[0];
   int rm = n - 2;
   for(int i = 1 ; rm && i < n ; ++i){
      rs += 1ll * min(2 , rm) * a[i];
      rm -= min(2 , rm);
   }
   cout << rs << "\n";
}

Measured memory_bytes: 3972
s="abcdefghij"
n=int(input())
ans=[["a",1]]
c=1
while(c<n):
    an=[]
    for i in ans:
        lim=min(i[1]+1,10)
        for j in range(lim):
            if (j==i[1]) and (j!=10):
                an.append([i[0]+s[j],i[1]+1])
            else:
                an.append([i[0]+s[j],i[1]])
    ans=an
    c+=1
for i in ans:
    print(i[0])

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N; i++){
    cin >> vec.at(i);
  }
  int count=0;
  
  for(int i=0; i<N; i++){
    if(vec.at(i)!=i+1){
      count++;
      //cout << count << endl;
    }
  }
  
  if(count <= 2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque
   
n = int(input())
dll = deque()
   
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
           
print(*dll)

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

int64_t gcd(int64_t a, int64_t b){
    return b==0 ? a : gcd(b, a%b);
}

bool solve(){
    int64_t A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A < B || B > D) return false;
    int64_t g = gcd(B, D);
    int64_t r = A%g;
    int64_t k = (C+g-r)/g;
    int64_t lim = g*k+r;
    return (lim >= B);
}

int main(){
    int T;
    cin >> T;
    while(T--) cout << (solve() ? "Yes" : "No") << endl;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int n ;
long double dp[3005][3005], ans ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    dp[0][0]=1 ;
    cin>> n ;
    vector<long double> p(n+1) ;
    for(int i=1 ; i<=n ; i++) cin>> p[i] ;
    for(int i=1 ; i<=n ; i++)
      {
        dp[i][0]=(1-p[i])*dp[i-1][0] ;
        for(int j=1 ; j<=i ; j++) dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j] ;
      }
    for(int i=(n+1)/2 ; i<=n ; i++) ans+=dp[n][i] ;
    cout<< fixed << setprecision(9) << ans << endl ;
  }


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

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  int maxt = -1;
  for (int i=1; i<=N; ++i) {
    int t = 0;
    int num = i;
    while (num % 2 == 0){
      ++t;
      num /= 2;
    }
    if (t > maxt) {
      maxt = t;
      ans = i;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iA = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            if (iX >= iA) { iOut = 10; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
"""
B - Increment Decrement
https://atcoder.jp/contests/abc052/tasks/abc052_b

"""
import sys


def solve(N, S):
    x = 0
    results = [x]
    for s in S:
        if s == 'I':
            x += 1
        else:
            x -= 1
        results.append(x)
    return max(results)


def main(args):
    N = int(input())
    S = input()
    ans = solve(N, S)
    print(ans)


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

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
const int NN =1e6+10;

using namespace std;
int cnt[10];
int main()
{
    int t=1;
    while(t--)
    {
        int a,b,c; cin >> a >> b >> c;
        cnt[a]++;cnt[b]++;cnt[c]++;
        if(cnt[5]==2 && cnt[7]==1)
        {
            cout << "YES"<<endl;
        }
        else
            cout << "NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn solve(n: u64) -> u32 {
    let a = n.to_string()
        .bytes()
        .map(|c| (c - b'0') as u32)
        .collect::<Vec<_>>();
    let r = (0..a.len())
        .map(|i| {
            (0..i).map(|j| a[j]).sum::<u32>() + cmp::max(a[i], 1) - 1 + 9 * (a.len() - i - 1) as u32
        })
        .max()
        .unwrap();
    cmp::max(r, a.into_iter().sum())
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next()));
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
a,b,c = gets.split(" ").map(&:to_i)
aa = [1,3,5,7,8,10,12]
bb = [4,6,9,11]
cc = [2]

if (aa.include?(a) && aa.include?(b)) ||
   (bb.include?(a) && bb.include?(b))
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
n = int(input())

score = [0, 0]
for i in range(n):
    c = input().split()
    if c[0] == c[1]:
        score[0] += 1
        score[1] += 1
    elif c[0] < c[1]:
        score[1] += 3
    else:
        score[0] += 3

print(*score)

Measured memory_bytes: 7700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long x = scanner.nextInt();
        final List<Long> values = new ArrayList<>();
        values.add(0L);
        for (long i = 1; i <= 1_000; i++) {
            final long pow = i * i * i * i * i;
            values.add(pow);
            values.add(-pow);
        }

        Collections.sort(values);
        for (int i = 0; i < values.size(); i++) {
            final long value = values.get(i);
            final long diff = x + value;
            final int index = Collections.binarySearch(values, diff);
            if (index >= 0) {
                System.out.println(getIndex(index) + " " + getIndex(i));
                return;
            }
        }
    }

    private static int getIndex(final int index) {
        return index - 1000;
    }


    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}

Measured memory_bytes: 36836
def cnt2(n):
    res=0
    while n%2==0:
        n//=2
        res+=1
    return res

def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

def LCM(x,y):
    return x*y//GCD(x,y)

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

s={cnt2(ai) for ai in a}
if 0 in s or len(s)>1:
    ans=0
else:
    lcm=1 # 2で割るのは後にする
    for ai in a:
        lcm=LCM(lcm,ai)
    lcm//=2
    ans=(M//lcm+1)//2

print(ans)

Measured memory_bytes: 14244
x = gets()
y = x.split()

a = y[0].to_i
b = y[1].to_i
c = y[2].to_i

if a <= b && a <= c
 min = a
elsif b <= a && b <= c
 min = b
else
 min = c
end

if b <= a &&  c <= a
 max = a
elsif a <= b && c <= b
 max = b
else
 max = c
end

if max == a && min == b
 cen = c
elsif max == b && min == a
 cen = c
elsif max == a && min ==c
 cen = b
elsif max == c && min ==a
 cen = b
else
 cen = a
end

puts "#{min} #{cen} #{max}" 


Measured memory_bytes: 6872
#include <stdio.h>
int main() {
    int T[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int K;
    scanf("%d", &K);
    printf("%d", T[K - 1]);
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = 0, m = 0;
	for (auto c : s) {
		if (c == 'S') {
			n++;
		} else if (n) {
			n--;
		} else {
			m++;
		}
	}
	cout << n + m << endl;
	return 0;
}


Measured memory_bytes: 640
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;
use std::usize::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    }
    let max_v = 100_001;
    let mut dp = vec![vec![2_000_000_000; max_v]; n + 1];
    dp[0][0] = 0;
    for i in 0..n {
        for sum_v in 0..max_v {
            let (w_, v_) = wv[i];
            if (sum_v >= v_) {
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v_] + w_);
            }
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        }
    }

    let mut ans = 0;
    for v in 0..max_v {
        if dp[n][v] <= w {
            ans = v
        }
    }
    println!("{}", ans);
}


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

int main(){
    int n;
    int x[25];
    cin >> n;
    for (int i=0; i<n; ++i){
        cin >> x[i];
//        cout << x[i] << endl;
    }

    int count = 0;
    for (int j=n-1; j>=0; --j){
        bool sea = true;
        for (int k=0; k<j; ++k) {
//            cout << x[k] << " " << x[j] << endl;
            if (x[k]>x[j]){
                sea = false;
                break;
            }
        }
        if (sea) ++count;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e5+9;
	int n,m,T,x[N],y[N],ok[N],ans[N],cnt[N];
	bitset<50099> rch[50099],tmp;
	int main(){
		n=read<int>(),m=read<int>(),T=read<int>();
		for(int i=1;i<=m;i++) x[i]=read<int>(),y[i]=read<int>();
		if(T==1){
			for(int i=1;i<=n;i++) rch[i].set(i);
			for(int i=m;i;i--){
				tmp=rch[x[i]]|rch[y[i]];
				rch[y[i]]=rch[x[i]]=tmp;
			}
			tmp=rch[1];
			for(int i=2;i<=n;i++) tmp&=rch[i];

			int pos=-1;
			for(int i=1;i<=n;i++)
				if(tmp[i]){pos=i;break;}
			if(pos==-1) puts("-1"),exit(0);
			
			ok[pos]=1;
			for(int i=m;i;i--) 
				if(ok[x[i]]) ans[i]=1,ok[y[i]]=1;
				else if(ok[y[i]]) ok[x[i]]=1;
		}else{
			for(int i=1;i<=n;i++) ok[i]=i,cnt[i]=1;
			for(int i=m;i;i--){
				if(ok[x[i]]==ok[y[i]]) continue;
			//	cout<<x[i]<<" "<<y[i]<<" "<<ok[x[i]]<<" "<<ok[y[i]]<<endl;
				if(cnt[ok[x[i]]]+1!=n) ans[i]=1,cnt[ok[x[i]]]++,cnt[ok[y[i]]]--,ok[y[i]]=ok[x[i]];
				else if(cnt[ok[y[i]]]+1!=n) cnt[ok[y[i]]]++,cnt[ok[x[i]]]--,ok[x[i]]=ok[y[i]];
				else puts("-1"),exit(0);
			//	cout<<x[i]<<" "<<y[i]<<" "<<ok[x[i]]<<" "<<ok[y[i]]<<endl;
			}
		}
		for(int i=1;i<=m;i++) putchar(ans[i]?'^':'v');
		puts("");
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 310016
#C
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
s = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            i = gcd(a,b,c)
            s += i
print(s)

Measured memory_bytes: 74984
# include <cstdio>
# include <cstring>
# include <iostream>
# define R register int
# define ll long long

using namespace std;

const int maxn=100005;
int n;
int a[maxn],m,l,r,mid,ans,c[maxn],t[maxn<<1];

void ins (int x) { for (R i=x;i<=2*n+2;i+=(i&(-i))) t[i]++; }
int ask (int x) { int ans=0; for (R i=x;i;i-=(i&(-i))) ans+=t[i]; return ans; }

bool check (int ans)
{
    ll cnt=0;
    memset(t,0,sizeof(t));
    for (R i=1;i<=n;++i)
        if(a[i]<=ans) c[i]=c[i-1]+1;
        else c[i]=c[i-1]-1;
    ins(n+1);
    for (R i=1;i<=n;++i)
    {
        cnt+=ask(c[i]+n);
        ins(c[i]+n+1);
    }
    ll b=1LL*n*(n+1)/2;
    b/=2;
    return cnt>=b+1;
}

int main()
{
    scanf("%d",&n);
    for (R i=1;i<=n;++i)
        scanf("%d",&a[i]),m=max(m,a[i]);
    l=0,r=m,ans=m;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(check(mid))
            ans=min(ans,mid),r=mid-1;
        else
            l=mid+1;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	COMinit();
	int n, k; cin >> n >> k;
	ll ans=1;
	for(int i=1;i<=min(n-1,k);i++){
		ans+=COM(n,i)*COM(n-1,n-i-1);
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12160
s = int(input())
d = [[int(v) for v in input().split()] for i in range(s)]
ans = False
cnt = 0
for j in range(len(d)):
    if all(elem == d[j][0] for elem in d[j]):
        cnt += 1
    else:
        cnt = 0

    if cnt == 3:
        ans = True
        break
if ans:
    print ("Yes")
else:
    print("No")


Measured memory_bytes: 9176
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
}


Measured memory_bytes: 21588
n = int(input())
a = list(map(int, input().split()))
sums = [sum(a)]
cnt = 0
N = 10 ** 9 + 7

for i in range(n-1):
    sums.append((sums[-1] - a[i]) % N)

for i in range(n-1):
    cnt += a[i] * sums[i+1]
    cnt %= N

print(cnt)

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

typedef long long ll;
const ll INF = 1000000000000000000;
const ll MOD = 1000000000 + 7;

vector<int> v;

bool comp(int a, int b) {
  return a > b;
}

int enum_devisors(int n) {
  for (int i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (n/i != i) v.push_back(n/i);
    }
  }

  sort(v.begin(), v.end(), comp);
  return 0;
}

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

  int N, M;
  cin >> N >> M;

  int amari = M % N;
  int base = M / N;
  
  if (amari == 0) {
    cout << base << endl;
    return 0;
  }
  
  enum_devisors(M);
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    if (M / v[i] >= N) {
      cout << v[i] << endl;
      return 0;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a;
ll b[200005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	m=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a.pb(x);
		b[x]++;
	}
	for(int i=0;i<200005;i++){
	    m+=b[i]*(b[i]-1)/2;
	}
	for(int i=0;i<n;i++){
	    cout<<m-b[a[i]]*(b[a[i]]-1)/2 + (b[a[i]]-2)*(b[a[i]]-1)/2<<endl;
	}
	
	




	return 0;
}







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

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    rep(i,n)
    {
        char c = s[i];
        if((i%2==0 && c=='L') || (i%2==1 && c=='R'))
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
 
namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split(' ');
            int a = int.Parse(A[0]);
            int b = int.Parse(A[1]);
            double c = a;
            double d = b;
            Console.Write("{0} {1} ",a/b,a%b);
            Console.WriteLine((c/d).ToString("0.00000000"));
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 9332
n = int(input())
m = int(input())

edge = [[] for i in range(n)] #a→b bはaに勝利
visited = [0 for i in range(n)]
maxpath = [-2 for i in range(n)]
toposo = []

for i in range(m):
    x,y = map(int , input().split())
    edge[y-1].append(x-1)

def dfs(v):
    global visited , maxpath , toposo
    if visited[v] : return maxpath[v]
    visited[v] = 1
    if not (len(edge[v])):
        maxpath[v] = 0
        toposo.append(v)
        return 0
    else : 
        aa = 0
        for next in edge[v]:
             aa = max(aa, dfs(next))
        maxpath[v] = aa+1
        toposo.append(v)
        return aa+1

ansans = 0

for vv in range(n):
    if not visited[vv] : ansans = max(ansans,dfs(vv))
    
for ans in toposo:
    print(ans+1)


if ansans == n-1 : print("0")
else : print("1")


Measured memory_bytes: 10588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S,T;cin>>S>>T;
    int s=S.size();
    int t=T.size();
    reverse(S.begin(),S.end());
    reverse(T.begin(),T.end());
    bool ans=false;
    int x;
    for(int i=0;i+t-1<s;i++){
        for(int j=0;j<t;j++){
            if(S[i+j]!='?'&&S[i+j]!=T[j])break;
            if(j==t-1){
                ans=true;
                x=i;
            }
        }
        if(ans)break;
    }
    if(ans){
        for(int i=0;i<t;i++)S[x+i]=T[i];
        for(int i=0;i<s;i++){
            if(S[i]=='?')S[i]='a';
        }
        reverse(S.begin(),S.end());
        cout<<S<<endl;
    }
    else cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
	int H, W;
	while(1){
		cin >> H >> W;
		if (H == 0 && W == 0)
			break;
		else {
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					if (i == 0 || i == H - 1 || j == 0 || j == W - 1)
						cout << '#';
					else
						cout << '.';
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3004
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include <string.h>
using namespace std;
int a[100005];
int main() {
	int a, b, c;
	vector<int> d;
	cin >> a >> b >> c;
	d.push_back(a);
	d.push_back(b);
	d.push_back(c);
	sort(d.begin(), d.end());
	int dif1 = d[1] - d[0];
	int dif2 = d[2] - d[0];
	int dif3 = d[2] - d[1];
	int th = dif3 / 2;
	int o = (d[2] - d[0]) / 2;
	int tw = (d[2] - d[1]) / 2;
	if ((dif2 + dif3) % 2 == 0) {
		cout << (dif2 + dif3) / 2 << endl;
	}
	else {
		cout << o + th + 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256