akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 1000000007
using ll = long long;

//a and b are assumed to be taken modulo p
inline ll add(ll a, ll b, ll p = mod){ ll c = a + b; if(c >= p) c -= p; return c; }
inline ll sub(ll a, ll b, ll p = mod){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll mul(ll a, ll b, ll p = mod){ return (a * 1ll * b) % p; }
 
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*1ll*x) % p;
    }
    return res;
}
const int MX = 2e5+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;
int mx = 2 * (ll)1e9 + 10;
set<ll> Sx[MX];
set<ll> Sy[MX];
int ans[MX];
vector<int> g[MX];
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    for (int i = 0; i < n; i++) {
        g[i].PB(i+1);
        g[i + 1].PB(i);
    }
    g[x].PB(y);
    g[y].PB(x);
    for (int i = 0; i < n; i++) {
        queue<int> Q;
        vector<int> dist(n,2e9);
        vector<int> vis(n,0);
        Q.push(i);
        dist[i] = 0;
        vis[i] = 1;
        while (!Q.empty()) {
            int q = Q.front();
            Q.pop();
            for (auto x : g[q]) {
                if (vis[x]) continue;
                if (dist[x] > dist[q] + 1) {
                    dist[x] = dist[q] + 1;
                    Q.push(x);
                }
            }
        }
        
        for (int j = i + 1; j < n; j++) {
            ans[dist[j]]++;
        }
    }
    for (int i = 1;i< n; i++) {
        cout << ans[i] <<endl;
    }
    return 0;
    
}


Measured memory_bytes: 24576
import java.util.*;
    public class Main{
	public static void main(String[] args){
	    Scanner scan = new Scanner(System.in);
	    int numE = scan.nextInt();
	    int numSquare = scan.nextInt();
	    if(numE < 9 && numSquare < 9){
		System.out.println("Yay!");
	    }else{
		System.out.println(":(");
	    }
		
	}

	
    }


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
    int i = 0;
    for(int j=0; j<k; j++){
        llong s = 0;
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while(right-left>1){
        mid = (left+right)/2;
        int v = check(mid);
        if(v>=n) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int N;
int A[214514];

int solve(int f){
    int sum=0;
   REP(i,N){
       sum+=abs(A[i]-f);
   }
   return sum;
}

signed main(void){
   cin >> N;
   REP(i,N){
       cin >> A[i];
       A[i]-=(i+1);
   }
   sort(A,A+N);
   
   
   //めぐる式(？)三分探索
   int ok=A[N-1],ng=A[0]-1,mid1=ng+1,mid2=ok-1;
   while(abs(ok-ng)>2){
       mid1=(ng+ng+ok)/3;
       mid2=(ng+ok+ok)/3;
       
       //最大値の時は>、最小値の時は<
       if(solve(mid1)<solve(mid2)){
           ok=mid2;
       }else{
           ng=mid1;
       } 
   }
   //おわり
   
   cout << min(min(solve(ok),solve(ng)),min(solve(mid1),solve(mid2))) << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    ls = [0] * n
    for i, v in enumerate(a):
        ls[i] += (((1 + v) * v) // 2) / v
    ls = [0] + list(itertools.accumulate(ls))
    mt = 0
    for i in range(k, n + 1):
        mt = max(mt, ls[i] - ls[i-k])
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 77856
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    h, w = map(int, input().split())
    n = int(input())
    a = list(map(int, input().split()))
    dx = [1, -1]
    mode = 0
    ans = [[0]*w for _ in range(h)]
    x = 0
    y = 0
    i = 0
    while(0 <= y < h):
        while(0 <= x < w):
            if(a[i] > 0):
                ans[y][x] = i+1
                x += dx[mode]
                a[i] -= 1
            else:
                i += 1
        y += 1
        mode = 1-mode
        x += dx[mode]
    for i in ans:
        print(*i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

template <class Itr>
Itr get_adv_itr(Itr _itr, int n) {
  Itr itr(_itr);
  advance(itr, n);
  return itr;
}

string in;
int L, temp, N;

int main() {
  while (getline(cin, in)) {
    istringstream is(in);
    is >> L;
    vector<int> cakes;
    while (is >> temp) cakes.push_back(temp);
    N = cakes.size();
    string ans = "NA";

    rep(i,N) {
      vector<int> cp_cakes(cakes);
      double cost = cp_cakes[i];
      cp_cakes.erase(get_adv_itr(cp_cakes.begin(),i));
      int last = (int)cost;
      while (cp_cakes.size()) {
        vector<int> dists;
        for (int j = 0; j < cp_cakes.size(); ++j)
          dists.push_back(pow(last - cp_cakes[j],2));
        int id = distance(dists.begin(),
                          max_element(dists.begin(), dists.end()));
        cost += sqrt(pow(last + cp_cakes[id],2) - pow(last - cp_cakes[id],2));
        last = cp_cakes[id];
        cp_cakes.erase(get_adv_itr(cp_cakes.begin(), id));
      }
      cost += last;
      if (L >= cost) {
        ans = "OK";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n,a,b = map(int, input().split())
Xs = list(map(int, input().split()))

ds = [0] * (n+10)
for i in range(n-1):
    cost1 = a*(Xs[i+1] - Xs[i])
    cost2 = b
    ds[i+1] = ds[i] + min(cost1, cost2)
print(ds[n-1])

Measured memory_bytes: 20116
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

vector<vector<int> > g, g0;
vector<int> val;

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    g.resize(n), g0.resize(n); val.resize(n);

    vector<int> cnt(n);
    int i;
    for(i=0; i<m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a-1].push_back(b-1);
        g0[b-1].push_back(a-1);
        cnt[a-1]++;
    }

    set<pair<int,int> > z;
    for(i=0; i<n; i++) z.insert(make_pair(cnt[i], i));

    int ans=0;
    while(!z.empty()) {
        int curr= z.begin()->second;

        int max=0;
        int siz=(int)g[curr].size();
        int k;
        for(k=0; k<siz; k++) {
            int next = g[curr][k];
            max = MAX(max, val[next]);
        }
        val[curr]=max+1;
        ans=MAX(ans,val[curr]);

        siz=(int)g0[curr].size();
        for(k=0; k<siz; k++) {
            int next = g0[curr][k];
            z.erase(make_pair(cnt[next],next));
            cnt[next]--;
            z.insert(make_pair(cnt[next],next));
        }
        z.erase(make_pair(cnt[curr],curr));
    }
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 16640
N, W = gets.chomp.split.map(&:to_i)

dp = []
(N+1).times do |n|
  dp << [0] * (W + 1)
end

1.upto(N) do |i|
  w_i, v_i = gets.chomp.split.map(&:to_i)

  1.upto(W) do |w|
    if w < w_i
      dp[i][w] = dp[i-1][w]
    else
      if dp[i-1][w] < dp[i-1][w-w_i] + v_i
        dp[i][w] = dp[i-1][w-w_i] + v_i
      else
        dp[i][w] = dp[i-1][w]
      end
    end
  end
end

puts dp[N][W]

Measured memory_bytes: 93240
n,m,x=map(int, input().split())
zen=[]
for y in range(2**n):
    zen.append(y)
book=[]
for y in range(n):
    a=list(map(int, input().split()))
    book.append(a)
kakaku=0
kakakum=10**7
skill=[0]*m
for y in zen:
    for z in range(n):
        if ((y>>z)&1):
            kakaku+=book[z][0]
            for aa in range(m):
                skill[aa]+=book[z][aa+1]
    skill.sort()
    if skill[0]>=x:
        if kakakum>kakaku:
            kakakum=kakaku
    skill=[0]*m
    kakaku=0
if kakakum==10**7:
    kakakum=-1
print(kakakum)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(i=0;i<N;i++)
int N;
vector<int> h;
int dfs(int s, int e){
  if(s>=e) return 0;
  int min = *min_element(&h[s],&h[e]);
  int sum=min,i,index;
  for(i=s;i<e;i++){
    h[i] -= min;
    if(h[i] == 0) index = i;
  }
  sum += dfs(s,index);
  sum += dfs(index+1,e);
  return sum;
}
int main(void){
  cin >> N;
  h.resize(N);
  int i;
  FOR(i,N) cin >> h[i];
  cout << dfs(0,N) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			long res = data[0];
			for(int i = 1; i < n; i++){
				res = gcd(res, data[i]);
			}
			System.out.println(res);
		}
	}
	
	private long gcd(long a, long b){
		if(b == 0)  return a;
		else        return gcd(b, a%b);
	}

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

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

}


Measured memory_bytes: 51512
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>
#define MOD (ll)(1e9 + 7)
#define MAX 21
ll dp[1 << MAX];
ll n;
ll mat[MAX][MAX];

ll solve(ll biti) {
    if (biti == 0) {
        return 1;
    }

    if (dp[biti] == -1) {
        ll k = __builtin_popcountll(biti) - 1;
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if (biti & (1 << i) && mat[i][k] == 1) {
                ans += solve(biti & (~(1 << i)));
                ans %= MOD;
            }
        }
        dp[biti] = ans;
    }
    return dp[biti];
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

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

    memset(dp, -1, sizeof(dp));

    cout << solve((1 << n) - 1) << "\n";
}

Measured memory_bytes: 16768
#include<stdio.h>
#include<math.h>
int num_of_factors(int n,int k){
  int ans=0;
  int m=k;
  while(n/k!=0){
    ans+=n/k;
    k*=m;
  }
  return ans;
}
     
int main(){
  int n,i,j,flag,a;
  long ans=1;
  scanf("%d",&n);
  for(i=2;i<=n;i++){
    flag=1;
    for(j=2;j<=(int)sqrt(i);j++){
      if(i%j==0) flag=0;
    }
    if(flag==1) {
      a=num_of_factors(n,i);
      ans=(ans*(a+1))%1000000007;
    }
  }
  printf("%ld\n",ans);
  return 0;
}


Measured memory_bytes: 256
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

ans = 0

for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i
print(ans)

Measured memory_bytes: 64424
#include<bits/stdc++.h>
using namespace std;
char s[1005000];
int main()
{
	int n,flag=1;
	scanf("%s",s);
	n=strlen(s);
	int i=0,j=(n-1)/2-1;
	while(i<j)
	{
		if(s[i]!=s[j])
		{
			flag=0;
			break;
		}
		i++;
		j--;
	}
	if(flag)
	{
		i=(n+3)/2-1;
		j=n-1;
		while(i<j)
		{
			if(s[i]!=s[j])
			{
				flag=0;
				break;
			}
			i++;
			j--;
		}
		if(flag)
		{
			i=0;
			j=n-1;
			while(i<j)
			{
				if(s[i]!=s[j])
				{
					flag=0;
					break;
				}
				i++;
				j--;
			}
			if(flag)
			printf("Yes\n");
			else
			printf("No\n");
			
		}
		else
		{
			printf("No\n");
		}
		
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define allv v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	ll n,q;cin>>n>>q;
	string s;cin>>s;
	ll x=s.length();
	vll v;
	ll a[s.length()];rep(i,0,x)a[i]=0;
	rep(i,0,s.length()){
		if(s[i]=='A'&&s[i+1]=='C'){v.pb(i);a[i+1]++;}
	}
	rep(i,0,x)a[i+1]+=a[i];
	while(q--){
		ll l,r;cin>>l>>r;
		l--;r--;
		if(l>0)
		cout<<a[r]-a[l]<<"\n";
		else cout<<a[r]<<"\n";
	}
	return 0;
}



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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) {
      break;
    }
    int ans = 0, i = 1;
    while (i < n) {
      int tmp = i, j = i + 1;
      while (tmp <= n) {
        tmp += j;
        j++;
        if (tmp == n) {
          ans++;
          break;
        }
      }
      i++;
    }
    cout << ans << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

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

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

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

int main(){

  int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int i;
  
  std::cin>>i;
  
  std::cout<<n[i-1];
  
}

Measured memory_bytes: 3192
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:i64,b:i64,c:i64,d:i64};

    if b < c || a > d {
        println!("0");
    } else {
        if a < c && b > d {
            println!("{}", d-c);
        }
        else if a < c {
            println!("{}", b-c);
        }
        else if b > d {
            println!("{}", d-a);
        }
        else {
            println!("{}", b-a);
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main(){
    string s,t;
    int cnt=0;
    cin>>s>>t;

    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            t[i]=s[i];
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
    
}


Measured memory_bytes: 3900
def f(m,l):
    tmpm=set()
    for x in m:
        tmpm.add(x+l);tmpm.add(x-l)
    return tmpm

s=input()+"T"
x,y=map(int,input().split())

while s and s[0]=="F":
    x-=1
    s=s[1:]
ss=[{0},{0}]
mode=0
l=0
for i in range(len(s)):
    if s[i]=="F": l+=1
    else:
        ss[mode]=f(ss[mode],l)    
        mode^=1
        l=0

print("Yes" if x in ss[0] and y in ss[1] else "No")

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


int main() {
  string s, t;
  cin >> s >> t;
  int s_len = s.length();
  int t_len = t.length();
  int diff_len = s_len - t_len;
  //cout << t_len << endl;
  int cnt;
  int Min = 1001001001;
  rep(i,diff_len+1) {
    cnt = 0;
    rep(j,t_len) if (s[i+j] != t[j]) cnt++;
    //cout << cnt << endl;
    Min = min(Min, cnt);
    //cout << Min << endl;
  }
  
  cout << Min << endl;
  
  return 0;
}

Measured memory_bytes: 3608
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(ReadLine());
        int b = int.Parse(ReadLine());
        int h = int.Parse(ReadLine());

        WriteLine((a + b) * h / 2);

        ReadKey();
    }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main(){

int n;

while(1){

scanf("%d",&n);if(n==0)break;

int x,y,h,w;
int S=0;
for(int i=0;i<n;i++)
{
scanf("%d %d %d %d",&x,&y,&h,&w);
int s=x+y+h;
int T1=0,T2=0;

if(s<=60)T1=1;
else if(s<=80)T1=2;
else if(s<=100)T1=3;
else if(s<=120)T1=4;
else if(s<=140)T1=5;
else if(s<=160)T1=6;
else if(s>160)T1=10;

if(w<=2)T2=1;
else if(w<=5)T2=2;
else if(w<=10)T2=3;
else if(w<=15)T2=4;
else if(w<=20)T2=5;
else if(w<=25)T2=6;
else if(w>25)T2=10;


if(T1<T2)T1=T2;

int p=0;
switch(T1){
case 1:
p=600;break;

case 2:
p=800;break;

case 3:
p=1000;break;

case 4:
p=1200;break;
case 5:
p=1400;break;
case 6:
p=1600;break;
case 10:
p=0;break;
}
S+=p;
}
printf("%d\n",S);

}
return 0;
}

Measured memory_bytes: 1028
N = int(input())
h = list(map(int,input().split()))
count = 0
ans = 0
for i in range(N):
    if i != N-1:
        if h[i] >= h[i+1]:
            count += 1
            if ans < count:
                ans = count
        else:
            count = 0

print(ans)

Measured memory_bytes: 14224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int h, w;
  char s[150][150];
  bool r[150] = {}, c[150] = {};

  scanf("%d%d", &h, &w);

  for(int i=0;i<h;i++){
    scanf("%s", s[i]);
    for(int j=0;j<w;j++){
      r[j] |= s[i][j] == '#';
      c[i] |= s[i][j] == '#';
    }
  }

  for(int i=0;i<h;i++){
    if(!c[i]) continue;
    for(int j=0;j<w;j++){
      if(!r[j]) continue;
      printf("%c", s[i][j]);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = []
if a:
  b = [a[0]-1] + [a[i+1]-a[i]-2 for i in range(m-1)] + [n-a[m-1]-1]
c = [1,1]+[0]*(n-1)
for i in range(2,n+1):
  c[i] = c[i-1] + c[i-2]
ans = 1
if b:
  for j in b:
    if j == -1:
      ans = 0
      break
    ans = (ans * c[j]) %1000000007
else:
  ans = c[n] % 1000000007
print(ans)

Measured memory_bytes: 464784
N = int(input())
l = []
m = []
for i in range(N):
    a,b = map(int,input().split())
    l.append(a)
    m.append(b)
flg = 0
c = 0
for i in range(len(l)):

    if l[i] == m[i]:
        c += 1
        if c==3:
            flg += 1
            
    else:
        c = 0
if flg == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int B=62;
ll a[B], b[B];

ll onlyB(ll i) {
    while(i>=0 && b[i]==0) i--;
    return 1LL<<(i+1);
}

ll onlyA(ll i) {
    ll ans=1;
    while(i>=0) {
        if(a[i]==0) ans+=1LL<<i;
        i--;
    }
    return ans;
}

ll cnt(ll i) {
    if(i<0) return 1;
    if(b[i]==1) return 1LL<<(i+1);
    if(a[i]==1) return onlyA(i)+onlyB(i);
    return (1LL<<i)+cnt(i-1);
}


int main() {
    ll i, av, bv, ans;
    scanf("%lld%lld", &av, &bv);
    for(i=0; i<B; i++) {
        a[i]=(av>>i)&1;
        b[i]=(bv>>i)&1;
    }
    for(i=B-1; i>=0 && a[i]==b[i]; i--);
    if(i<0) return printf("1\n"), 0;
    ans=onlyA(i-1);
    ans+=cnt(i-1);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
// 問題文読んでないけど負数が奇数の場合は両端どっちかで偶数の場合はなんとなく全部正にできそう
// """0""" の存在を忘れていた...
// 意味不明なことにWA
// アホだった なーにが「両端どっちか」じゃボケが 最小値にすることが可能
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	S := 0
	minus := 0
	zero := false
	minn := int(1e10)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		if V == 0 {
			zero = true
		} else {
			minn = min(minn, abs(V))
		}
		A[i] = abs(V)
		S += abs(V)
		if V < 0 {
			minus++
		}
	}
	if zero {
		fmt.Println(S)
	} else if minus%2 == 0 {
		fmt.Println(S)
	} else {
		fmt.Println(S - minn*2)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}


Measured memory_bytes: 5504
<?php
$s = trim(fgets(STDIN));
$g = 0;
$p = 0;
$score = 0;
for($i = 0, $I = strlen($s); $i < $I; $i++){
    $t = $s[$i];
    if($t == "p"){
        if($g > $p){
            $p++;
        }else{
            $g++;
            $score--;
        }
    }else{
        if($g > $p){
            $p++;
            $score++;
        }else{
            $g++;
        }
    }
}
echo $score,"\n";


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll X;
    cin >> X;
	ll P = 100;
	ll y = 0;
	while(X>P){
		y++;
		P += ll(P*0.01);
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<pair<ll,ll> >list[10];
ll sum[4][105];

int main(){

	int N;

	ll W;

	scanf("%d %lld",&N,&W);

	int i,j;

	ll w,v,w1;

	for(i=0;i<N;i++){
		scanf("%lld %lld",&w,&v);
		if(i==0){w1=w;}
		list[w-w1].push_back(make_pair(v,w));
	}
	for(i=0;i<4;i++){
		sort(list[i].begin(),list[i].end());
		reverse(list[i].begin(),list[i].end());
	}

	for(i=0;i<4;i++){
		for(j=0;j<list[i].size();j++){
			sum[i][j+1]=sum[i][j]+list[i][j].first;
		}
	}

	ll ans=0ll;

	ll a,b,c,d;

	for(a=0ll;a<=(ll)list[0].size();a+=1ll){
		for(b=0ll;b<=(ll)list[1].size();b+=1ll){
			for(c=0ll;c<=(ll)list[2].size();c+=1ll){
				for(d=0ll;d<=(ll)list[3].size();d+=1ll){
					if((a*w1)+b*(w1+1ll)+c*(w1+2ll)+d*(w1+3ll)<=W){
						ans=max(ans,sum[0][a]+sum[1][b]+sum[2][c]+sum[3][d]);
					}
				}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
    if(D-A != 0&&(D-A)-B==0){
      cout << A*1 << endl;
    }
  else if(A>=D){
    cout << D << endl;
  }
  else if((D-A != 0 && (D-A)-B!=0) && ((D-A)-B)<C){
    cout << 1*A + (-1)*((D-A)-B) << endl;
  }
  else{
    cout << 1*A+(-1)*C << endl;
  }
}

Measured memory_bytes: 3672
import Foundation

let input_line: String = readLine()!

let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let a = Int(split[0])!
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
let b = Int(split[1])!

if a*b % 2 == 0{
    print("Even")
}else{
    print("Odd")
}


Measured memory_bytes: 14056
/*
 * 2524.cc: Mysterious Operator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sign = 1;
  if (s[0] == '-') {
    sign = -1;
    s.erase(0, 1);
  }
  int n = s.size(), cnt = 0;

  for (int i = 0; i < n; i++) {
    if (s[i] == '0') continue;
    int m = (i == 0) ? 0 : atoi(s.substr(0, i).c_str());
    int p = atoi(s.substr(i).c_str());

    int x2 = p + m * sign;
    int y2 = p - m * sign;

    if (x2 >= 0 && y2 >= 0 && ! (x2 & 1) && ! (y2 & 1)) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#include <stdio.h>

constexpr int buf_size = 5000;
char Input[buf_size];
char* ptr = Input;

inline int getint(void){
    int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}
inline long long int getlong(void){
    long long int res = 0; char c; while((c = *ptr++ - '0') >= 0) res = 10 * res + c;
    return res;
}

char Out[20];

inline void println(long long int a){
    if(a){
      char* t = Out;
      while(a) *t++ = a % 10, a /= 10;
      while(t != Out) putchar_unlocked(*(--t) | '0');
    }
    else putchar_unlocked('0');
    putchar_unlocked('\n');
}

int main(void){
    fread_unlocked(Input, 1, buf_size, stdin);
    int n = getint() - 2; 
    const long long int a = getlong(), b = getlong();
    long long int B = 0; while(n--) B ^= getlong();
    const long long int A = a + b - B;
    const long long int C = A >> 1;
    if(A < 0 or (A & 1) or (B & C) or (a < C)){ puts("-1"); return 0; }
    long long int res = C;
    for(long long int x = 1LL << 40; x ; x >>= 1) if(B & x) if((res | x) <= a) res |= x; 
    if(res) println(a - res); else puts("-1");
    return 0;
}

Measured memory_bytes: 1528
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
void solve() {
	lli a, b, c, k;
	lli x;
	cin >> a >> b >> c >> k;
	lli ret = 0;

	x = min(a, k);
	ret += (1 * x);
	//cout << ret << endl;
	k -= x;
	//cout << k << " " << ret << endl;
	x = min(b, k);
	k -= x;
	//cout << k << " " << ret << endl;
	x = min(c, k);
	ret += (-1 * x);
	k -= x;
	//cout << k << " " << ret << endl;
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main (){
    int i,k,m,l,j,h,n;
    int card[5][14];
    int number;
    char mark;
    scanf("%d",&n);
    for(i=1; i<=4; i++){
        for(k=1; k<=13; k++){
            card[i][k]=0;
        }
    }
     for(j=1; j<=n; j++){
        scanf(" %c %d",&mark,&number);
        if(mark=='S'){
            card[1][number]=1;
        }
        else if(mark=='H'){
            card[2][number]=1;
        }
        else if(mark=='C'){
            card[3][number]=1;
        }
        else if(mark=='D'){
            card[4][number]=1;
        }
    }
     /*       for(m=1; m<=4; m++){
        for(l=1; l<=13; l++){
            printf("%d ",card[m][l]);
        }  printf("\n");
    }*/
               for(m=1; m<=4; m++){
        for(l=1; l<=13; l++){
        if(m==1&&card[m][l]==0){
            printf("S %d\n",l);
        }
        else if(m==2&&card[m][l]==0){
            printf("H %d\n",l);
        }
        else if(m==3&&card[m][l]==0){
            printf("C %d\n",l);
        }
        else if(m==4&&card[m][l]==0){
            printf("D %d\n",l);
        }

        }
    }


return 0;}

Measured memory_bytes: 1772
n = input()
l = []
isz = 0
for i in xrange(n):
    x, y, h = map(int, raw_input().strip().split())
    if h == 0: isz += 1
    l.append([x, y, h])

assert isz != n

ans = [0,0,0]

for cx in xrange(101):
    for cy in xrange(101):
        H = 0
        zH = int(1e18)
        poss = True
        for xyh in l:
            x, y, h = xyh
            tx = abs(cx - x) + abs(cy - y)
            if h != 0:
                nH = tx + h
                if H != 0 and nH != H:
                    poss = False
                    break
                elif H == 0: H = nH
            elif h == 0:
                zH = min(zH, tx)

        if poss:
            if H > zH: poss = False
             
        if poss:
            ans = [cx, cy, H]
            break
        
    if poss: break
    
if ans != [0, 0, 0]:
    check = True
    for xyh in l:
        x, y, h = xyh
        tx = abs(cx - x) + abs(cy - y)
        assert h == max(ans[2] - tx, 0)

print ans[0], ans[1], ans[2]

Measured memory_bytes: 32876
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	b[1]=999999;
	int s=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=b[i])
		{
			s++;
			b[i+1]=a[i];
		}
		else
		b[i+1]=b[i];
	}
	cout<<s;
	return 0;
}

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

int main(){
  int N; long long T; cin >> N >> T;
  long long t[200010];
  for(int i=0;i<N;i++) cin >> t[i];
  long long sumt=0;
  for(int i=1;i<N;i++){
    if(t[i-1]+T <= t[i])
      sumt += T;
    else 
    sumt += t[i]-t[i-1];
  }
  cout << sumt+T << endl;
}
  
  

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

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

	int count = 0;
	for(int i = 0; i < n; i ++)
	{
		int a, b;
		cin >> a >> b;

		if(a == b)
			count ++;
		else
			count = 0;
		if(count == 3)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 200000 + 5;
int a[10005],vis[1000005];

ll modpow(ll x,ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n>>1; 
    }
    return ans;
}

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		int t = a[i];
		for(int j = 2; j*j <= t; j++){
			if(t % j != 0)
				continue;
			int cnt = 1;
			while((t/=j)%j == 0)
				++cnt;
			vis[j] = max(vis[j],cnt);
		}
		if(t > 1)
			vis[t] = max(vis[t],1);
	}
	ll z = 1;
	ll ans = 0;
	for(int i = 1; i <= 1000000; i++){
		while(vis[i]--)
			z = z * i % mod;
	}
	for(int i = 1; i <= n; i++){
		ans = (ans + z * modpow(a[i],mod-2))%mod;
	}
	cout << ans << endl;
    return 0;
}

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

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n), d(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	d[0] = k - a[n - 1] + a[0];
	for (int i = 1; i < n; i++)
		d[i] = a[i] - a[i - 1];
	int max = 0;
	for (int i = 0; i < n; i++)
		if (max <= d[i])
			max = d[i];
	cout << k - max << endl;
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define LL long long
using namespace std;
#define inf 0x3fffffff

int n,m;
double a[200010];

int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        scanf("%lf",&a[i]);
    double sum=0,ans=0;
    for (int i=1;i<=m;i++)
        sum+=(a[i]+1.0)/2.0;
    ans=sum;
    for (int i=m+1;i<=n;i++)
    {
        sum+=(a[i]+1.0)/2.0-(a[i-m]+1.0)/2.0;
        ans=max(ans,sum);
    }
    printf("%0.8f\n",ans);
    return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    if(a > 0){
      c -= b;
    }
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    if(c > 0){
      a -= d;
    }
    if(a <= 0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3592
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=2000005;
inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
const int N=2e6+5;
int dp[M][2][2];
int n;
int solve(int pos,int x,int y)
{
    if(pos>n)
    {
        if(x==1 && y==1 )return 1;
        else return 0;
    }
    int &ret=dp[pos][x][y];
    if(ret!=-1)return ret;
    ret=0;
    for(int j=1;j<=8;j++)
    {
        ret=ad(ret,solve(pos+1,x,y));
    }
    ret=ad(ret,solve(pos+1,1,y));
    ret=ad(ret,solve(pos+1,x,1));
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>n;
    int ses=solve(1,0,0);
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 144224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================
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;}

int main() {
  int X, N;
  ins(X, N);

  vi A(N);
  rep(i, N) {
    cin >> A[i];
  }
  all(sort, A);
  int ans = 1000;
  int kaitou = -1;
  rep(i, 101) {
    if (chmin(ans, abs(X+i)))
      kaitou = -i;
  }
  rep(i, 1001) {
    if (all(binary_search, A, i))
      continue;
    if (chmin(ans, abs(X-i)))
      kaitou = i;
  }
  cout << kaitou << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	int n, u, k, v;
	int G[100][100] = {0};
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d %d", &u, &k);
		for(int j = 0; j < k; ++j)
		{
			scanf("%d", &v);
			G[u-1][v-1] = 1;
		}
	}
	
	for(int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n - 1; ++j)
		{
			printf("%d ", G[i][j]);
		}
		printf("%d\n", G[i][n-1]);
	}
}



Measured memory_bytes: 2120
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		int n=0;
		n=a+b;
		if(a%3==0||b%3==0||n%3==0)
		   printf("Possible\n");
		else 
	   	   printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
P1 = sum(p[:k])
ans = P1
for i in range(k,n):
    P1 +=(p[i]-p[i-k])
    if ans < P1:
        ans = P1
print((ans+k)/2)

Measured memory_bytes: 25060
#include <iostream>
#define NUM 10000

using namespace std;

int main(){
    long long a[NUM], max, min, sum, i;
    cin >> i >> a[0];
    i=1;
    sum = max = min = a[0];
    while (cin >> a[i]) {
        if (max < a[i]) max = a[i];
        if (min > a[i]) min = a[i];
        sum += a[i++];
    }
    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N,M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl; 


}

Measured memory_bytes: 256
// 2018/12/05 Tazoe

#include <iostream>
using namespace std;

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

	int cnt = 0;

	for(int i=A; i<=B; i++){
		if(H%i==0){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }


signed main() {
	int n, x;
	cin >> n >> x;
	V<int> L(n);
	RBF(l, L) {
		cin >> l;
	}

	int cnt = 1, p = 0;
	RBF(l, L) {
		p += l;
		if (p <= x) {
			cnt++;
		}
	}

	col(cnt);
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long m, k;
	cin>>m>>k;
	long long arr[m];
	for(int i=0;i<m;i++){cin>>arr[i];}
	sort(arr,arr+m);
	for(int i=0;i<k;i++)
	{
	    int g=m-1-i;
	    arr[g]=0;
	}
	long long sum=0;
	for(int i=0;i<m;i++)sum+=arr[i];
	cout<<sum;
	
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){

long long a,b,k;
cin>>a>>b>>k;
if(a>=k){
  a=a-k;

}
else {
  k-=a;
  a=0;
  if(b>=k){
    b-=k;
  }
  else {
    b=0;
  }
}
cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;


ll X;
string S;
bool flag;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> X;
	int cnt = 0;
	ll cur = 100;
	while (cur < X) {
		cnt++;
		cur *= 1.01;
	}
	cout << cnt << endl;

	

	return 0;
}


Measured memory_bytes: 3192
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, flag = 0;
  scanf("%d", &n);
  for (int i = 0; i < 100 / 7; i++)
  {
    for (int j = 0; j < 100 / 4; j++)
    {
      int tmp = 4 * j + 7 * i;
      if (tmp == n)
      {
        flag = 1;
        break;
      }
    }
  }
  puts(flag ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define N 10000

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key) i++;
  return i!=n;
}

int main(){
  int i,n,A[N+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  scanf("%d",&q);
for(i=0;i<q;i++){
 scanf("%d",&key);
 if(search(A,n,key))sum++;
  }

 
 printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2144