akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define orep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define rrep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  orep(h, 3500) {
    orep(n, 3500) {
      ll bunshi = - h * n * N;
      ll bunbo = N * n + N * h - 4 * h * n;
      if(bunbo < 0 && bunshi % bunbo == 0) {
        cout << h << " " << n << " " << (bunshi / bunbo) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n) + out
        X_dumy = int(X_dumy / n)
    return out

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

print(len(Base_10_to_n(N, K)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
using ll = long long;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll a;
    long double b;
    cin >> a >> b;
    cout << ll(floor(a * b)) << endl;
}


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

int step,x,y;

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

int main(){
	while(scanf("%d %d",&x,&y)*x*y){
		step=0;
		if(x<y)swap(&x,&y);
		while(y>0){
			step++;
			x=x%y;
			swap(&x,&y);
		}
		printf("%d %d\n",x,step);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using ld = long double; 
int INF = 1e9;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  multiset<int> m;
  rep(i,n) {
    cin >> a[i];
    if(*m.begin() >= a[i] || i == 0) m.insert(a[i]);
    else{
      auto it = m.lower_bound(a[i]);
      m.erase(--it);
      m.insert(a[i]);
    }  
  }
  cout << m.size() << endl;
}


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

int N, M, a, b, ans;
vector<int> V[100100];
int dp[100100];

int f(int a) {
	if (V[a].size() == 0) return 0;
	if (dp[a] != -1) return dp[a];
	dp[a] = 0;
	for(int i=0; i<V[a].size(); i++) {
		int b = V[a][i];
		dp[a] = max(dp[a], f(b)+1);
	}
	return dp[a];
}

int main() {
	cin >> N >> M;
	for(int i=0; i<M; i++) {
		cin >> a >> b;
		V[a].push_back(b);
	}
	memset(dp, -1, sizeof(dp));
	for(int i=1; i<=N; i++) {
		ans = max(ans, f(i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	if (N < 1200) {
		cout << "ABC\n";
		return 0;
	}
	if (N < 2800) {
		cout << "ARC\n";
		return 0;
	}
	cout << "AGC\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vsz = vector<size_t>;

int main ()
{
    i64 x;
    cin >> x;
    vector<i64> lookup (128);
    for (i64 i = 0; i < 128; i++) {
        lookup[i] = i * i * i * i * i;
    }
    i64 a, b;
    for (int i = 0; i < 128; i++) {
        for (int j = i; j < 128; j++) {
            if (x == (lookup[i] - lookup[j])) {
                a = i;
                b = j;
                goto l_exit;
            }
            if (x == (lookup[i] + lookup[j])) {
                a = i;
                b = -j;
                goto l_exit;
            }
            if (x == (-lookup[i] - lookup[j])) {
                a = -i;
                b = j;
                goto l_exit;
            }
            if (x == (-lookup[i] + lookup[j])) {
                a = -i;
                b = -j;
                goto l_exit;
            }
        }
    }
l_exit:
    cout << a << " " << b;
}


Measured memory_bytes: 3632
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0513?year=2007

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> cards(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        cards[i] = i + 1;
    }

    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;

        if (k == 0) {//リフル
            vector<int> tmp(2 * n);
            for (int j = 0; j < n; ++j) {
                tmp[j * 2] = cards[j];
                tmp[j * 2 + 1] = cards[j + n];
            }
            cards = tmp;
        } else {//カット
            vector<int> bk;
            copy(cards.begin(), cards.begin() + k, back_inserter(bk));
            
            vector<int> fr;
            copy(cards.begin() + k, cards.end(), back_inserter(fr));

            copy(bk.begin(), bk.end(), back_inserter(fr));
            cards = fr;
        }
    }

    for (auto x:cards) {
        cout << x << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3112
function main(s) {
	s = s.split('\n')[0].split(' ').map(n => Number(n));

	if (s[0] === 1) s[0] += 13;
	if (s[1] === 1) s[1] += 13;

	if (s[0] > s[1]) console.log('Alice');
	else if (s[0] < s[1]) console.log('Bob');
	else console.log('Draw')
}

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



Measured memory_bytes: 18376
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

string s;
lint arr[1000001];
int main() {
	cin >> s;
	IREP(i, SZ(s)) {
		arr[SZ(s) - i - 1] = (s[i] - '0');
	}
	lint cnt = 0;
	REP(i, SZ(s) + 1) {
		if (arr[i] < 5 ||(arr[i] == 5 && arr[i + 1] < 5)) {
			cnt += arr[i];
		}
		else {
			cnt += (10 - arr[i]);
			arr[i + 1]++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 12060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>
#include <functional>
#include <stack>
#include <map>

int main (){
	int n;

	std::cin >> n;

	std::string s;

	std::cin >> s;

	for (size_t i = 0; i < s.length(); i++)
	{
		s[i] += n;
		if (s[i] > 'Z') {
			s[i] -= 26;
		}
	}

	std::cout << s << std::endl;

	return 0;
}

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

cnt = [0]*N
town = 1
for i in range(K):
    if cnt[town-1] ==1:
        break

    cnt[town-1] += 1
    town = A[town-1]


ans1 = sum(cnt)

import copy
town2 = copy.deepcopy(town)

cnt2 = [0]*N

for i in range(K):
    if cnt2[town2-1] ==1:
        break

    cnt2[town2-1] += 1
    town2 = A[town2-1]
    
ans2 = sum(cnt2)

if K <= 10**8:
    town4 = 1
    for i in range(K):
        town4 = A[town4-1]
    print(town4)
else:
    town3 = 1
    cnt3=[0]*N
    K2 = ((K-(ans1-ans2))%(ans2))+(ans1-ans2)
    for i in range(K2):
        if cnt3[town3-1] ==1:
            break

        cnt[town3-1] += 1
        town3 = A[town3-1]
    print(town3)

Measured memory_bytes: 32008
import java.io.*;
import java.util.*;

public class Main {


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int x= in.nextInt();
        int y = in.nextInt();
        int z =in.nextInt();
        in.out.println(z + " "+ x + " " + y);
        in.out.close();
    }
}


class FastScanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    PrintWriter out;

    FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    FastScanner(String in, String out_) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(in));
        out = new PrintWriter(out_);
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

Measured memory_bytes: 21204
#include<iostream>


using namespace std;

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

	int train_lowCost = 0;
	int bus_lowCost = 0;

	if (A < B) {
		train_lowCost = A;
	}
	else {
		train_lowCost = B;
	}

	if (C < D) {
		bus_lowCost = C;
	}
	else {
		bus_lowCost = D;
	}

	cout << train_lowCost + bus_lowCost << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll h, cnt = 1;
    cin >> h;
    ll ans = 0;
    while (h != 0) {
        h /= 2;
        ans += cnt;
        cnt*= 2;
    }
    cout << ans << endl;




}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
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; }
 
 
int main() {

	ll H, W, A, B;
	cin >> H >> W >> A >> B;

	bool flg = false;
	//if (B == 0 && A == 0) {
	//	cout << "No" << endl;
	//	return 0;
	//}

	//if (B != 0 && A != 0) {
	//	if (H % B != 0 && W % A != 0) {
	//		cout << "No" << endl;
	//		return 0;
	//	}
	//	if (H % B == 0) {
	//		flg = true;
	//	}
	//	else {
	//		flg = false;
	//	}
	//}

	ll cnt = 0;
	ll ycnt = 0;

	//if (!flg) {
	//	rep(y, H) {
	//		rep(x, W) {
	//			if (x < A) {
	//				if (y < B) cout << "1 ";
	//				else cout << "0 ";
	//			}
	//			else {
	//				if (y < B) cout << "0 ";
	//				else cout << "1 ";
	//			}
	//		}
	//		cout << endl;
	//	}
	//}
	//else {
		rep(y, H) {
			rep(x, W) {
				if (x < A) {
					if (y < B) cout << "1";
					else cout << "0";
				}
				else {
					if (y < B) cout << "0";
					else cout << "1";
				}
			}
			cout << endl;
		}
	//}


	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)a--;
	else b--;
	cout << a << " " << b;*/


	string s;
	cin >> s;
	rep(i, s.size()) {
		cout << "x";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[100005];
int dp[100005];
int dif(int a, int b)
{
    if(a>=b)return a-b;
    return b-a;
}
int min(int a, int b)
{
    if(a<=b)return a;
    return b;
}
int main(void) {
	// your code goes here
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%dd",&a[i]);
	dp[2] = dif(a[2],a[1]);
	for(i=3;i<=n;i++)
	dp[i] = min(dp[i-1] + dif(a[i],a[i-1]),dp[i-2] + dif(a[i],a[i-2]));
	printf("%d\n",dp[n]);
	return 0;
}



Measured memory_bytes: 896
using System;
using System.Linq;
using static System.Math;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (Abs(abcd[2] - abcd[0]) <= abcd[3])
            {
                Console.WriteLine("Yes");
            }
            else if (Abs(abcd[0] - abcd[1]) <= abcd[3] && Abs(abcd[1] - abcd[2]) <= abcd[3])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void){
    int H,W,t,i;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
        break;
    }
    for(i=0;i<H;i++){
        for(t=0;t<W;t++){
            if(i%2==0){
                switch(t%2){
                case 0 : putchar('#'); break;
                case 1 : putchar('.'); break;
                }

            }

            else if(i%2==1){
                switch(t%2){
                case 1 : putchar('#'); break;
                case 0 : putchar('.'); break;
                }
        }

        }
        printf("\n");
    }
    printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1812
import sys
import bisect
input = sys.stdin.readline

n=int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans=0

for j in range(n):
    al=bisect.bisect_left(a,b[j])
    cl=n-bisect.bisect_right(c,b[j])
    ans+=al*cl
print(ans)


Measured memory_bytes: 94180
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt1=0,cnt2=0;
	for(int i=0;i<n;i++)
	  {
	  	if(s[i]=='R')
	  	  cnt1++;
	  }
	  if(cnt1==n)
	    cout<<"0"<<endl;
	    else 
	    {
	    	for(int i=0;i<cnt1;i++)
	    	  {
	    	  	if(s[i]=='R')
	    	  	     cnt2++;
			  }
			  cout<<(cnt1-cnt2)<<endl;
		}
		return 0;
}

Measured memory_bytes: 3704
#include <stdio.h>

int main()
{
	int W, H, x, y, r;

	scanf("%d" "%d" "%d" "%d" "%d", &W, &H, &x, &y, &r);
    if ((x >= r && x <= W - r) && (y >= r && y <= H - r))
		printf("Yes\n");
	else
		printf("No\n");
}


Measured memory_bytes: 2680
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int H, W;
    int h, w;
 
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
         
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        for (h = 2; h < H; h++) {
            putchar('#');
            for (w = 2; w < W; w++) putchar('.');
            putchar('#');
            putchar('\n');
        }
 
        for (w = 0; w < W; w++) putchar('#');
        putchar('\n');
 
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2044
def main():
    examC()

def examA():
    S = SI()
    if S[-1]=="s":
        ans = S+"es"
    else:
        ans = S+"s"
    print(ans)
    return

def examB():
    N = I()
    D = [LI()for _ in range(N)]
    current = 0
    for d1,d2 in D:
        if d1==d2:
            current += 1
        else:
            current = 0
        if current==3:
            print("Yes")
            return
    print("No")
    return

def examC():
    N = I()
    cnt = 0
    for i in range(1,N):
        for j in range(1,1+N//i-(N%i==0)):
            cnt += 1
    ans = cnt
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 83836
import java.util.*;
import java.math.BigInteger; 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        BigInteger lin_sum = new BigInteger("0");
        BigInteger sq_sum = new BigInteger("0");
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
            BigInteger ele = new BigInteger(Integer.toString(a[i]));
            BigInteger sq = ele.multiply(ele);
            lin_sum = lin_sum.add(ele);
            sq_sum = sq_sum.add(sq);
        }
       BigInteger lin_sq = lin_sum.pow(2);
       BigInteger minus = lin_sq.subtract(sq_sum);
       BigInteger two = new BigInteger("2");
       BigInteger ans = minus.divide(two);
       BigInteger mx = new BigInteger("1000000007");
       ans = ans.mod(mx);
        System.out.println(ans);
    }
}

Measured memory_bytes: 60316
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int h,w;std::cin>>h>>w;
    std::vector<std::vector<char>>g(h,std::vector<char>(w));
    for(auto&v:g)for(char&c:v)std::cin>>c;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(g.at(i).at(j)=='#'
                    &&(i==0||g.at(i-1).at(j)=='.')
                    &&(j==0||g.at(i).at(j-1)=='.')
                    &&(i==h-1||g.at(i+1).at(j)=='.')
                    &&(j==w-1||g.at(i).at(j+1)=='.')){
                std::cout<<"No"<<'\n';
                return 0;
            }
        }
    }
    std::cout<<"Yes"<<'\n';
}


Measured memory_bytes: 256
s = int(input())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)    
    p = 10 ** 9 + 7
    N = 2000  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)       
    return fact[n] * factinv[r] * factinv[n-r] % p

l = s//3
ans = 0
if s == 1 or s==2:
    print(0)
else:
    for i in range(l):
        n = i+1
        if n == 1:
            ans_n = 1
        else:
            ans_n = cmb((n-1)+s-3*n,n-1,10**9+7)
        ans = ans + ans_n
    ans = int(ans%(10**9+7))
    print(ans)

Measured memory_bytes: 9520
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    N = int(input())
    A = int(input())

    N %= 500

    if A >= N:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 5060
#include<iostream>
#include<vector>
#include<cstdlib>
#include<string>
#include<typeinfo>
using namespace std;

int main(){
  string str;
  int mini = 1000;
  cin >> str;
  int a;
  string b;
  for(int i = 0; i < str.length()-2; i++){
    string x,y,z;
    x = str[i];
    y = str[i+1];
    z = str[i+2];
    b = x+y+z;
    a = atoi(b.c_str());
    if(mini > abs(a-753)) mini = abs(a-753);
  }
  cout << mini << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	int a,b,c,k;
	cin >> a >> b >> c;
	
	if(a>b && a>c)if(b>c)cout << (a-b)+(b-c) << endl;
					else cout << (a-c)+(c-b) << endl;
	else if(b>c)if(a>c)cout << (b-a)+(a-c) << endl;
				else cout << (b-c)+(c-a) << endl;
	else if(a>b)cout << (c-a)+(a-b) << endl;
	else cout << (c-b)+(b-a) << endl;
	
return 0;
}

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

int main() {
  string a;
  cin >>a;
  for(int i=0; i<3; i++){
    if(a.at(i)=='7'){
      cout <<"Yes" <<endl;
      return 0;
    }
  }
  cout <<"No" <<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
static const ll MOD = 1000000007;

int a[200009];
int ans[200009];

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

  for(int i=0;i<n;i++) cin >> a[i];

  if(n%2==0){
    int front = 0;
    int back = n-1;
    for(int i=n-1;i>=0;i--){
      if(i%2 != 0){
        ans[front] = a[i];
        front++;
      }else{
        ans[back] = a[i];
        back--;
      }
    }
  }else{
    int front = 0;
    int back = n-1;
    for(int i=n-1;i>=0;i--){
      if(i%2 == 0){
        ans[front] = a[i];
        front++;
      }else{
        ans[back] = a[i];
        back--;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i!=0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3712
package main

// Solution for https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_d

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	A := make([]int, N+1)
	for i := 0; i < N; i++ {
		con.Scan(&A[i])
	}
	D := 0
	M := 1000
	S := 0
	if A[1] > A[0] {
		S += M / A[0]
		M %= A[0]
		D = 1
	}
	for i := 1; i < N; i++ {
		if D == 0 {
			if A[i+1] > A[i] {
				S += M / A[i]
				M %= A[i]
				D = 1
			}
		} else {
			if A[i+1] < A[i] {
				M += S * A[i]
				S = 0
				D = 0
			}
		}
	}
	con.Println(M)
	return nil
}


Measured memory_bytes: 1848
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();;
        int H = reader.nextInt();;
        int W = reader.nextInt();;
        System.out.println((N-H+1)*(N-W+1));
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21204
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(void){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    double result =sqrt(pow(x2-x1,2) + pow(y2-y1,2));
    printf("%f",result);
}

Measured memory_bytes: 1228
#include<stdio.h>
int main(void){
    int i,k,h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if(h == 0 && w == 0)break;
        for(i = 0; i < h; i ++ ){
            for(k = 0; k < w; k ++ ){
                if(i % 2 == 0){
                    if(k % 2 == 0)printf("#");
                    else printf(".");
                }
                else {
                    if(k % 2 == 0)printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
// 2017/08/01 Tazoe

#include <iostream>
using namespace std;

bool check(bool P[1000][1000], int N)
{
	for(int y=0; y<N/2; y++){
		for(int x=0; x<N/2; x++){
			if(P[y][x]==P[y][N-1-x]
			&& P[y][x]==P[N-1-y][x]
			&& P[y][x]==P[N-1-y][N-1-x])
				continue;

			return false;
		}
	}

	return true;
}


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

	bool P[1000][1000];
	for(int y=0; y<N; y++){
		for(int x=0; x<N; x++){
			char p;
			cin >> p;

			P[y][x] = (bool)(p-'0');
		}
	}
/*
	for(int y=0; y<N; y++){
		for(int x=0; x<N; x++){
			cout << (int)P[y][x];
		}
		cout << endl;
	}
*/

	bool Q[1000][1000];
	int  sumQ = 0;
	for(int y=0; y<N/2; y++){
		for(int x=0; x<N/2; x++){
			Q[y][x]         = !(P[y][x]==P[y][x]);
			Q[y][N-1-x]     = !(P[y][N-1-x]==P[y][x]);
			Q[N-1-y][x]     = !(P[N-1-y][x]==P[y][x]);
			Q[N-1-y][N-1-x] = !(P[N-1-y][N-1-x]==P[y][x]);
			if(Q[y][x])          sumQ++;
			if(Q[y][N-1-x])      sumQ++;
			if(Q[N-1-y][x])      sumQ++;
			if(Q[N-1-y][N-1-x])  sumQ++;
		}
	}

//	cout << sumQ << endl;

	int cnt = 0;

	if(sumQ==0){
		cnt++;
	}

	for(int i=1; i<C; i++){
		int D;
		cin >> D;

		for(int j=0; j<D; j++){
			int r, c;
			cin >> r >> c;

			if(r<=N/2 && c<=N/2){
				Q[r-1][N-c] = !Q[r-1][N-c];
				Q[N-r][c-1] = !Q[N-r][c-1];
				Q[N-r][N-c] = !Q[N-r][N-c];
				if(Q[r-1][N-c])  sumQ++;  else  sumQ--;
				if(Q[N-r][c-1])  sumQ++;  else  sumQ--;
				if(Q[N-r][N-c])  sumQ++;  else  sumQ--;
			}
			else{
				Q[r-1][c-1] = !Q[r-1][c-1];
				if(Q[r-1][c-1])  sumQ++;  else  sumQ--;
			}
		}

		if(sumQ==0){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 5052
def main():
    num = int(input())
    data_a = list(map(int, input().split()))
    data_a.sort()
    data_b = list(map(int, input().split()))
    data_b.sort()
    data_c = list(map(int, input().split()))
    data_c.sort()

    shita_b = [0 for i in range(num)]

    ind = 0
    for i in range(num):
        now_b = data_b[i]
        while data_c[ind] <= now_b:
            ind += 1
            if ind >= num:
                ind = num
                break
        if ind == num:
            break
        shita_b[i] = num - ind


    ans = 0
    tasu_now = sum(shita_b)
    ind = 0
    for i in range(num):
        now_a = data_a[i]
        while now_a >= data_b[ind]:
            tasu_now -= shita_b[ind]
            ind += 1
            if ind >= num:
                ind = num
                break
        if ind == num:
            break
        ans += tasu_now

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 24052
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//#include <stdlib.h> 

int main(void) {
	int m, r, f;
	int sum;
	
	while (1) {
		scanf("%d %d %d", &m, &r, &f);
		if ((m == -1 && r == -1) && f == -1)
			break;
		sum = m + r;

		if (m == -1 || r == -1) {
			printf("F\n");
		}
		else {
			if (sum >= 80)
				printf("A\n");
			else if (sum >= 65 && sum < 80)
				printf("B\n");
			else if (sum >= 50 && sum < 65)
				printf("C\n");
			else if (sum >= 30 && sum < 50) {
				if (f >= 50)
					printf("C\n");
				else
					printf("D\n");
			}
			else if (sum < 30)
				printf("F\n");
		}
	}

	

	//system("pause");


	return 0;
}


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

int main(){
	ll h;
    cin >> h;
    ll ta = 1;
    int cou = 0;
    ll ans = 0;
    while(h > 1){
      cou++;
      ans += ta;
      ta *= 2;
      h/=2;
    }
	cout << ans + ta << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N, K, X ,Y;
	scanf("%d %d %d %d", &N, &K, &X, &Y);
	if (N <= K){
		printf("%d\n", N*X);
	}
	else if (N > K){
		printf("%d\n", K*X+(N-K)*Y);
	}
	return 0;
}

    


Measured memory_bytes: 128
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
    print(0)
else:
    m=max(a,c)
    M=min(b,d)
    print(M-m)


Measured memory_bytes: 77308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	vector<int> L;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		L.push_back(x);
	}
	sort(L.begin(), L.end());
	int sum = 0;
	for (int i = 0; i + 1 < L.size(); i++) sum += L[i];
	if (sum > L[N - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
}


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

// Binary Indexed Tree (0-indexed)
template<class T> struct BIT {
    int n;
    vector<T> bit;
    void init(int _n) { n = _n; bit.assign(n+1, 0); }

    // [0, i)
    T sum(int i) {
        assert(0 <= i && i <= n);
        T res = 0;
        while(i)  res += bit[i], i -= i & (-i);
        return res;
    }

    void add(int i, T x) {
        assert(0 <= i && i <= n-1);
        i++;
        while(i <= n)  bit[i] += x, i += i & (-i);
    }

    // sum(i) >= val なる最小のiを返す
    int lower_bound(T val) {
        int ok = n;
        int ng = 0;
        while(ok - ng > 1) {
            int m = (ok + ng) / 2;
            (sum(m) >= val ? ok : ng) = m;
        }
        return ok;
    }
};

lint n;
vector<tuple<lint, lint, lint>> qs;
vector<lint> as, bs;
BIT<lint> ia, va;

int main() {
    cin >> n;
    for(lint i = 0; i < n; i++) {
        lint t;  cin >> t;
        if(t == 1) {
            lint a, b;  cin >> a >> b;
            qs.emplace_back(t, a, b);
            as.push_back(a);  bs.push_back(b);
        }
        if(t == 2)  qs.emplace_back(t, 0, 0);
    }

    map<lint, lint> rank;
    sort(as.begin(), as.end());
    as.erase(unique(as.begin(), as.end()), as.end());
    for(lint i = 0; i < as.size(); i++)  rank[as[i]] = i;

    ia.init(as.size());
    va.init(as.size());

    lint sz = 0;
    lint sum_b = 0;
    for(auto e : qs) {
        lint t, a, b;  tie(t, a, b) = e;
        if(t == 1) {
            ia.add(rank[a], 1);
            va.add(rank[a], a);
            sum_b += b;
            sz++;
        }

        if(t == 2) {
            lint im = ia.lower_bound( (sz+1)/2 ) - 1;
            lint vm = as[im];
            lint left = vm * ia.sum(im) - va.sum(im);
            lint right = va.sum(as.size()) - va.sum(im+1) 
                       - vm * (ia.sum(as.size()) - ia.sum(im+1));
            lint sum_a = left + right;
            cout << vm << " " << sum_a + sum_b << endl;
        }
    }
}

Measured memory_bytes: 16684
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()


int main() {
  ll H,W;
  cin>>H>>W;
  vector<string> vec(H);
  for(ll i=0;i<H;i++) {
cin>>vec[i];
  }
  
  vector<vector<ll>> a(H,vector<ll>(0));
  vector<vector<ll>> b(W,vector<ll>(0));
vector<vector<ll>> A(H,vector<ll> (W,0));
  for(ll i=0;i<H;i++) {
ll count=0;
    ll sum=0;
    for(ll j=0;j<W;j++) {
if(vec[i][j]=='#') {
count++;
  a[i].push_back(sum);
  sum=-1;
}
      A[i][j]=count;
      sum++;
    }
    
a[i].push_back(sum);
    
    
  }
  
  
  vector<vector<ll>> B(W,vector<ll>(H,0));
  for(ll i=0;i<W;i++) {
    ll count=0;
    ll sum=0;
    for(ll j=0;j<H;j++) {
      if(vec[j][i]=='#') {
count++;
        b[i].push_back(sum);
       
        sum=-1;
      }
      B[i][j]=count;
      sum++;
    }
    b[i].push_back(sum);
    
  }
  
  ll ans=0;
  for(ll i=0;i<H;i++) {
for(ll j=0;j<W;j++) {
if(vec[i][j]=='#') {
continue;
}
  ll p=A[i][j];
  ll q=B[j][i];
  
  ans=max(ans,a[i][p]+b[j][q]-1);
}
  }
  
  cout<<ans<<endl;
}


  

Measured memory_bytes: 137616
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [A, B, M] = r.nn()

    const ap = r.nn()
    const bp = r.nn()

    const amin = ap.reduce((a, b) => Math.min(a, b), Infinity)
    const bmin = bp.reduce((a, b) => Math.min(a, b), Infinity)

    let res = amin + bmin

    for (let i = 0; i < M; i++) {
      const [x, y, c] = r.nn()

      res = Math.min(res, ap[x - 1] + bp[y - 1] - c)
    }

    return res
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<ll,int> pl;

int main()
{
    int n;
    ll L,T;
    scanf(" %d %lld %lld", &n, &L, &T);

    vector<ll> x(n);
    vector<int> w(n);
    rep(i,n) scanf(" %lld %d", &x[i], &w[i]);

    vector<pl> ant_pos(n);
    rep(i,n)
    {
        if(w[i]==1) ant_pos[i] = pl((x[i]+T)%L,i);
        else ant_pos[i] = pl((x[i]-T+L*1000000000LL)%L,-i);
    }
    sort(all(ant_pos));

    // rep(i,n) printf(" %lld, %d\n", ant_pos[i].fi, ant_pos[i].se);

    ll ct=0;
    for(int i=1; i<n; ++i)
    {
        if(w[0] != w[i])
        {
            ll d;
            if(w[0]==1) d=x[i]-x[0];
            else d=x[0]+L-x[i];

            ll add = 0;

            ll dist = 2*T;
            dist -= d;

            if(dist<0) continue;

            ++add;
            add += dist/L;
            // printf("add = %lld\n", add);


            if(w[0]==1) (ct+=add)%=n;
            else ct = (ct-add+n*1000000000LL)%n;
        }
    }

    // printf("ct = %d\n", ct);
    int idx=0;
    while(idx<n && ant_pos[idx].se!=0) ++idx;

    idx = (idx-ct+n)%n;

    rep(i,n) printf("%lld\n", ant_pos[(i+idx)%n].fi);
    return 0;
}


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

struct UnionFind
{
    vector<int> par;
    vector<int> size;

    UnionFind(int N) : par(N), size(N)
    {
        for (int i = 0; i < N; i++){
            par[i] = i;
            size[i] = 1;
        }
    }

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

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
        size[ry] += size[rx];
        size[rx] = 0;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


 
int main(){
  int n, m;
  cin >> n >> m;
  
  UnionFind tree(n);
  
  rep(i, m){
      int a, b;
      cin >> a >> b;
      
      tree.unite(a-1, b-1);
  }
  
  int ans = 0;
  
  rep(i, n)ans = ans<tree.size[i]? tree.size[i] : ans;
  
  cout << ans << endl;
}

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

int main(){
  string s; cin >> s;
  int len=s.size();
  bool flag=(s.at(0)=='1' && s.at(len-1)=='0');
  for(int i=0;i<len-1;i++){
    if(s.at(i)!=s.at(len-2-i))flag=false;
  }
  if(!flag){
    cout << -1 << "\n";
    return 0;
  }
  flag=1;
  int temp=0;
  for(int i=1;i<len;i++){
    printf("%d %d\n",temp+1,i+1);
    if(flag)temp=i;
    if(s.at(i)=='1')flag=1;
    else flag=0;
  }
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n,m,k;
    cin >> n >> m >> k;
    vll a(n);
    vll b(m);
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    }
    for(ll i=0;i<m;i++) { 
    	cin >> b[i];
    }
    for(ll i=1;i<n;i++) {
    	a[i] += a[i-1];
    }
    for(ll i=1;i<m;i++) {
    	b[i] += b[i-1];
    }
    ll ans = 0;
    // if(a[0] > k && b[0] > k) {
    // 	cout << ""
    // }
    for(ll i=0;i<n;i++) {
    	ll tmp = a[i];
    	ll srch = k - tmp;
    	if(srch < 0) {
    		break;
    	}
    	auto up = upper_bound(all(b), srch);
    	ll cnt = (ll) (up - b.begin());
    	ans = max(ans, i+1 + cnt);
    }
    for(ll i=0;i<m;i++) {
    	ll tmp = b[i];
    	ll srch = k - tmp;
    	if(srch < 0) {
    		break;
    	}
    	auto up = upper_bound(all(a), srch);
    	ll cnt = (ll) (up - a.begin());
    	ans = max(ans, i+1 + cnt);
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

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

int main() {

    string S;
    ll K;
    cin >> S >> K;

    rep(i, K) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }

    cout << "1" << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans =0;
  for(int i=1;i<N;++i){
    int cnt =0;
    
    for(char c = 'a';c <= 'z';c++){
      bool left = false,right = false;
      
      for(int j=0;j<i;++j){
        if(S[j] == c)left = true;
      }
      for(int j=i;j<N;++j){
        if(S[j]==c)right =true;
      }
      if(left&&right)cnt++;
    }
    if(ans<cnt) ans=cnt;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 25
#define NIL -1
struct Node_struct{int p, s, d, l, r;}; /*p: 親(parent), l: 左の子(left child), r:右の子(right child)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];

void print(int u){
 
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d", u, T[u].p, T[u].s, T[u].d, D[u], H[u]);


  
  if(T[u].p == NIL) printf(", root");
  else if(T[u].d == 0) printf(", leaf");
  else printf(", internal node");
  
  
  
  printf("\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
  if(T[u].r != NIL) calcDepth(T[u].r,p+1);
}

void calcHeight(int u, int p){
  
  if(T[u].d == 0) H[u] = 0;
  else{
  
  if(T[u].l != NIL) calcHeight(T[u].l,p);
  if(T[u].r != NIL) calcHeight(T[u].r,p);

  H[u] = H[T[u].l]+1;
  
  if(H[T[u].l] < H[T[u].r]) H[u] = H[T[u].r]+1;
  }
}

     
int main(){
  int i, j;
  int n;
  int id, childr, childl;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    T[i].p = T[i].s = T[i].l = T[i].r = NIL;
    T[i].d =0;
    H[i] = -1;
  }
  for(i=0; i<n; i++){
    scanf("%d %d %d", &id, &childr, &childl);
    if(childr != -1){
      T[id].r = childr;
      T[childr].p = id;
      T[id].d++;
      
    }
    if(childl != -1){
       T[id].l = childl;
      T[childl].p = id;
      T[id].d++;
    }
    if((childr != -1)&&(childl != -1)){
    T[childr].s = childl;
    T[childl].s = childr;
    }
    
  }
  

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //それぞれのノードの高さを求める
  calcHeight(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 2052