akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int A[M];
    for(int i=0;i<M;i++) cin >>A[i];
    for(int i=0;i<M;i++){
        N-=A[i];
    }
    if (N<0) N=-1;
    cout << N;
}

Measured memory_bytes: 3644
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
a,b=map(int,input().split())
if a==0:
    print(0)
else:
    if a%b==0:
        print(0)
    else:
        x=a%b 
        while True:
            if x>abs(x-b):
                x=abs(x-b)
            else:
                break 
        print(x)
        


Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for (int l = 0; l < d; l++) {
				set.add(sc.nextInt());
			}
		}
		int kotae = n - set.size();
		System.out.println(kotae);

		sc.close();
	}
}

Measured memory_bytes: 37328
import java.util.Scanner;

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

			String S = scan.next();
			String T = scan.next();

			char[]s = S.toCharArray();
			char[]t = T.toCharArray();
			int max = 0;

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

				for(int j = 0;j<t.length;j++) {
					if(s[i+j]==t[j]) {
						count++;
					}
				}
				//System.out.println(count);
				if(max<count)max = count;

			}


			System.out.println(T.length()-max);



		}


	}


}


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

int A, B;

int main() {
	cin >> A >> B;
	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;
	if (A > B)
		cout << "Alice" << endl;
	else if (A == B)
		cout << "Draw" << endl;
	else
		cout << "Bob" << endl;
}

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

#define N 128
#define INT(X) \
  ( *( (int *)(X) ) )

typedef struct
{
  int time;
  int diff;
} k_pair;

int cpr (
  const void  * a,
  const void  * b
  )
{
  return ( INT(a) - INT(b) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    k_pair d[ N * 2 ];
    int res = 0;
    int sp = 0;
    int n;

    scanf ( "%d", &n );
    if ( !n ) break ;
    for ( i = 0; i < n; ++i )
    {
      int m, a, b;

      scanf ( "%d%d%d", &m, &a, &b );
      d[ sp   ].time = a;
      d[ sp++ ].diff = m;
      d[ sp   ].time = b;
      d[ sp++ ].diff = -m;
    }

    qsort ( d, sp, sizeof ( k_pair ), cpr );
    for ( i = 0; i < sp; ++i )
    {
      res += d[ i ].diff;
      while ( i + 1 < sp && d[ i + 1 ].time == d[ i ].time )
      {
        res += d[ ++i ].diff;
      }
      if ( res > 150 )
      {
        puts ( "NG" );
        goto BREAKK;
      }
    }
    puts ( "OK" );
BREAKK: ;
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

long long mod = 1000000007;
long long ones[60], dp[60], X, K, N;

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> K;
  for (size_t i = 0; i < N; i++) {
    cin >> X;
    for(int i = 0;i < 42;i++) {
      if((1LL << i) & X) {
        ones[i]++;
      }
    }
  }

  for(int i = 0;i < 42;i++) {
    dp[i] = (1LL << i) * max(ones[i], N-ones[i]);
    if(i != 0) {
      dp[i] += dp[i-1];
    }
  }

  long long ans = 0, tans = 0;
  for(int i = 41;i >= 0;i--) {
    if(K - (1LL << i) >= 0) {
      ans = max(ans, tans + ones[i]*(1LL << i) + ((i > 0) ? dp[i-1] : 0));
      tans += (N-ones[i])*(1LL << i);
      K -= (1LL << i);
    } else {
      tans += ones[i]*(1LL << i);
    }
  }

  ans = max(ans, tans);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);

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 string dir = "DRUL";

int H, W;
bool IsIn(int x,int y){
    return 0<=x&&x<H&&0<=y&&y<W;
}
ll dp[110][110];
int main() {

    cin >> H >> W;
    vector<string> A(H);
    rep(i,H)cin >> A[i];
    rep(i,H)rep(j,W)dp[i][j] = INFLL;
    dp[0][0] = (A[0][0] == '#' ? 1:0);
    rep(i,H)rep(j,W){
        rep(k,2){
            int ni = i + dx[k];
            int nj = j + dy[k];
            if(!IsIn(ni, nj))continue;
            int cost = 0;
            if(A[i][j] == '.' && A[ni][nj] == '#')cost++;
            chmin(dp[ni][nj], dp[i][j] + cost);
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 384
import numpy as np
def resolve():
    n, k = map(int, input().split())
    a = np.array(input().split(), dtype=np.int64)
    a.sort()
 
    zero = np.count_nonzero(a == 0)
    positive = a[a > 0]
    negative = a[a < 0]
 
    def count(x):  # 積が x 以下のペアは何個あるか？
        ans = 0
        if x >= 0:  # 片側が 0 の場合
            ans += n * zero
        ans += np.searchsorted(a, x // positive, side="right").sum()  # 片側が正の場合
        ans += n * len(negative) - np.searchsorted(a, -(-x // negative), side="left").sum()  # 片側が負の場合 切り上げは -(-a//b)
        ans -= np.count_nonzero(a * a <= x)  # 同じもの2つは選べない
        return ans // 2
 
    ok = 10 ** 18
    ng = -ok - 1
    while ok - ng > 1:  # 二分探索
        cen = (ok + ng) // 2
        if count(cen) >= k:
            ok = cen
        else:
            ng = cen
    print(ok)
 
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 50568
#include <iostream>
#include <algorithm>
#define MAX 10000000
using namespace std;

int main(){
  int n,m;
  int go[101][101];
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++) go[i][j] = MAX;
  }
  cin >> n;
  for(int i=0;i<n;i++){
    int r,k,tmp;
    cin >> r >> k;
    for(int j=0;j<k;j++){
      cin >> tmp;
      go[r][tmp] = 1;
    }
  }
  cin >> m;
  while(m--){
    int s,d,ttl;
    cin >> s >> d >> ttl;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
	  go[j][k] = min(go[j][k],go[j][i] + go[i][k]);
	}
      }
    }
    if(go[s][d]+1 > ttl) cout << "NA" << endl;
    else cout << go[s][d]+1 << endl;
  }
}

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

int main() {

    int A , B , C , D ;

    cin >> A >> B >> C >> D ;

    for (int i = 1 ; i < 101 ; i++) {

        if (A - D*(i-1) > 0 && C - B*i <= 0){

            cout << "Yes" << endl;
            break;

        }

        else if (A - D*i <= 0 && C - B*i > 0 ){

            cout << "No" << endl;
            break;

        }

    }
}

Measured memory_bytes: 3636
#include <cstdio>

#define MAX(x, y) (x < y) ? y : x

int main(void)
{
	int n, k;
	int data[100000] = {0};
	
	while (1){
		scanf("%d %d", &n, &k);
		if (n == 0 && k == 0) break;
		for (int i = 0; i < n; i++){
			scanf("%d", &data[i]);
		}
		
		for (int i = 0; i < n - 1; i++){
			data[i + 1] += data[i];
		}
		for (int i = 0; i < n; i++){
//			printf("%2d ", data[i]);
		}
		int max = 0;
		for (int i = 0; i <= (n - k); i++){
			if (!(i == 0)) max = MAX(max, data[i + k - 1] - data[i - 1]);
			else max = data[i + k - 1];
		}
//		printf("\n");
		/*
		int max = 0, tmp;
		for (int i = 0; i <= (n - k); i++){
			tmp = 0;
			for (int j = i; j < (i + k); j++){
				tmp += data[j];
			}
			max = MAX(max, tmp);
		}*/
		
		printf("%d\n", max);
	}
	
	return (0);
}

Measured memory_bytes: 0
N = gets.to_i
is = (0...N/2).map{ |i| i*2+1 }.reverse + (0...(N+1)/2).map{ |i| 2*i }
if N%2 == 1
  is.reverse!
end
A = gets.split.map(&:to_i)
puts is.map{ |i| A[i] }.join(" ")


Measured memory_bytes: 27876
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	
	
	
	ll a,b;cin>>a>>b;
	ll ans=max(a*b,max(a+b,a-b));
	cout<<ans;
	
	
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;

  int c[m];
  for (int i = 0; i < m; ++i)
    cin >> c[i];

  int dp[m + 1][n + 1];
  memset(dp, 0, sizeof(int) * (m + 1) * (n + 1));

  for (int i = 0; i < m; ++i) {
    if (c[i] < n + 1)
      dp[i + 1][c[i]] = 1;
  }

  for (int i = 0; i < m; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (c[i] > j) {
        dp[i + 1][j] = dp[i][j];
      } else {
        int tmp;
        if (dp[i + 1][j - c[i]] > 0)
          tmp = dp[i + 1][j - c[i]] + 1;
        else
          tmp = 1000000;
        if (dp[i][j - c[i]] > 0)
          tmp = min(dp[i][j - c[i]] + 1, tmp);
        if (dp[i + 1][j] > 0)
          tmp = min(dp[i + 1][j], tmp);
        if (dp[i][j] > 0)
          tmp = min(dp[i][j], tmp);
        dp[i + 1][j] = tmp;
      }
    }
  }

  cout << dp[m][n] << endl;

  return 0;
}


Measured memory_bytes: 7200
using System;
using System.Collections.Generic;
using System.Linq;

namespace comp
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var inputs = Console.ReadLine ().Split (' ').Select(x => int.Parse (x)).ToArray();

			var a = inputs[0] - 1;
			var b = inputs[1] - 1;

			var answer = a * b;

			Console.WriteLine(answer);
		}
	}
}


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

int main() {
    int N, M;
    cin >> N >> M;
    bool table[15][15] {};
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        table[a][b] = true;
        table[b][a] = true;
    }

    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i + 1;

    int ans = 0;
    do {
        if (v[0] != 1) break;
        bool check = true;
        for (int i = 1; i < N; i++) {
            if (!table[v[i]][v[i - 1]]) check = false;
        }
        if (check) ans++;
    } while (next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

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

long long n;
int main(){
cin>>n;//jumlah siswa
int a[n],b[n];//a = urutan & b = absen
for(int i=0;i<n;i++){
	cin>>a[i];//input urutan
	b[a[i]-1]=i+1;//urutan ke-a adalah absen b
}
for(int i=0;i<n;i++){
	cout<<b[i]<<" ";//output absen berdasar urutan
}
}

Measured memory_bytes: 1536
#include <stdio.h>

#define N 128

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int p, q;
  int i;

  while ( scanf ( "%d%d", &p, &q ) == 2 )
  {
    int r[ N ];
    int b = -1, n;

    r[ 0 ] = p % q;
    for ( n = 1; b == -1 && r[ n - 1 ]; ++n )
    {
      r[ n ] = ( r[ n - 1 ] * 10 ) % q;

      for ( i = 0; i < n; ++i )
      {
        if ( r[ i ] == r[ n ] )
        {
          b = i;
          break ;
        }
      }
    }

    for ( i = 0; i < n - 1; ++i )   putchar ( '0' + r[ i ] * 10 / q );
    puts ( "" );
    if ( b != -1 )
    {
      for ( i = 0; i < b; ++i )     putchar ( ' ' );
      for ( i = b; i < n - 1; ++i ) putchar ( '^' );
      puts ( "" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int i,j,n,d[30],deck,index;
	for(;scanf("%d",&n)&&n;){
		deck=32;
		for(i=0;i<n;i++)scanf("%d",&d[i]);
		for(i=0;deck>0;i++){
			index=i%n;
			deck-=(deck-1)%5;
			printf("%d\n",deck>0?deck:0);
			if(deck<=0)break;
			deck-=d[index];
			printf("%d\n",deck>0?deck:0);}}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
ll B[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n;

    for(int i=1;i<=n+1;i++)
        cin>>A[i];

    for(int i=1;i<=n;i++)
        cin>>B[i];

    ll res = 0;

    for(int i=1;i<=n+1;i++){
        if(A[i]<B[i-1]){
            res+=A[i]; A[i] = 0;
        }
        else {
            res+=B[i-1]; A[i]-=B[i-1];
        }
        if(A[i]>B[i]){
            res+=B[i]; B[i] = 0;
        }
        else {
            res+=A[i]; B[i]-=A[i];
        }
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 1792
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int n, m, p;

typedef tuple<int, int, int> tup;

vector<int> dist, pre;

bool bellmanFord(vector<tup>& edge, int s, vector<bool>& used){
    dist = vector<int>(n + 1, INF);
    pre = vector<int>(n + 1, -1);
    dist[s] = 0;
    bool negative = false;
    for (int i = 0;; i++) {
        bool update = false;

        for(tup e : edge){
            int from, to, cost;
            tie(from, to, cost) = e;

            if(not used[from] || not used[to]){
                continue;
            }
            if (dist[from] != INF && dist[to] > dist[from] - cost + p) {
                dist[to] = dist[from] - cost + p;
                pre[to] = from;
                update = true;
            }
        }
        if (!update) break;
        if (i > n) { negative = true; break; }
    }
    return negative;
}

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

    cin >> n >> m >> p;

    vector<tup> vt(m);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        vt[i] = make_tuple(a, b, c);
    }

    auto edge = initVec2<int>(n + 1, 0);
    rep(i, m){
        int a, b, c;
        tie(a, b, c) = vt[i];

        edge[b].push_back(a);
    }
    vector<bool> used(n + 1, false);
    stack<int> st;
    st.push(n);
    while(not st.empty()){
        int v = st.top();
        st.pop();

        if(used[v]){
            continue;
        }
        used[v] = true;

        for(int u : edge[v]){
            if(used[u]){
                continue;
            }
            st.push(u);
        }
    }

    int negative_cycle = bellmanFord(vt, 1, used);

    if(negative_cycle){
        cout << -1 << endl;
    }else{
        cout << max(-dist[n], 0LL) << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int a,b;
	for(a = 0; 9 > a; a++){
		for(b = 0; 9 > b; b++){
			printf("%dx%d=%d\n",a+1,b+1,(a+1)*(b+1));
		}
	}
	return 0;
}

Measured memory_bytes: 524
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()
    println(when {
        a > b -> a + (a - 1)
        a < b -> b + (b - 1)
        else -> a + b
    })
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37992
n,m,k=(int(i) for i in input().split())
mod = 998244353
fac=[1]
inv=[]
for i in range(n-1):
  fac.append(fac[-1]*(i+2)%mod)
for i in range(n):
  inv.append(pow(fac[i],mod-2,mod))
def modcom(n,k,fac,inv):
  if k>n or k<0:
    return 0
  elif k==n or k==0:
    return 1
  else:
    return((fac[n-1]*inv[k-1]*inv[n-k-1])%mod)
r=0
for i in range(0,k+1):
  r+=(m%mod)*pow(m-1,n-1-i,mod)*modcom(n-1,i,fac,inv)
print(r%mod)

  

Measured memory_bytes: 86268
def main():
    S = input()
    cnt = 0
    if(S[0] == "0"):
        if(len(S)%2 == 0):
            ans = "01"*(len(S)//2)
        else:
            ans = "01"*(len(S)//2)+"0"
    else:
        if(len(S)%2 == 0):
            ans = "10"*(len(S)//2)
        else:
            ans = "10"*(len(S)//2)+"1"
    
    for i in range(len(S)):
        if(S[i] != ans[i]):
            cnt += 1
    print(cnt)
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
int dyy[]={1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1};
int dxx[]={0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1};

int A,B,K;

signed main() {
    IOS();
    cin>>A>>B>>K;
    rrep(i,0,min(A,B)){
        if(A%(i+1)==0&&B%(i+1)==0)K--;
        if(K==0){
            cout<<(i+1)<<endl;
            return 0;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

const string YES = "Yes";
const string NO = "No";

string S;

bool isOK(ll from, ll to) {
  rep(i, from + 1, to - 1) {
    if (S[i] == '#' && S[i + 1] == '#') {
      return false;
    }
  }
  return true;
}

bool isOK2(ll mFrom, ll mTo) {
  rep(i, mFrom - 1, mTo) {
    if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
      return true;
    }
  }

  return false;
}

void solve(long long N, long long A, long long B, long long C, long long D) {
  A--;
  B--;
  C--;
  D--;

  if (D < C) {
    if (isOK(B, D) && isOK(A, C) && isOK2(B, D)) {
      print(YES);
      return;
    }
  } else {
    if (isOK(B, D) && isOK(A, C)) {
      print(YES);
      return;
    }
  }
  print(NO);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  std::cin >> S;
  solve(N, A, B, C, D);
  return 0;
}


Measured memory_bytes: 640
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void _yn(bool p) {
	p ? _y() : _n();
}

void _YN(bool p) {
	p ? _Y() : _N();
}


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n;
	cin >> n;
	int k = log10(n) + 1;
	int c = (n / (int)pow(10, k-1));
	int m = 0;
	if (k == 1) {
		cout << n;
		return 0;
	}
	f(i, 0, k-1) {
		m += (9 * (int)pow(10, i));
	}
	m += (c * (int)pow(10, k-1));
	if (n >= m) {
		cout << c + 9 * (k - 1);
	}
	else {
		cout << (c - 1) + 9 * (k - 1);
	}
	return 0;
}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

int main()
{
    FastIO 
    ll n, k;
    cin >> n >> k;
    ll x = n%k;
    cout << min(x, k-x) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define all(x) x.begin(),x.end()
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=998244353;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=200050;
struct segment{
	ll l,r;
}a[MAXN]; 
ll dp[MAXN],sum[MAXN];
void solve(int T){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%lld %lld",&a[i].l,&a[i].r);
	}
	dp[1]=sum[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i]+=(sum[max(0ll,i-a[j].l)]-sum[max(0ll,i-a[j].r-1)]+MOD)%MOD;
			dp[i]%=MOD;
		}
		sum[i]=sum[i-1]+dp[i];
		sum[i]%=MOD;
	}
	printf("%lld\n",(dp[n]+MOD)%MOD);
}
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 6924
/**
 * Created by Sakib on 06/16/2018.
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(args...) { dbg,args; cerr<<"\n"; }
template <typename T>
using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
struct debugger{
template<typename T>debugger& operator,(const T& v){cerr<<v<<" ";return *this;}}dbg;

#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

LL a[ N ];
vector < LL > V;

int main( int argc, char const *argv[] ) {
    fast_io;
    int n;
    cin >> n;
    FOR( i , 1 , n ) {
        cin >> a[i];
        if( a[i]%2 == 0 ) V.pb( a[i] );
    }
    sort( all(V) );
    LL t = 0;
    for( int i = 0; i < V.size(); i++ ) {
        while( V[i]%2 == 0 ) {
            V[i] /= 2;
            t++;
        }
    }
    cout <<t << endl;
    return 0;
}








Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int H, W, N;
while(
  cin >> H >> W >> N,W){
  VVI xs(H, VI(W));
  REP(y,H) REP(x,W) cin >> xs[y][x];
 
  VVI cnt(H+1, VI(W+1));
  cnt[0][0] = N-1;
  REP(y,H) REP(x,W){
	cnt[y][x+1] += cnt[y][x] / 2;
	cnt[y+1][x] += cnt[y][x] / 2;
	if(xs[y][x]) cnt[y][x+1] += cnt[y][x] % 2;
	else cnt[y+1][x] += cnt[y][x] % 2;
  }
 
  int x = 0, y = 0;
  while(x < W && y < H){
	if((xs[y][x] + cnt[y][x]) % 2) ++x;
	else ++y;
  }
  cout << y+1 << " " << x+1 << endl;  
 }
  return 0;
}

Measured memory_bytes: 10764
#include <stdio.h>
#include <string.h>

#define MAX 8
char table[MAX][MAX];

void rotate_90()
{
	char tmp[MAX][MAX];
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			tmp[j][(MAX-1)-i] = table[i][j];	
		}
	}

	memcpy( table, tmp, sizeof( table ) );
}

void print_table() 
{
	for ( int i = 0 ; i < MAX ; i++ ) {
		for ( int j = 0 ; j < MAX ; j++ ) {
			printf( "%c", table[i][j] );
		}
		printf( "\n" );
	}
}

int main()
{
	int i = 0;

	for ( i = 0 ; i < MAX ; i++ ) {
		scanf( "%s", table[i] );
	}

	for ( i = 1 ; i < 4 ; i++ ) {
		rotate_90();
		printf( "%d\n", 90 * i );
		print_table();
	}

	return 0;
}



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

int main(){
    int n; cin >> n;
    double ans;
    vector <int> A(n);
    
    for (int i=0; i<n; i++) cin >> A[i];
    sort(A.begin(),A.end());
    
    ans=(A[0]+A[1])/2.0;
    for (int i=2; i<n; i++){
        ans=(double)(ans+A[i])/2.0;
    }
    
    cout << ans;
}

Measured memory_bytes: 256
let n = read_int ()
let rec f n = if n mod 2 = 1 then 0 else 1 + f (n / 2)
let ans, m = ref 1, ref 0
let _ = for i = 1 to n do let c = f i in if c > !m then (m := c; ans := i) done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;
ll k;
pair<int, ll> p[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	FOR(i, n) {
		cin >> p[i].first >> p[i].second;
 	}
 	sort(p, p + n);
 	ll sum = 0, ans;
 	FOR(i, n) {
 		sum += p[i].second;
 		if (k <= sum) {
 			ans = p[i].first;
 			break;
 		}
 	}
 	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
 int n=in,m=in;
  if (n == m) out("Yes");
  else out("No");
}

Measured memory_bytes: 256
import sys  
input = sys.stdin.readline

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

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

maxans = 0
for l in range(K+1):
    for r in range(K-l+1):
        d = K - l- r
        if l+r > N:
            break
        hand = []
        hand.extend(V[:l])
        if r != 0:
            hand.extend(V[-r:])
        hand.sort()
        ans = sum(hand)

        for i in range(d):
            if len(hand) <= i+1:
                break
            if hand[i] < 0:
                ans -= hand[i]
        
        if ans > maxans:
            maxans = ans

print(maxans)

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        //bytesのiterを生成
        .bytes()
        //それをas charでchar型に変換したiterを生成
        .map(|c| c.expect("failed to read char") as char)
        //c.is_whitespace()がfalseになるまで（つまり普通の文字が出るまで）iterを進めたiterを生成
        .skip_while(|c| c.is_whitespace())
        // !c.is_whitespace()がtrue, 即ち（普通の文字の間）iterを進め, 進んだところまでのiterを生成
        .take_while(|c| !c.is_whitespace())
        // それをcollect()してiterからStringを作る
        .collect();
    // parse()で任意の型に変換して返す。
    token.parse().ok().expect("failed to parse token")
}

fn read_one_line_to_vec<T: FromStr>() -> Vec<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let v: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c == &'\x0d' || c == &'\x0a')
        .take_while(|c| !(c == &'\x0d' || c == &'\x0a'))
        .collect();
    v.split_whitespace()
        .map(|c| { let string = c.to_string();
            string.parse::<T>().ok().expect("failed to parse token")})
        .collect()
}


fn main() {
    let _n: usize = read();
    let numbers_used_for_creating_m: Vec<i32> = read_one_line_to_vec();
    let _q: usize = read();
    let m : Vec<i32> = read_one_line_to_vec();

    for m in m {
        if solve(0, m, &numbers_used_for_creating_m) {
            println!("yes")
        } else {
            println!("no")
        }
    }
}

fn solve(i: usize, m: i32, numbers_used_for_creating_m: &Vec<i32>) -> bool {
    if m == 0 {return true};
    if i >= numbers_used_for_creating_m.len() ||
        m < 0 {
        return false
    };

    solve(i+1, m - numbers_used_for_creating_m[i], numbers_used_for_creating_m)
        || solve(i+1, m, numbers_used_for_creating_m)
}

/*
fn print_vec(v: Vec<i32>) {
    let mut v_iter = v.iter();
    print!("{}", v_iter.next().as_ref().unwrap());
    for v in v_iter {
        print!(" {}", v)
    }
    println!();
}
*/


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

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

	int fx = 0;

	for( int x = N; x > 0; x /= 10 ) {
		fx += x % 10;
	}

	if( N % fx == 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main() {
    int n;
    while (cin >> n) {
        int mod = n % 39;
        if (mod == 0) mod = 39;
        cout << "3C"s << setfill('0') << setw(2) << mod << endl;
    }
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int main() {
  int x, y, s;
  while(cin >> x >> y >> s){
    if(x==0) return 0;
    int ans=0;
    REP(i, 1, s)REP(j, 1, s){
      int t = i*(100+x)/100 + j*(100+x)/100;
      if(t==s){
        int tt = i*(100+y)/100 + j*(100+y)/100;
        if(tt>ans) ans = tt;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int n, m, k;
int cnt;

void dfs(int i, int sm) {
    if (i == n) {
        cnt += max(1LL, sm - k);
        return;
    }

    rep2(d, 1, m + 1) dfs(i + 1, sm + d);
}

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

    while (cin >> n >> m >> k, n) {
        cnt = 0;
        dfs(0, 0);
        printf("%.10f\n", cnt / pow(m, n));
    }
}

Measured memory_bytes: 3284
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  vector<pair<ll, ll> > sushi(N);
  vector<vector<ll> > sushi1(N), sushi3(N);
  ll t;
  ll d;
  for(ll i=0;i<N;++i) {
    cin>>t>>d;
    t--;
    sushi[i] = mp(d, t);
    sushi1[t].push_back(d);
  }
  sort(sushi.begin(), sushi.end(), greater<pair<ll, ll> >());
  vector<ll> sushi2;
  ll seed=0, score=0;
  map<ll, ll> amap;
  for(ll i=0;i<K;++i) {
    if(amap[sushi[i].se]==0) seed++;
    amap[sushi[i].se]++;
    score += sushi[i].fi;
    sushi3[sushi[i].se].push_back(sushi[i].fi);
  }
  for(ll i=0;i<N;++i) {
    sort(sushi3[i].begin(), sushi3[i].end());
    if(sushi3[i].size()>0) for(ll j=0;j<sushi3[i].size()-1;++j) sushi2.push_back(sushi3[i][j]);
  }
  sort(sushi2.begin(), sushi2.end(), greater<ll>());
  vector<ll> ans;
  ans.push_back(score+seed*seed);
  for(ll i=K;i<N;++i) {
    if(amap[sushi[i].se]>0 || sushi2.size()==0) continue;
    score = score-sushi2[sushi2.size()-1]+sushi[i].fi;
    seed++;
    ans.push_back(score+seed*seed);
    sushi2.pop_back();
    amap[sushi[i].se]++;
  }
  sort(ans.begin(), ans.end(), greater<ll>());
  cout<<ans[0]<<endl;
}



Measured memory_bytes: 20436
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])

ans = 0
cnt = 0
for a, b in AB:
  if cnt+b <= M:
    cnt += b
    ans += a*b
    continue
  ans += a * (M - cnt)
  break
print(ans)  
    
  

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//
ll N;
vector<ll> A;

bool solve() {
    ll sum = 0;
    for (int i = 0; i < N; ++i) sum += A[i];

    // 操作回数(あまりが出る場合NO)
    ll num = sum / (N * (N + 1) / 2);
    if (sum % (N * (N + 1) / 2) != 0){
        return false;
    }

    // 隣接要素の差を考える
    for (int i = 0; i < N; ++i) {
        ll b = A[(i+1)%N] - A[i] - num;
        if (b % N != 0 || b > 0){
            return false;
        }
    }
    return true;
}


int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    A.resize(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    if (solve()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(){
  long s[200000],N,i,j,k,ans,bear,snuke;

  scanf("%ld",&N);
  for(i=0;i<N;i++){
    scanf("%ld",&s[i]);
  }

  bear = 0;
  for(j=1;j<N;j++){
    bear += s[j];
  }

  snuke = s[0];

  ans = labs(bear - snuke);

  for(k=1;k<N-1;k++){
    snuke += s[k];
    bear -= s[k];
    if(labs(snuke - bear)<ans){
      ans = labs(snuke -bear);
    }
  }

  printf("%ld\n",ans);
}


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

int partition(int A[],int p,int r){
  int x = A[r];
  int i = p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[j],A[i]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n;cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int pibot = partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i) printf(" ");
    if(i==pibot){
      printf("[%d]",A[i]);
    }else{
      printf("%d",A[i]);
    }
  }
  printf("\n");
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
long long MOD = 1e9 + 7;

long long RepeatSquaring(long long N, long long P, long long M){
    if(P==0) return 1;
    if(P%2==0){
        long long t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long f(long long N,long long A){
    long long num = 1,den = 1;
    for(long long i = N; N-A < i;i--){
        num *= i;
        num %= MOD; 
    }
    for(long long i = 1; i <= A;i++){
        den *= i;
        den %= MOD;
    }
    return num * modinv(den,MOD) % MOD;
}


int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long res = RepeatSquaring(2,n,MOD) - 1 - f(n,a) - f(n,b);
    res %= MOD;
    cout << (res < 0 ? res + MOD : res) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    string s;
    int k;
    cin >> s >> k;
    int len = 1, idx = 0, count = 0;
    set<string>se;
    bool check;
    char ch = 'a';
    while (true) {
        if (s[idx] == ch) {
            for (int i = 1; i <= s.size()-idx; i++) {
                string str = s.substr(idx, i);
                if (se.find(str) == se.end()) {
                    count++;
                    se.insert(str);
                }
		if (i == 5) break;
            }
        }
        idx++;
        if (idx == s.size()) {
            if (count >= k) break;
            ch++;
            if (ch > 'z') break;
            idx = 0;
        }
    }
    int i = 0;
    for (auto it = se.begin(); it != se.end(); it++) {
        i++;
        if (i == k) {
            cout << *it << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    char s;
    cin >> s;
    if(s >= 'A' && s <= 'Z')
    println("A");
    else println("a");
    return 0;
}

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

int main() {
    int A[] = {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; cin >> k;
    cout << A[k-1] << endl;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())

qu = deque([7,5,3])
cnt = 0

while qu:
	t = qu.popleft()
	if t > n:
		continue
	if set(str(t)) == {'7','5','3'}:
		cnt += 1
	qu.append(t*10+7)
	qu.append(t*10+5)
	qu.append(t*10+3)

print(cnt)

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

int main(){

    bool holds = true;
    vector<int> mem(4,0);//0が三角形の数　１が直角　２が鋭角　３が鈍角
    vector<int> tri(3);

    while(holds){
        vector<int> node(3);
        int a,b,c;
        cin>>node[0]>>node[1]>>node[2];

        for(int i=0;i<3;i++){
            if(node[i] >= node[(i+1)%3] + node[(i+2)%3]){
                holds = false;
            }
            else {
               sort(node.begin(),node.end());
               a = node[2];
               b = node[1];
               c = node[0];
            }
        }

        if(holds){
            mem[0]++;
            if(a*a > b*b + c*c) mem[3]++;
            else if (a*a < b*b + c*c) mem[2]++;
            else mem[1]++;
        }
    }
    for(int i=0;i<3;i++){
        cout<<mem[i]<<" ";
    }
    cout<<mem[3]<<endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yn(int o){
    if (o == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

int main() {
    int n, k; cin >> n >> k;
    cout << n * n - k << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b,c,k;cin>>a>>b>>c>>k;
	if(a>=k)cout<<k<<endl;
	else if(a+b>=k)cout<<a<<endl;
	else cout<<a-(k-(a+b))<<endl;
}


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

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

Measured memory_bytes: 256
N,K=map(int,input().split())
S=[1]*(N+1)
S[0]=0

for i in range(1,K+1):
  d=int(input())
  A=list(map(int,input().split()))
#  print(A)
  for j in A:
#    print(j)
    if S[j]==1:
      S[j]=0
      
Ans=sum(S)
print(Ans)
  

Measured memory_bytes: 9156
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
# ruby??§1/2???????????§0??????????????????????????¨??????????????????????????§???
# ?????¢??????????¨???????????????????????????????????????????????????£??????

include Math
require 'matrix'

def fractal(x1,y1,x2,y2)
	third = one_third(x1,y1,x2,y2)
	s = [x1+third[0],y1+third[1]]
	t = [x1+third[0]*2,y1+third[1]*2]
	vector = (Matrix[[1/2.to_f,-sqrt(3)/2.to_f],[sqrt(3)/2.to_f,1/2.to_f]]*Matrix[[third[0]],[third[1]]]).to_a
	u = [s[0]+vector[0][0],s[1]+vector[1][0]]
	return s,u,t,[x2,y2]
end

def one_third(x1,y1,x2,y2)
	return [((x2-x1)/3).to_f,((y2-y1)/3).to_f]
	#return (sqrt((x1-x2)**2+(y1-y2)**2))/3
end

n = gets.chomp.to_i
arrays = [[0.000000000,0.000000000],[100.000000000,0.000000000]]
n.times do 
	array1 = arrays[0]
	new_arrays = [[0.000000000,0.000000000]]
	arrays[1..(arrays.length-1)].each do |array2|
		new_array = fractal(array1[0],array1[1],array2[0],array2[1])
		new_array.each do |a|
			new_arrays.push(a)
		end
		array1 = array2
	end
	arrays = new_arrays
end
arrays.each do |array|
	puts array[0].to_s+' '+array[1].to_s
end

Measured memory_bytes: 9240