akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)
 
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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;
 
// -------------------------------------------------------
ll N, M, Q;
ll a[100], b[100], c[100], d[100];
ll arr[20];
ll ans;
 
void score()
{
    ll sum = 0;
    rep(i, 0, Q)
    {
        if (arr[b[i] - 1] - arr[a[i] - 1] == c[i]) {
            sum += d[i];
        }
    }
    chmax(ans, sum);
}
 
void dfs(ll n, ll cur)
{
    if (cur == N) {
        score();
        return;
    }
    for (ll i = n; i <= M; i++) {
        arr[cur] = i;
        dfs(i, cur + 1);
    }
    return;
}
 
int main()
{
    cin >> N >> M >> Q;
    rep(i, 0, Q)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>
//#include <stdlib.h>
//#include <math.h>
#include <string.h>

int lcs[1001][1001];

int max(int a,int b){
  if(a>b) return a;
  else return b;
}

int main(){
  int n,c,i,j,ii,iii,lx,ly;
  int ans[150];
  char x[1001];
  char y[1001];

  scanf("%d",&n);

  for(c=0;c<n;c++){
    //Initialize(初期化)
    for(ii=0;ii<1000;ii++){
      for(iii=0;iii<1000;iii++){
	if(lcs[ii][iii]=='\0')break;
	lcs[ii][iii]='\0';
      }
      if(x[ii]=='\0' && y[ii]=='\0')break;
      x[ii]='\0';
      y[ii]='\0';
    }

    
    scanf("%s %s",x,y);


    //strlen \0の1こ前まで
    //sizeof \0含む

    lx = strlen(x);
    ly = strlen(y);

    //printf("%d %d\n",lx,ly);
    
    for(i=0;i<lx+1;i++){
      for(j=0;j<ly+1;j++){
	if(i==0 || j==0)lcs[i][j]=0;
	else if(x[i-1]==y[j-1])lcs[i][j]=lcs[i-1][j-1] + 1;
	else lcs[i][j]=max(lcs[i][j-1],lcs[i-1][j]);
	//printf("%d ",lcs[i][j]);
      }
      //printf("\n");
    }
   
    ans[c]=lcs[lx][ly];
  }
  for(c=0;c<n;c++)
    printf("%d\n",ans[c]);

  return 0;
}



Measured memory_bytes: 5652
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  
  int r,g,b;
  cin>>r>>g>>b;
  if((r*100+g*10+b)%4==0){
      cout<<"YES"<<endl;
  }
  else{
      cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;

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

        int N = Integer.parseInt(br.readLine());
        ArrayList<Integer> V = new ArrayList<>();
        ArrayList<Integer> C = new ArrayList<>();
        for (var e : br.readLine().split(" ")) {
            V.add(Integer.parseInt(e));
        }
        for (var e : br.readLine().split(" ")) {
            C.add(Integer.parseInt(e));
        }

        int res = 0;
        for (int i = 0; i < N; ++i) {
            var diff = V.get(i) - C.get(i);
            if (diff > 0) res += diff;
        }

        System.out.println(res);
    }
}



Measured memory_bytes: 32580
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();

        int i=0;
        int tall=0;
        int count=0;

        for(i=0;i<N;i++){
            tall=sc.nextInt();
            if(tall>=K){
                count++;
            }
        }
        System.out.println(count);
        //END
    }
}



Measured memory_bytes: 48992
nums=gets.strip.split(" ").map do |i|
  i.to_i
end
a = nums[0]
b = nums[1]
c = nums[2]
k = nums[3]

sum = 0

if k<=a
  sum +=k
elsif k<=a+b
  sum+=a
else
  sum+=a-(k-a-b)
end

puts sum

Measured memory_bytes: 14244
/*
AizuOnline A2369
cat checker
*/
#include <stdio.h>
#include <string.h>

#define MAXLEN 500
char S[MAXLEN+1];
char stack[MAXLEN+1]; 
int  depth;
int  state;
#define AFTERW 0
#define AFTERM 1
#define AFTERMW 2
#define  AFTERE 3
#define AFTEREW 4

int ismew(char * s,int len)
{
  int i, state;
  char c;
  if(len==0)return(1);
  depth=0;state=AFTERW;
  for(i=0;i<len;i++)
  {
          c=s[i];
          // printf("%d %c:",state,c);
          if(c=='m') 
          { 
                  if(state==AFTERW && i==0)
                  {
                          stack[depth]=state;
                          depth++;
                          state = AFTERM;
                  }
                  else if(state==AFTERM || state==AFTERE)
                  { 
                          stack[depth]=state;
                          state=AFTERM;
                          depth++;
                  }
                  else
                          return(0);
          }
          else if(c=='e')
          {
                  if(state==AFTERM || state==AFTERMW)
                          state=AFTERE;
                  else
                          return(0);
          }
          else if(c=='w')
          {
                  if(state==AFTERE ||state==AFTEREW)
                  { 
                          depth--;
                          state=stack[depth];
                          if(state != AFTERW)
                                  state++; 
                  }
                  else
                          return(0);
          }
          //printf("%d\n",state);
    }
    if(depth == 0 && state == AFTERW)
            return(1);
    else
            return(0);
}

main()
{
        int ret;

        scanf("%s",S);
   
        ret=ismew(S,strlen(S));
  
        printf("%s\n",ret?"Cat":"Rabbit");
    
        return(0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
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; }

int main()
{
    string s, t;
    cin >> s >> t;
    if(s.size()+1 == t.size())
    {
        string tmp = t.substr(0, s.size());
        if(s == tmp)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3516
n, *x = map(int, input().split())
L = [int(input()) for _ in range(n)]

def dfs(i, a, b, c):
    if i == len(L):
        if min(a, b, c) > 0:
            return abs(x[0] - a) + abs(x[1] - b) + abs(x[2] - c) - 30
        else:
            return 10 ** 9

    ret0 = dfs(i + 1, a, b, c)
    ret1 = dfs(i + 1, a + L[i], b, c) + 10
    ret2 = dfs(i + 1, a, b + L[i], c) + 10
    ret3 = dfs(i + 1, a, b, c + L[i]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> v(4);
	rep(i, n)
	{
		string s; cin >> s;
		if (s == "AC")++v[0];
		else if (s == "WA")++v[1];
		else if (s == "TLE")++v[2];
		else ++v[3];
	}
	cout << "AC x " << v[0] << endl;
	cout << "WA x " << v[1] << endl;
	cout << "TLE x " << v[2] << endl;
	cout << "RE x " << v[3] << endl;
}

Measured memory_bytes: 3624
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int done[20][20];
char tile[20][20];
int mw,mh;
string temp;
int loopchk(int h,int w,int v);
int check(int h,int w);
int check(int h,int w){
	int posw=114514;
	int posh=114514;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(tile[i][j] == '@'){
				posh = i;
				posw = j;
				break;
			}
		}
		if(posw!=114514){break;}
	}
	return 1+loopchk(posh,posw,0);
}
int loopchk(int h,int w,int v){
	int value=v;
	if(done[h][w] == 1){
		return value-1;
	}else{
		done[h][w] = 1;
	}
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(w + j < 0 || w + j > mw - 1){continue;}
			if(h + i < 0 || h + i > mh - 1){continue;}
			if(i == 0 && j == 0){continue;}
			if(i == -1 && j == -1 || i == -1 && j == 1 || i == 1 && j == -1 || i == 1 && j == 1){continue;} 
			if(tile[h+i][w+j] == '.'){
				value = 1 + loopchk(h + i, w + j,value);
			}
		}
	}
	return value;
}
int main(){
	int w,h;
	while(cin >> w >> h, w != 0 || h != 0){
		mw = w;
		mh = h;
		for(int i=0;i<20;i++){
			for(int j=0;j<20;j++){
				done[i][j] = 0;
				tile[i][j] = '#';
			}
		}
		for(int i=0;i<h;i++){
			cin >> temp;
			for(int j=0;j<w;j++){
				tile[i][j] = temp[j];
			}
		}
		cout << check(h,w) << endl;
	}
	return 0;
}

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

template <typename T> void max_self(T& a,T b){
    a = max(a,b);
}
bool first_row_or_column(pair<int,int> p){
    return p.first == 0 || p.second == 0;
}
const int INF= 1e9+5;
int main()
{
    string s,t;
    cin>>s>>t;
    vector<vector<pair<int,pair<int,int>>>> dp(s.length()+1,
        vector<pair<int,pair<int,int>>> (t.length()+1,{-INF,{0,0}}));
    dp[0][0]={0,{0,0}};    
    //dp[i][j].first is max length matched so far)
    REP(i,(int)s.length()){
        REP(j,(int)t.length()){
            if(s[i]==t[j]){
                max_self(dp[i+1][j+1],make_pair(dp[i][j].first+1,make_pair(i,j)));
            }
            max_self(dp[i+1][j],make_pair(dp[i][j].first,make_pair(i,j)));
            max_self(dp[i][j+1],make_pair(dp[i][j].first,make_pair(i,j)));
        }
        
    }
    pair<int,pair<int,int>> answer = {0,{0,0}};
    REP(i,(int)s.length()+1){
        REP(j,(int)t.length()+1){
            max_self(answer,make_pair(dp[i][j].first,make_pair(i,j)));
        }
    }
    string res;
    pair<int,int> cur = answer.second;
    while(!first_row_or_column(cur)){
        int i = cur.first;
        int j = cur.second;
        pair<int,int> previous = dp[i][j].second; 
        if(previous==make_pair(i-1,j-1)){
            assert(s[i-1]==t[j-1]);
            res+=s[i-1];
        }
        cur = previous;
    }
    reverse(res.begin(),res.end());
    cout << res << endl;
    return 0;
}


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

const int inf = 1000000000;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int n;
long long a[200200];
int cnt2[200200], cnt5[200200];
pair<int, int> number[200200];
int cnt_five[111];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n){
		string s;
		cin >> s;
		int j = s.size() - 1;
		while(j >= 0 && s[j] != '.') j--;
		if(j >= 0) cnt2[i] -= ((int)s.size() - j - 1), cnt5[i] -= ((int)s.size() - j - 1);
		for(j = 0; j < s.size(); j++){
			if(s[j] != '.') a[i] = a[i] * 10LL + (long long)(s[j] - '0');
		}
	}
	int mn_five = 100, mx_five = -100;
	rep(i, n){
		long long na = (long long)a[i];
		while(na % 2ll == 0) {
			cnt2[i]++;
			na /= 2ll;
		}
		while(na % 5ll == 0){
			cnt5[i]++;
			na /= 5ll;
		}
		mn_five = min(mn_five, cnt5[i]);
		mx_five = max(mx_five, cnt5[i]);
		number[i] = make_pair(cnt2[i], cnt5[i]);
	}
	sort(number, number + n);
	int r = n-1;
	long long ans = 0;
	for(int i = 0; i < n; i++){
		while(r >= i && number[r].first + number[i].first >= 0){
			cnt_five[number[r].second - mn_five]++;
			r--;
		}
		if(r == i-1){
			cnt_five[number[i].second - mn_five]--;
			r++;
		}
		for(int j = mx_five - mn_five; j >= -number[i].second - mn_five && j >= 0; j--){
			ans += cnt_five[j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8252
#!/usr/bin/env python
"""AtCoder Beginner Contest 168: D - .. (Double Dots)
https://atcoder.jp/contests/abc168/tasks/abc168_d
"""


def main():
    N, M = map(int, input().split())

    to = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        to[a-1].append(b-1)
        to[b-1].append(a-1)

    dist = [-1]*N
    q = [0]
    while q:
        v = q.pop(0)
        for i in to[v]:
            if dist[i] != -1:
                continue
            dist[i] = v
            q.append(i)

    print('Yes')
    for i in range(1, N):
        print(dist[i]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33684
N, K = map(int, input().split(" "))
count = []
ans = 0
for i in range(N):
    score = i + 1
    n = 0 
    while  True:
        if score >= K:
            break
        else:
            score *= 2
            n += 1
    count.append(n)

for m in count:
    ans += 2 ** (-m)

print(ans / N)

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;
	cin >> s;
	vector<int> a(26,0);
	for(int i = 0; i < s.size(); i++) {
		a[s[i] - 'a']++; 
	}
	bool flag = false;
	for(int i = 0; i < 26; i++) {
		if (a[i] % 2 != 0){
			flag = true;
			break;
		}
	}
	if (flag){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
ll value (ll v1, ll v2, ll v3, ll v4) {
	ll a = max(v1, v2);
	a = max(a, v3);
	a = max(a, v4);
	ll b = min(v1, v2);
	b = min(b, v3);
	b = min(b, v4);
	return a - b;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll n;
 	cin >> n;
 	vector <ll> pref(n + 1);
 	ll x;
 	pref[0] = 0;
 	for (ll i = 1; i <= n; i++) {
 		cin >> x;
 		pref[i] = pref[i - 1] + x;
 	}   
 	ll ans = 1e18;   
 	for (ll i = 3; i <= n - 1; i++) {
 		ll temp1 = pref[i - 1] / 2;
 		ll ind = lower_bound(all(pref), temp1) - pref.begin();
 		ll temp2 = (pref[n] - pref[i - 1]) / 2;
 		ll ind2 = lower_bound(all(pref), temp2 + pref[i - 1]) - pref.begin();
 		vector <ll> v1;
 		vector <ll> v2;
 		if (ind != 1) {
 			v1.pb(ind);
 		}
 		if (ind + 1 != i) {
 			v1.pb(ind + 1);
 		}
 		if (ind2 != i) {
 			v2.pb(ind2);
 		}
 		if (ind2 != n) {
 			v2.pb(ind2 + 1);
 		}
 		for (ll j = 0; j < sz(v1); j++) {
 			for (ll k = 0; k < sz(v2); k++) {
 				ans = min(ans, value(pref[i - 1] - pref[v1[j] - 1], pref[v1[j] - 1], pref[n] - pref[v2[k] - 1], pref[v2[k] - 1] - pref[i - 1]));
 			}
 		}
 	}
 	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,x=map(int,readline().split())
    a=list(map(int,readline().split()))

    ans=0
    for i in range(n):
        if i==0:
            if a[i]>x:
                ans+=a[i]-x
                a[i]=x
        else:
            if a[i-1]+a[i]>x:
                ans+=a[i]+a[i-1]-x
                a[i]-=a[i]+a[i-1]-x

    print(ans)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 14076
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
string s;
signed main() {
	cin >> n >> s;
	int ans = 0;
	rep(i, n - 2) {
		if (s.substr(i, 3) == "ABC")ans++;
	}
	cout << ans << endl;
	ggr
}




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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))

#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    int a[n], b[n], c[n];

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

    ll dp[n+1][3];
    for(int i=0; i<3; i++) 
        dp[0][i] = 0;

    for(int i=1; i<=n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i-1];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i-1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i-1];  
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';

    return 0;
   
}

Measured memory_bytes: 7080
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<double>a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  double sum = 0;
  for(int i=0;i<n;i++){
    sum += 1.0 / a[i];
  }
  
  sum = 1.0 / sum;
  
  cout << setprecision(10) << sum << endl;
  
  return 0;
}
  

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

int main(){
	const int INF=1000000000;
	int n,c;
	static int dp[2][5000+2][2];
	for(int i=0;i<2;i++)for(int j=0;j<5002;j++){dp[i][j][0]=INF; dp[i][j][1]=INF;}
	dp[0][1][0]=0;
	dp[0][0][1]=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d",&c);
		for(int j=0;j<=n/2;j++){
			if(j==0)dp[1][j][0]=INF;
			else dp[1][j][0]=min(dp[0][j-1][0],dp[0][j-1][1]+c);
			dp[1][j][1]=min(dp[0][j][0]+c,dp[0][j][1]);
		}
		for(int j=0;j<=n/2;j++){
			dp[0][j][0]=dp[1][j][0];
			dp[0][j][1]=dp[1][j][1];
		}
	}
	printf("%d\n",min(dp[0][n/2][0],dp[0][n/2][1]));
}

Measured memory_bytes: 1248
import sys
s = input()
t = input()
ls = len(s)
lt = len(t)
noexist = 'UNRESTORABLE'
if lt>ls:
    print(noexist)
    sys.exit()
last = -1
for i in range(ls-lt+1):
    for j, c in enumerate(t):
        if s[i+j]!='?' and s[i+j]!=c:
            break
    else:
        last = i
if last < 0:
    print(noexist)
    sys.exit()
ind = 0
while(ind<ls):
    if ind==last:
        print(t, end='')
        ind += lt
    else:
        print(s[ind] if s[ind]!='?' else 'a', end='')
        ind += 1

Measured memory_bytes: 3064
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;
 
template<typename T> using V = vector<T>;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int n; cin >> n;
	vector<int> h(n + 1);
	vector<int> dp(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	dp[n] = 0;
	for (int i = n - 1; i > 0; --i) {
		if (h[i] >= h[i + 1]) {
			dp[i] = dp[i + 1] + 1;
		}
	}
	cout << *max_element(all(dp));
}

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

int main(){
    while(1){
        int a,b;
        char op;
        cin>>a>>op>>b;
        if(op=='?') break;
        if(op=='+'){
            cout<<a+b<<endl;
        }else if(op=='-'){
            cout<<a-b<<endl;
        }else if(op=='*'){
            cout<<a*b<<endl;
        }else{
            cout<<a/b<<endl;
        }
        
        
    }
    return 0;
}


Measured memory_bytes: 3080
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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


int main()
{
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b) * h / 2 << endl;

}


Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
ans = float('inf')
k = 0
if n == 2: k = 10
elif n == 3: k = 100
for i in range(k, 1000):
    flg = True
    for s, c in sc:
        if list(str(i))[s-1] == str(c): continue
        flg = False
    if flg:
        ans = i
        break
if ans == float('inf'): ans = -1
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

int V;
vector<int> g[101010];
int match[101010];
bool used[101010];
void add_edge(int v, int u) {
        g[v].push_back(u);
        g[u].push_back(v);
}
bool dfs(int v) {
        used[v] = true;
        for (auto u : g[v]) {
                int w = match[u];
                if (w < 0 || (!used[w] && dfs(w))) {
                        match[v] = u;
                        match[u] = v;
                        return true;
                }
        }
        return false;
}
int BipartiteMatching() {
        int res = 0;
        memset(match, -1, sizeof match);
        for (int v = 0; v < V; v ++) {
                if (match[v] < 0) {
                        memset(used, 0, sizeof used);
                        if (dfs(v)) {
                                res ++;
                        }
                }
        }
        return res;
}

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> u, v;
        for (int i = 0; i < n; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                u.emplace_back(a, b);
        }
        for (int i = 0; i < n; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                v.emplace_back(a, b);
        }
        V = 2 * n;
        for (int i = 0; i < n; i ++) {
                for (int j = 0; j < n; j ++) {
                        if (u[i].first < v[j].first && u[i].second < v[j].second) {
                                add_edge(i, j + n);
                        }
                }
        }
        printf("%d\n", BipartiteMatching());
        return 0;
}



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

int main(void){
    int K, N, Abuf;
    vector<int> A;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
    }
    sort(A.begin(), A.end());
    cout << accumulate(A.begin(), A.begin()+K, 0) << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

struct Circle {
  double x, y, r;
};

double distpow(double x1, double y1, double x2, double y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

bool kasanari(Circle c1, Circle c2) {
  return (c1.r + c2.r) * (c1.r + c2.r) > distpow(c1.x, c1.y, c2.x, c2.y) + eps;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<int> col(n);
    vector<Circle> circles(n);
    for(int i=0;i<n;++i) {
      cin >> circles[i].x >> circles[i].y >> circles[i].r >> col[i];
    }

    vector<int> over(n, 0);
    for(int i=0;i<n;++i) {
      for(int j=0;j<i;++j) {
        if(kasanari(circles[i], circles[j])) {
          over[i] |= 1<<j;
        }
      }
    }
/*     for(int i=0;i<n;++i) {
      cout << bitset<4>(over[i]) << endl;
    } */

    vector<int> dp(1<<n, -1);
    dp[(1<<n)-1] = 0;
    for(int i=(1<<n)-1;i>=0;--i) {
      if(dp[i] == -1) continue;
      for(int j=0;j<n;++j) {
        if(((i>>j)&1) == 0) continue;
        for(int k=j+1;k<n;++k) {
          if(((i>>k)&1) == 0) continue;
          
          if(col[j] != col[k]) continue;
          //cout << i << ":" << j << ":" << k << endl;
          if(((i & over[j]) != 0) || ((i & over[k]) != 0)) continue;
          
          dp[i ^ (1<<j) ^ (1<<k)] = dp[i] + 2;
        }
      }
    }
    //printv(dp);

    int ma = 0;
    for(int i=0;i<(1<<n);++i) {
      ma = max(ma, dp[i]);
    }
    cout << ma << endl;

  }


}



Measured memory_bytes: 68604
h,w = map(int, input().split())
area = [[0 for _ in range(w)] for _ in range(h)]
bomb = [[1 for _ in range(w)] for _ in range(h)]

def add_bomb(area, i, j):
    if i+1 < h:
        area[i+1][j] += 1
        if j+1 < w:
            area[i+1][j+1] += 1
        if j-1 >= 0:
            area[i+1][j-1] += 1

    if i-1 >= 0:
        area[i-1][j] += 1
        if j+1 < w:
            area[i-1][j+1] += 1
        if j-1 >= 0:
            area[i-1][j-1] += 1

    if j+1 < w:
        area[i][j+1] += 1
    if j-1 >= 0:
        area[i][j-1] += 1

    return area

for i in range(h):
    for j, x in enumerate(list(input())):
        if x == '#':
            area = add_bomb(area, i, j)
            bomb[i][j] = 0

for a_ls, b_ls in zip(area, bomb):
    print(''.join([str(a) if b == 1 else '#' for a, b in zip(a_ls, b_ls)]))


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

int main() {
	long int n,k;
	std::cin >> n>>k;
	long int t=n%k;
	if(k-t>t)
	{
	    std::cout << t << std::endl;
	}
	else
	{
	    std::cout << k-t << std::endl;
	}
	return 0;
}

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

vector<long long> meat_num(51, 1);
vector<long long> all_num(51, 1);

long long solve(int y, long long z){
    if (z == all_num[y]) return meat_num[y];
    if (z <= 1) return 0;
    if (z <= all_num[y - 1] + 1) return solve(y - 1, z - 1);
    return meat_num[y - 1] + 1 + solve(y - 1, z - all_num[y - 1] - 2); 
}

int main(){
    int n; long long x;
    cin >> n >> x;
    for (int i = 0; i < 50; i++) meat_num[i + 1] = meat_num[i] * 2 + 1;
    for (int i = 0; i < 50; i++) all_num[i + 1] = all_num[i] * 2 + 3;
    cout << solve(n, x) << endl;
}

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String s = br.readLine();	//?????????????????????????????????
        String p = br.readLine();	//?????????????????????????????????
        sb.append(s);				//sb?????????????????¨??????????????????????????¨??????????????????
        sb.append(s);
        if(sb.indexOf(p) != -1){
        	//??????????????????????±??????????????????????????????????????????????indexOf??§??????
        	//????±?????????????????????£?????´?????????-1??????????????§!=?????¶?????????
        	System.out.println("Yes");
        	//-1??\????????£??????Yes??????????????????
        }else{
        	System.out.println("No");
        	//-1?????£??????No??????????????????
        }
     }
}

Measured memory_bytes: 16984
#include<stdio.h>
void swap(int *a,int *b)
{
	int t;
	t = *a;
	*a = *b;
	*b = t;
}
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	swap(&a,&b);
	swap(&a,&c);
	printf("%d %d %d",a,b,c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C, D;
    cin >> A >> B >> C >>D;
    int res;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back
const int v = pow(10, 5);

int main() {
  int N;
  cin >> N;
  int n = N/2;
  int tmp;
  vector<int> a(v + 1, 0);
  vector<int> b(v + 1, 0);

  rep(i, n){
    cin >> tmp;
    a[tmp-1]++;

    cin >> tmp;
    b[tmp-1]++;
  }

  int a_max = v, b_max = v;
  int a_max2 = v, b_max2 = v;
  rep(i, v) {
    if (a[a_max] < a[i]) {
      a_max2 = a_max;
      a_max = i;
    } else if (a[a_max2] < a[i]){
      a_max2 = i;
    }

    if (b[b_max] < b[i]) {
      b_max2 = b_max;
      b_max = i;
    } else if (b[b_max2] < b[i]){
      b_max2 = i;
    }
  }
  // cout << a_max << " " << b_max << endl;
  // cout << a_max2 << " " << b_max2 << endl;


  int ans = 0;
  if (a_max != b_max) {
    ans = (n - a[a_max]) + (n - b[b_max]);
  } else { // 数が同じ場合
      int n1 = (n - a[a_max2]) + (n - b[b_max]);
      int n2 = (n - b[b_max2]) + (n - a[a_max]);
      ans = min(n1, n2);
  }
  
  cout << ans << endl;

}


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


int main() {
    int a,b;
    cin>>a>>b;
    vector<int> f(3);

    f.at(0) =a+b;
    f.at(1) =a*b;
    f.at(2) =a-b;

    sort(f.begin(),f.end());
    cout<<f.at(2)<<endl;



}


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

int main()
{
	int N; cin >> N;
	vector<int>A(N);
	vector<int>cnt(100001);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int cnt2 = 0;
	int ans = 0;
	for (int i = 0; i < 100001; i++) {
		while (cnt[i] >= 3)cnt[i] -= 2;

		if (cnt[i] == 2) {
			ans++;
			cnt2++;
		}
		else if (cnt[i] == 1)ans++;
	}
	if (cnt2 % 2)ans--;

	cout << ans << endl;

    return 0;
}



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


int as(char s[101]){
  for(int i=0;i<strlen(s);i++){
    if(i%2==0){
      if(s[i]=='L'){
        return 0;
      }
    }else{
      if(s[i]=='R'){
        return 0;
      }
    }
  }
  return 1;
}
    

int main(){
  char s[101];
  scanf("%s",s);
  if(as(s)==1){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define pb push_back
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define MOD 10000000000

ll factorial(ll n) { if(n == 0 || n == 1) return 1; ll res = 1;for(ll i=2;i<=n;i++) res = (res*n)%MOD;return res;}
ll mpow(ll a, ll n) { ll ret=1; ll b=a; while(n) { if(n&1) {ret=(ret*b)%MOD;} b=(b*b)%MOD; n>>=1; } return (ll)ret; }
int toint(const string &s) { stringstream ss(s); int x; ss >> x; return x; }
ll xGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) {x = 1;y = 0;return a;} ll x1, y1, gcd = xGCD(b, a % b, x1, y1); x = y1; y = x1 - (a / b) * y1; return gcd; }
ll inverse(ll a) {ll x, y;ll gcd = xGCD(a, MOD, x, y);return (x%MOD+MOD)%MOD;}
ll bc(ll n, ll k) { if(n == k || k == 0) return 1; if(k == 1 || k == n-1) return n;ll a = factorial(n);ll b = inverse(factorial(k));ll c = inverse(factorial(n - k));return ((a%MOD*b%MOD)*c%MOD)%MOD;}
void fastscan(ll &x) { bool neg=false; register int c; x =0;c=getchar();if(c=='-') {neg = true;c=getchar();}for(;(c>47 && c<58);c=getchar())x = (x<<1) + (x<<3) +c -48;if(neg) x *=-1;}


int main() {
//     fstream fin,fout;
//     fin.open("sample.txt");
//     fout.open("res.txt");
    int x;
    cin>>x;
    
    double sides = 360.0/(float)x;
    
    double i=1.0;
    
    while(true) {
        double diff =sides*i-(int)(sides*i);
        //cout<<diff<<endl;
        if(diff > 1e-3) i++;
        else break;
    }
    
    cout<<sides*i;
//     cout << duration.count() << endl;
//     fin.close();
//     fout.close();
    return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
//
// Created by karayuu on 2018-12-23.
//

int main() {
    double r;
    cin >> r;

    double s = r * r * M_PI;
    double l = 2 * r * M_PI;

    printf("%.6lf %.6lf\n", s, l);
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, L;
  cin >> N >> L;
  vector<vector<int>> data(N, vector<int> (L));
  char a;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < L; j++) {
      cin >> a;
      data.at(i).at(j) = a - 'a';
    }
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < L; j++) {
      a = data.at(i).at(j) + 'a';
      cout << a;
    }
  }
  cout << endl;
  return 0;
}

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

int k, n;
int d[200008];

int main()
{
  cin >> k >> n;
  int i;
  for(i = 1; i <= n; i++)
    cin >> d[i];
  int maxgap = d[2] - d[1];
  for(i = 3; i <= n; i++)
    maxgap = max(maxgap, d[i]- d[i-1]);
  
  maxgap = max(maxgap, k-d[n] + d[1]);
  cout << k - maxgap;
  
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
int main(){
    int n;
    cin >> n;
    vector<lli> a(n);
    lli ans = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] > 4){
            ans += a[i]-4;
            a[i] = 4;
        }
    }
    sort(a.begin(), a.end(), greater<lli>());
    if(n==5 && a[0]==4 && a[1]==3 && a[2]==3 && a[3]==3 && a[4]==3){
        ans += 8;
    }else if(n==5 && a[0]==3 && a[1]==3 && a[2]==3 && a[3]==3 && a[4]==3){
        ans += 7;
    }else if(n==5 && a[0]==3 && a[1]==2 && a[2]==2 && a[3]==2 && a[4]==2){
        ans += 5;
    }else if(n==5 && a[0]==2 && a[1]==2 && a[2]==2 && a[3]==2 && a[4]==2){
        ans += 4;
    }else if(n==4 && a[0]==2 && a[1]==2 && a[2]==2 && a[3]==2){
        ans += 4;
    }else{
        for(int i=0; i<n; i++){
            ans += max(a[i]-i, 0LL);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3136
#include<stdio.h>

int main(void){

    int thp,tpw,ahp,apw;
    int tmp1,tmp2,tat_count,aat_count;

    scanf("%d %d %d %d",&thp,&tpw,&ahp,&apw);

    tmp1 = thp%apw;
    tmp2 = ahp%tpw;
    tat_count = thp/apw;
    aat_count = ahp/tpw;

    if(tmp1>0) tat_count++;
    if(tmp2>0) aat_count++;

    if(tat_count>=aat_count){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
int main(){
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(d2==1) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
def ii(): return int(input())


def mi(): return map(int, input().split())


def li(): return list(map(int, input().split()))


MOD = 10**9 + 7


class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    def __str__(self): return str(self.x)
    __repr__ = __str__
    def __int__(self): return self.x
    __index__ = __int__

    def __add__(self, other): return ModInt(self.x + ModInt(other).x)
    def __sub__(self, other): return ModInt(self.x - ModInt(other).x)
    def __mul__(self, other): return ModInt(self.x * ModInt(other).x)
    def __pow__(self, other): return ModInt(pow(self.x, ModInt(other).x, MOD))
    def __truediv__(self, other): return ModInt(
        self.x * pow(ModInt(other).x, MOD - 2, MOD))

    def __floordiv__(self, other): return ModInt(self.x // ModInt(other).x)
    def __radd__(self, other): return ModInt(other + self.x)
    def __rsub__(self, other): return ModInt(other - self.x)
    def __rpow__(self, other): return ModInt(pow(other, self.x, MOD))
    def __rmul__(self, other): return ModInt(other * self.x)
    def __rtruediv__(self, other): return ModInt(
        other * pow(self.x, MOD - 2, MOD))

    def __rfloordiv__(self, other): return ModInt(other // self.x)

    def __lt__(self, other): return self.x < ModInt(other).x
    def __gt__(self, other): return self.x > ModInt(other).x
    def __le__(self, other): return self.x <= ModInt(other).x
    def __ge__(self, other): return self.x >= ModInt(other).x
    def __eq__(self, other): return self.x == ModInt(other).x
    def __ne__(self, other): return self.x != ModInt(other).x


def cmb(n, r):  # nCr = n!/(n-r)!r!
    retVal = 1
    for i in range(n-r+1, n+1):
        retVal *= i
    for i in range(2, r+1):
        retVal //= i
    return retVal


n = ii()

l = [0, 0, 0, 1] + [0] * 2000
l = list(map(ModInt, l))


if n < 4:
    print(l[n])

else:
    for i in range(4, n+1):
        tmp = 0

        for j in range(3, i-2):
            tmp += l[j]

        l[i] = 1 + tmp

    print(l[n])


Measured memory_bytes: 9472
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long a = long.Parse(input[1]);
    long b = long.Parse(input[2]);
		long c = long.Parse(input[3]);
    long d = long.Parse(input[4]);
    bool answer = false;

    for(long i = 0; i <= n-1; i++)
    {
      if(a-d*(n-1-i)+c*i <= b && b <= a-c*(n-1-i)+d*i) answer = true;
    }
    
    Console.WriteLine((answer) ? "YES" : "NO");
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

int N, M, Q;

int main()
{
    cin >> N >> M;
    vector<vector<int> > g(N);
    vector<int> vd(N, -1);
    vector<int> col(N, 0);

    for (int i = 0; i < M;i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin >> Q;
    vector<int> v(Q), d(Q), c(Q);
    for (int i = 0; i < Q;i++)
    {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    queue<int> que;
    for (int i = Q - 1; i >= 0; i--)
    {
        auto push = [&](int vv, int dd)
        {
            if(vd[vv] < dd)
            {
                vd[vv] = dd;
                if (col[vv] == 0)
                {
                    col[vv] = c[i];
                }
                que.push(vv);
            }
        };
        push(v[i], d[i]);
        while(que.size())
        {
            int vv = que.front();
            que.pop();
            if(vd[vv] == 0)
            {
                continue;
            }
            for (int j = 0; j < g[vv].size(); j++)
            {
                push(g[vv][j], vd[vv]-1);
            }
        }
    }

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


Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i,j,a;
	a=s.size();
	for(i=0;i<a;i++)
	{
		for(j=i+1;j<a;j++)
		{
			if(s[i]==s[j])
			{
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H==0&&W==0)
            break;
            for(int y=0;y<H;y++){
                if(y%2==0){
                     for(int x=0;x<W;x++){ 
                         if(x%2==0){
                         System.out.print("#");
                         }else{
                         System.out.print(".");
                         }
                     }
                }else{
                    for(int x=0;x<W;x++){
                        if(x%2==0){
                        System.out.print(".");
                        }else{
                        System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33200
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;



signed main(){
    int x;
    cin >> x;
    x=x%7;

        if(x==0)
        {
            cout << "thu" << endl;
        }
        if(x==1)
        {
            cout<<"fri"<<endl;
        }
        if(x==2)
        {
            cout << "sat" <<endl;
        }
        if(x==3)
        {
            cout << "sun" << endl;
        }
        if(x==4)
        {
            cout << "mon" << endl;
        }
        if(x==5)
        {
            cout << "tue" << endl;
        }
        if(x==6)
        {
            cout << "wed" << endl;
        }
    return 0;
}


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

const int inf=2000114514;
int n,a[200010],v,p[3],vv,pp[10],ff[10],ppn;

int main()
{
	scanf("%d",&n),a[1]=0;
	for (int i=2; i<=n+1; i++) scanf("%d",&a[i]);
	a[n+=2]=0,v=0,p[0]=0,p[1]=p[2]=inf;
	for (int i=2; i<=n; i++)
	{
		ppn=0;
		for (int j=0; j<3; j++)
		{
			if (p[j]<=a[i]) pp[++ppn]=p[j];
			if (p[j]>=a[i-1]-a[i]&&p[j]<=a[i-1]) pp[++ppn]=p[j]-a[i-1]+a[i];
		}
		sort(pp+1,pp+1+ppn);
		for (int j=1; j<=ppn; j++)
		{
			ff[j]=inf;
			for (int k=0; k<3; k++) if (p[k]!=inf)
				ff[j]=min(ff[j],v-k+(pp[j]<p[k])+(pp[j]<a[i]-a[i-1]+p[k]));
		}
		int nw=0;
		for (int j=1; j<=ppn; j++)
			if (j==1||ff[j]!=ff[j-1]) 
			{
				p[nw++]=pp[j];
				if (nw==1) v=ff[j];
			}
		while (nw<3) p[nw++]=inf;
	}
	for (int k=2; k>=0; k--) if (p[k]!=inf) return printf("%d\n",v-k),0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 int main() {
     int N, K; cin >> N >> K;
     string S; cin >> S;

     int happy = 0;
     rep(i, 0, N - 1) if (S.at(i) == S.at(i + 1)) happy++;

     cout << min(N - 1, happy + 2 * K) << endl;
 }


Measured memory_bytes: 512