akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  
  if(N!=1){
  
  for(int i=0;i<N;i++){
    if(pow(2,i)>N){
cout<<pow(2,i-1)<<endl;
      break;
    }
  }
  }
    
    else{
cout<<1<<endl;
    }
  }
  

Measured memory_bytes: 512
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt;
 
 
int getArea( char *checkstr, int start )
{
    int i,j;
    int ravine,water,maxh;
    int down;
    
    gareas[gcnt]=water=ravine=maxh=down=0;
    for( i=start, j=0; '\0'!=*(checkstr+i) &&  j<MAXLEN; i++, j++ ) {
        if( '\\'== *(checkstr+i) ) {
            ravine++;
            water++;
            water+=((ravine-1)*2);
        } else if( 0 < ravine && '/' == *(checkstr+i) ) {
            if( maxh < ravine ) { maxh=ravine; }     
            ravine--;
            if( 0 == ravine ) {
                gareas[gcnt]+=water;
                garea+=gareas[gcnt];
                gcnt++;
                return j;
            }           
        } else {
        	if( 0 < ravine ) {
	     		gareas[gcnt]+=ravine;
	    	}
        }       
    }
 
    return 0;
}
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; '\0'!=inputs[i]; i++ ) {
        next=getArea( inputs, i );
        i+=next;
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    if( gcnt ) {
        printf( "%d ", gcnt );
        for( i=0; i<gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt-1 ) {
                printf( " " );  
            } else {
                printf( "\n" ); 
            }
        }
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

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

int main (){
    int N, i, a[100];
    cin >> N;

    for (i = 0; i< N; ++i){
        cin >> a[i];
    }

    for (i = N; i > 0; --i){
        if (i != 1){
            cout << a[i-1] << " ";
        }
        else{
            cout << a[i-1] << endl;
        }
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a+b)*h/2;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3540
#!/usr/bin/env python3
import sys
from itertools import accumulate


def solve(N: int, X: int, x: "List[int]"):
    coeff = [2*i+1 if i >= 3 else 5 for i in range(N+1)]
    acc = list(accumulate([0]+x))
    ans = 10**32
    for i in range(1, N+1):
        tmp = 0
        p, q = N//i, N % i
        for j in range(p):
            tmp += coeff[p-j]*(acc[q+i*(j+1)]-acc[q+i*j])
        if q > 0:
            tmp += coeff[p+1]*acc[q]
        tmp += N*X+i*X

        ans = min(ans, tmp)
    print(ans)
    return


# Generated by 1.1.3 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
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46756
while True:
    n, x = [int(i) for i in input().split(' ')]
    if n == 0 and x == 0: break

    combis = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if x - i - j > j and x - i - j <= n:
                combis += 1
    print(combis)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5,Mod=1e9+7;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,a,b,ans,Fac[MAXN],iFac[MAXN],Inv[MAXN];
inline void Init(int n){
	Inv[1]=1;Rep(i,2,n)Inv[i]=1ll*(Mod-Mod/i)*Inv[Mod%i]%Mod;
	Fac[0]=iFac[0]=1;Rep(i,1,n)Fac[i]=1ll*Fac[i-1]*i%Mod,iFac[i]=1ll*iFac[i-1]*Inv[i]%Mod;
}
inline int C(int n,int m){return n<0||m<0||n<m?0:1ll*Fac[n]*iFac[m]%Mod*iFac[n-m]%Mod;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),a=read(),b=read(),Init(n+m);
	Rep(i,1,n-a)ans=(ans+1ll*C(b+i-2,b-1)*C(n-i+m-b-1,n-i))%Mod;
	cout<<ans<<'\n';
	return 0;
}





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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    //xがa以上でa＋b以下でyes
    if (a <= x && a + b >= x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    map<pair<int, int>, int> color;
    map<int, vector<int>> near;
    vector<pair<int, int>> ans;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        pair<int, int> p = {a, b};
        if (a > b)
            swap(p.first, p.second);
        ans.push_back(p);
        color[p] = -1;
        near[a].push_back(b);
        near[b].push_back(a);
    }
    int res = 0;
    for (auto vert : near) {
        int k = 1;
        set<int> st;
        for (int ngh : vert.second) {
            pair<int, int> p = {vert.first, ngh};
            if (p.first > p.second)
                swap(p.first, p.second);
            if (color[p] > 0) {
                st.insert(color[p]);
            }
        }
        for (int ngh : vert.second) {
            pair<int, int> p = {vert.first, ngh};
            if (p.first > p.second)
                swap(p.first, p.second);
            if (color[p] < 0) {
                while (st.count(k))
                    k++;
                color[p] = k;
                res = max(res, k);
                k++;
            }
        }
    }
    cout << res << endl;
    for (auto x : ans)
        cout << color[x] << endl;
}

Measured memory_bytes: 18548
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    rep(i,s.size()) cout << (s[i] == '9' ? '1' : '9');
    cout << endl;
}





Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
#define deg_to_rad(deg)			(((deg)/180)*M_PI)
#define rad_to_deg(rad)			((rad*180)/M_PI)
#define prique(T)				priority_queue<T, vector<T>, greater<T>>

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<int, int> P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

int main()
{
	char b;
	cin >> b;

	if (b == 'A') cout << 'T';
	else if (b == 'T') cout << 'A';
	else if (b == 'G') cout << 'C';
	else cout << 'G';

	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

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

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    bool isC = false;
    int c = 0;
    for(int i = 2; i < s.size() - 1; i++){
        if(s[i] == 'C'){
            isC = true;
            c = i;
        }
    }
    if(!isC){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 1; i < s.size(); i++){
        if(i == c) continue;
        if(isupper(s[i])){
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] items = Console.ReadLine().Split(' ');
    int N = int.Parse(items[0]);
    int X = int.Parse(items[1]);
    int minM = 1 << 30;

    for (int i = 0; i < N; ++i)
    {
      int m = int.Parse(Console.ReadLine());
      X -= m;
      minM = Math.Min(minM, m);
    }

    int ans = N + (X / minM);

    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13140
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 998244353

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,K=mint()
lr=[lint() for _ in range(K)]
dp=[0]*(N+1)
dp[1]=1
dp[2]=-1
tmp=0
for i in range(1,N):
    tmp+=dp[i]
    tmp%=MOD
    for l,r in lr:
        if i+l<=N:
            dp[i+l]+=tmp
            dp[i+l]%=MOD
        if i+r+1<=N:
            dp[i+r+1]-=tmp
            dp[i+r+1]%=MOD
print(sum(dp)%MOD)

Measured memory_bytes: 70768
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

int n;
long long a[100100], b[100100];
long long s[100100];
vector<pair<int, int> >V;
long long answer = 0;

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> a[i] >> b[i];
    s[i] = a[i] + b[i];
    V.push_back(make_pair(s[i], i));
  }
  sort(V.begin(), V.end());
  while(V.size() != 0){
    answer += a[V.back().second];
    V.pop_back();
    if(V.size() != 0){
      answer -= b[V.back().second];
      V.pop_back();
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 3572
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        eps=1e-10

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

bool dfs(vector<int>& balls,int i, int left, int right){
    if(i >= balls.size()) return true;

    bool l = true, r = true;
    if(left > balls[i]) l = false;
    if(right > balls[i]) r = false;

    if(!l && !r) return false;

    bool ok = false;

    if(l) ok |= dfs(balls, i+1, balls[i], right);
    if(r) ok |= dfs(balls, i+1, left, balls[i]);

    return ok;
}
int main(){
    int N;
    cin >> N;
    
    for(int i=0;i<N;i++){
        vector<int> balls(10);
        for(int j=0;j<10;j++) cin >> balls[j];

        bool ans = dfs(balls, 0, 0, 0);

        if(ans) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));//p^num
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, P;
    cin >> N >> P;
    ll ans = 1;
    auto res = prime_factorize(P);
    for(auto x : res){
        REP(i, x.second/N) ans *= x.first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println((X - A) % B);
        }
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N;
	cin >> N;
	vint P(N), Q(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}

	vint list;
	for (int i = 1; i <= N; i++) {
		list.emplace_back(i);
	}

	int np = -1;
	int nq = -1;

	for (int i = 0; i < 1000000; i++) {

		for (int j = 0; j < N; j++) {
			if (P[j] != list[j]) {
				break;
			}
			else if (j == N - 1) {
				np = i + 1;
			}
		}

		for (int j = 0; j < N; j++) {
			if (Q[j] != list[j]) {
				break;
			}
			else if (j == N - 1) {
				nq = i + 1;
			}
		}

		if (np >= 0 && nq >= 0) {
			break;
		}


		next_permutation(list.begin(), list.end());
	}


	cout << abs(np - nq);

}


Measured memory_bytes: 892
from sys import stdin
a = stdin.readline().rstrip()
a = list(str(a))
cnt = 0
e = 0
if len(a)%2 == 0:
	end = len(a)//2 
else:
	end = len(a)//2 +1

for s,t in zip(a,a[::-1]):
	cnt +=1
	if s != t:
		e += 1
	if cnt == end:
		break

                   
print(e)


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define  No cout<<"NO"<<endl;
#define  Yes cout<<"YES"<<endl;
#define  nl cout<<endl;

template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}
// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...); }

#ifdef _DEBUG // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }


const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

ll mul(ll a, ll b) {
    a *= b;
    return a % mod;
}

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MXN = 1e5+5;
vector<int>graph[MXN];
int dp[MXN];
int vis[MXN];
int ans=0;
void dfs(int  u){
vis[u]=1;
 for(auto i:graph[u]){

     if(!vis[i]){
         dfs(i);
     }
     dp[u]=max(dp[u],dp[i]+1);
 }
    ans=max(ans,dp[u]);
}
void solve() {
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        graph[u].pb(v);
    }
    for(int i=1;i<=n;i++) {
        if(!vis[i])
        dfs(i);
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//#endif
    int t = 1;
    //cin>>t;
    while (t--)solve();
    // cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}
//look if it requires ll

Measured memory_bytes: 12420
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	if(s == "Cloudy")
		cout << "Rainy" << endl;
	if(s == "Rainy")
		cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
num_map = dict()

for i in range(n):
    if l[i] not in num_map:
        num_map[l[i]] = 1
    else:
        num_map[l[i]] += 1

num_list = sorted(list(num_map.keys()))
m = len(num_list)
res = 0
for i in range(m - 2):
    for j in range(i + 1, m - 1):
        for k in range(j + 1, m):
            if num_list[i] + num_list[j] > num_list[k]:
                res += num_map[num_list[i]] * num_map[num_list[j]] * num_map[num_list[k]]
print(res)

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

int main() {
  int n,k; 
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin>>p.at(i);
  sort(p.begin(),p.end());
  int a=0;
  for(int y=0;y<k;y++)a+=p.at(y);
  cout<<a<<endl;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int x, int y, int H, int W) { return (0 <= x && x<H) && (0 <= y && y<W); }

struct Edge{
	int fr,to,val;
	bool operator < (Edge x){
		return (val<x.val);
	}
};

struct Graph {
	struct Edge {
		int fr, to, val;
		Edge(int f, int t, int v) :fr(f), to(t), val(v) {}
	};

	int V, E, t;
	vector<int>cost;
	vector<bool>vzt;
	vector<vector<pair<int,int>>>adj;//to,val
	void init(int n,int dflt) {//dflt!=0
		t = 1;
		V = n;
		adj = vector<vector<pair<int,int>>>(V + 1);
		cost = vector<int>(V + 1, dflt);
		vzt = vector<bool>(V + 1, false);
		return;
	}

	void Dijkstra(int s){
		priority_queue<pair<int,int>>pq;
		pq.push({s,0});
		cost[s]=0;
		while(!pq.empty()){
			auto now=pq.top().first,ncos=pq.top().second;
			pq.pop();
			for(int i=0;i<adj[now].size();i++){
				if(cost[adj[now][i].first]>cost[now]+adj[now][i].second){
					cost[adj[now][i].first]=cost[now]+adj[now][i].second;
					pq.push({ adj[now][i].first,cost[adj[now][i].first] });
				}
			}
		}
		return;
	}
};

int n;
Graph G;

int main() {
	cin >> n;
	G.init(n,(1<<30));
	for(int i=0;i<n;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int v,c;
			cin>>v>>c;
			G.adj[u].push_back({v,c});
		}
	}
	G.Dijkstra(0);
	for(int i=0;i<n;i++){
		cout<<i<<" "<<G.cost[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3156
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 2011
#define MAX_K 2011
using namespace std;
typedef long long ll;
const ll p = 1000000000 + 7;

ll binpow_mod(ll a, ll n, ll m) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n = n >> 1;
  }
  return res;
}

ll comb_mod(ll n, ll r, ll m) {
  ll ans = 1;
  for (ll i = 0; i <= r-1 ; i++) ans = (ans * (n-i)) % m;
  for (int i = r; i >= 1 ; i--) {
    ll num = binpow_mod(i, m-2, m);
    ans = (ans * num) % m;
  }
  return ans;
}

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

    ll N, K;
    cin >> N >> K;

    ll ans[MAX_K];
    fill(ans, ans + MAX_K, 0);

    for (ll i = 1; i <= K; i++) {
      if((N-K) + 1 >= i) {
	ans[i] = comb_mod((N-K) + 1, i, p);
	ans[i] %= p;
      }
      else {
	ans[i] = 0;	  
	break;
      }
      
      if(K-1 >= i-1) {
	ans[i] *= comb_mod(K-1, i-1, p);
	ans[i] %= p;
      }
      else {
	ans[i] = 0;
	break;
      }
    }

    for (ll i = 1; i <= K; i++) cout << ans[i] << endl;

    return 0;
}
    


Measured memory_bytes: 3212
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int H,W;
char c[32][32];
int a[2][32][32][32][32];
int rest[2][32][32][32][32];
int dy[] = {0,1,0,-1,0};
int dx[] = {1,0,-1,0,0};

typedef pair<int,pair<pair<int,int>,pair<int,int>>> state;

bool ok(int y,int x){return 0<=y && y<H && 0<=x && x<W
	&& (c[y][x] == '.' || c[y][x] == 'E');}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>W>>H && W){
		rep(i,H)cin>>c[i];
		int sqy,sqx,say,sax;
		rep(i,H)rep(j,W){
			if(c[i][j] == 'Q'){
				sqy=i, sqx=j, c[i][j] = '.';
			}
			if(c[i][j] == 'A'){
				say=i, sax=j, c[i][j] = '.';
			}
		}
		memset(a,0,sizeof(a));
		memset(rest,0,sizeof(rest));
		queue<state> Q;
		rep(qi,H)rep(qj,W)rep(ai,H)rep(aj,W)if(ok(qi,qj) && ok(ai,aj)){
			if(qi == ai && qj == aj){
				a[0][qi][qj][ai][aj] = -1;
				Q.push(mp(0,mp(mp(qi,qj),mp(ai,aj))));
			}
			else if(c[qi][qj] == 'E'){
				a[0][qi][qj][ai][aj] = 1;
				Q.push(mp(0,mp(mp(qi,qj),mp(ai,aj))));
			}
			else{
				rep(dir,5){
					int Qi = qi+dy[dir], Qj = qj+dx[dir];
					rest[0][qi][qj][ai][aj] += ok(Qi,Qj);
				}
			}
			rep(dir,5){
				int Ai = ai+dy[dir], Aj = aj+dx[dir];
				rest[1][qi][qj][ai][aj] += ok(Ai,Aj);
			}
		}
		while(sz(Q)){
			state q = Q.front(); Q.pop();
			int p = q.fir;
			int qy = q.sec.fir.fir, qx = q.sec.fir.sec;
			int ay = q.sec.sec.fir, ax = q.sec.sec.sec;
			int res = a[p][qy][qx][ay][ax];
			//cout<<p<<" "<<qy<<" "<<qx<<" "<<ay<<" "<<ax<<" : "<<res<<endl;
			if(p == 0){
				if(qy == sqy && qx == sqx && ay == say && ax == sax){
					if(res == 1)cout<<"Queen can escape."<<endl;
					else cout<<"Army can catch Queen."<<endl;
					goto end;
				}
				rep(dir,5){
					int Ay = ay+dy[dir], Ax = ax+dx[dir];
					if(!ok(Ay,Ax) || a[1][qy][qx][Ay][Ax] != 0)continue;
					if(res == 1){
						rest[1][qy][qx][Ay][Ax]--;
					}
					if(res == -1 || res == 1 && rest[1][qy][qx][Ay][Ax] == 0){
						a[1][qy][qx][Ay][Ax] = -res;
						Q.push(mp(1,mp(mp(qy,qx),mp(Ay,Ax))));
					}
				}
			}
			else{
				rep(dir,5){
					int Qy = qy+dy[dir], Qx = qx+dx[dir];
					if(!ok(Qy,Qx) || a[0][Qy][Qx][ay][ax] != 0)continue;
					if(res == 1){
						rest[0][Qy][Qx][ay][ax]--;
					}
					if(res == -1 || res == 1 && rest[0][Qy][Qx][ay][ax] == 0){
						a[0][Qy][Qx][ay][ax] = -res;
						Q.push(mp(0,mp(mp(Qy,Qx),mp(ay,ax))));
					}
				}
			}
		}
		cout<<"Queen can not escape and Army can not catch Queen."<<endl;
		end:;
	}
}

Measured memory_bytes: 17636
#include<iostream>
#include<algorithm>
#include<string>
#include<numeric>
#define int long long int
using namespace std;
int i, j, k, a, b, c, d, p[100][100], n, f;
signed main() {
	string s;
	cin >> s;
	string ss = "CODEFESTIVAL2016";
	for (i = 0; i < s.size(); i++) {
		if (s[i] != ss[i])
			n++;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    string s;
	cin>>n>>s;
    int i=0,j=n-1,ans=0;
	while (i < j){
		while (i < n and s[i] == 'R') i++;
		while (j >= 0 and s[j] == 'W') j--;
		if (i == n || j < 0 || i>j) break;
		ans++;i++;j--;
	}
	cout <<ans<<"\n";
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

vector< vector<lint> > prime_table(int n) {
  vector< vector<lint> > prime(n + 1);
  for(int i = 2; i <= n; i++) {
    if(prime[i].size()) continue;
    for(int j = i; j <= n; j += i) {
      prime[j].push_back(i);
    }
  }
  return prime;
}

void leave(string message) {
  cout << message << endl;
  exit(0);
}

int main() {
  lint N;
  cin >> N;
  vector<lint> A(N);
  for(auto& elem : A) cin >> elem;

  bool pairwise = true;
  auto pt = prime_table(1123456);

  set<lint> st;
  for(auto a : A) {
    for(auto prime : pt[a]) {
      if(st.count(prime)) {
        pairwise = false;
        break;
      }
      st.insert(prime);
    }
  }

  if(pairwise) leave("pairwise coprime");

  lint g = A[0];
  for(auto a : A) g = gcd(a, g);
  if(g == 1) leave("setwise coprime");

  cout << "not coprime" << endl;
}

Measured memory_bytes: 93892
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

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

int main(){
    int mod=1000000007;
    int n,s;
    scanf("%d",&n);
    for (int i=0;i<n;++i) {
        scanf("%d",&s);
        int w1[10]={0};
        int w2[10]={0};
        for (int j=0;j<8;++j) {
            w1[s%10]+=1;
            w2[s%10]+=1;
            s/=10;
        }
        int x=0,y=0;
        int tmp1=10000000;
        for (int a=0;a<8;++a) {
            for (int b=9;b>=0;--b) {
                if (w1[b]>0) {
                    x+=(b*tmp1);
                    tmp1/=10;
                    w1[b]-=1;
                    break;
                }
            }
        }
        int tmp2=10000000;
        for (int a=0;a<8;++a) {
            for (int b=0;b<10;++b) {
                if (w2[b]>0) {
                    y+=(b*tmp2);
                    tmp2/=10;
                    w2[b]-=1;
                    break;
                }
            }
        }
        printf("%d\n",x-y);
    }
    return 0;
}

Measured memory_bytes: 3096
#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>;

const double PI = acos(-1);

int main(void){
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double th, tm;
  th = (h*60 + m) / 720 *2*PI;
  tm = m / 60 *2*PI;
  double xh, yh, xm, ym;
  xh = a*sin(th); yh = a*cos(th);
  xm = b*sin(tm); ym = b*cos(tm);
  double dx, dy;
  dx = xh - xm;
  dy = yh - ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.12f",ans);
  return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int N_MAX = 3010;



int main() {
    int N; cin >> N;
    int m = 0;
    int a = 0;
    int r = 0;
    int c = 0;
    int h = 0;
    rp(i, 0, N) {
        string s;
        cin >> s;
        if(s[0] == 'M') m++;
        if(s[0] == 'A') a++;
        if(s[0] == 'R') r++;
        if(s[0] == 'C') c++;
        if(s[0] == 'H') h++;
    }
    ll res = 0;
    res += (ll) m * a * (r+c+h);
    res += (ll) m * r * (c+h);
    res += (ll) m * c * h;
    res += (ll) a * r * (c+h);
    res += (ll) a * c * h;
    res += (ll) r * c * h;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  string str;
  cin >> str;
  
  string cur_slime="";
  int cnt=0;
  for(int i=0;i<N;i++){
    if(cur_slime != str.substr(i, 1)){
      cur_slime = str.substr(i, 1);
      cnt += 1;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

/**
 * アルゴリズム
 * 10以上： 内部レーティング
 * 10未満： 100×(10−K)
 */

public class Main {
    public static void main(String[] args) {
        // 変数
        int n = 0; // 参加回数
        int r = 0; // 表示レーティング
        int rate = 0; // 内部レーティング

        // 入力値
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        r = sc.nextInt();

        if(n >= 10){
            rate = r;
        } else {
            rate = r + (100 * (10-n));
        }

        // 出力
        System.out.println(rate);
    }
}


Measured memory_bytes: 21844
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vector<vii> AdjList;

vi pai, color, dist, ts;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long int n, m;

	cin >> n >> m;
	n%=m;
	cout << min(n,m-n) << endl;
	return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    final int M = 1_000_000_007;
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] grid = new char[H + 1][W + 1];
    for (int i = 1; i <= H; i++) System.arraycopy(scanner.next().toCharArray(), 0, grid[i], 1, W);

    long[][] dp = new long[H + 1][W + 1];
    dp[0][1] = 1;
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if (grid[i][j] == '.') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % M;
      }
    }
    System.out.println(dp[H][W]);
  }
}


Measured memory_bytes: 49492
const main = (input: void) => {
  const args: string[] = input.split('');
  let cnt = 0;

  if (args[0] === '1') {
    cnt++;
  }
  if (args[1] === '1') {
    cnt++;
  }
  if (args[2] === '1') {
    cnt++;
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll n, a[55], sum;

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n;
    for (ll i = 0; i < n; ++i)
        cin >> a[i], sum += a[i];
    sort(a, a + n, greater<ll>());
    ll k = 0;
    if (sum - n * n > 0) {
        ll moves = sum - n * n;
        k = moves;
        ll mx = 0;
        for (int i = 0; i < n; ++i)
            a[i] += moves, mx = max(mx, a[i]);
        ll L = 0, R = mx;
        ll new_moves;
        while (L < R) {
            ll mid = (L + R) / 2;
            new_moves = 0;
            for (int i = 0; i < n; ++i)
                new_moves += max(0LL, a[i] - mid) / (n + 1);
            if (new_moves <= moves)
                R = mid;
            else
                L = mid + 1;
        }
        new_moves = 0;
        for (int i = 0; i < n; ++i)
            new_moves += max(0LL, a[i] - L) / (n + 1), a[i] -= max(0LL, a[i] - L) / (n + 1) * (n + 1);
        moves -= new_moves;
        sort(a, a + n, greater<ll>());
        while (moves--) {
            a[0] -= n + 1;
            sort(a, a + n, greater<ll>());
        }
    }

    while (a[0] >= n) {
        a[0] -= n;
        for (int i = 1; i < n; ++i)
            ++a[i];
        sort(a, a + n, greater<ll>());
        ++k;
    }

    cout << k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long int n, k;
    cin >> n >> k;
    int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    
    double t = 0.0; 
    
    for(int i=0;i<k;i++) t += (p[i]-1)*0.5+1;
    
    double max = t;
    for(int i=k;i<n;i++){
        t = t + ((p[i]-1)*0.5+1) - ((p[i-k]-1)*0.5+1);
        if(max < t) max = t;
        
    }
    
    cout << fixed << setprecision(10) << max << endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '1') {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    vector<int> A(10);
    rep(i,10) cin >> A[i];
    sort(ALL(A));
    reverse(ALL(A));
    cout << A[0] << endl;
    cout << A[1] << endl;
    cout << A[2] << endl;
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
using namespace std;
int S[15][1005];
int pre[15][1005];
int pos[15];
int ans=9999999;

int square(int x,int y,int p,int q)
{
	return pre[y][q]-pre[x][q]-(pre[y][p]-pre[x][p]);
}

int H,W,K;

int dfs(int x)
{
	if(x==H)
	{
		int res=0;
		pos[0]=1;
		pos[H]=1;
		int u,v;
		u=v=0;
		for(int k=1;k<H;k++)
		if(pos[k]) res++;
		for(int i=1;i<=W;i++)
		{
			int flag=u=0;
			for(int j=1;j<=H;j++)
			{
				if(pos[j])
				{
					int n;n=square(u,j,v,i);
					if(n>K) { flag=1;break;}
					u=j;
				}
			}
			if(flag){
				if(v==i-1) return 0;
				v=i-1;i--;res++;				
			}
		}
		ans=min(ans,res);
		return 0;
	}
	else{
		pos[x]=0;
		dfs(x+1);
		pos[x]=1;
		dfs(x+1);
	}
}


int main()
{
	string str;
	cin>>H>>W>>K;
	for(int i=1;i<=H;i++)
	{
		cin>>str;str='2'+str;
		for(int j=1;j<=W;j++)
		{
			S[i][j]=str[j]-'0';
			pre[i][j]=pre[i][j-1]+pre[i-1][j]-pre[i-1][j-1]+S[i][j];
		}
	}
	dfs(1);
	int m=square(1,3,3,5);
	cout<<ans<<endl;
	
	
} 

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


int main(){
    int N; cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    
    int Ma=0;
    for(int i=0; i<N; i++){
        int sum=0;
        for(int j=0; j<=i; j++){
            sum += A[j];
        }
        for(int k=i; k<N; k++){
            sum += B[k];
        }
        Ma = max(Ma, sum);
    }
    cout << Ma << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	bool p = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '?') S[i] = 'D';
	}
	cout << S << endl;
}


Measured memory_bytes: 3724
def main():
    S = input()
    string = 'ACGT'
    current = 0
    ans = 0
    i = 0
    while i <= (len(S)-1):
        if S[i] in string:
            current = 1
            j = i+1
            while j<len(S) and S[j] in string:
                j = j+1
                current = current+1
            if current>ans:
                ans = current
        i = i+1
    print(ans)
main()

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

int main()
{
	int a[6]={0};
	for(int i=0;i<5;i++)
	{
		int x;
		cin>>x;
		
		a[x]++;
	}
	for(int i=1;i<=5;i++)
	  if(a[i]==0)
	    cout<<i<<endl;
	
	return 0;   
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int A, B;
char ans[100][100];


void makeAns(){
	rep(i, 0, 50)
		rep(j, 0, 100) ans[i][j] = '.';
	rep(i, 50, 100)
		rep(j, 0, 100) ans[i][j] = '#';
		A--, B--;
	for(int i = 0;i < 50;i+=2){
		for(int j = 0;j < 100;j+=2){
			if(B == 0){ i = 50; break; }
			ans[i][j] = '#';
			B--;
		}
	}
	for(int i = 99;i >= 0;i-=2){
		for(int j = 0;j < 100;j+=2){
			if(A == 0){ i = 0; break; }
			ans[i][j] = '.';
			A--;
		}
	}
}


signed main(){
	cin >> A >> B;
	
	makeAns();
	
	cout << 100 << ' ' << 100 << endl;
	rep(i, 0, 100){
		rep(j, 0, 100) cout << ans[i][j];
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;

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

int main()
{
    int h, w, sy, sx, gy, gx;
    cin >> h >> w >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    auto dist = make_vec(h, w, INF);
    deque<P> que;
    dist[sy][sx] = 0;
    que.emplace_back(sy, sx);
    
    while(!que.empty())
    {
        auto [y, x] = que.front();
        que.pop_front();
        rep(i,4)
        {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s[ny][nx] == '#') continue;
            if(chmin(dist[ny][nx], dist[y][x]))
            {
                que.emplace_front(ny, nx);
            }
        }
        for(int i = -2; i <= 2; i++)
            for(int j = -2; j <= 2; j++)
            {
                if(abs(i) + abs(j) <= 1) continue;
                int ny = y + i;
                int nx = x + j;
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(s[ny][nx] == '#') continue;
                if(chmin(dist[ny][nx], dist[y][x] + 1))
                {
                    que.emplace_back(ny, nx);
                }
            }
    }
    ll ans = dist[gy][gx];
    if(ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8616
using System;
using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] tmpS = Console.ReadLine().Split(' ');
			int[] S = new int[n];
			for (int i = 0; i < n; i++)
			{
				S[i] = int.Parse(tmpS[i]);
			}
			int q = int.Parse(Console.ReadLine());
			string[] tmpT = Console.ReadLine().Split(' ');
			int[] T = new int[q];
			for (int i = 0; i < q; i++)
			{
				T[i] = int.Parse(tmpT[i]);
			}
			int count = 0;
			for (int j = 0; j < q; j++)
			{
				for (int i = 0; i < n; i++)
				{
					if (S[i] == T[j])
					{
						count++;
						break;
					}
				}
			}
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 9692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0]!=s[s.size()-1]){
        if(s.size() % 2 == 1) cout << "First" << endl;
        else
            cout << "Second" << endl;
    }else{
        if (s.size() % 2 == 0)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }
    

}


Measured memory_bytes: 512
from sys import exit

N, K = map(int, input().split())

S = input()

ans = ''

for i in range(N):
    if i == K - 1:
        if S[i] == 'A':
            ans += 'a'
        elif S[i] == 'B':
            ans += 'b'
        else:
            ans += 'c'
    else:
        ans += S[i]

print(ans)


Measured memory_bytes: 2940