akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

template <typename T>//	Tはintかlong long
T gcd(T a, T b) {//	最大公約数
	if (a < 0) { a = -a; }
	if (b < 0) { b = -b; }
	if (a == 0) { return b; }
	if (b == 0) { return a; }
	if (a < b) {
		return gcd(a, b % a);
	}
	return gcd(b, a % b);
}

///////////////   セグメント木
const ll INF = (ll)1234567891011121314;

ll segtree_func(ll a, ll b) {
	return gcd(a, b);
}

class SegmentTree {
public:
	SegmentTree() {
		N = 0;
		node = NULL;
	}
	void activate(int N, ll value) {// 初期化
		if (node != NULL) { delete[] node; }

		this->N = N;
		size = 1; while (size < N) { size *= 2; }

		node = new ll[2 * size - 1];
		for (int i = 0; i < 2 * size - 1; i++) { node[i] = value; }
	}

	void activate(vector<ll> v) {
		if (node != NULL) { delete[] node; }

		N = v.size();
		size = 1; while (size < N) { size *= 2; }

		node = new ll[2 * size];

		for (ll i = 0; i < N; i++) node[i + size - 1] = v[i];
		for (ll i = size - 2; i >= 0; i--) node[i] = segtree_func(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void update(int pos, ll v) {// posの値をvに更新する
		int k = pos + size - 1;
		node[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = segtree_func(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}

	ll get(ll pos) {// posの値を取得する
		ll k = pos + size - 1;
		return node[k];
	}
	ll get(ll L, ll R) {// 半開区間[L, R) におけるqueryに答える
		return query(L, R, 0, 0, size);
	}

	void DebugCout() {// デバッグ用
		cout << endl << endl;
		cout << "範囲 : " << 0 << " to " << N - 1 << endl;
		int k = 2;
		for (int i = 0; i < size * 2 - 1; i++) {
			cout << node[i] << " ";
			if (i + 2 == k) {
				cout << endl;
				k *= 2;
			}
		}
		cout << endl << endl;
	}
private:
	int size, N;
	ll* node;// 管理用

	ll query(ll a, ll b, int k, int l, int r) {
		if (a <= l && r <= b) return node[k];

		int c = (l + r) / 2;

		if (c <= a) { return query(a, b, k * 2 + 2, c, r); }
		if (b <= c) { return query(a, b, k * 2 + 1, l, c); }

		return segtree_func(query(a, b, k * 2 + 2, c, r), query(a, b, k * 2 + 1, l, c));
	}
};
int main() {
	int N; cin >> N;
	SegmentTree ST; ST.activate(N, 0);

	for (int i = 0; i < N; i++) {
		ll k; cin >> k;
		ST.update(i, k);
	}

	ll m = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			m = max(m, ST.get(i + 1, N));
		}
		else if (i == N - 1) {
			m = max(m, ST.get(0, i));
		}
		else {
			m = max(m, gcd(ST.get(0, i), ST.get(i + 1, N)));
		}
	}

	cout << m << endl;

	return 0;
}


Measured memory_bytes: 2304
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
/*
A : 65
Z : 90
a : 97
z : 122
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S1 = read::<String>();
    let mut S1 = S1.chars().collect::<Vec<char>>();

    let S2 = read::<String>();
    let S2 = S2.chars().collect::<Vec<char>>();

    let S3 = read::<String>();
    let S3 = S3.chars().collect::<Vec<char>>();

    println!("{}{}{}", (S1[0] as u8 - 32) as char,
                        (S2[0] as u8 - 32) as char,
                        (S3[0] as u8 - 32) as char);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int main(){
	char s[5001];
	int K;
	cin >> s >> K;

	char sub[5][5001] = {
		"",
		"",
		"",
		"",
		"",
	};

	for (int i = 0; i < strlen(s); i++){
		for (int j = 1; j <= strlen(s) - i; j++){
			bool flag = false;
			char temp[5001];

			strncpy(temp, s + i, j);
			temp[j] = '\0';

			for (int k = 0; k < 5; k++){
				if(strcmp(sub[k], "") == 0){
					strcpy(sub[k], temp);
					break;
				}

				int cmp = strcmp(temp, sub[k]);
				if (cmp == 0){
					break;
				}
				if (cmp < 0){
					for (int l = K - 1; l > k; l--){
						strcpy(sub[l], sub[l - 1]);
					}
					strcpy(sub[k], temp);
					break;
				}
				if(k==4){
					flag = true;
				}
			}
			if(flag){
				break;
			}
		}
	}

	cout << sub[K - 1] << endl;

	return 0;
}


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

namespace AtCoder_2019_04_27_A
{
	/*
	問題文
	ビスケット生産装置を起動すると、起動してから A秒後、2A秒後、3A秒後、...(Aの倍数秒後) に B枚ずつビスケットを生産します。
	ビスケット生産装置を起動してから T+0.5秒後までに生産されるビスケットの合計枚数を求めてください。

	制約
	入力は全て整数である。
	1 ≤ A,B,T ≤ 20

	入力
	入力は以下の形式で標準入力から与えられる。
	A B T

	出力
	ビスケット生産装置を起動してから T+0.5 秒後までに生産されるビスケットの合計枚数を出力せよ。
	*/

	class Program
	{
		static void Main(string[] args)
		{
			string[] str = Console.ReadLine().Split(' ');
			int A = int.Parse(str[0]);
			int B = int.Parse(str[1]);
			double T = double.Parse(str[2]) + 0.5;
			int total = 0;

			for(int i = 1; i * A < T; i++)
			{
				total += B;
			}

			Console.WriteLine(total);
		}
	}
}

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

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

  // int型の2次元配列(3×4要素の)の宣言
  vector<int>B(M);
  vector<vector<int>> A(N, vector<int>(M));
  
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }

  // 入力 (2重ループを用いる)
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int ans=0;
  int cnt;
  for (int i = 0; i < N; i++) {
    cnt =C;
    for (int j = 0; j < M; j++) {
      cnt+=A.at(i).at(j)*B.at(j);
    }
    if(cnt>0){
      ans++;
    }
  }


   cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    public static void main(String args[]) {
        scanner = new Scanner(System.in);
        
        String s = scanner.nextLine();
        
        for(int i = 0; i < s.length(); ++i) {
            char c = s.charAt(i);
            if(Character.isLowerCase(c)) {
                c = Character.toUpperCase(c);
            }else if(Character.isUpperCase(c)) {
                c = Character.toLowerCase(c);
            }
            System.out.print(c);
        }
        System.out.println();
    }
}


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

int main(){
    int S;
    cin>>S;
    if((S%100>12||S%100<1)&&(S/100>12||S/100<1)){
        cout<<"NA"<<endl;
    }
    if((S%100<=12&&S%100>=1)&&(S/100>12||S/100<1)){
        cout<<"YYMM"<<endl;
    }
    if((S%100>12||S%100<1)&&(S/100<=12&&S/100>=1)){
        cout<<"MMYY"<<endl;
    }
    if((S%100<=12&&S%100>=1)&&(S/100<=12&&S/100>=1)){
        cout<<"AMBIGUOUS"<<endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,ans=0,sum=0, Max=-1, Min=3e9+1;
  string s;
  cin >> n;
  pri(n+(n*n)+(n*n*n));
  return 0;
}

Measured memory_bytes: 3628
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
if not c1[0]-c1[1] == c2[0]-c2[1] == c3[0]-c3[1]:
    print('No')
    exit()
if not c1[2]-c1[1] == c2[2]-c2[1] == c3[2]-c3[1]:
    print('No')
    exit()
if not c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2]:
    print('No')
    exit()
if not c3[0]-c2[0] == c3[1]-c2[1] == c3[2]-c2[2]:
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int total = a + b + c + d;
  int m = total / 60;
  cout << m << endl
       << total % 60 << endl;
}



Measured memory_bytes: 3100
N = int(input())

A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
C = [0 for _ in range(N)]

for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())

dp = [[0, 0, 0] for _ in range(N)]

dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]

for i in range(1, N):
    
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + B[i]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i]

print(max(dp[-1]))

Measured memory_bytes: 64672
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
    N1 = N - r*R
    for g in range(N1 // G + 1):
        N2 = N1 - g*G
        if N2 % B == 0: ans += 1
print(ans)

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if(*(a.end()-1) == *(b.begin()) && *(b.end()-1) == *(c.begin()))
		printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
package main

import "fmt"

var n int
var hs []int
var dp []int

const INF = 1 << 60

func main() {
	fmt.Scan(&n)
	hs = make([]int, n)
	for i := range hs {
		fmt.Scan(&hs[i])
	}
	dp = make([]int, n)
	for i := range dp {
		dp[i] = INF
	}

	dp[0] = 0
	for i := 1; i < n; i++ {
		chmin(&dp[i], dp[i-1]+abs(hs[i]-hs[i-1]))
		if i > 1 {
			chmin(&dp[i], dp[i-2]+abs(hs[i]-hs[i-2]))
		}
	}
	fmt.Println(dp[n-1])
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <ratio>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define iT(_t,_x) _t _x;std::cin >> _x;  
#define iInt(_x) int _x;in(_x); 
#define ill(_x) ll _x;in(_x); 
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }

int a[100000] = {};
int main() {
	iInt(n);
	while(n--)
	{
		iInt(x); if (x >= 1) { a[x]++; a[x-1]++; a[x+1]++;
		}
		else { a[x]++; a[x + 1]++; }
	}
	std::cout << *(max_element(a, a + len(a)));
		

}


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

int main() {
	LL n;
	cin>>n;
	LL a[n+1],b[n];
	for(LL i=0;i<=n;i++){
	    cin>>a[i];
	}
	for(LL i=0;i<n;i++){
	    cin>>b[i];
	}
	LL cnt=0;
	for(LL i=0;i<n;i++){
	    LL x=a[i];
	    LL y=a[i+1];
	    if(x+y<=b[i]){
	        cnt+=x+y;
	        a[i]=0;
	        a[i+1]=0;
	    }
	    else{
	        if(x>b[i]){
	            a[i]=a[i]-b[i];
	            cnt+=b[i];
	        }
	        else{
	            a[i]=0;
	            cnt+=x;
	            a[i+1]=a[i+1]-abs(b[i]-x);
	            if(a[i+1]<=0){
	                a[i+1]=0;
	                cnt+=a[i+1];
	            }
	            else{
	                cnt+=abs(b[i]-x);
	            }
	        }
	    }
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main()
{
    // input
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >>A[i];
    }
    
    int left=0,right=0;
    
    for (int i = 0; i < M; i++)
    {
        if(A[i]>X){
            right ++;
        }else{
            left++;
            
        }
    }
    
    cout << min(left,right) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 500
#define MOD 1000000007
#define int long long int
#define INF 1000000000000000
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
int a[N],pre[N];
int dp[N][N];
int fun(int i,int j)
{
    if(i>=j-1)return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    int cnt=INF;
    for(int k=i+1;k<j;k++)
    {
       cnt=min(fun(i,k)+fun(k,j)+pre[j]-pre[i],cnt);
    }
    dp[i][j]=cnt;
    return dp[i][j];
}
signed main() {  
     ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
   int n;cin>>n;
   fn(i,n)cin>>a[i];
   rep(i,1,n)pre[i]=pre[i-1]+a[i-1];
   fn(i,N){
       fn(j,N)dp[i][j]=-1;
   }
  int ans=fun(0,n);
  cout<<ans<<endl;
    return 0; 
}




Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,W,M;
    cin >> H >> W >> M;
    
    vector<int> hnum(H), wnum(W);
    vector<vector<int>> hvec(H), wvec(W);

    REP(i, M){
        int h,w;
        cin >> h >> w;
        h--;w--;
        hnum[h]++;
        wnum[w]++;

        wvec[w].pb(h);
        hvec[h].pb(w);
    }

    int hmax_id = max_element(ALL(hnum)) - hnum.begin();
    int wmax_id = max_element(ALL(wnum)) - wnum.begin();


    int ans = 0;
    REP(i, W){
        SORT(wvec[i]);
        if(FIND(wvec[i], hmax_id)){
            chmax(ans, hnum[hmax_id]+wnum[i]-1);
        }else{
            chmax(ans, hnum[hmax_id]+wnum[i]);
        }
    }

    REP(i, H){
        SORT(hvec[i]);
        if(FIND(hvec[i], wmax_id)){
            chmax(ans, wnum[wmax_id]+hnum[i]-1);
        }else{
            chmax(ans, wnum[wmax_id]+hnum[i]);
        }
    }

    pr(ans);
}

Measured memory_bytes: 38260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    cin>>s;
    string ans="";
    for(char c:s){
        if(c!='B')ans+=c;
        else if(ans.size())ans.pop_back();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    long long x,y;
    cin>>x>>y;
    long long a=10000000000,b=10000000000,c=10000000000,d=10000000000;
    if(x<=y)a=y-x;
    if(x*-1<=y)b=y-(x*-1)+1;
    if(x<=y*-1)c=(y*-1)-x+1;
    if(x*-1<=y*-1)d=(y*-1)-(x*-1)+2;
    cout<<min(min(min(a,b),c),d)<<endl;
    return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a+b==c || b+c==a || c+a==b) cout << "Yes" << ln;
	else cout << "No" << ln;
}

Measured memory_bytes: 256
N = int(input())
s = 0
o = []
for i in range(N):
    o.append(tuple(map(int,input().split())))

for A,B in o:
    if A == B:
        s += 1
        if s == 3:
            print('Yes')
            exit()
    else:
        s = 0
print('No')

Measured memory_bytes: 62420
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int max = -1;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            if (max - array[i] > 1) {
                System.out.println("No");
                return;
            }
            max = Math.max(max, array[i]);
        }
        System.out.println("Yes");
    }
}

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

int main(){
    double a, b, c, d, e, f, x, y;
    while(cin >> a >> b >> c >> d >> e >> f){
        y = (a*f-d*c)/(a*e-b*d);
        x = (c-b*y)/a;
        printf("%.3f %.3f\n", x, y);
    }
}

Measured memory_bytes: 1232
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;

struct edge{
	int a,b;
	ll c;
};

bool operator > (const edge &e1,const edge &e2){
	return (e1.c!=e2.c)?(e1.c>e2.c):(e1.a+200000+e1.b>e2.a+200000+e2.b);
}

int n,m,s,t;
unordered_map<int,int> edges[2][100000];

int main() {
	cin >> n >> m >> s >> t;
	s--; t--;
	for(int i = 0; i < m; i++) {
		int u,v,a,b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edges[0][u][v] = a;
		edges[0][v][u] = a;
		edges[1][u][v] = b;
		edges[1][v][u] = b;
	}
	unordered_map<int,bool> arrived[2];
	unordered_map<int,ll> dp[2];
	priority_queue<edge,vector<edge>,greater<edge> > q[2];
	{
		for(auto itr = edges[0][s].begin(); itr != edges[0][s].end(); itr++) {
			q[0].push((edge){s,itr->first,itr->second});
		}
		arrived[0][s] = true;
		dp[0][s] = 0;
		while(!q[0].empty()) {
			edge _e = q[0].top(); q[0].pop();
			if(arrived[0][_e.b]) continue;
			arrived[0][_e.b] = true;
			dp[0][_e.b] = dp[0][_e.a]+edges[0][_e.a][_e.b];
			for(auto itr = edges[0][_e.b].begin(); itr != edges[0][_e.b].end(); itr++) {
				if(!arrived[0][itr->first]) q[0].push((edge){_e.b,itr->first,itr->second+dp[0][_e.b]});
			}
		}
	}
	{
		for(auto itr = edges[1][t].begin(); itr != edges[1][t].end(); itr++) {
			q[1].push((edge){t,itr->first,itr->second});
		}
		arrived[1][t] = true;
		dp[1][t] = 0;
		while(!q[1].empty()) {
			edge _e = q[1].top(); q[1].pop();
			if(arrived[1][_e.b]) continue;
			arrived[1][_e.b] = true;
			dp[1][_e.b] = dp[1][_e.a]+edges[1][_e.a][_e.b];
			for(auto itr = edges[1][_e.b].begin(); itr != edges[1][_e.b].end(); itr++) {
				if(!arrived[1][itr->first]) q[1].push((edge){_e.b,itr->first,itr->second+dp[1][_e.b]});
			}
		}
	}
	/*
	for(int i = 0; i < n; i++) {
		cout << dp[0][i] << " " << dp[1][i] << endl;
	}
	*/
	ll ans[100000];
	ans[n-1] = (dp[0][n-1]+dp[1][n-1]);
	for(int i = n-2; i >= 0; i--) {
		ans[i] = min(ans[i+1],(dp[0][i]+dp[1][i]));
	}
	for(int i = 0; i < n; i++) {
		cout << 1000000000000000LL-(ans[i]) << endl;
	}
}


Measured memory_bytes: 49812
n, k = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)

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

bool chmin(long long &a, long long b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	
	vector<long long> b(n + 1, a[n]);
	for (int i = n; i--> 0;) {
		b[i] = b[i + 1] + a[i];
	}
	
	long long v = 1;
	for (int i = 0; i < n + 1; i++) {
		if (chmin(b[i], v)) {
			v = (v - a[i]) * 2LL;
		}
	}
	
	long long ans = 0;
	bool ok = true;
	for (int i = 0; i < n + 1; i++) {
		ok &= (b[i] >= a[i]);
		ans += b[i];
	}
	
	if (not ok) ans = -1;
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 4576
//E
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
const int INF = 1e9+10;
int f[maxn];
int w[105],v[105];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,W;
	cin >> n >> W;
	for(int i = 1;i < maxn;i++)f[i] = INF;
	for(int i = 1;i <= n;i++)cin >> w[i] >> v[i];
	for(int i = 1;i <= n;i++){
		for(int j = maxn-1;j >= 0;j--)if(j >= v[i])f[j] = min(f[j],f[j-v[i]] + w[i]);
	}
	int ans = 0;
	for(int i = 0;i < maxn;i++)if(f[i] <= W)ans = max(ans,i);
	cout << ans;
	return 0;
}


Measured memory_bytes: 4036
import collections
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
D_1 = collections.Counter(D)
T_1 = collections.Counter(T)
for i in set(T):
    if D_1[i] < T_1[i]:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 65456
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int n;
  cin >> n;
  cout << n*(n+1)/2;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  int t = in();
  vector<int> ins(n);
  foreach(i,ins)i=in();
  sort(all(ins));
  vector<int> line;
  ll ans = 1;
  foreach(i,ins){
    if(line.empty()){
      line.push_back(i);
      continue;
    }
    int p = lower_bound(all(line),i-t) - line.begin();
    ans *= line.size() - p + 1;
    ans %= MOD;
    line.push_back(i);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3876
N = int(input())
C = list(input().split())

BC = [0] * N
SC = [0] * N

#boubblesort
for i in range(N):
    BC[i] = C[i]
    SC[i] = C[i]
for i in range(N):
    for j in range(N-1, i, -1):
        if int(BC[j][1]) < int(BC[j-1][1]):
            BC[j], BC[j-1] = BC[j-1], BC[j]

print(' '.join(list(map(str, BC))))
print("Stable")

#Selectionsort

for i in range(N):
    minj = i
    for j in range(i, N):
        if int(SC[j][1]) < int(SC[minj][1]):
            minj = j
    SC[minj], SC[i] = SC[i], SC[minj]
    
print(' '.join(list(map(str, SC))))
if SC == BC:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5612
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N = intinp()
H = list(mapint_inp())

H = H[::-1]

mn = 10**9+7
ans = True
for i in range(N-1):
    mn = min(mn, H[i])
    if i == 0:
        continue
    if H[i]-1 > mn:
        ans = False
        break

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> A(N), B(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }

    sort(all(A), greater<int>());
    sort(all(B), greater<int>());

    int res = 0;
    rep(i, N) {
        if (B[i] >= A[0]) {
            H -= B[i];
            res++;
            if (H <= 0) {
                break;
                cout << res << endl;
                return 0;
            }
        }
    }

    while (H > 0) {
        H -= A[0];
        res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1776
#include <iostream>
using namespace std;
int main()
{
    int h,w;
    for(int i=0; ;i++){
        cin>>h>>w;
        if(h==0&&w==0)break;
        
        //長方形描く作業
        for(int u=0;u<h;u++){
            for(int y=0;y<w;y++){
                cout<<"#";
            }
                cout<<endl;
            }
            cout<<endl;
        }
        
        
    
    return 0;
}


Measured memory_bytes: 3096
n,*abc=map(int,input().split())
ip=[0]*n
for i in range(n):
	tmp=input()
	if tmp=="AB":
		ip[i]=[0,1]
	elif tmp=="BC":
		ip[i]=[1,2]
	else:
		ip[i]=[0,2]
ans="Yes"
res=[0]*n
s=sum(abc)
if s==0:
	ans="No"
elif s==1:
	for i in range(n):
		i1=ip[i][0]
		i2=ip[i][1]
		if abc[i1]+abc[i2]==0:
			ans="No"
		elif abc[i1]+abc[i2]==1:
			if abc[i1]==0:
				abc[i1]+=1
				abc[i2]-=1
				res[i]=i1
			else:
				abc[i1]-=1
				abc[i2]+=1
				res[i]=i2
else:
	i1=ip[0][0]
	i2=ip[0][1]
	if abc[i1]+abc[i2]==0:
		ans="No"
	else:
		for i in range(n):
			i1=ip[i][0]
			i2=ip[i][1]
			if abc[i1]*abc[i2]==0:
				if abc[i1]==0:
					abc[i1]+=1
					abc[i2]-=1
					res[i]=i1
				else:
					abc[i1]-=1
					abc[i2]+=1
					res[i]=i2
			elif i+1<n and ip[i+1]!=ip[i]:
				c=list(set(ip[i])&set(ip[i+1]))[0]
				if i1==c:
					abc[i1]+=1
					abc[i2]-=1
					res[i]=i1
				else:
					abc[i1]-=1
					abc[i2]+=1
					res[i]=i2
			else:
				abc[i1]+=1
				abc[i2]-=1
				res[i]=i1
print(ans)
if ans=="Yes":
	for i in range(n):
		if res[i]==0:
			print("A")
		elif res[i]==1:
			print("B")
		else:
			print("C")

Measured memory_bytes: 18656
n,k = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = -10**100
for i in range(n):
    start = i
    cur = i
    i_s_score = 0
    i_s_score_max = C[P[cur]-1]
    move_num = 0
    for j in range(n):
        cur = P[cur]-1
        i_s_score += C[cur]
        i_s_score_max = max(i_s_score, i_s_score_max)
        move_num += 1
        if cur == start:
            break
    if i_s_score <= 0:
        ans = max(ans, i_s_score_max)
    else:
        temp = i_s_score*(k//move_num)
        if (k//move_num >= 1):
            temp_dash = i_s_score*(k//move_num-1)+i_s_score_max
            ans = max(ans, temp_dash)
        rest = k%move_num
        ans = max(ans, temp)
        i_s_score = temp
        for j in range(rest):
            cur = P[cur]-1
            i_s_score += C[cur]
            ans = max(ans, i_s_score)
print(ans)


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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " ";cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 2e5 + 3;

void solve()
{
	int n, m;
	cin >> n >> m;
	double a[n];
	double sum = 0;
	loop(i, 0, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	double c = m;
	m = m * 4;

	double x = sum / m;
	int cnt = 0;
	loop(i, 0, n)
	{
		if (a[i] >= x) cnt++;
	}
	if (cnt >= c)cout << "Yes";
	else cout << "No";

	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	//cout << setprecision(9) << fixed;
	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 256
n, y = gets.split.map(&:to_i)

t =
  catch(true) do
    (0..n).each do |a|
      (0..(n - a)).each do |b|
        c = n - a - b
        next if c < 0
        total = 10000 * a + 5000 * b + 1000 * c
        throw(true, [a, b, c]) if total == y
      end
    end
    [-1] * 3
  end

puts t.join(' ')


Measured memory_bytes: 1788
program step
  implicit none
  integer :: n, i
  integer(8) :: a(200000) = 0, m, x = 0
  read(*,*) n
  read(*,*) a(1:n)
  m = a(1)
  do i = 2, n
    x = x + max(m - a(i), 0_8)
    m = max(m, a(i))
  end do
  write(*,'(i0)') x
end program step

Measured memory_bytes: 4624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

ll f(ll b, ll n){
    if(b<2) return INF;
    ll ret = 0;
    while(n>=b) ret += n%b, n/=b;
    return ret + n;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin>>N>>S;
    ll ans = LINF;
    if(N==S) ans = N+1;
    else{
        for(int i=2;i<sqrt(N)+1;i++) if(f(i,N) == S) ans = min(ans,(ll)i);
        for(int i=1;i<sqrt(N);i++){
            ll B = (N-S) / i + 1;
            if(f(B,N) == S) ans = min(ans,B);
        }
    }
    if(ans == LINF) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll sum=0,esum=0,ans;
  rep(i,n){
     cin>>a[i];
     sum+=a[i];
     if(i%2)esum+=a[i]; 
  }
  ans=sum-esum*2;
  rep(i,n){
    cout<<ans<<" ";
    ans=(a[i]-ans/2)*2;
  }
  return 0;
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans -= min(c, k);

	cout << ans;

	return 0;
}


Measured memory_bytes: 3648
// O(nk)
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#define l first
#define r second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
const ll mod=998244353;
int n,k;
ll f[N],s[N];
pii a[N];
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>k;
        for(int i=1; i<=n; i++)
            cin>>a[i].l>>a[i].r;
        f[1]=1;
        s[1]=1;
        for(int i=2; i<=n; i++)
        {
            for(int j=1; j<=k; j++)
                f[i]=(f[i]+s[max(0,i-a[j].l)]-s[max(0,i-a[j].r-1)])%mod;
            s[i]=(s[i-1]+f[i])%mod;
        }
        cout<<(f[n]+mod)%mod<<'\n';
    }
    return 0;
}



Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5000 + 10;
const ll mod = 1e9 + 7;
char s[maxn];
ll f[maxn][maxn], tmp[maxn], ret[maxn], h[maxn];
int n, m;
void add(ll & x, const ll y)
{
	x += y;
	if(x >= mod) x -= mod;
}
void calc(ll * ret, ll * a, ll * b)
{
	memset(tmp, 0, sizeof tmp);
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
			add(tmp[i], a[i - j] * b[j] % mod);
	for(int i = 0; i <= n; ++i) ret[i] = tmp[i]; 
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	m = strlen(s + 1);
	f[0][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
		{
			if(j) add(f[i][j], f[i - 1][j - 1] * 2 % mod);
			add(f[i][j], f[i - 1][j + 1]);
		}
	for(int i = 0; i <= n; ++i) h[i] = f[i][0];
	memset(f, 0, sizeof f);
	f[0][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
		{
			if(j) add(f[i][j], f[i - 1][j - 1] * 2 % mod);
			else add(f[i][j], f[i - 1][j]);
			add(f[i][j], f[i - 1][j + 1]);
		}
	for(int i = 0; i <= n; ++i) ret[i] = f[i][0];
	int k = m;
	while(k)
	{
		if(k & 1) calc(ret, ret, h);
		calc(h, h, h); k >>= 1;
	}
	printf("%lld\n", ret[n - m]);
	return 0;
}
	

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

int main() {
    int N;
    int count=0;
    cin >> N;

    string S;
    cin >> S;

    for(int i=0; i<N-2; i++){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a; cin >> a;
    bool p = 0, w = 0, g = 0, y = 0;
    REP(i, a){
        char b; cin >> b;
        if(b == 'P') p = 1;
        if(b == 'W') w = 1;
        if(b == 'G') g = 1;
        if(b == 'Y') y = 1;
    }
    int ans = 0;
    if(p) ans++;
    if(w) ans++;
    if(g) ans++;
    if(y) ans++;
    cout << (ans == 3 ? "Three" : "Four") << endl;

}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w, m;
    cin >> h >> w >> m;

    vector<int> row(h), col(w);
    set<pii> st;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        row[x]++;
        col[y]++;

        st.emplace(x, y);
    }

    int max_row = *max_element(ALL(row));
    int max_col = *max_element(ALL(col));

    vector<int> rows, cols;

    for (int i = 0; i < h; i++) {
        if (row[i] == max_row) {
            rows.push_back(i);
        }
    }

    for (int i = 0; i < w; i++) {
        if (col[i] == max_col) {
            cols.push_back(i);
        }
    }

    for (int &x : rows) {
        for (int &y : cols) {
            if (st.count(pii(x, y)) == 0) {
                cout << max_row + max_col << '\n';
                return 0;
            }
        }
    }

    cout << max_row + max_col - 1 << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
}
  sort(p.begin(), p.end());
  cout<<p.at(N/2)-p.at(N/2-1)<<endl;
}

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

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

    int a=Integer.parseInt(scan.next());
    int b=Integer.parseInt(scan.next());
    int c=Integer.parseInt(scan.next());
    int count=0;

    for(int i=1;i<=c;i++){
      if( (c%i==0) && (a<=i) && (i<=b)){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26208
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;

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

    int ans = (H + A - 1) / A;// 切り上げ

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x>=30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 212345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

vector<int> getDivisors(int x) {
    vector<int> res;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            res.push_back(i);
            if (res.back() != x / i) {
                res.push_back(x / i);
            }
        }
    }
    return res;
}

bool has[112];

int32_t main() {
    $
    int a, b, k;
    vi x, y;
    cin >> a >> b >> k;
    x = getDivisors(a);
    y = getDivisors(b);
    for (int i = 0; i < (int)x.size(); ++i) {
        has[x[i]] = 1;
    }
    vector<int> ans;
    for (int i = 0; i < (int)y.size(); ++i) {
        if (has[y[i]]) {
            ans.push_back(y[i]);
        }
    }
    sort(all(ans), greater<int>());
    cout << ans[k - 1] << '\n';
}   



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
num = 0
Ans = [0] * N
for a in A:
    num = (a - num // 2) * 2

num //= 2
for i, a in enumerate(A):
    Ans[i] = str(num)
    num = (a - num // 2) * 2

print(' '.join(Ans))


Measured memory_bytes: 82916
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long m, long long n){
  long long temp;
  while(m%n!=0){
    temp=n;
    n=m%n;
    m=temp;}
  return n;}
long long lcm(long long m, long long n){return m/gcd(m,n)*n;}
 
int main() {
  long long N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  long long b=gcd(N,M); //最大公約数
  long long a=lcm(N,M); //最小公倍数
  long long s=N/b;
  long long t=M/b;
  long long ans=a;
  for(long long i=0;s*i<N && t*i<M;i++){
    if(S[s*i]!=T[t*i]){ans=-1;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B,N=mis()
    if N>=B:
        x=B-1
    else:
        x=N
    print(A*x//B - A*(x//B))


main()



Measured memory_bytes: 9992
#include <bits/stdc++.h>
#define int long long
using namespace std;
char str[(signed)1e5+10];
int cost[10];
int get_cost(char c){
    if(c=='r'){
        return cost[3];
    }
    if(c=='s'){
        return cost[1];
    }
    return cost[2];
}
int vis[(signed)1e5+10];
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=3;i++)cin>>cost[i];
    scanf("%s",str+1);
    int len=strlen(str+1);
    int ans=0;
    for(int i=1;i<=len;i++){
        if(i<=k){
            ans+=get_cost(str[i]);
            vis[i]=1;
            continue;
        }
        if(str[i-k]==str[i]&&vis[i-k]){
            continue;
        }
        ans+=get_cost(str[i]);
        vis[i]=1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
// ConsoleApplication1.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <set>

//071 B

using namespace std;
int main()
{
	int N, M;
	cin >> N >> M;
	int a[55] = {};
	int b[55] = {};
	int c[55] = {};
	for (int i = 0; i < M; i++)
		cin >> a[i] >> b[i];

	for(int i = 0; i < M; i++){
		c[a[i]]++;
		c[b[i]]++;
	}

	for (int i = 0; i < N; i++) {
		cout << c[i+1] << endl;
	}



	return 0;
}



Measured memory_bytes: 256