akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string S; int n;
    
    set<string> T;
    
    scanf("%d", &n);
    
    while(n--)
    {
        cin >> S;
        
        int c = 0;
        
        for(int i = 1; i < S.size(); i++)
        {
            c += (S[i - 1] == S[i] ? 1 : 0);
        }
        
        if(c + 1 == S.size())
        {
            printf("1\n");
        }
        else
        {
            T.clear();
            
            for(int j = 1; j < S.size(); j++)
            {
                string A = S.substr(0, j);
                string B = S.substr(j, S.size() - j);
                
                string C = A; reverse(C.begin(), C.end());
                string D = B; reverse(D.begin(), D.end());
                
                T.insert(A + B);
                T.insert(B + A);
                T.insert(A + D);
                T.insert(D + A);
                T.insert(C + B);
                T.insert(B + C);
                T.insert(C + D);
                T.insert(D + C);
            }
            
            printf("%d\n", T.size());
        }
    }
    
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <stack>
#define DEBUG false
using namespace std;

struct P{ int w,h,x,y; bool f; };

int main(){
  int n, ans;
  int a[5][5];
  stack<P> st;
  P p;
  bool f;

  cin >> n;
  for( int loop=0;loop<n;loop++ ){
    while( !st.empty() ) st.pop();

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

    p.w=1; p.h=1; p.f=true;
    for( int i=0; i<5; i++ ){
      for( int j=0;j<5;j++ ){
	if( a[i][j]==1 ){
	  p.x=i; p.y=j;
	  st.push( p ); p.f=!p.f; st.push( p );
	}
	if( DEBUG ) cout << a[i][j] << " ";
      }
      if( DEBUG ) cout << endl;
    }
    ans=1;
    while( !st.empty() ){
      p = st.top(); st.pop();
      f = false;
      if( p.f ){ // ツ可。ツ陛サツ古シ
	if( p.x+p.w<5 ){
	  for( int i=0;i<p.h;i++ ){
	    if( a[p.x+p.w][p.y+i]==0 ) break;
	    if( i==p.h-1 ) f=true;
	  }
	  if( f ) p.w++;
	}
      }else{ // ツ縦ツ陛サツ古シ
	if( p.y+p.h<5 ){
	  for( int i=0;i<p.w;i++ ){
	    if( a[p.x+i][p.y+p.h]==0 ) break;
	    if( i==p.w-1 ) f=true;
	  }
	  if( f ) p.h++;
	}
      }
      if( f ){
	int area = p.w*p.h;
	if( area> ans ){  ans = area;	}
	st.push( p ); p.f=!p.f; st.push( p );
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 11;

long long ans = 0; 

int main() {

	File();

	string str;

	cin >> str;
	For (i, 0, str.size() - 1) {
		long long coef = 0;
		For (j, 0, str.size() - 1 - i) {
			long long p = 1; For (k, 1, j) p *= 10;
			coef += p << (max(0, (int)str.size() - 2 - i - j));
		}
		ans += (coef << i) * (str[i] ^ '0');
	}


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

	return 0;

}


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

count = 0
for i in range(N):
    if A[i] + A[i+1] > B[i]:
        count += B[i]
        if A[i] >= B[i]:
            A[i] -= B[i]
        else:
            A[i+1] -= B[i] - A[i]
            A[i] = 0
    else:
        count += A[i] + A[i+1]
        A[i]   = 0
        A[i+1] = 0

print(count)

Measured memory_bytes: 19156
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

#include<cstring>

char str[123456];

int main(void)
{
	scanf("%s", str);
	int ans = 0;
	for (int i = 1; i < strlen(str); ++i)
	{
		if (str[i - 1] != str[i])++ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A > 0 && A < 10 && B > 0 && B < 10) {
			System.out.println(A * B);
		} else {
			System.out.println("-1");
		}

		sc.close();

	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
	int u,to,w;
};
node edge[N<<1];
bool b[N];
int dep[N],a[N],c[N],f[N],bb[N],head[N];
int k,n,m;
void add(int x,int y,int z) {
	edge[k].u=y; edge[k].to=head[x]; edge[k].w=z; head[x]=k++;
}
void dfs(int now,int fa,int d)
{
	b[now]=1; dep[now]=d;
	for (int i=head[now];i!=-1;i=edge[i].to) {
		int u=edge[i].u;
		if (!b[u]) dfs(u,now,d+1);
	}
	if (f[now]==1)
	for (int i=head[now];i!=-1;i=edge[i].to) {
		int u=edge[i].u;
		if (dep[u]<dep[now]) {
			f[now]^=1; f[u]^=1; c[edge[i].w]^=1; break;
		}
	}
}
int main() {
	scanf("%d%d",&n,&m);
		memset(head,-1,sizeof(head));
		for (int i=1;i<=m;i++) {
			scanf("%d%d",&a[i],&bb[i]); add(a[i],bb[i],i); add(bb[i],a[i],i);
			f[a[i]]^=1;
			c[i]=1;
	    }
	    for (int i=1;i<=n;i++) if (!b[i]){
	    	dfs(i,0,1);
		}
		for (int i=1;i<=n;i++) if (f[i]==1) {
			printf("%d\n",-1); return 0;
		}  
	    for (int i=1;i<=m;i++) if (c[i]) printf("%d %d\n",a[i],bb[i]); else printf("%d %d\n",bb[i],a[i]);
}

Measured memory_bytes: 10880
N, M = map(int, input().split())

c = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())

    if a > M:
        continue
    c[M - a].append(b)

import heapq

h = []
heapq.heapify(h)
ans = 0

for i in range(M - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans += -1 * heapq.heappop(h)

print(ans)

Measured memory_bytes: 18428
import sys

def findLCS(X, Y):
    m, n = len(X), len(Y)
    C = [0] * (n + 1)

    for i in range(m):
        tmp = C[:]
        for j in range(n):
            if X[i] == Y[j]:
                C[j + 1] = tmp[j] + 1
            elif C[j + 1] < C[j]:
                C[j + 1] = C[j]

    return C[-1]

lines = sys.stdin.readlines()
N = int(lines[0])

for i in range(N):
    X = lines[2 * i + 1].strip()
    Y = lines[2 * i + 2].strip()
    print findLCS(X, Y)

Measured memory_bytes: 6436
import sys

table = [0]*26
 
letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()
 
for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1
 
for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


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

vector<int> g[100010];

int main()
{
    int n, m; cin>>n>>m;
    int s=0;
    while (m--) {
        int a, b; cin>>a>>b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
        s=a;
    }

    vector<bool> visited(n);
    vector<int> path;

    function<void(int)> dfs=[&](int v)
    {
        visited[v]=true;
        path.push_back(v);
        for(int u: g[v]) if (!visited[u]) {
            dfs(u);
            break;
        }
    };

    dfs(s);
    path={rbegin(path), rend(path)};
    path.pop_back();
    auto res=path;

    path.clear();
    dfs(s);
    copy(begin(path), end(path), back_inserter(res));

    cout<<res.size()<<endl;
    for(int v: res) cout<<v+1<<' ';
    cout<<endl;
}

Measured memory_bytes: 9628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int, int>
#define Point Vect
#define no {cout << "0\n"; return;}
#define mkp make_pair
#define cerr if (0) cerr

void solve() {
    int a, b, n;
    cin >> a >> b >> n;
    cout << (n >= b - 1 ? a * (b - 1) / b : a * n / b);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
void ABC150(void);
void ABC151(void);
void ABC152(void);
void ABC153(void);
void ABC154(void);
void ABC155(void);
void ABC156(void);
void ABC157(void);
void ABC158(void);
void ABC159(void);

int main(void){
    ABC151();
}

void ABC151(){
    char c;
    cin>>c;
    c=c+1;
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll N, X;
	cin >> N >> X;
	ll step = 0;
	ll ans = 1;
	vector<ll> L(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> L[i];
		step += L[i];
		if (step > X) {
			cout << ans << endl;
			return 0;
		}
		else {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int a,b,c,d,n;
long long s;
int main()
{
    scanf ("%d %d %d %d", &a, &b, &c, &d);
    scanf ("%d", &n);
    if ((a*4)<c)
        c=a*4;
    if ((b*2)<c)
        c=b*2;
    if ((c*2)<d)
        d=c*2;
    s=(0LL)+(1LL)*d*(n/2)+(1LL)*c*(n%2);
    printf ("%lld\n", s);
    return 0;
}


Measured memory_bytes: 128
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [i32; n],
    }
    let mut b: Vec<i32>  = Vec::new();
    for _ in 0..n {
        b.push (0);
    }
    let mut m = 0;
    for i in (1..n + 1).rev() {
        let mut c = a[i - 1];
        let mut j = i;
        while j <= n {
            c += b[j - 1];
            j += i;
        }
        b[i - 1] = c % 2;
        m += b[i - 1];
    }
    println! ("{}", m);
    if m == 0 {
        return;
    }
    for i in 0..n {
        if b[i] > 0 {
            print! ("{} ", i + 1);
        }
    }
    println! ("");
}

fn main() {
    run();
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int S = 0;
  for (int i = 0; i < N; i++) S ^= A.at(i);
  for (int i = 0; i < N; i++) cout << (int)(S ^ A.at(i)) << " ";
  cout << endl;
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int a;
  REP(i, N) {
    cin >> a;
    A[i] = a - i;
  }
  sort(A.begin(), A.end());
  if(A.size() & 1) {
    ll ans = 0;
    REP(i, N) {
      ans += abs(A[i] - A[N / 2]);
    }
    cout << ans << endl;
  } else {
    ll ans = 0;
    REP(i, N) {
      ans += abs(A[i] - A[N / 2]);
    }
    ll ans_cmp = 0;
    REP(i, N) {
      ans_cmp += abs(A[i] - A[N / 2 - 1]);
    }
    ans = min(ans, ans_cmp);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n;
    cout<<ceil(n*1.0/2)<<"\n";
    return 0;
}



Measured memory_bytes: 256
n=int(input())
m=2**n
for i in range(m):
    temp=[0 for i in range(n)]
    j=i
    count=0
    while j>0:
        if j%2==1:
            temp[count]=1
            #print(count,temp[count])
        j//=2
        count+=1

    temp2=[]
    for k in range(n):
        if temp[k]==1:
            temp2.append(k)
    print(i,end="")
    if i!=0:
        print(":",end=" " )
        print(*temp2)
    else:
        print(":")



Measured memory_bytes: 6248
#include <iostream>
#include <math.h>
#define MAX 500000
//#define INFINITY 200000000
using namespace std;

void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
//int n,S[MAX];
int L[MAX/2+2],R[MAX/2+2];
int cnt;

int main(){
  int i,n;
  cnt = 0;
  int A[MAX];
  cin >> n;
  //scanf("%d",&n);
  for(i = 0; i < n; i++){
    cin >> A[i];
    //scanf("%d",&A[i]);
    //mergeSort(S[i],0,i);
  }
  mergeSort(A,n,0,n);
  for(i = 0; i < n; i++){
    if(0 < i){
      cout << " ";
      //printf(" ");
    }
    cout << A[i];
    //printf("%d",A[i]);
  }
  cout << endl << cnt << endl; /**/
  //printf("\n%d\n",cnt);
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  /*L[0...n1],R[0...n2]?????????*/
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  //L[n1] = SMAX;
  //R[n2] = SMAX;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int A[], int n, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

Measured memory_bytes: 6936
#include<iostream>
using namespace std;
int main(){
  int box[21][21]={};
  while(1){
    int N,i,I,n,x,y,X=10,Y=10,a=0,l;
    char h;
    cin>>N;
    if(N==0) break;
    else{
      for(i=0;i<N;i++){    
      cin>>x>>y;
      box[x][y]=1;
      }
      cin>>n;
      for(i=0;i<n;i++){
	cin>>h>>l;
	if(h=='N'){
	  for(I=0;I<l;I++){
	    Y++;
	    box[X][Y]=0;
	  }
	}	
	if(h=='S'){
	  for(I=0;I<l;I++){
	    Y--;
	   box[X][Y]=0;
	  }
	}	
	if(h=='E'){
	  for(I=0;I<l;I++){
	    X++;
	    box[X][Y]=0;
	  }
	}	
	if(h=='W'){
	  for(I=0;I<l;I++){
	    X--;
	    box[X][Y]=0;
	  }
	}
      }
      for(i=0;i<21;i++){
	for(I=0;I<21;I++){
	  if(box[i][I]==0) a++;
	}
      }
     
      if(a==441) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
    a=0;
    X=10;
    Y=10;
    for(i=0;i<21;i++){
      for(I=0;I<21;I++){
	box[i][I]=0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1152
s_dash = input()
t = input()

s = ''

slen = len(s_dash)
tlen = len(t)

k = None

for i in range(slen-tlen+1):
    for j in range(tlen):
        if s_dash[i+j] != t[j] and s_dash[i+j] != '?':
            break
    else:
        k = i

if k == None:
    print('UNRESTORABLE')
    exit()

for i in range(k):
    if s_dash[i] == '?':
        s = s + 'a'
    else:
        s = s + s_dash[i]
for i in range(tlen):
    s = s + t[i]
for i in range(k+tlen,slen):
    if s_dash[i] == '?':
        s = s + 'a'
    else:
        s = s + s_dash[i]
print(s)

 

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

using namespace std;

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int s = 0;
	s+= min(k,a);
	k-=min(k,a);
	k-=min(k,b);
	if(k<=0) cout << s << "\n";
	else cout << s-k << "\n";
	return 0;
}


Measured memory_bytes: 3572
N, K = map(int, input().split())
S = input()
Nums = []
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
# 累積和を作る
# 0 1 2 3 4 5 6
#  0 1 2 3 4 5
sum = [0] * (len(Nums) + 1)
for i in range(len(Nums)):
    sum[i + 1] = sum[i] + Nums[i]
ans = 0
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    # 次のleft, rightを計算する [left, right)
    left = i
    right = min(i + Add, len(Nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

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

signed main() {
  string s; cin >> s;
  int K; cin >> K;
  map<string, int> map;
  
  rep(i, s.size()) rep(j, min((int)(s.size()-i), 5)) {
    map[s.substr(i, j+1)]++;
  }
  
  int k = 1;
  for(auto p : map) {
    if(k == K) {
      cout << p.first << endl;
      return 0;
    }
    k++;
  }

}

Measured memory_bytes: 1920
#include<stdio.h>
#include<stdlib.h>

#define N 100000
#define Q 50000

int binaly(int);

int s[N],n;

//???????????¢??°
int main(void){

  //??????????????°?????£?¨?
  int i,q,count=0;
  int t;

 
  scanf("%d",&n);
  if(n>N) exit(1);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  
  scanf("%d",&q);
  if(q>Q) exit(2);  
  for(i=0;i<q;i++){
    scanf("%d",&t);
    if(binaly(t)) count++;
  }

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


int binaly(int key){
  int left=0,right=n,mid;
  while(left<right){
    mid=(left+right)/2;
    if(s[mid]==key) return 1;
    else if(s[mid]<key) left=mid+1;
    else right=mid;
  }
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> v(3, 0);
    string s; cin >> s;
    for (auto &x: s) v[x-'a']++;
    sort(v.begin(), v.end());
    if (v[2] - v[0] > 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

//Make KND So Fat
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int S = sc.nextInt(), D = sc.nextInt(), M = sc.nextInt();
			int[][] buy = new int[S][M+1];
			for(int i=0;i<S;i++){
				int k = sc.nextInt();
				int[] w = new int[k], p = new int[k];
				for(int j=0;j<k;j++){
					w[j] = sc.nextInt();
					p[j] = sc.nextInt();
				}
				int[][] dp = new int[k][M+1];
				for(int u=0;u<k;u++)for(int j=0;j<=M;j++){
					if(u>0)dp[u][j] = dp[u-1][j];
					if(p[u]<=j)dp[u][j] = Math.max(dp[u][j], w[u] + (u>0?dp[u-1][j-p[u]]:0));
				}
				for(int j=0;j<=M;j++)buy[i][j] = dp[k-1][j];
			}
			int[] f = new int[D+1];
			for(int i=0;i<D;i++)f[i]=sc.nextInt();
			int[][] dp = new int[D][M+1];
			for(int i=0;i<D;i++)for(int j=0;j<=M;j++){
				if(i>0)dp[i][j] = dp[i-1][j];
				int s = f[i];
				for(int u=0;u<=j;u++)dp[i][j] = Math.max(dp[i][j], buy[s][u] + (i>0?dp[i-1][j-u]:0));
			}
			int res = -1, m = -1;
			for(int i=0;i<=M;i++)if(res<dp[D-1][i]){
				res = dp[D-1][i];
				m = i;
			}
			System.out.println(res+" "+m);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int sum[1010];

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

    rep(i, 1002) {
        sum[i] += i;
        if (i) sum[i] += sum[i-1];
    }

    for (int i=1; i<1000; ++i) {
        int tmp = sum[i] - a;
        if (tmp+b == sum[i+1]) {
            cout << tmp << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys, itertools
input = sys.stdin.readline
H, W, K = list(map(int, input().split()))

choco = []
for i in range(H):
  s = input().strip()
  a = list(map(int, list(s)))
  choco.append(a)

def min_split(h):
  sum_cnt = [0] * H
  num_split = 0
  for j in range(W):
    c = 0
    cnt = [0] * H
    flag = False
    for i in range(H):
      if choco[i][j] == 1:
        cnt[c] += 1
        if cnt[c] > K:
          return float('inf')
        if cnt[c] + sum_cnt[c] > K:
          flag = True
      if i < H-1 and h[i] == 1:
        c += 1
    if flag:
      num_split += 1
      sum_cnt = cnt
    else:
      for i in range(len(cnt)):
      	sum_cnt[i] += cnt[i]
  return num_split + sum(h)

min_m = float('inf')
for h in itertools.product([0,1], repeat=H-1):
  m = min_split(h)
  min_m = min(min_m, m)
print(min_m)

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

int main() {
  int n;
  string ans="Yes";
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++) {
    cin >> h.at(i);
    if(i>0) {
      if(h.at(i-1)<h.at(i)) h.at(i)--;
    } else {
      h.at(i)--;
    };
  };
  for(int i=0;i<n-1&&ans=="Yes";i++) {
    if(h.at(i)>h.at(i+1)) ans="No";
  };

  cout << ans << endl;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define p push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=7+1e9;
const int inf=1e9;
const int N=1e5+5;
vector<int>g[N];
int deg[N],dis[N];
bool vis[N];
void dfs(int u)
{
    vis[u]=1;
    for(auto v:g[u])
    {
        dis[v]=max(dis[v],dis[u]+1);
        deg[v]--;
        if(deg[v]==0&&!vis[v])
        {
            dfs(v);
        }
    }
}
int main()
{
#ifdef LOCAL
    freopen("input.in", "r", stdin);
#endif
    IOS;
    int n,m;
    cin>>n>>m;
    re(i,m)
    {
        int u,v;
        cin>>u>>v;
        g[u].p(v);
        deg[v]++;
    }
    rep(i,1,n+1)
    {
        if(!vis[i]&&deg[i]==0)
            dfs(i);
    }
    int ans=0;
    rep(i,1,n+1)ans=max(ans,dis[i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 9728
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

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

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

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

  vector<ll> dp(N, 0), dp2(N, 0);
  for (ll i = 0; i < N; i++) {
    if (N % 2) dp[i] = A[i];
    else dp[i] = -A[i];
  }
  dp2 = dp;

  for (ll len = 2; len <= N; len++) {
    for (ll l = 0; l + len - 1 < N; l++) {
      ll r = l + len - 1;
      ll al = dp2[l], ar = dp2[r];
      if ((N - len) % 2) {
        dp[l] = min(-A[l] + dp2[l + 1], -A[r] + dp2[l]);
      } else {
        dp[l] = max(A[l] + dp2[l + 1], A[r] + dp2[l]);
      }
    }
    dp2 = dp;
  }
  cout << dp[0] << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define nn 508
#define mod 998244353
ll n;ll cost[nn][nn];
ll dp[nn][nn];
void upd(ll&x,ll y){
	x=min(x,y);
}
ll pre[nn][nn],pres[nn][nn];ll prec[nn][nn],precs[nn][nn];

ll cut(ll l,ll r,ll x,ll y){
	return pres[r][y]-pres[l-1][y]-pres[r][x-1]+pres[l-1][x-1];
}

ll ccut(ll l,ll r,ll x,ll y){
	return precs[r][y]-precs[l-1][y]-precs[r][x-1]+precs[l-1][x-1];
}
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) if(i!=j) scanf("%lld",&cost[i][j]); 
		for(int j=1;j<=n;j++) pre[i][j]+=pre[i][j-1]+cost[i][j];
	}	
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) pres[i][j]+=pres[i-1][j]+pre[i][j];
	
	
	
	
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) cost[i][j]*=(i<j);
		for(int j=1;j<=n;j++) prec[i][j]+=prec[i][j-1]+cost[i][j];
	}	
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) precs[i][j]+=precs[i-1][j]+prec[i][j];
	
	ll ans=1e18;
	memset(dp,0x3f,sizeof dp);dp[0][0]=0;
	for(int x=0;x<=n;x++)
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				upd(dp[x][i],dp[i][j]+cut(x+1,n,j+1,i)+ccut(i+1,x,i+1,x));
			}
			//dp[x][i]<<":"<<ans<<"\n";
			upd(ans,dp[x][i]+ccut(x+1,n,x+1,n));
		}
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 12288
//this is O(n) approach refer editorial for  more information
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll n){ return n*(n+1)/2;}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ll r = n/i;
   // cout<<r<<" "<<f(r)<<"\n";
    ans += f(r) * i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
struct DSU
{
    vector<ll> p,sz;
    void intialize(int x)
    {
        p.resize(x+5);
        sz.resize(x+5);
        for(ll i=0;i<x;i++)   p[i] = i,sz[i] = 1;
    }
    ll getp(ll k)
    {
        while(k!=p[k])
        {
            p[k]=p[p[k]];
            k=p[k];
        }
        return k;
    }
    ll getsize(ll k)
    {
        return sz[getp(k)];
    }
    void unionn(ll u,ll v)
    {
        ll p1=getp(u),p2=getp(v);
        if(p1==p2)    return;
        if(sz[p1]>sz[p2])  swap(p1,p2);
        sz[p2]+=sz[p1];
        sz[p1]=0;
        p[p1]=p[p2];
    }
};
void solve()
{
    ll n,m;
    cin >> n >> m;
    DSU dsu;
    dsu.intialize(n+5);
    for(ll i=0,x,y;i<m;i++)
    {
        cin >> x >> y;
        dsu.unionn(x,y);
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++)
    {
        ll tmep = dsu.getsize(i);
        ans = max(ans,tmep);
    }
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
 // cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 6356
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<time.h>
#include<cmath>
#include<queue>
using namespace std;
#define INF 1000000
int s1[10]={0,1,2,3,4,5,6,7,8,9};
int L,ans=0,s;

void Permutation(int s2[],int t,int num){
	if(num==L){
		if(t==s)ans++;
	}else{
		if(t>s)return;
		for(int i=0;i<10-num;i++){
			int a=s2[i];
			s2[i]=s2[10-num-1];
			Permutation(s2,t+(num+1)*a,num+1);
			s2[10-num-1]=s2[i];
			s2[i]=a;
		}
	}
}
int main(){
	while(cin>>L>>s){
		ans=0;
		Permutation(s1,0,0);
		cout<<ans<<endl;
	}

	return 0;
}	

Measured memory_bytes: 1160
n,m = map(int,input().split())

ans = 0
rd = 10**9 + 7
if(abs(n-m) > 1):
    ans = 0
    print(ans)
elif(abs(n-m) == 1):
    tmp = min(n,m)
    tmp_mx = max(n,m)
    sm = 1
    for i in range(tmp):
        sm = (sm * (i+1))%rd
    
    ans = (sm * sm * tmp_mx)%rd
    print(ans)
else:
    sm = 1
    for i in range(n):
        sm = (sm * (i+1))%rd
    
    ans = (2*sm * sm)%rd
    print(ans)



Measured memory_bytes: 9072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] v = new int[n];
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                v[a]++;
                v[b]++;
            }
            for (int i = 0; i < n; i++) {
                out.println(v[i]);
            }
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 20948
#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 lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	lli a,b;
	cin>>a>>b;
	cout<<a*b;
}



Measured memory_bytes: 3632
def add(B,a,n):
    x = a
    while x<=n:
        B[x]+=1
        x+=x&(-x)
        
def sums(B,a):
    x=a
    S=0
    while x!=0:
        S+=B[x]
        x-=x&(-x)
    return S
  
def invnumber(n,A):
  S=[0]*n
  A=sorted([(A[i],i) for i in range(n)])
  for i in range(1,n):
     S[A[i][1]]=i
  B=[0]*(n*2+1)
  invs=0
  for i in range(n):
      s=S[i]+n
      invs+=sums(B,s)
      add(B,s,n*2)
  return invs
N,K=map(int,input().split())     
A=[int(input())-K for i in range(N)]
T=[0]
for i in range(N):
  T.append(T[-1]+A[i])

print(invnumber(N+1,T))
  
  

Measured memory_bytes: 83028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl

int main() {
    ll K,A,B;
    string ans = "NG";
    cin >> K >> A >> B;
    for(int i = A; i <= B; i++){
        if(i % K == 0)ans = "OK";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

int map[200];
int main(){
	string s;
	cin >> s;

	rep(i, s.size()) map[s[i]]++;

	int ans = 1000;
	rep(i, 4) ans = min(ans, map["KUPC"[i]]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<lcm(a,b);
}


Measured memory_bytes: 256
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<9, mod = 119<<23|1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define lcm(x, y) (((x)/__gcd(x, y))*(y))

bool prime(int a) {
	for(int d = 2; d*d <= a; d++) if(a%d == 0) return 0;
	return 1;
}

int n;
ll mat[maxn][maxn];
void check() {
	ll m = max(mat[0][0], mat[0][1]) % min(mat[0][0], mat[0][1]);
	for(int i = 0; i + 1 < n; i++)
		for(int j = 0; j < n; j++)
			if(max(mat[i][j], mat[i + 1][j]) % min(mat[i][j], mat[i + 1][j]) != m) cerr << i << " " << j << " " << "d\n";
	for(int j = 0; j + 1 < n; j++)
		for(int i = 0; i < n; i++)
			if(max(mat[i][j], mat[i][j + 1]) % min(mat[i][j], mat[i][j + 1]) != m) cerr << i << " " << j << " " << "f\n";
	ll mcnt = 0;
	map<ll, ll> cnt;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			mcnt = max(mcnt, ++cnt[mat[i][j]]);
	if(mcnt > 1)cerr << "BAD\n";
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
ll on = n; n = 502;
	vi a, b;
	for(int i = 2; b.size() < n; i++) {
		if(!prime(i)) continue;
		if(a.size() < n/2) {
			if(a.size()) {
				a.pb(a.back()*i);
			}
			a.pb(i);
		} else {
			if(b.size()) {
				b.pb(b.back()*i);
			}
			b.pb(i);
		}
	}
	set<ll> pf;
	for(int i = 0; i < n; i++) {
		for(int j = (i&1)^1; j < n; j+=2) {
			mat[i][j] = a[i/2] * b[j/2];
			while(pf.count(mat[i][j])) mat[i][j] *= 2;
			pf.insert(mat[i][j]);
		}
	}
	for(int i = 0; i < n; i++)
		for(int j = (i&1); j < n; j+=2) {
			ll g = 1;
			if(i) g = lcm(g, mat[i-1][j]);
			if(i+1 < n) g = lcm(g, mat[i+1][j]);
			if(j) g = lcm(g, mat[i][j-1]);
			if(j+1 < n) g = lcm(g, mat[i][j+1]);
			mat[i][j] = g + 1;
		}
	set<ll> found = pf;
	for(int i = 0; i < n; i++)
		for(int j = (i&1); j < n; j+=2) {
			ll g = mat[i][j]-1;
			while(found.count(mat[i][j])) mat[i][j] += g;
			found.insert(mat[i][j]);
		}
	n=on;
	ll mx = 0;
	for(int i = 0; i < n; i++, cout << '\n')
		for(int j = 0; j < n; j++) {
			cout << mat[i][j] << " ";
		}
	check();
	//if(mx > 1e15) exit(-1);
}
//


Measured memory_bytes: 38400
import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
b = [0] * n
for i in range(n,0,-1):
  c = 0
  for j in range(i,(n//i+1)*i,i):
    c += b[j-1]
  if c % 2 == a[i-1]:
    continue
  else:
    b[i-1] = 1
d = []
for i in range(n):
  if b[i] == 1:
    d.append(i+1)
print(len(d))
print(' '.join(map(str,d)))

Measured memory_bytes: 19868
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pii make_pair
#define pb push_back
#define ff first
#define ss second
int ceil(int a, int b) { if(a%b==0) return a/b; else return a/b+1; }
bool checkbit(int pos, int mask) { return mask&(1<<pos); }
int turnon(int pos, int mask) { return mask|(1<<pos); }

main()
{
    fastio;
    int n, a, b, cnt=0, fl=0;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>a>>b;
        if(a==b) cnt++;
        else cnt=0;
        if(cnt==3) {
            fl=1;
        }
    }
    if(fl) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3568
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int count = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;

		if ((i + 1) % 2 == 1) {
			//マス番号が奇数
			if (a % 2 == 1) {
				//マスに書かれた整数が奇数
				count++;
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

int main()
{
	int D[MX];
	for(int i = 0; i < 7; i++) scanf("%d", D+i);
	ll ans = 0;
	ans = D[1];
	ans += D[0]/2 * 2;
	ans += D[3]/2 * 2;
	ans += D[4]/2 * 2;
	if( D[0]%2 && D[3]%2 && D[4]%2 ) ans += 3;
	else if( D[0] && D[3]%2 && D[4]%2 ) ans ++;
	else if( D[0]%2 && D[3] && D[4]%2 ) ans ++;
	else if( D[0]%2 && D[3]%2 && D[4] ) ans ++;
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <iomanip>
#include <cmath>
const double pi = acos(-1);

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r;
    cin, r;
    cout << fixed << setprecision(15) << 2 * r * pi << endl;
    return 0;
}


Measured memory_bytes: 3804
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
ans_t=0
ans_h=0
n.times do
  t,h=get
  if t>h
    ans_t+=3
  elsif t<h
    ans_h+=3
  else
    ans_t+=1
    ans_h+=1
  end
end
puts [ans_t,ans_h].join(" ")


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n;
  cin >> n;
  vector<long long> even, odd;
  for(int i = 0; i < n; i++){
    long long a;
    cin >> a;
    if(i%2 == 0) even.push_back(a);
    else odd.push_back(a);
  }
  if(n%2 == 0){
    for(int i = odd.size()-1; i >= 0; i--) cout << odd[i] << " ";
    for(int i = 0; i < even.size(); i++) cout << even[i] << " ";
  }
  else{
    for(int i = even.size()-1; i >= 0; i--) cout << even[i] << " ";
    for(int i = 0; i < odd.size(); i++) cout << odd[i] << " ";
  }
  cout << endl;
  return 0;
}

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

int N, K, p, rev;
char S[1000010];

void sim() {
	if(S[p] == 'A') {
		if(rev) {
			rev = false;
			S[p + N] = 'A';
			p++;
		}
		else {
			S[p] = 'B';
		}
	}
	else {
		if(rev) {
			S[p] = 'A';
		}
		else {
			rev = true;
			S[p + N] = 'B';
			p++;
		}
	}
}

void out() {
	for(int i = p; i < p + N; i++) {
		char c = S[i];
		if(rev) c = (c == 'A') ? 'B' : 'A';
		cout << c;
	}
	cout << endl;
}

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

	cin >> N >> K >> S;

	int rem = K;
	for(int i = 0; i < min(2 * N, K); i++) {
		sim();
		rem--;
	}
	if(rem && rem % 2) sim();

	out();
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int Kannondou(int n){
	int dp[4] = {1,2,4,0};

	if(n<=3)
		return 1;

	for(int i = 3; i < n; ++i){
		dp[ 3 ] = dp[ 2 ] + dp[ 1 ] + dp[ 0 ];
		dp[ 0 ] = dp[ 1 ];
		dp[ 1 ] = dp[ 2 ];
		dp[ 2 ] = dp[ 3 ];
	}
	return ( dp[ 3 ] - 1 ) / 3650 + 1;
}
int main(){
	while(true){
		int n;

		cin>>n;
		if(n == 0)
			break;

		cout << Kannondou( n ) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b < c + d) {
        cout << "Right" << endl;
    }
    else if (a + b == c + d) {
        cout << "Balanced" << endl;
    }
    else cout << "Left" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int page[100];

int main() {
  int n;
  while (scanf("%d", &n), n) {
    MEMSET(page, -1);
    REP(i, n) {
      scanf("%d", &page[i + 1]);
    }
    bool first = true;
    REP(i, n) {
      if (page[i + 1] == page[i] + 1 && page[i + 1] == page[i + 2] - 1) {;}
      else if (page[i + 1] == page[i] + 1) {
        printf("-%d", page[i + 1]);
      } else if (page[i + 1] == page[i + 2] - 1) {
        if (!first) { putchar(' '); }
        first = false;
        printf("%d", page[i + 1]);
      } else {
        if (!first) { putchar(' '); }
        first = false;
        printf("%d", page[i + 1]);
      }
    }
    puts("");
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
  int n,t;
  cin>>n>>t;
  int sum=0,tim,tmp;
  cin>>tmp;
  rep(i,n-1)
  {
    int a;
    cin>>a;
    sum+=min(a-tmp,t);
    tmp=a;
  }
  cout<<sum+t<<endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        r = 0
        if n == 0 or n == 2:
            r = 1
        elif n == 1:
            r = 2

        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9024
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll 				long long int
#define ld 				long double
#define mk 				make_pair
#define pb 				push_back
#define f				first
#define s				second
#define fo(i,a,b) 		for(i=a;i<b;i++)
#define foe(i,a,b) 		for(i=a;i<=b;i++)
#define all(x)			x.begin(),x.end()
// #define vi 				vector<int>
#define vl 				vector <long long int>
// #define pii 			pair <int,int>
#define pll 			pair <long long int, long long int>
// #define vpii			vector< pair<int,int> >
#define vpll 			vector < pair <long long int,long long int> >
#define MOD				1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
	boost;
	ll a, b;
	cin >> a >> b;
	cout << a*b;



	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
#define INF 1000000007
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    cout << a[0] << b[1] << c[2] << 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;
using ll = long long;

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll price;
  ll minp = 100000000000000;
  for(int i = 0; i <= max(2*x,2*y); i+=2){
    price = c * i + max(0,x - i / 2) * a +max(0,y - i / 2) * b;
    minp = min(price, minp);
    price = 0;
  }
  cout << minp << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	long long  a[5];//march
	cin>>n;
	for(int i=0;i<5;i++)
	a[i]=0;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='M') a[0]++;
		else if(s[0]=='A') a[1]++;
		else if(s[0]=='R') a[2]++;
		else if(s[0]=='C') a[3]++;
		else if(s[0]=='H') a[4]++;
	}
	long long num=0;
	for(int i=0;i<5;i++){
		if(a[i]==0)continue;
		for(int j=i+1;j<5;j++)
		{
			if(a[j]==0) continue;
			for(int z=j+1;z<5;z++)
			{
				if(a[z]==0) continue;
				num+=a[i]*a[j]*a[z];
			}
		}
			
	}
	printf("%lld",num);	
	return 0;
}

Measured memory_bytes: 256