akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[200003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flag[1003]={};

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
  int min=1000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=111110;
  int max=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
  scanf("%d", &a);

  for(i=0;i<a;i++){
    scanf("%d", &B[i]);
  }

  for(i=0;i<a;i++){
    num1=0;
    num2=0;
    min=0;
    
    for(j=0;j<i;j++){
       num1=num1+B[j];
    }
    for(j=i;j<a;j++){
       num2=num2+B[j];
    }
    min=abs(num1-num2);
//    printf("%d\n",min);
    if(ans>min)ans=min;
  }
  
  printf("%d\n",ans);

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 512
n=int(input())
if n==3:
    ans=[2,5,63]
elif n==4:
    ans=[2,5,20,63]
elif n==5:
    ans=[2,3,4,6,9]
else:
    ans=[]
    cnt,s=0,0
    for i in range(2,30001):
        if i%2==0 or i%3==0:
            ans.append(i)
            cnt+=1
            s+=i
        if cnt==n:
            break
    if s%6==2:
        ans.remove(8)
        ans.append((i//6)*6+6)
    elif s%6==3:
        ans.remove(9)
        ans.append((i//6)*6+6)
    elif s%6==5:
        ans.remove(9)
        ans.append(((i+2)//6)*6+4)
print(*ans)

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

int int_cmp(const int *a, const int *b)
{
    if (*a > *b)
        return (-1);
    else if (*a < *b)
        return (1);
    return (0);
}

int main(void){
    int i;
	int x[10];
	for(i=0;i<10;i++){
		scanf("%d",&x[i]);
	}
	qsort(x,10,sizeof(int),  (int(*)(const void*, const void*))int_cmp);

	printf("%d\n%d\n%d\n",x[0],x[1],x[2]);

}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e3+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        sum+=i;
    }
    cout<<sum<<'\n';




}


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

int n,m,dp[5][10010];

int dfs(int now,int sy)
{
	if(now>3) return !sy;
	if(dp[now][sy]!=-1) return dp[now][sy];
	int i,res=0;
	for(i=0;i<=min(n,sy);i++)
	{
		res+=dfs(now+1,sy-i);
	}
	return dp[now][sy]=res;
}

int main()
{
	int a,b;
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	cout<<dfs(1,m);
}

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int main()
{

    _fastIO;

    int x,y;
    cin>>x>>y;
    string a,b;
    for(int i=0; i<x; i++)a.push_back(y+'0');
    for(int i=0; i<y; i++)b.push_back(x+'0');
    if(a<b)cout<<a<<endl;
    else cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int a[N]={0};
int main()
{
    IOS();
   
    int i,j;
    string s;
    cin>>s;
    f(i,0,s.size())
    {
      if(i&1 && s[i]=='R')
      {
        cout<<"No";
        return 0;
      }
      else if(i%2==0 && s[i]=='L')
      {
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
    return 0;
   return 0;




  
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
#define mod 1000000007
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
/****************************/
ll n,m,k;
int main()
{
	cin>>n>>m>>k;
	ll time=abs(n)/k;
	ll ans1=abs(n)%k;
	ll ans2=ans1-k;
	ll ans;
	if(m<=time)
	{
		ans=abs(n)-m*k;
		cout<<ans;
		return 0;
	}
	if((m-time)%2==0)
	{
		ans=abs(ans1);
	}
	else
	{
		ans=abs(ans2);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3612
N,Q=map(int,input().split())
S=input()
l=[]
r=[]
lst1=[0 for i in range(N)]
for i in range(N-1):
    i+=1
    if S[i-1:i+1]=="AC":
        lst1[i]=lst1[i-1]+1
    else:
        lst1[i]=lst1[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    l=l-1
    r-=1
    print(lst1[r]-lst1[l])


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

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i=0; i<k; i++){
		int a, b, ans;
		scanf("%d %d", &a, &b);
		if(a > n / 2) a = n - a + 1;
		if(b > n / 2) b = n - b + 1;
		if(a < b){
			ans = a % 3;
		}else{
			ans = b % 3;
		}
		if(ans == 0) ans = 3;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll n;
  cin >> n;
  
  int x = n%10+(n/10)%10+(n/100)%10+(n/1000)%10+(n/10000)%10+(n/100000)%10
    +(n/1000000)%10+(n/10000000)%10+(n/100000000)%10;
  
  cout << (n%x==0?"Yes":"No") << endl;
  
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let T: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = (0..3).filter(|&i| S[i] == T[i]).count();

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


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359

int main() {
    // input
    ll N;
    cin >> N;
    ll A[N - 1];
    for (ll i = 0; i < N - 1; i++) {
        cin >> A[i];
    }

    // process
    ll ans[N];
    memset(ans, 0, sizeof(ans));

    for (ll i = 0; i < N - 1; ++i) {
        ans[A[i] - 1]++;
    }

    for (ll j = 0; j < N; ++j) {
        cout << ans[j] << endl;
    }

    return 0;
}

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

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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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


	if (a > b) {
		swap(a, b);
	}

	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 12:26-

            int n = sc.nextInt();
            int[] as = new int[n + 1];
            int[] vs = new int[n + 1];
            for (int i = 1; i < as.length; i++) as[i] = sc.nextInt();

            for (int i = n; i > 0; i--) {
                int sum = 0;
//                for (int j = 1; j * i < as.length; j+=2) {
                for (int j = 1; j * i < as.length; j++) {
                    sum += vs[j * i];
                }
//                if (2 * i < vs.length) sum += vs[2 * i];
                vs[i] = (sum % 2) ^ as[i];
            }

            List<Integer> balls = new ArrayList<>();
            for (int i = 1; i < vs.length; i++) {
                if (vs[i] > 0) balls.add(i);
            }

            out.println(balls.size());
            for (Integer ball : balls) {
                out.println(ball);
            }
        }
    }
}


Measured memory_bytes: 83644
package main

import (
	"fmt"
	"math"
)

func reverse(s string) string {
	if len(s) <= 1 {
		return s
	}
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var (
		NS string
	)

	fmt.Scanf("%s\n", &NS)
	NS = "0" + NS
	var dp [1000005][2]int
	n := len(NS)
	for i := 0; i <= n; i++ {
		for j := 0; j < 2; j++ {
			dp[i][j] = 1<<31 - 1
		}
	}
	dp[0][0] = 0
	for i := 0; i < n; i++ {
		for j := 0; j < 2; j++ {
			nd := int(NS[n-i-1] - '0')
			for d := 0; d < 10; d++ {
				ni, nj := i+1, 0
				a := d - nd - j
				if a < 0 {
					nj = 1
					a += 10
				}
				dp[ni][nj] = int(math.Min(float64(dp[ni][nj]), float64(dp[i][j]+a+d)))
			}
		}
	}
	fmt.Println(dp[n][0])
}


Measured memory_bytes: 21632
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.reverse()
c = a + b
d = [0]
for i in range(n + m):
    d.append(d[-1] + c[i])
start = 0
end = n
ans = 0
while end <= n + m:
    if start >= n + 1:
        break
    while d[end] - d[start] > k:
        start += 1
    else:
        ans = max(ans, end - start)
        end += 1
print(ans)

Measured memory_bytes: 52236
from collections import defaultdict
N, M = map(int, input().split())
X = list(map(int, input().split()))
R = [0]*M
R_paired = [0]*M
d = defaultdict(int)
for x in X:
    d[x]+=1
for k, v in d.items():
    if v%2 == 1:
        R[k%M]+=1
        R_paired[k%M]+=v//2
    else:
        R_paired[k%M]+=v//2
ans = R[0]//2
for i in range(1, (M-1)//2+1):
    if R[i]>R[M-i]:
        if R_paired[M-i]:
            r = min(R_paired[M-i], (R[i]-R[M-i])//2)
            R_paired[M-i]-=r
            R[M-i]+=2*r
    else:
        if R_paired[i]:
            r = min(R_paired[i], (R[M-i]-R[i])//2)
            R_paired[i]-=r
            R[i]+=2*r
    ans+=min(R[i], R[M-i])
if M%2 == 0:
    ans+=R[M//2]//2
ans+=sum(R_paired)
print(ans)



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
  	if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  	else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define rep(i,a,n) for (int i=a; i<=n; ++i)
# define per(i,a,n) for (int i=a; i>=n; --i)
# define bug puts("H");
# define pb push_back
# define mp make_pair
# define all(x) (x).begin(), (x).end()
# define SZ(x) (int)x.size()
# define fi first
# define se second
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mem(a,b) memset(a,b,sizeof(a))
# define INF 1000000001
# define MOD 998244353
typedef vector<int> Vi;
typedef long long i64;
typedef pair<int, int> Pi;
mt19937 mrand(random_device{}());
int rnd(int x) {return mrand()%x;}
i64 powmod(i64 a, i64 b){i64 res=1;a%=MOD;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
i64 Inv(i64 b){return powmod(b,(i64)MOD-2);}
const int N = 200005;
const double eps = 1e-9;
const long long inf = 1e18;

int a[N];
int A[N], n;
struct Seg{
    int tag, sum, mod;
}seg[N<<3];

void push_up(int p){seg[p].sum=(seg[p<<1].sum+seg[p<<1|1].sum)%MOD;}
void push_down(int p){
    if (!seg[p].tag) return ;
    seg[p].sum=(1ll*seg[p].tag*seg[p].mod)%MOD;
    seg[p<<1].tag = seg[p].tag; seg[p<<1|1].tag = seg[p].tag; seg[p].tag = 0;
}
void update(int p, int l, int r, int L, int R, int val){
    push_down(p);
    if (L>r||R<l) return ;
    if (L<=l&&R>=r) seg[p].tag=val, push_down(p);
    else {
        int mid=(l+r)>>1;
        update(lch,L,R,val); update(rch,L,R,val); push_up(p);
    }
}
void init(int p, int l, int r){
    push_down(p);
    if (l == r) {
        seg[p].sum = seg[p].mod = A[n+1-l];
        return ;
    }
    int mid=(l+r)>>1;
    init(lch); init(rch); push_up(p); seg[p].mod = (seg[p<<1].mod + seg[p<<1|1].mod) % MOD;
}
int main()
{
    int q, l, r, d;
    scanf("%d%d", &n, &q);
    A[1] = 1; rep(i,2,n) A[i] = 1ll*A[i-1]*10%MOD;
    init(1,1,n);
    while (q--) {
        scanf("%d%d%d", &l, &r, &d);
        update(1,1,n,l,r,d);
        printf("%d\n", seg[1].sum);
    }
    return 0;
}


Measured memory_bytes: 16872
#include<stdio.h>
#include<stdlib.h>
void swap(int *,int *);

int main(void){
  int A[100];
  int i,j,N,x,min;
  int a,b;
  
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  x = 0;
  for(i=0; i<N; i++){
    min = i;
    for(j=i; j<N; j++){
      if(A[j] < A[min]){
	min = j;
      }
    }
    a = A[i];
    b = A[min];
    if(b < a){
      x++;
    }
    swap(&a,&b);
    A[i] = a;
    A[min] = b;
  }
  for(i=0; i<N; i++){
    if(i != 0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",x);
  return 0;
}

void swap(int *x,int *y){
  int temp;
  temp=*x;
  *x=*y;
  *y=temp;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  int m;
  cin >> m;
  vint b(m);
  rep(i, m) cin >> b[i];
  vint res;
  set_intersection(all(a), all(b), inserter(res, res.end()));
  for(int x : res) cout << x << endl;

  return 0;
}



Measured memory_bytes: 6472
import Data.Bits

calc' [] n = return n
calc' (x:xs) n = calc' xs $ if x then 2 * n + 1 else 2 * n

calc n = do
  let bits = reverse $ take 100 $ map f $ map (2 ^) [1..]
  return bits
  where f i = if i == 2 then (n `mod` 4 == 1 || n`mod` 4 == 2) else if n `mod` i*2 < i then False else even (n `mod` i)

main = do
  (a:b:_) <- map read . words <$> getLine :: IO [Integer]
  if a == 0 then print b else do
    b <- calc b
    a <- calc (a - 1)
    print =<< calc' (zipWith xor a b) 0


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
const int N=105,mo=1e9+7;
inline int poww(int x,int y){
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)ans=1ll*ans*x%mo;
	return ans;
}
inline int SS(int x){return poww(2,x+1)-1;}
inline int S(int l,int r){return (SS(r)+mo-SS(l))%mo;}
int n,h[N],hh[N],h2[N],i,j,k,f[N][N],nn,ans;
inline void work(int i,int z,int x){
	for(;i<=h2[z];++i)
		f[z][i]=(f[z][i]+1ll*x*(hh[i]>1?S(h[z]-hh[i]-1,h[z]-max(1,hh[i-1])-1):0))%mo;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",h+i),hh[i]=h[i];
	sort(hh+1,hh+n+1);nn=unique(hh+1,hh+n+1)-hh-1;
	for(i=1;i<=n;++i)h2[i]=lower_bound(hh+1,hh+nn+1,h[i])-hh;
	f[1][0]=2;work(1,1,2);
	for(i=1;i<n;++i){
		for(j=1;j<=h2[i] && j<=h2[i+1];++j)f[i+1][j]=1ll*(h2[i]<h2[i+1]?poww(2,h[i+1]-h[i]):1)*f[i][j]%mo;
		work(h2[i]+1,i+1,(h2[i]==1?2ll:2ll)*f[i][0]%mo);
		for(j=0;j<=h2[i];++j)if(!j || j>h2[i+1])f[i+1][0]=(f[i+1][0]+2ll*f[i][j])%mo;
	}
	for(i=0;i<=h2[n];++i)ans=(ans+f[n][i])%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if a==b:
    if c!=a:print("Yes")
    else:print("No")
elif a==c:
    if b!=a:print("Yes")
    else:print("No")
elif b==c:
    if a!=b:print("Yes")
    else:print("No")
else:
    print("No")

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

const int MAX_N = 200005;
const int R = 256 * 1024;

vector<int> P[MAX_N];
int n, q, B[MAX_N], T[2 * R];

int get_min(int x, int y) {
    x += R;
    y += R;
    int w = min(T[x], T[y]);
    while(x / 2 != y / 2) {
        if(x % 2 == 0) w = min(w, T[x + 1]);
        if(y % 2 == 1) w = min(w, T[y - 1]);
        x /= 2;
        y /= 2;
    }
    return w;
}

void update(int x, int w) {
//     cout << "Update " << x << " " << w << endl;
    x += R;
    T[x] = w;
    while(x > 1) {
        x /= 2;
        T[x] = min(T[2 * x], T[2 * x + 1]);
    }
}

int main() {
    for(int i = 1; i < 2 * R; i++) T[i] = MAX_N;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> B[i];
    cin >> q;
    for(int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        P[l].push_back(r);
    }
    int result = 0;
    for(int i = 1; i <= n; i++) if(B[i] == 0) result++;
    update(0, 0);
    for(int i = 1; i <= n; i++) {
        for(int r : P[i]) update(r, get_min(i - 1, r));
        update(i, min(T[i + R], T[i - 1 + R] + (B[i] == 1 ? 1 : -1)));
    }
    cout << result + T[n + R];
    
    return 0;
}

Measured memory_bytes: 11776
#include<cstdio>
using namespace std;
const int N=2020,M=200200;
int i,j,k,n,m,q,ch,ff,ans;
int a[N][N],z[N][N],s[N][N],u[N][N],d[N][N],l[N][N],r[N][N];
char str[N][N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void dfs(int x,int y) {
	z[x][y]=1;
	if (x<n && a[x+1][y] && !z[x+1][y]) {
		u[x+1][y]=1;
		dfs(x+1,y);
	}
	if (x>1 && a[x-1][y] && !z[x-1][y]) {
		d[x-1][y]=1;
		dfs(x-1,y);
	}
	if (y<m && a[x][y+1] && !z[x][y+1]) {
		l[x][y+1]=1;
		dfs(x,y+1);
	}
	if (y>1 && a[x][y-1] && !z[x][y-1]) {
		r[x][y-1]=1;
		dfs(x,y-1);
	}
}
int main() {
	R(n);R(m);R(q);
	for (i=1;i<=n;i++) scanf("%s",str[i]+1);
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) if (str[i][j]=='1') a[i][j]=1;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) if (a[i][j] && !z[i][j]) {
			s[i][j]=1;
			dfs(i,j);
		}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) {
			s[i][j]+=s[i][j-1]+s[i-1][j]-s[i-1][j-1];
			l[i][j]+=l[i-1][j];
			r[i][j]+=r[i-1][j];
			u[i][j]+=u[i][j-1];
			d[i][j]+=d[i][j-1];
		}
	for (i=1;i<=q;i++) {
		int x1,y1,x2,y2;
		R(x1);R(y1);R(x2);R(y2);
		ans=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
		ans+=l[x2][y1]-l[x1-1][y1];
		ans+=r[x2][y2]-r[x1-1][y2];
		ans+=u[x1][y2]-u[x1][y1-1];
		ans+=d[x2][y2]-d[x2][y1-1];
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 117632
#include<cstdio>
int main()
{
    int a=0,b=0,n,s;
    int f[8]={0,0,0,0,0,0,0,0};
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&s);
        for(int i=1;i<=8;i++)
        {
            if(s<i*400&&s>=(i-1)*400&&f[i-1]==0) a++,f[i-1]++;
        }
        if(s>=3200) b++;
    }
    if(a==0) a++,b--;
    printf("%d %d\n",a,a+b);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int x;
    cin>>x;

    for (ll a=-200; a<200; ++a)
    {
        for (ll b=-200; b<200; ++b)
        {
            if ((a*a*a*a*a)-(b*b*b*b*b)==x)
            {
                cout<<a<<" "<<b;
                return 0;
            }
        }

    }




}


Measured memory_bytes: 3616
#include <iostream>
//#include <conio.h>
#include <vector>
using namespace std;

vector<int> graph[200005];

int main()
{
	int n, m;
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (int i = 0; i < graph[1].size(); i++)
	{
		for (int j = 0; j < graph[graph[1][i]].size(); j++)
		{
			if (graph[graph[1][i]][j] == n)
			{
				cout << "POSSIBLE";
				//_getch();
				return 0;
			}
		}
	}

	cout << "IMPOSSIBLE";
	//_getch();
	return 0;
}

Measured memory_bytes: 12016
#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;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  string s; cin >> s;
  int n = s.length();
  int k; cin >> k;
  set <string> p;
  for(int i = 0; i < n; i++) {
    for(int j = 1; j <= k and i + j <= n; j++) {
      p.insert(s.substr(i, j));
    }
  }
  vector <string> have;
  for(auto x : p) have.push_back(x);
  cout << have[k - 1] << '\n';
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
using namespace std;

int R, C, K;
int f[3010][3010][4];
int g[3010][3010];

int dfs(int r, int c, int k) {
    if (r < 1 or r > R or c < 1 or c > C or k < 0) return 0;
    int& res = f[r][c][k];
    if (~res) return res;
    res = 0;
    int grc = g[r][c];

    res = max(dfs(r + 1, c, 3), dfs(r, c + 1, k));
    if (grc) {
        if (k >= 1) {
            res = max(res, max(dfs(r + 1, c, 3), dfs(r, c + 1, k - 1)) + grc);
        }
    }
    return res;
}

signed main() {
    fastio;
    cin >> R >> C >> K;
    memset(f, -1, sizeof f);
    memset(g, 0, sizeof g);
    rep(k, K) {
        int r, c;
        cin >> r >> c;
        cin >> g[r][c];
    }

    int res = dfs(1, 1, 3);
    cout << res << endl;
}

Measured memory_bytes: 357568
using System;
class p
{
  static void Main()
  {
    string S = Console.ReadLine();
    int count = 0;
    do {
      S = S.Remove(S.Length - 1, 1);
      if (S.Length % 2 == 0) {
        string s1 = S.Substring(0, S.Length / 2);
        string s2 = S.Substring(S.Length / 2, S.Length / 2);
        if (s1 == s2) {
          count = S.Length;
        }
      }
    } while (count == 0);
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <vector>

int H;

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void maxHeap(int k[], int i){
  int l = 2*i, r = 2*i+1;
  int large;
  if(l <= H && k[l] > k[i]) large = l;
  else large = i;
  if(r <= H && k[r] > k[large]) large = r;

  if(large != i){
    swap(&k[i], &k[large]);
    maxHeap(&k[0], large);
  }
}

void buildMaxHeap(int k[]){
  for(int i=H/2; i>1 ;--i)
    maxHeap(&k[0], i);
}

using namespace std;

int main(){

  int kin;
  vector <int> k;
  scanf("%d", &H);
  k.push_back(-1);
  for(int i=1;i<=H;++i){
    scanf("%d", &kin);
    k.push_back(kin);
  }
  buildMaxHeap(&k[0]);
  maxHeap(&k[0], 1);
  for(int i=1;i<=H;++i)
    printf(" %d", k[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 4452
def addCell(j, str)
  j % 2 == 0 ? str + "." : str + "#"
end

loop do
  h, w = gets.split.map!(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    pattern = ""
    w.times do |j|
      pattern = addCell(i % 2 == 1 ? j : j + 1, pattern)
    end
    puts pattern
  end
  puts ""
end

Measured memory_bytes: 9328
#include <cstdio>
#define Maxn 100
int a[Maxn+5];
int main(){
	int n;
	scanf("%d",&n);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		ans+=1.0/a[i];
	}
	ans=1.0/ans;
	printf("%.7lf\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;}
template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main() {
    int n;cin >> n;
    int a,b;cin >> a >> b;
    for(;a<=b;a++){
	if(a%n==0){
	    cout << "OK" << endl;
	    return 0;
	}
    }
    cout << "NG" << endl;
    return 0;
}


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> v(h+2,vector<char>(w+2,'#'));
  r(i,h){
    r(j,w)cin >> v.at(i+1).at(j+1);
  }
  r(i,h+2){
    r(j,w+2)cout << v.at(i).at(j);
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
 
int dp[200001][3];

signed main(){
	int n;
	cin>>n;
	int a[n][3];
	r(i,n)r(j,3)cin>>a[i][j];
	r(i,n){
		r(j,3){
			r(k,3){
				if(j==k)continue;
				dp[i+1][j]=max(dp[i+1][j],dp[i][k]+a[i][j]);
			}
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int d[30][30];
int main() {
  int n,c;
  cin >> n >> c;
  rep(i,c)rep(j,c) cin >> d[i][j];
  vector<vector<ll>> v(3,vector<ll>(c));
  rep(i,n)rep(j,n){
    int k = (i+j)%3;
    int s;
    cin >> s;
    --s;
    rep(t,c) v[k][t] += d[s][t];
  }

  ll ans = 1e18L;
  rep(i,c)rep(j,c)rep(k,c){
    if(i==j||j==k||k==i) continue;
    ans = min(ans,v[0][i]+v[1][j]+v[2][k]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll a, b;
  cin >> a >> b;
  if (a>8 || b>8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
A = list(map(int,input().split()))

P = N+2
es = [[] for i in range(P)] # [[to1,cap1,rev1], ...]

def add_edge(fr,to,cap):
    es[fr].append([to,cap,len(es[to])])
    es[to].append([fr,0,len(es[fr])-1])

INF = float('inf')
score = 0
for i,a in enumerate(A):
    if a > 0:
        add_edge(0,i+1,a)
        score += a
    elif a < 0:
        add_edge(i+1,N+1,-a)
for n in range(1,N//2+1):
    for m in range(2*n,N+1,n):
        add_edge(m,n,INF)

level = [0] * P
iters = [0] * P

def dinic_max_flow(s,t):
    global iters

    def _bfs(s):
        global level
        level = [-1] * P
        level[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for to,cap,rev in es[v]:
                if cap > 0 and level[to] < 0:
                    level[to] = level[v] + 1
                    q.append(to)

    def _dfs(v,t,f):
        if v == t: return f
        for i in range(iters[v],len(es[v])):
            iters[v] += 1
            to,cap,rev = es[v][i]
            if es[v][i][1] > 0 and level[v] < level[to]:
                d = _dfs(to,t,min(f,es[v][i][1]))
                if d > 0:
                    es[v][i][1] -= d #cap
                    es[to][rev][1] += d
                    return d
        return 0

    flow = 0
    while True:
        _bfs(s)
        if level[t] < 0: return flow
        iters = [0] * P
        f = 0
        while True:
            f = _dfs(s,t,INF)
            if f <= 0: break
            flow += f

print(score - dinic_max_flow(0,N+1))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=j;i<n;i++)
int bubblesort(int A[],int N){
    int C=0;
    rep(i,0,N){
        for(int j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                int v=A[j];
                A[j]=A[j-1];
                A[j-1]=v;
                C++;
            }
        }
    }
    return C;
}
int main(){
    int n;cin>>n;
    int A[n];int ans;
    rep(i,0,n)cin>>A[i];
    ans=bubblesort(A,n);
    rep(i,0,n-1)cout<<A[i]<<" ";
    cout<<A[n-1]<<endl;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3092
#include <stdio.h>

int main() {
    int n, a, b, sum = 0;
    scanf("%d%d%d", &n, &a, &b);

    for (int i = 0, s; i <= n; i++) {
        s = 0;
        for (int j = i; j > 0; j /= 10)
            s += j % 10;
        if (s >= a && s <= b)
            sum += i;
    }

    printf("%d", sum);

    return 0;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;



int main(void){
	int n, k; cin>>n>>k;
	string S; cin>>S;

	vector<int> nums;
	if (S[0] == '0') nums.push_back(0);
	for (int i = 0; i < S.size();) {
		int j = i;
		while (j < S.size() && S[j] == S[i]) ++j;
		nums.push_back(j - i);
		i = j;
	}
	if (S.back() == '0') nums.push_back(0);

	vector<int> sums((int)nums.size() + 1, 0);
	for (int i = 0; i < nums.size(); i++) sums[i + 1] = sums[i] + nums[i];

	int res = 0;
	for (int left = 0; left < sums.size(); left += 2) {
		int right = left + k * 2 + 1;
		if (right >= sums.size()) right = (int)sums.size() - 1;
		res = max(res, sums[right] - sums[left]);
	}
	cout<< res <<endl;
	
	return 0;
}

Measured memory_bytes: 1272
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll k, fst, snd;
    cin>>k>>fst;
    cout<<((k<=fst)? "unsafe" :"safe");
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3592
let h = stdin.ReadLine() |> int64

let rec f x n =
 match x with
 | 1L -> n
 | _ -> f (x / 2L) (n + 1L)

let ind = f h 0L

let ans = int64 (2.0 ** (float (ind + 1L))) - 1L

ans
|>stdout.WriteLine

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

using int64 = long long;

const int64 mod = 1e9 + 7;

int64 pow_mod(int64 a, int64 b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        int64 c = pow_mod(a, b / 2);
        return (c * c) % mod;
    } else {
        return (a * pow_mod(a, b - 1)) % mod;
    }
}

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

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

    static int64 table[410][410];   // table[i][j] := (a_i^j + a_(i+1)^j + ... + B_i^j)
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= C; j++) {
            for (int k = A[i]; k <= B[i]; k++) {
                (table[i][j] += pow_mod(k, j)) %= mod;
            }
        }
    }

    static int64 dp[410][410];
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= C; j++) {

            for (int k = 0; k <= C; k++) {
                // if (j - k < 0 or dp[i][j - k] < 0) continue;
                if (j - k < 0) continue;
                (dp[i + 1][j] += (table[i][k] * dp[i][j - k]) % mod) %= mod;
            }
        }
    }
    cout << dp[N][C] << endl;

    return 0;
}

Measured memory_bytes: 2816
import Data.List

difs :: [Int] -> [Int]
difs []  = []
difs [x] = []
difs (x:y:xs) = (abs (x-y)) : difs (y:xs)

main :: IO ()
main = do
  [n,x] <- map read <$> words <$> getLine
  l     <- map read <$> words <$> getLine
  let nums = insert x $ sort l
  putStrLn $ show $ foldr1 gcd $ difs nums


Measured memory_bytes: 39804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const ll MOD = 1e9+7;

int main(){
    int N; cin >> N;
    vector<ll> A(N),sum(N+1);
    rep(i,N){
        int a ; scanf("%d", &a);
        A[i] = a;
    }
    ll s=0;
    for(int i=N-1;i>=0;i--){
        sum[i] = sum[i+1]+A[i];
        sum[i] %= MOD;
    }

    ll res = 0;
    rep(i,N){
        res += A[i]*sum[i+1];
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 6344
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N = int(stdin.readline().rstrip())

ans = 0

for i in range(1, N+1):
    if len(str(i)) % 2 != 0:
        ans += 1

print(ans)

Measured memory_bytes: 66028
U=[]
T=[]
N=int(input())
for i in range(N):
  U.append(input())
M=int(input())
for i in range(M):
  T.append(input())
count=0
for i in range(len(T)):
  for j in range(len(U)):
    if T[i]==U[j]:
      if count==0:
        print("Opened by",T[i])
        count=1
        break
      if count==1:
        print("Closed by",T[i])
        count=0
        break
    if j==int(len(U))-1:
      print("Unknown",T[i])


Measured memory_bytes: 5676
n, _ = map(int, input().split())
a = sorted(tuple(map(int, input().split())) for _ in range(n))
r = [(0,0)]
for s, t, c in a:
    u, i = min((u+0.5*(c!=d), i) for i, (u, d) in enumerate(r))
    if s < u:
        r.append((t, c))
    else:
        r[i] = (t, c)
print(len(r))

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

void compress(string s, vector<int> &v) {
    for (int i = 0; i < s.size(); i++) {
        int cnt = 1;
        while (i + 1 < s.size() && s[i] == s[i + 1]) {
            cnt++;
            i++;
        }
        v.push_back(cnt);
    }
}

int main() {
    string s;
    ll ans = 0;
    cin >> s;
    vector<int> v;
    if (s[0] == '>') v.push_back(0);
    compress(s, v);
    for (int i = 0; i < v.size(); i += 2) {
        ll cl, cr;
        cl = v[i];
        cr = (i == v.size() - 1 ? 0 : v[i + 1]);
        if (cl < cr)
            ans += cr * (cr + 1) / 2 + (cl - 1) * cl / 2;
        else
            ans += cl * (cl + 1) / 2 + (cr - 1) * cr / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 
int main(){
  char s[4];
 
  scanf("%s", s);
 
  if(s[0] == 'S'){
    if(s[1] == 'U') printf("7\n");
 
    else printf("1\n");
  }
 
  else if(s[0] == 'M') printf("6\n");
 
  else if(s[0] == 'T'){
    if(s[1] == 'U') printf("5\n");
 
    else printf("3\n");
  }
 
  else if(s[0] == 'W') printf("4\n");
 
  else if(s[0] == 'F') printf("2\n");
 
  return 0;
}

Measured memory_bytes: 128
len = gets.to_i
nums = gets.split(' ')
result = true

len.times do |n|
  num = nums[n].to_i
  if num.even?
    unless num % 3 == 0 || num % 5 == 0
      result = false
    end
  end
end

if result
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 1788
#include <unistd.h>
#include <algorithm>
#include <functional>

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

int n;
int S[1<<18];
int Q[19];

int main(){
  readall();
  n = read_uint();
  for(int i=0;i<(1<<n);i++) S[i] = read_uint();
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--){
      int x = Q[l];
      Q[l] = a;
      a += x;
    }
    if(a<S[i]){
      write(STDOUT_FILENO, "No\n", 3);
      return 0;
    }
    l++;
    Q[l] += a-S[i];
    for(int t=0;t<l;t++) Q[t] += S[i];
    n -= !Q[n];
  }
  write(STDOUT_FILENO, "Yes\n", 4);
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>

using namespace std;

const double PI = 3.14159265358979;

vector<int> G[100000];
int visited[100000];

void dfs_stack(int node, int color) {

	stack<int> st;

	visited[node] = color;
	st.push(node);

	while (!st.empty()) {

		int u = st.top();
		bool isPop = true;
		for (int i = 0; i < G[u].size(); i++) {
			if (!visited[G[u][i]]) {
				visited[G[u][i]] = color;
				st.push(G[u][i]);
				isPop = false;
			}
		}
		if (isPop) {
			st.pop();
		}
	}
}

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

	for (int i = 0; i < m; i++)	{
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < n; i++)	{
		if (!visited[i])
			dfs_stack(i, i + 1);
	}

	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		if (visited[a] == visited[b] && visited[a] && visited[b]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;
ll N;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
int n,m;
int ans=0;

vector<vector<int>> grid;
vector<ll> H, S;
vector<bool> seen;
vector<ll>sum;
vector<int> pl;

int main(int argc, char **argv){
	int n,d; cin>>n>>d;
	int cnt=1;
	int sum=0;

	sum=2*d+1;
	while(sum<n){
		sum+=2*d+1;
		cnt++;
	}

	cout<<cnt<<endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
char s[maxn], arr[3];

bool check()
{
	int ind = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == arr[ind])
			ind++;
	return (ind == 3);
}

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

	cin >> n >> s;
	ll ans = 0;
	for (arr[0] = '0'; arr[0] <= '9'; arr[0]++)
		for (arr[1] = '0'; arr[1] <= '9'; arr[1]++)
			for (arr[2] = '0'; arr[2] <= '9'; arr[2]++)
				ans += check();
	cout << ans << endl;
}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 110;
int dp[maxn][maxn][maxn], A[maxn];

int dfs(const int i, const int j, const int k)
{
    if (i > j || !k)
        return 0;
    int& ans = dp[i][j][k];
    if (-1 == ans) {
        ans = -inf;
        const int a = dfs(i+1,j,k-1) + A[i];
        const int b = dfs(i,j-1,k-1) + A[j];
        ans = max(ans,max(a,b));
        if (k >= 2) {
            /* throw out the one */
            const int c = dfs(i+1,j,k-2);
            const int d = dfs(i,j-1,k-2);
            ans = max(ans,max(c,d));
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n)
            cin >> A[i];
        int ans = 0;
        FOR(x,0,k+1)
            ans = max(ans, dfs(0,n-1,x));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include<cstdio>
#include<algorithm>
#define INF 2100000006
#define MAXN 100006
using namespace std;
long long m,T,minone,a[MAXN],d[MAXN];
int n,l[MAXN],last;
int find(int x)
{
	int l=1,r=x;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(T-2*(a[x]-a[mid])>0) r=mid;
		else l=mid+1;
	}
	return l;
}
int main()
{
	//freopen("computer.in","r",stdin);
	//freopen("computer.out","w",stdout);
	scanf("%d%lld%lld",&n,&m,&T);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		l[i]=find(i);
	minone=INF;
	for(int i=1;i<=n;i++)
	{
		while(last<l[i]-1)
		{
			last++;
			minone=min(minone,d[last-1]-a[last-1]-2*a[last]);
		}
		long long len=a[i]-a[l[i]];
		d[i]=d[l[i]-1]+a[l[i]]-a[l[i]-1]+len+T;
		d[i]=min(d[i],minone+3*a[i]);
	}
	printf("%lld",d[n]+m-a[n]);
}

Measured memory_bytes: 2304
#include <stdio.h>
int main()
{
	int a[10001], i;
	for (i = 1; i <= 10000; i++){
		scanf("%d", &a[i]);
	};
	for (i = 1; i <= 10000; i++){
		printf("Case %d: %d\n", i, a[i]);
	};
	return 0;
}
	
	

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

using namespace std;

const int N=5e5+5;

using ll=long long;

int u,v,k,d,c,n,m,dp[N][19],tc,a[N];

ll ans;

pair<int,int>b[N];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<m;i++)
		scanf("%d %d",&b[i].second,&b[i].first);
	sort(a,a+n);
	sort(b,b+m,greater<pair<int,int>>());
	int curr=0;
	for(int i=0;i<m;i++){
		int rem=b[i].second;
		while(curr<n && rem>0){
			if (a[curr]>=b[i].first)
				break;
			a[curr++]=b[i].first;
			rem--;
		}
	}
	for(int i=0;i<n;i++)
		ans+=a[i];
	printf("%lld\n",ans);
}



Measured memory_bytes: 5120