akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

// Begin Template IO/Utility
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out(){
	cerr<<endl;
}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
	cerr<<' '<< H; 
	dbg_out(T...);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &V){
	os<<'[';
	for(int i=0;i<(int)V.size();i++)
		os<<V[i]<<",]"[i==(int)V.size()-1];
	return os;
}
template<typename T> istream& operator>>(istream &is, vector<T> &V){
	for(T &x:V)
		is>>x;
	return is;
}
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T,U> &p){
	os<<'{'<<p.first<<','<<p.second<<'}';
	return os;
}
template<typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){
	is>>p.first>>p.second;
	return is;
}
template<typename T> void minself(T &a, T &b){
	a=min(a,b);
}
template<typename T> void maxself(T &a, T &b){
	a=max(a,b);
}
// End Template IO/Utility
int const MAXN=200100;
long long fact[MAXN];
int fastexp(long long base, long long esp, int mod){
	long long res=1;
	base%=mod;
	while(esp>0){
		if(esp%2)
			res=(res*base)%mod;
		esp/=2;
		base=(base*base)%mod;
	}
	return res;
}
int inv(int n, int mod){
	return fastexp(n,mod-2,mod);
}
int mod=1e9+7;

int bin(int n, int k){
	long long den=(fact[k]*fact[n-k])%mod;
	long long res=(fact[n]*inv(den,mod))%mod;
	return res;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n, k;
	cin>>n>>k;
	fact[0]=1;
	fact[1]=1;
	for(int i=2;i<=n+1;i++)
		fact[i]=(fact[i-1]*i)%mod;
	long long ans=0;
	for(int i=k;i<=n+1;i++){
		long long upp=((2LL*(n+1LL)-i+1LL)*i/2);
		long long low=(i*(i+1LL)/2);
		long long diff=(upp-low)%mod;
		ans=(ans+diff+1)%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 5200
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner (System.in);
        int X = sc.nextInt();
        while(true){
            boolean check = true;
            for(int i=2;i<Math.sqrt(X);i++){
                if(X%i==0){
                    check =false;
                    X++;
                    break;
                }
            }
            if(check) break;
        }
        System.out.println(X);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[100];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	  for (int j=1;j<=m;j++)
	  {
	     scanf("%s",s);
	     if (strcmp(s,"snuke")==0) 
		 {
		   printf("%c%d\n",j+'A'-1,i);
		   break;
		 } 
	  }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include <cstring> // strlen?????¨?????????????????????????????????????????????????????£?????????????????????????????¨??????????????£?????????
using namespace std;
 
int main()
{
	char num[1001];

	while(1){
		scanf("%s",num);//%s??????????????¨????????\??????????????¨?????¨???
		if(num[0] == '0') break;
		int s=0;

		for(int i=0;i<strlen(num);i++){//strlen??????????????????????????????????????´??????
			s += num[i] - '0';//??¢????????????????????§num?????????????????°??????????????????s????¶????
		}
		printf("%d\n",s);
	}

    return 0;
}

Measured memory_bytes: 1132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[][] s = new char[2][n];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		sc.close();

		int m = 1000000007;
		long ans = 3;
		boolean tate = true;
		int i = 1;
		if (s[0][0] != s[1][0]) {
			ans = 6;
			tate = false;
			i = 2;
		}
		for ( ; i < n; i++) {
			if (tate) {
				ans *= 2;
				ans %= m;
				if (s[0][i] != s[1][i]) {
					tate = false;
					i++;
				}
			} else {
				if (s[0][i] == s[1][i]) {
					tate = true;
				} else {
					ans *= 3;
					ans %= m;
					i++;
				}
			}
		}
		System.out.println(ans);
	}
}


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

LL arr[105];

int main()
{
    int N;
    cin >> N;
    for(int i=0;i<N;i++)
        cin >> arr[i];
    sort(arr, arr+N);
    int cnt=0;
    for(int i=0;i<N;i++)
        for(int j=i+1;j<N;j++)
        for(int k=j+1;k<N;k++)
    {
        if(arr[i]+arr[j]>arr[k]&&arr[i]!=arr[j]&&arr[j]!=arr[k])
          cnt++;
    }
    cout << cnt;


    return 0;
}


Measured memory_bytes: 3632
def second_problem():
    length = int(input())
    numbers_array: [int] = list(map(lambda n: int(n), input().split(' ')))

    questions_len = int(input())
    questions: [int] = list(map(lambda n: int(n), input().split(' ')))
    answers: [str] = ['no'] * questions_len

    for state in range(pow(2, length)):

        bit_arr = [(state >> x) & 1 for x in range(length)]
        state_val = sum([val * bit for val, bit in zip(numbers_array, bit_arr)])

        # Don't check numbers that we already have answers for
        for q_index in range(len(questions)):
            q = questions[q_index]
            if q == state_val:
                answers[q_index] = 'yes'
                # print(f'found solution for {q} at {bit_arr}')

    for ans in answers:
        print(ans)


second_problem()


Measured memory_bytes: 5628
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long 
#define ll long long 
#define pre(a,b) cout<<fixed<<setprecision(a)<<b<<"\n";//a for precision b for answer
#define mp make_pair
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b) 
#define forn(n) for(ll i=0;i<n;i++) 
#define ff first
#define ss second
#define MAX 1e18;
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define vmin *min_element
#define vmax *max_element
const int MOD = 1e9 + 7;
const int v1=1e5+5;
#define pi 3.141592653589793238
const int N=2e5+5;
 
 
//cout<<"Case #"<<p<<": "<<;
//f ile input  freopen("input.txt","r",stdin); 
//file output freopen("output.txt","w",stdout);
 
using namespace std;

int32_t main()
{
  IOS;
  ll h,w=0;
  cin>>h>>w;
  char a[h][w]={};
  ll dp[h][w]={};
  forn(h)
  {
    for(ll j=0;j<w;j++)
    {
      cin>>a[i][j];
    }
  }
  forn(h)
  {
    if(a[i][0]=='.')
      dp[i][0]=1;
    else
      break;
  }
  forn(w)
  {
    if(a[0][i]=='.')
    {
      dp[0][i]=1;
    }
    else
      break;
  }
  for(ll i=1;i<h;i++)
  {
    for(ll j=1;j<w;j++)
    {
      if(a[i][j]=='.')
      dp[i][j]=dp[i-1][j]+dp[i][j-1];
      else
        dp[i][j]=0;
      dp[i][j]%=MOD;
    }
  }
  cout<<dp[h-1][w-1]<<"\n";
}


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

/*
 * selection sort
 *  未ソート部分の先頭の要素を、未ソート部分の最小要素と交換
 *  全体の要素の先頭からソート済の列になる
 *
 *  安定ではない
 */
int selectionSort(vector<int>& a, int n) {
    int min_j, cnt = 0;
    for (int i=0; i<n; i++) {
        min_j = i;
        for (int j=i; j<n; j++) {
            if (a[j] < a[min_j]) {
                min_j = j;
            }
        }
        swap(a[i], a[min_j]);
        if (min_j != i) cnt++;
    }

    for (int i=0; i<a.size()-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;

    return cnt;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];

    cout << selectionSort(A, N) << endl;

    return 0;
}



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

using namespace std;

int h,w,sum,a[55][55];
char s[55][55];

void bt(int u, int v)
{
    int x=a[u][v]+1;
    if (s[u-1][v]=='.')
        if (x<a[u-1][v])
        {
            a[u-1][v]=x;
            bt(u-1,v);
        }
    if (s[u][v-1]=='.')
        if (x<a[u][v-1])
        {
            a[u][v-1]=x;
            bt(u,v-1);
        }
    if (s[u][v+1]=='.')
        if (x<a[u][v+1])
        {
            a[u][v+1]=x;
            bt(u,v+1);
        }
    if (s[u+1][v]=='.')
        if (x<a[u+1][v])
        {
            a[u+1][v]=x;
            bt(u+1,v);
        }
}

int main()
{
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
        {
            cin >> s[i][j];
            if (s[i][j]=='#') sum++;
        }
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            a[i][j]=3000;
    a[1][1]=1;
    bt(1,1);
    if (a[h][w]==3000) cout << -1;
    else cout << h*w-sum-a[h][w];
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    lli a,b;
    cin>>a>>b;
    a--;
    lli ans1,ans2;
	if(a%4==0)ans1=a;if(a%4==1)ans1=1;if(a%4==2)ans1=a^1;if(a%4==3)ans1=0;
 	if(b%4==0)ans2=b;if(b%4==1)ans2=1;if(b%4==2)ans2=b^1;if(b%4==3)ans2=0;
    cout<<(ans2^ans1);
    return 0;
}


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

int main(){
    int n, m, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> m;
        int j = 2;
        while(true) {
            if (j > sqrt(m)){
                cnt++; break;
            }
            else if(m%j == 0) break;
            j++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3100
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 17:22:34
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    int n = s.length();
    map<string, int> dict;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            dict[s.substr(i, j)]++;
        }
    }

    int m = 0;
    string ans;
    for (const auto& x : dict) {
        if (++m == k) {
            ans = x.first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
long long int ans=2019,n,d,a,b;
double x[100][100];
int main()
{
	cin>>a>>b;
	if(b-a>=2019)ans=0;
	a%=2019,b%=2019;
	
	if(b<a)b+=2019;
	for(long long int i=a;i<=b;i++)
	{
		for(long long int j=i+1;j<=b;j++)
		{
			ans=min((i*j)%2019,ans);
		}
	}
	ans%=2019;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int x,y;
    cin >> x >> y;
    int a = x+y, b = x-y, c = x*y; 
    int ans = max(a,b);
    ans = max(ans,c);
    cout << ans << endl;
}


Measured memory_bytes: 256
use std::cmp;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<i64>();
    let k = sc.value::<i64>();
    let mut a = sc.array::<i64>(n as usize);

    a.sort();
    let mut ans = 10_i64.pow(18);
    for i in 0..n-k+1 {
        ans = cmp::min(ans, a[(i+k-1) as usize] - a[i as usize]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int MAXN = 200005;
vector<vector<ll>> dp(MAXN, vector<ll>(3));

int main() {
    int n;
	cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    bool odd_flg = false;
    if (n%2) odd_flg = true;
    // rep(j,3) dp[0][j] = 0;
    rep(i,n/2) {
        dp[i+1][0] = dp[i][0] + a[i*2];
        dp[i+1][1] = max(dp[i][0]+a[i*2+1], dp[i][1]+a[i*2+1]);
        if(odd_flg) {
            dp[i+1][2] = max(max(dp[i][0]+a[i*2+2], dp[i][1]+a[i*2+2]), dp[i][2]+a[i*2+2]);
        }

    }
    ll ans = max(dp[n/2][0], dp[n/2][1]);
    if(odd_flg) ans = max(ans, dp[n/2][2]);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 15668
#include <stdio.h>
#define INF 1e9

int N, M, R;
int r[8];
int flag[8];
int graph[200][200];
int res = INF;

void chmin(int *a, int b){
  if(*a > b) *a = b;
}

void dfs(int depth, int las, int dist){
  if(depth == R){
    chmin(&res, dist);
    return;
  }
  for (int next = 0; next < R; next++) {
    if(flag[next]) continue;
    flag[next] = 1;
    if(las == -1) dfs(depth+1, next, 0);
    else dfs(depth+1, next, dist+graph[r[las]][r[next]]);
    flag[next] = 0;
  }
}

int main(void){
  scanf("%d%d%d", &N, &M, &R);

  for (int i = 0; i < R; i++) {
    scanf("%d", &r[i]);
    r[i]--;
    flag[i] = 0;
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if(i != j) graph[i][j] = INF;
    }
  }

  int a, b, c;
  for (int i = 0; i < M; i++) {
    scanf("%d%d%d", &a, &b, &c);
    a--; b--;
    graph[a][b] = graph[b][a] = c;
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        chmin(&graph[i][j], graph[i][k]+graph[k][j]);
      }
    }
  }

  dfs(0, -1, 0);

  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long tc;
	long long hasil = 1;
	
	scanf("%lld", &tc);
	
	long long input[tc];
	
	for(int i = 0 ; i < tc; i++){
		scanf("%lld", &input[i]);
	}
	
	for(int i = 0; i < tc; i++){
		if(input[i] == 0){
			printf("0\n");
			return 0;
		}
	}
	for(int i = 0; i < tc; i++){
		if(input[i] <= 1000000000000000000/hasil){
			hasil *= input[i];
		}else{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", hasil);
}

Measured memory_bytes: 2468
#include <iostream>
using namespace std;
int main() {
	
	int count[128]={0};

	string a;

	while (getline(cin , a)){
	
		for (int i=0; i<a.size(); i++){
			if (a[i] >= 'A' && a[i] <= 'Z'){
				a[i] = a[i]+32;
		} 
			count[a[i]]++;
		}
	}
		for (char j='a'; j<'{'; j++){
		
			cout << j << " : "<<  count [j] << endl;
		
		}
		cin>> a;
			
	
    
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 5;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> nums(n);
	for(int& x : nums) {
		scanf("%d", &x);
	}
	auto sum = [&](int start, int end) {
		long long sum = 0;
		for(int i=start; i <= end; ++i) {
			sum += nums[i];
		}
		return sum;
	};
	vector<vector<long long>> dp(n, vector<long long>(n));
	for(int i=0; i<n; ++i) {
		dp[i][i] = 0;
	}
	for(int i=2; i<=n; ++i) {
		for(int j=0; j<n-i+1; ++j) {
			int start = j, end = j+i-1;
			dp[start][end] = INF;
			for(int x=start; x < end; ++x) {
				dp[start][end] = min(dp[start][end], dp[start][x] + dp[x+1][end] + sum(start, end));
			}
		}
	} 
	printf("%lld\n", dp[0][n-1]);
	return 0;
}


Measured memory_bytes: 4864
<?php
$tower = [
  [
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
  ],
  [
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
  ],
  [
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
  ],
  [
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
    [0,0,0,0,0,0,0,0,0,0,],
  ],
];
$info = trim(fgets(STDIN));
for ($k = 0; $k < $info; $k++){
  $input_num = explode(" ", trim(fgets(STDIN)));
  $tower[$input_num[0] -1][$input_num[1] -1][$input_num[2] -1] = $tower[$input_num[0] -1][$input_num[1] -1][$input_num[2] -1] + $input_num[3];
}
foreach ($tower as $key => $value) {
  if ($key != 0)
  echo '####################'. PHP_EOL;
  foreach ($value as $k => $v) {
  echo ' ';
  echo implode(' ',$v);
  echo PHP_EOL;
  }
  }

Measured memory_bytes: 9336
#include<stdio.h>
#include<string.h>
 
int main()
{
	char input[201] ;
	char copy[201] ;
	int i;
	int m,r,n;
	
	while(scanf("%s\n",input),strcmp(input,"-"))
	{
		scanf("%d",&m);
		
		n = strlen(input);
		
		for(i = 0;i < m;i++)
		{
			scanf("%d",&r);
			strcpy(copy,&input[r]);
			strncat(copy,input,r);
			input[n] = '\0';
			
			strcpy(input,copy);
		}
		
		printf("%s\n",input);

  }
  return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    vector<int> B(M);
    vector<int> C(M);
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        for(int j=0; j<B[i]; j++){
            int c; cin >> c;
            c--;
            C[i] += (1 << c);
        }
    }
    
    
    
    vector<int> dp(1<<N, INF);
    dp[0] = 0;
    
    
    for(int i=0; i<1<<N; i++){
        for(int j=0; j<M; j++){
            dp[i | C[j]] = min(dp[i | C[j]], dp[i] + A[j]);
        }
    }
    
    cout << (dp[(1<<N) - 1] == INF? -1 : dp[(1<<N) - 1]) << endl;
    
    
    return 0;
}




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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int dx;

int main()
{
  while(cin >> dx){
    int res = 0;
    for(int d=dx; d<600; d+=dx) res += dx * d * d;
    cout << res << endl;
  }

  return 0;
}

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

using namespace std;

int comb (long long n ) {
	long long int sum = n * (n-1) / 2  ; 
	return sum ; 
}

int main() { 

ios_base::sync_with_stdio ;
cin.tie(NULL) ; 

int n , m ; 

cin >> n >> m ; 
unsigned long long x = comb(n) ; 
 x += comb(m);
cout << x << endl ; 
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
 
 
public class Main {
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        final int m = sc.nextInt();
        
        for(int tt = 0; tt < m; tt++){
        	boolean[][] map = new boolean[5][5];
        	
        	for(int i = 0; i < 5; i++){
        		for(int j = 0; j < 5; j++){
        			map[i][j] = sc.nextInt() == 1;
        		}
        	}
        	
        	int max = 0;
        	
        	for(int i = 0; i < 5; i++){
        		for(int j = 0; j < 5; j++){
        			loop:
        			for(int k = i; k < 5; k++){
        				for(int l = j; l < 5; l++){
        					for(int p = i; p <= k; p++){
        						for(int q = j; q <= l; q++){
        							if(!map[p][q]){
        								continue loop;
        							}
        						}
        					}
        					
        					max = Math.max(max, (k - i + 1) * (l - j + 1));
        				}
        			}
        		}
        	}
        	
        	System.out.println(max);
        }
         
         
    }
 
}

Measured memory_bytes: 26384
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let total = Array.fold_left (+) 0 a in
    let rec loop i acc best =
        if i = n - 1 then best else
            let acc = acc + a.(i) in
            loop (i + 1) acc (min best (abs (total - acc * 2)))
    in
    loop 0 0 max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
using namespace std;
#define fi first
#define se second
typedef long long lli;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
const int maxh = 1e4 + 5;
const int INF = 1e9 + 19;
int n, k;
int h[maxn];
int dp[maxn];

void ReadInput()
{
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
        cin >> h[i];
}

void Solve()
{
    fill(begin(dp), end(dp), INF);
    dp[1] = 0;
    for(int i = 1; i < n; ++i)
        for(int j = i + 1; j <= min(i + k, n); ++j)
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
    cout << dp[n] << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace templete
{
    class abc96_b
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            int sum = 0;

            Array.Sort(input);
            int max = input[input.Length-1];
            input[input.Length-1] = max*(int)Pow(2, n);

            foreach(var item in input)
            {
                sum += item;
            }
            WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11348
#include<cstdio>
#include<vector>
#include<algorithm>
const int MaxN=200010,mod=1000000007;
int n,vs[MaxN],left[MaxN],right[MaxN];
struct item{int x,v;bool operator<(const item&it)const{return x<it.x;}}a[MaxN];
bool cmp(int i,int j){return a[i].v<a[j].v;}
std::vector<int>lst[MaxN];
int T[1<<19],tag[1<<19];
#define Def int o,int L,int R
#define Mid (L+R>>1)
#define Ls o<<1,L,Mid
#define Rs o<<1|1,Mid,R
void build(Def){
	tag[o]=1;
	if(R-L>1)build(Ls),build(Rs);
}
void ins(int o,int x){
	T[o]=1ll*T[o]*x%mod;
	tag[o]=1ll*tag[o]*x%mod;
}
void pd(int o){
	if(tag[o]!=1){
		ins(o<<1,tag[o]);
		ins(o<<1|1,tag[o]);
		tag[o]=1;
	}
}
void mul(Def,int i){
	if(i==R)ins(o,2);
	else{
		pd(o);
		if(i<=Mid)mul(Ls,i);
		else mul(Ls,Mid),mul(Rs,i);
		T[o]=(T[o<<1]+T[o<<1|1])%mod;
	}
}
void mdf(Def,int i,int x){
	if(R-L==1)T[o]=x;
	else{
		pd(o);
		if(i<Mid)mdf(Ls,i,x);
		else mdf(Rs,i,x);
		T[o]=(T[o<<1]+T[o<<1|1])%mod;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].v);
		vs[i]=i;
	}
	std::sort(vs,vs+n,cmp);
	for(int i=0;i<n;i++)a[vs[i]].v=i;
	std::sort(a,a+n);
	for(int i=n;i--;){
		left[i]=i<n-1?left[i+1]:a[i].v;
		if(a[i].v<left[i])left[i]=a[i].v;
	}
	for(int i=0;i<n;i++){
		right[i]=i?right[i-1]:a[i].v;
		if(a[i].v>right[i])right[i]=a[i].v;
		lst[right[i]+1].push_back(left[i]);
	}
	build(1,0,n);
	int f=1,c=1;
	mdf(1,0,n,0,1);
	for(int i=1;i<=n;i++){
		for(int j=lst[i].size();j--;){
			int l=lst[i][j];
			if(l>0)mul(1,0,n,l);
			c=c*2%mod;
		}
		f=(c+mod-T[1])%mod;
		if(i<n)mdf(1,0,n,i,f);
	}
	printf("%d\n",f);
}

Measured memory_bytes: 19200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = sc.NextInt();
        }
        if (n % 2 == 1)
        {
            Console.WriteLine(0);
            return;
        }
        Array.Sort(d);
        if (d[n / 2] == d[n / 2 - 1])
        {
            Console.WriteLine(0);
            return;
        }
        Console.WriteLine(d[n / 2] - d[n / 2 - 1]);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


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

using namespace std;

const int P=1e9+7;

int n,K,ans;
vector<int> g[100010];

inline void dfs(int x,int fa){
	int cnt=g[x].size();

	if(x==1)ans=K;
	else cnt--;
	
	if(x==1){
		for(int i=K-1,j=1;j<=cnt;i--,j++)
			ans=(long long)ans*i%P;
	}else{
		for(int i=K-2,j=1;j<=cnt;i--,j++)
			ans=(long long)ans*i%P;
	}

	for(auto i: g[x])
		if(i!=fa)
			dfs(i,x);
}

int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,0);

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using  namespace std;
const int N = 1e5+5;
pair<int, int> p[N];
int n;
int main() {
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++)
    {
        scanf("%d", &p[i].first);
        p[i].second = i+1;
    }
    sort(p, p+n);
    for(int i = 0 ; i < n ; i++)
        cout<<p[i].second<<" ";
    return 0;
}

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

int const N=1e3+5, M=1e9+7, OO = 0x3f3f3f3f;

int n,m;
char grid[N][N];

long long mem[N][N];
long long solve(int i, int j)
{
    if(i==n-1 && j==m-1)
        return 1;
    if(mem[i][j]!=-1)
        return mem[i][j];
    long long ret=0;
    ret=(ret+((j+1<m && grid[i][j+1]=='.') ? solve(i,j+1) : 0))%M;
    ret=(ret+((i+1<n && grid[i+1][j]=='.') ? solve(i+1,j) : 0))%M;
    return mem[i][j]=ret;
}


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d %d",&n, &m);
    for(int i=0; i<n; i++)
        scanf("%s",grid[i]);
    memset(mem, -1, sizeof mem);
    printf("%lld\n",solve(0,0));


}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    bool ret1 = true;
    int N = S.size();
    for(int i = 0;i < N;i++) {
        if(S.at(i) != S.at(N - 1 - i)) {
            ret1 = false;
        }
    }
    for(int i = 0;i < (N - 1) / 2;i++) {
        if(S.at(i) != S.at((N - 1) / 2 - 1 - i)) {
            ret1 = false;
        }
    }
    for(int i = 0;i < (N - 1) / 2;i++) {
        if(S.at(i + (N + 3) / 2 - 1) != S.at(N - 1 - i)) {
            ret1 = false;
        }
    }
    if(ret1 == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main(void)
{
    // ll a, b;
    // cin >> a >> b;
    // vector<ll> AB(int(1e9));
    // for (int i = 1; i < min(a, b) + 1; i++)
    // {
    //     if (a % i == 0 && b % i == 0)
    //     {
    //         AB.push_back(i);
    //     }
    // }

    // ll ans = 0;
    // for (int i = AB.size() - 1; i >= 0; i--)
    // {
    //     for (int j = i - 1; j >= 0; j--)
    //     {
    //         if (float(AB[j]) / AB[i] == 0)
    //         {
    //             ans++;
    //         }
    //     }
    // }
    // cout << ans << endl;

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

    vector<int> ans(N);
    for (int i = 0; i < N; i++)
    {
        ans[A[i] - 1] = i + 1;
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 1664
#include<map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int mo=998244353;
string s;
map<string,int>g,f;
int F(string s);
int G(string s)
{
	if(g[s]) return g[s];
	int n=s.size(), t=(n>1?0:s[0]-47);
	fo(i,1,n/2) if(n%i==0)
	{
		string s1="";
		fo(j,0,i-1)
		{
			s1+="1";
			fo(k,0,n/i-1) if(s[i*k+j]=='0') {s1[j]='0'; break;}
		}
		t=(t+F(s1))%mo;
	}
	return g[s]=t;
}
int F(string s)
{
	if(f[s]) return f[s];
	int n=s.size(), t=0;
	fo(i,1,n) t=(t+1ll*G(s.substr(0,i))*F(s.substr(i,n-i)))%mo;
	return f[s]=t;
}
int main()
{
	cin>>s; f[""]=1;
	cout<<F(s); 
}

Measured memory_bytes: 14084
# S: SS,WW - o  SW,WS - x  true
# W: SS,WW - x  SW,WS - o  false

N = gets.to_i
S = gets
A = Array.new(N)
def b(c, n)
    A[0] = c
    current = n
    (1..(N - 1)).each do |i|
        A[i] = current
        if (current && S[i] == 'x') || (!current && S[i] == 'o') then
            current = !A[i - 1]
        else
            current = A[i - 1]
        end
    end

    if current == c &&
        ((c && (S[0] == 'o' ? A[1] == A[-1] : A[1] != A[-1])) ||
            (!c && (S[0] == 'x' ? A[1] == A[-1] : A[1] != A[-1]))) then
        return A.map{|a| a ? 'S' : 'W'}.join()
    end

    return false
end

puts b(true,true) || b(true,false) || b(false,true) || b(false,false) || -1


Measured memory_bytes: 7804
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

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

		if (A - B * 2 <= 0) {
			cout << 0 << endl;
		}

		else {
			cout << A - B * 2 << endl;
		}
		
		
	}
		

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

ll a,b,k;

int main(){
    cin>>a>>b>>k;
    ll k2=max(0ll,k-a);
    cout<<max(0ll,a-k)<<" "<<max(0ll,b-k2)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC046A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a ==b && b ==c)
            {
                Console.WriteLine("1");
            }

            else if (a == b || b == c || a == c)
            {
                Console.WriteLine("2");
            }

            else
            {
                Console.WriteLine("3");
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import math

def koch(d,p1x,p1y,p2x,p2y):
    if d == 0:
        return 0
    
    sin = math.sin(math.radians(60))
    cos = math.cos(math.radians(60))
    ax = (2 * p1x + 1 * p2x)/3 
    ay = (2 * p1y + 1 * p2y)/3 
    bx = (1 * p1x + 2 * p2x)/3 
    by = (1 * p1y + 2 * p2y)/3
    ux = (bx - ax)* cos - (by - ay)*sin + ax 
    uy = (bx - ax)* sin + (by - ay)*cos + ay

    koch(d-1,p1x,p1y,ax,ay)
    print(ax,ay)
    koch(d-1,ax,ay,ux,uy)
    print(ux,uy)
    koch(d-1,ux,uy,bx,by)
    print(bx,by)
    koch(d-1,bx,by,p2x,p2y)

d = int(input())
print(0,0)
koch(d,0,0,100,0)
print(100,0)


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n-1){
        ll x;
        cin >> x;
        a[x-1]++;
    }
    rep(i,n){
        cout << a[i] << endl;
    }

    return 0;
}






Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    
    int n = N;
    int L[100] = {};
    int i = 0;
    int a = 0;
    while (n--){
        cin >> L[i];
        a += L[i];
        i++;
    }
    
    i = 0;
    int max_L = 0;
    while(N--){
        max_L = max(max_L,L[i]);
        i++;
    }
    if(max_L*2<a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	int [] vx = {0,1,0,-1,1,1,-1,-1};
	int [] vy = {1,0,-1,0,1,-1,-1,1};
	char [][] data;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = 8;
			data = new char[n][n];
			for(int i = 0; i < n; i++){
				data[i] = sc.next().toCharArray();
			}
			boolean update = true;
			while(update){
				update = false;
				int max = 0, x = 0, y = 0;
				for(int i = 0; i < n; i++){
					for(int j = 0; j < n; j++){
						if(data[i][j] != '.')continue;
						int temp = find(i,j, 'o');
						if(max < temp){
							max = temp;
							x = j;
							y = i;
						}
					}
				}
				
				if(max > 0){
					update = true;
					data[y][x] = 'o';
					paint(x,y, 'o');
				}
				
				int max2 = 0, x2 = 0, y2 = 0;
				for(int i = n-1; i >= 0; i--){
					for(int j = n-1; j >= 0; j--){
						if(data[i][j] != '.')continue;
						int temp = find(i, j, 'x');
						if(max2 < temp){
							max2 = temp;
							x2 = j;
							y2 = i;
						}
					}
				}
				if(max2 > 0){
					update = true;
					data[y2][x2] = 'x';
					paint(x2,y2,'x');
				}
			}
			disp();
		}
	}

	private void disp() {
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				System.out.print(data[i][j]);
			}
			System.out.println();
		}
	}

	private void paint(int x, int y, char c) {
		for(int i = 0; i < vx.length; i++){
			int xx = x + vx[i];
			int yy = y + vy[i];
			boolean flg = false;
			while(true){
				if(! isOK(xx,yy))break;
				if(data[yy][xx] == c){
					flg = true;
					break;
				}
				else if(data[yy][xx] == '.'){
					break;
				}
				xx += vx[i];
				yy += vy[i];
			}
			
			if(flg){
				xx = x + vx[i];
				yy = y + vy[i];
				while(true){
					if(! isOK(xx,yy))break;
					if(data[yy][xx] == c){
						break;
					}
					else if(data[yy][xx] == '.'){
						break;
					}
					data[yy][xx] = c;
					xx += vx[i];
					yy += vy[i];
				}
			}
		}
	}

	private int find(int y, int x, char c) {
		int count = 0;
		for(int i = 0; i < vx.length; i++){
			int xx = x + vx[i];
			int yy = y + vy[i];
			int now = 0;
			while(true){
				if(! isOK(xx,yy))break;
				if(data[yy][xx] == c){
					count += now;
					break;
				}
				else if(data[yy][xx] == '.'){
					break;
				}
				now++;
				xx = xx + vx[i];
				yy = yy + vy[i];
			}
		}
		return count;
	}

	private boolean isOK(int xx, int yy) {
		if(0 <= xx && xx < 8 && 0 <= yy && yy < 8)return true;
		return false;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 18420
#%%

N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
#%%
cnt = 0
flag = False
for d in D:
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
#include<stdio.h>
#include<math.h>
int main(){
   int a,b,c,k;scanf("%d %d%d%d",&a,&b,&c,&k);
   if(k<=a){
       printf("%d",k);return 0;
   }
   if(k<=a+b){
       printf("%d",a);return 0;
   }
   if(k<=a+b+c){
       printf("%d",a-(k-a-b));return 0;
   }
   printf("%d",a-c);
}

Measured memory_bytes: 1716
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>

using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;

	a += b;

	cout << a * h / 2 << endl;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt()-sc.nextInt();
		
		out.println(n >= 0 ? n : 0);
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

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

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  ll x;
  cin>>x;
  ll cnt=0;
  ll y=100;//yokin
  while(y<x){
  y+=y/100;
  cnt++;
  }
  cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 3632
S = input()
T = input()

## 辞書順最小、を満たすために後ろから探索する
for s in range(len(S)-1, len(T)-2, -1):
  ## 1.一番後ろの文字が条件を満たした
  if (S[s] == T[-1]) or S[s] == '?':
    
    ## 2.そのまま、後ろから順に条件を満たすかを確認していく
    for t in range(1,len(T),1):
      if (S[s-t] != T[-t-1]) and S[s-t] != '?':
        break
    ## 条件をクリアしたindexが見つかった場合
    else:
      ## 全ての?をaに置き換えて
      S = S.replace('?', 'a')
      ## 条件をクリアしたindexをTと置換する
      ans = S[:s-len(T)+1] + T + S[s+1:]
      
      ## loopを抜ける
      break
else:
  ans = 'UNRESTORABLE'

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    double a;
    cin >> a;
    
    cout << a * 2 * M_PI << endl;
    
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <set> 
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <int> v(n);
    ll sum=0;
    map<int,int>mp; 
    for(int i=0;i<n;i++){
        cin>>v[i];
        mp[v[i]]++;
        sum+=v[i];
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        //cout<<mp[100]<<endl;
        sum-=((ll)mp[b]*b);
        sum+=((ll)mp[b]*c);
        mp[c]+=mp[b];
        mp[b]=0;
        
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 8028
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
int main(){
    
    int n;
    cin>>n;
    int i=1;
    int j=0;
    int ans[100];
    
    while(i<=n){
        
        if(i%3==0){
            cout<<' '<<i;
        }else{
            int x=i;
            while(x>=1){
                if(x%10==3){
                    cout<<' '<<i;
                    break;
                }
                x=x/10;
            }
            
        }
        i++;
    }

   cout<<endl;
    
    return 0;

}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<climits>
using namespace std;

#define ll long long
#define tc                int T;cin>>T;while(T--)
int a[100000];
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n, c, b ; cin >> n;
	for (int& e : a)cin >> e;
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e : {i + 1, i + 2}) {
			if (e < n)
				if ((dp[i] + abs(a[e] - a[i])) < dp[e])
					dp[e] = dp[i] + abs(a[e] - a[i]);
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
s=s[:-1]
while len(s)>0:
    if s[:len(s)//2]==s[len(s)//2:]:
        print(len(s))
        exit()
    s=s[:-1]


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

int main(){
	int N; cin >> N;
	vector<int> d(N); for(int i = 0; i < N; ++i) cin >> d[i];
	sort(d.begin(), d.end());

	if(N % 2 == 1) { cout << 0 << endl; return 0; }

	cout << d[N/2] - d[N/2-1] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    long int n, m, l, ans;
    cin >> n;
    cin >> m;
    cin >> l;
    long int A[n][m], B[m][l];

    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < m; j++ ) {
            cin >> A[i][j];
        }
    }

    for ( int i = 0; i < m; i++ ) {
        for ( int j = 0; j < l; j++ ) {
            cin >> B[i][j];
        }
    }

    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < l; j++ ) {
            ans = 0;
            for ( int k = 0; k < m; k++ ) {
                ans += A[i][k] * B[k][j];
            }
            cout << ans;
            if ( j != l - 1 ) {
                cout << ' ';
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3140