akhauriyash/Code-Regression huggingface dataset:
/*************************************************************************
  >         File: D.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 04 Sep 2016 08:35:41 PM CST
*************************************************************************/
#include <bits/stdc++.h>

const int N = 1e5 + 5;
int next[N], mark[N], dep[N], p[N][20];
std::vector<int> edges[N];

void DfsDep(int x, int p = 1, int dep = 0) {
  ::dep[x] = dep;
  ::p[x][0] = p;
  for (int i = 1; i < 20; i++) ::p[x][i] = ::p[::p[x][i - 1]][i - 1];
  for(auto &y: edges[x]) if (y != p) {
    DfsDep(y, x, dep + 1);
  }
}

int goStep(int x, int step) {
  for (int i = 0; i < 20; i++) {
    if (step & (1 << i)) x = p[x][i];
  }
  return x;
}

void goDown(int x) {
  if (mark[x]) return ;
  mark[x] = 1;
  for(auto &y: edges[x]) if (dep[y] > dep[x]) {
    goDown(y);
  }
}

int main() {
  std::ios::sync_with_stdio(0);
  int n, k;
  std::cin >> n >> k;
  for (int i = 1; i <= n; i++) std::cin >> next[i], edges[next[i]].push_back(i);
  int answer = 0;
  if (next[1] != 1) {
    answer++;
    edges[next[1]].erase(std::find(edges[next[1]].begin(), edges[next[1]].end(), 1));
    next[1] = 1;
  }
  DfsDep(1);
  std::priority_queue<std::pair<int, int>> q;
  for (int i = 1; i <= n; i++) {
    q.emplace(dep[i], i);
  }
  while (!q.empty()) {
    int dis, x;
    std::tie(dis, x) = q.top(); q.pop();
    if (dis <= k) break;
    if (mark[x]) continue;
    else {
      int fa = goStep(x, k - 1);
      answer++;
      goDown(fa);
    }
  }
  std::cout << answer << std::endl;
  return 0;
}


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

using namespace std;

int x[111111];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);
	int m = 1e9;
	for (int i = 0; i <= n - k; i++)
		m = min(m, min(abs(x[i]), abs(x[i + k - 1])) + abs(x[i] - x[i + k - 1]));
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	char c;
	cin >> c;
	cout << char(c + 1) << endl;

}

Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    ll now0=1,now1=1;
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        now0=(now0+a-1)/a*a;now1=(now1+b-1)/b*b;
        ll d=max(now0/a,now1/b);
        now0=a*d,now1=b*d;
    }
    cout << now0+ now1 << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3592
from fractions import gcd  # in math module python >= 3.5


def main():
    n = int(input())
    a = list(map(int, input().split()))
    if len(a) < 3:
        print(max(a))
        return

    ls = []
    for i in range(n+1):
        if i == 0:
            ls.append(0)
        else:
            ls.append(gcd(ls[i-1], a[i-1]))

    rs = []
    for i in range(n+1):
        if i == 0:
            rs.append(0)
        else:
            rs.append(gcd(rs[i-1], a[-i]))
    rs = list(reversed(rs)) + [0]

    m = [gcd(ls[i], rs[i+1]) for i in range(n+1)]

    print(max(m))


main()

Measured memory_bytes: 16160
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    
    string S;
    
    cin >> N >> S;
    
    int ans=0;
    
    int temp = 0;
    //全部黒
    for(int i=0; i<N; i++){
        if(S[i]=='.'){
            temp++;
        }
    }
    ans = temp;
    
    
    for(int i=0; i<N; i++){
        if(S[i]=='.'){
            temp--;
        }else{
            temp++;
        }
        ans=min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty;
    int dx = tx-sx;
    int dy = ty-sy;
    rep(i,dy) cout<<'U';
    rep(i,dx) cout<<'R';
    rep(i,dy) cout<<'D';
    rep(i,dx+1) cout<<'L';
    rep(i,dy+1) cout<<'U';
    rep(i,dx+1) cout<<'R';
    cout<<"DR";
    rep(i,dy+1) cout<<'D';
    rep(i,dx+1) cout<<'L';
    cout<<"U\n";
    return 0;
}


Measured memory_bytes: 256
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    def r(n,p):
        d=int(p**(1/n))
        k=1
        for i in range(1,d+1):
            if p%(i**n)==0:
                k=i
        return k
    c=1
    while r(n,p)!=1:
        s=r(n,p)
        c*=s
        p=p/(s**n)
    print(c)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
	long long N, W;

	cin >> N >> W;

	long long *weight = new  long long[N + 1], *value = new  long long[N + 1];

	for (long long i = 1; i <= N; i++) {
		cin >> weight[i] >> value[i];
	}

	long long **DP = new  long long*[W + 1];

	for (long long i = 0; i < W + 1; i++) {
		DP[i] = new  long long[N + 1];
	}

	//初期化
	for (long long i = 0; i <= N; i++)
		DP[0][i] = 0;
	for (long long i = 0; i <= W; i++)
		DP[i][0] = 0;

	for (long long i = 1; i <= W; i++) {
		for (long long j = 1; j <= N; j++) {
			if (i - weight[j] >= 0 && DP[i - weight[j]][j - 1] + value[j] > DP[i][j - 1]) {
				DP[i][j] = DP[i - weight[j]][j - 1] + value[j];
			}
			else
				DP[i][j] = DP[i][j - 1];
		}
	}

	cout << DP[W][N] << endl;

	delete[] value;
	delete[] weight;
	for (long long i = 0; i < W + 1; i++)
		delete[] DP[i];
	delete[] DP;

	return 0;
}

Measured memory_bytes: 80768
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    String s = sc.next();
	    char[] c = s.toCharArray();
	    for (int i = 0; i < s.length(); i ++) {
	      if (c[i] + n > 'Z') {
	        System.out.print((char)(c[i] + n - 26));
	      } else {
	        System.out.print((char)(c[i] + n));
	      }
	    }
	    System.out.println();
	}
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll x,y;cin>>x>>y;
    if(x==1&&y==1){
        cout<<1000000<<endl;
        return 0;
    }
    ll ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

  int N,A,B; //N??????????????°?????°A????????°????????????B?????????????????°?????????
  int x; //?????°???????????????
  cin >> N >> A >> B>> x;
  //cout << N << A << B << x;
  int y[N];//??????????????°???????????????
  for(int i=0;i<N; i++){
    cin >> y[i];
  }
  //input???????????£???
  sort(y,y+N);
  reverse(y,y+N);
  //cout << y[0] << endl;
  //y?????§?????????????????£???

  //???????????¶?????°???????????????
  int buf;
  int max = x/A;
  int S[N];
  S[0] = y[0];
  for(int i=1; i<N;i++){
    S[i] = S[i-1]+y[i];
    //cout << S[i] << endl;
  }

  for(int i=0; i<N; i++){
    buf = (x+S[i])/(A+(i+1)*B);
    if(buf >= max){
        max = buf;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 1176
// We Love Golf

func main() {
    let k = Int(readLine()!)!
    let ab = readLine()!.split(separator: " ").map{Int($0)!}
    if (ab[0] / k != ab[1] / k) || ab[0] % k == 0 {
        print("OK")
    } else {
        print("NG")
    }
}

main()

Measured memory_bytes: 8264
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;

using lint = long long int;

int main(){
    int N,A,B;
    lint v[52];
    lint ave = 0;
    lint count = 0;
    lint nCr[52][52]={};
    multiset <lint> multiv;

    for(int i=0;i<=50;i++){
        nCr[i][0] = 1;
    }
    for(int n=1;n<=50;n++){
        for(int r=1;r<=50;r++){
            nCr[n][r] = nCr[n][r-1] * (n-r+1) / r;
        }
    }

    cin >> N >> A >> B;
    for(int i=0;i<N;i++) cin >> v[i];
    sort(v,v+N,greater<lint>());
    
    for(int i=0;i<A;i++){
        ave += v[i];
        multiv.insert(v[i]);
    }

    if(multiv.count(v[0])==A){
        int n = 0;
        for(int i=0;i<N;i++){
            if(v[i]==v[0]) n++;
        }
        for(int r=A;r<=B;r++){
            count += nCr[n][r];
        }
    }
    else{
        auto itr = multiv.begin();
        lint temp_min = *itr;
        int r = multiv.count(temp_min);
        int n = 0;
        for(int i=0;i<N;i++){
            if(v[i] == temp_min) n++;
        }
        count += nCr[n][r];
    }

    printf("%.6f\n",(double)ave/(double)A);
    //cout << (double)ave/(double)A << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;cin >> c;
    if(c-'a'>=0&&c-'a'<=25){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 3644
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        char[][] f=new char[h][w];
        for (int i = 0; i < h; i++) {
            String t=sc.next();
            for (int j = 0; j < w; j++) {
                f[i][j]=t.charAt(j);
            }
        }
        long ans=0;
        int[] dx={-1,0,1,0};
        int[] dy={0,-1,0,1};
        long[][] node=new long[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(node[i][j]==0) {
                    Queue<Point> q = new ArrayDeque<>();
                    if(f[i][j]=='#'){
                        q.add(new Point(i, j));
                        node[i][j]++;
                    }
                    long tempW = 0, tempB = 0;
                    while (!q.isEmpty()) {
                        Point p = q.poll();
                        if (f[p.x][p.y] == '.') tempW++;
                        else tempB++;
                        for (int k = 0; k < 4; k++) {
                            int x = p.x + dx[k];
                            int y = p.y + dy[k];
                            if (0 <= x && x < h && 0 <= y && y < w) {
                                if (node[x][y] == 0 && f[p.x][p.y] != f[x][y]) {
                                    q.add(new Point(x, y));
                                    node[x][y]++;
                                }
                            }
                        }
                    }
                    ans += tempB * tempW;
                }
            }
        }
        out.println(ans);
    }
}


Measured memory_bytes: 39876
#include<stdio.h>
int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x >= r && y >= r && x <= W - r && y <= H - r){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;

}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e5+5;
const LL Mod = 1000000007;
LL a[N], b[N];
int main() {
  LL n, ans = 1; read(n);
  for(int i = 1; i <= n; i++) {
    read(a[i]);
    if(a[i] == 0) {
      ans = (3 - b[0]) * ans % Mod;
      b[0]++;
    }
    else {
      LL k = b[a[i] - 1];
      ans = ans * (k - b[a[i]]) % Mod;
      b[a[i]]++;
    }
  } 
  cout << ans << endl;
} 

Measured memory_bytes: 1792
#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>;
 
 
int main() {
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 150010
#define inf 1000000007 
//#define mod 1000000009
#define inv 500000005
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll,int>pii;
typedef bitset<maxn> bit;
typedef long double ld;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int T,A,B,C,D,k;
bool check(int mid)
{
    int a=A-mid/(k+1)*k-mid%(k+1);
    int b=B-mid/(k+1);
    return b<=1ll*a*k;
}
int main()
{
    T=read();
    while(T--)
    {
        A=read();B=read();C=read();D=read();
        k=max(ceil(1.0*A/(B+1)),ceil(1.0*B/(A+1)));
        int l=0,r=A+B+1,L=0,R;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(check(mid))  L=mid+1,l=mid+1;
            else            r=mid-1;
        }
        int a=A-L/(k+1)*k-L%(k+1);
        int b=B-L/(k+1);
        R=L+b-a*k+1;
        for(int i=C;i<=min(D,L);i++)
        {
            if(i%(k+1))  printf("A");
            else         printf("B");
        }
        for(int i=max(L+1,C);i<=D;i++)
        {
            if((i-R)%(k+1))  printf("B");
            else             printf("A");
        }
        puts("");
    }
    return 0; 
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define cyes cout<<"Yes"<<endl;
#define cno cout<<"No"<<endl;
#define gcd __gcd
using namespace std;
int f(int n) {
  if(n%2) return 3*n+1;
  return n/2;
}

signed main() {
  int s;
  cin>>s;
  vector<int>vec(1000000);
  vec.at(0)=s;
  for(int i=1;i<1000000;i++) {
    vec.at(i)=f(vec.at(i-1));
    if(2<i) {
      if(vec.at(i-3)==vec.at(i)) {
        cout<<i+1<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 8064
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
	int n, x, y;
	cin >> n >> x >> y;
	x--, y--;
  
	vvi dist(n, vi(n,0));
    
	rep(i,n-1){
		rep3(j,i+1,n-1){
			dist[i][j] = min(j-i, abs(i-x)+1+abs(j-y));
		}
	}  
	/*
	rep(i,n){
		rep(j,n){
			cout << dist[i][j]<< " ";
		}
		cout << endl;
	}  
	//*/
	vi cnt(n,0);
	rep(i,n-1){
		rep3(j,i+1,n-1){
			cnt[dist[i][j]]++;
		}
	}
	rep3(i,1,n-1) cout << cnt[i] << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 16000
import math
n = int(input())
six_ls = []
nine_ls = []
def nine_plus(base):
    "base : list of int"
    kuriagari = 1
    for num in range(len(base) - 1, -1, -1):
        if base[num] + kuriagari >= 9:
            base[num] = 0
            continue
        else:
            base[num] += kuriagari
            break
    return base

def six_plus(base):
    "base : list of int"
    kuriagari = 1
    for num in range(len(base) - 1, -1, -1):
        if base[num] + kuriagari >= 6:
            base[num] = 0
            continue
        else:
            base[num] += kuriagari
            break
    return base

six_sinsu = [0 for i in range(math.floor(math.log(n, 6)) + 2)]
nine_sinsu = [0 for i in range(math.floor(math.log(n, 9)) + 2)]

for i in range(n+1):
    six_ls.append(sum(six_sinsu))
    nine_ls.append(sum(nine_sinsu))
    six_sinsu = six_plus(six_sinsu)
    nine_sinsu = nine_plus(nine_sinsu)
hoge = [a + b for a, b in zip(six_ls, nine_ls[::-1])]
print(min(hoge))

Measured memory_bytes: 6340
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

using namespace std;

int main()
{
    int n, i=0;
    cin >>n;
    int x[3];
    while(i<3)
    {
        x[i]= n%10;
        n= n/10;
        i++;
    }
    if(x[0]==7 || x[1]==7 || x[2]==7)
    {
        cout <<"Yes" <<endl;
    }
    else
    {
        cout <<"No" <<endl;
    }
    return 0;
}





Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,b;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&b);
		if(b&1){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*const long long M = 1000000007 , N = 1001;
int r1,r2,r3,c1,c2,c3,c4,n,polycoff[N][N],group2[N][N];
string s1,s2,s3;
void fix(int &a){
	if(a >= M){
		a -= M;
	}else if(a < 0){
		a += M;
	}
}
int main(){
	cin >> n >> r1 >> s1 >> r2 >> s2 >> r3 >> s3;
	for(int i = 0 ; i < n ; i += 1){
		if(s1[i] != s2[i] && s2[i] == s3[i]){
			c1 += 1;
		}else if(s1[i] != s2[i] && s1[i] == s3[i]){
			c2 += 1;
		}else if(s1[i] == s2[i] && s2[i] != s3[i]){
			c3 += 1;
		}else{
			c4 += 1;
		}
	}
	int rr1 = r1-c2-c3-c4 , rr2 = r2-c1-c3-c4 , rr3 = r3-c1-c2-c4;
	for(int i = 0 ; i <= n ; i += 1){
		polycoff[i][0] = polycoff[i][i] = 1;
		for(int j = 1 ; j < i ; j += 1){
			polycoff[i][j] = polycoff[i-1][j] + polycoff[i-1][j-1];
			fix(polycoff[i][j]);
		}
	}
	for(int i = 0 ; i <= c3 ; i += 1){
		for(int j = 0 ; j <= c4 ; j += 1){
			group2[i+j][i-j+c4] = (long long)polycoff[c3][i] * polycoff[c4][j]%M;
		}
	}
	for(int i = 0 ; i <= c3+c4 ; i += 1){
		for(int j = -c4 ; j <= c3 ; j += 1){
			int jj = j+c4;
			group2[i][jj] += (i > 0 ? group2[i-1][jj] : 0) + (jj > 0 ? group2[i][jj-1] : 0);
			fix(group2[i][jj]);
			if(i > 0 && jj > 0){
				group2[i][jj] -= group2[i-1][jj-1];
			}
			fix(group2[i][jj]);
		}
	}
	long long ans = 0;
	for(int i = 0 ; i <= c1 ; i += 1){
		for(int j = 0 ; j <= c2 ; j += 1){
			int rrr1 = rr1 - i + j,rrr2 = rr2 + i - j , rrr3 = rr3 + i + j , rrr4 = max(-rrr1,-rrr2);
			if(rrr4 > c3+c4 || rrr3+c4 < 0){
				continue;
			}
			rrr3 = min(rrr3,c3);
			ans += (polycoff[c1][i]*polycoff[c2][j])*(group2[rrr4][c3+c4]-(rrr3+c4 > 0 ? group2[rrr4][rrr3+c4-1] : 0));
			ans %= M;
		}
	}
	cout << (ans+M)%M << endl;
}
*/
/*
3
1 000
1 100
0 111
*/

int main(){
	string s;
	int n,ans=0;
	cin >> n >> s;
	for(int i = 0 ; i < n-2 ; i += 1){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
			ans += 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, k);
	int n = 50, p = k / n, q = k % n;
	vector< int > a(n, n + p - q - 1);
	REP(i, q) {
		a[i] += 51;
	}

	
	OUT(n)BR;
	REP(i, n) {
		OUT(a[i]);
		if (i < n - 1) SP;
	}
	BR;
	
  return 0;
}


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

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

    int n;
    cin >> n;
    vector<vector<int>> adj(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int> cs(n);
    for (int i = 0; i < n; i++) cin >> cs[i];
    sort(cs.rbegin(), cs.rend());

    vector<int> ans(n);
    int idx = 0;
    function<void(int, int)> dfs = [&](int v, int p) {
        ans[v] = cs[idx++];
        for (int s : adj[v]) {
            if (s != p) {
                dfs(s, v);
            }
        }
    };
    dfs(0, -1);

    long long sum = 0;
    for (int a = 0; a < n; a++) {
        for (int b : adj[a]) {
            if (a < b) {
                sum += min(ans[a], ans[b]);
            }
        }
    }
    cout << sum << endl;
    for (int a : ans) cout << a << ' ';
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n+1) cin >> a[i];
    vector<int> b(n);
    rep(i, n) cin >> b[i];
    ll ans = 0;
    rep(i, n) {
        ans += min(a[i]+a[i+1], b[i]);
        if (a[i] < b[i] && a[i]+a[i+1] > b[i]) a[i+1] -= b[i]-a[i]; 
        else if (a[i] < b[i] && a[i]+a[i+1] <= b[i]) a[i+1] = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4024
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 100005
#define ll long long
#define MOD 1000000007
int n,k,h,ans;
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h);
		if(h>=k) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
ll x, k, d, t, ans;
int main(){
	scanf("%lld%lld%lld", &x, &k, &d);
	x = abs(x);
	t = x / d;
	if(k < t) ans = x - d*k;
	else{
		k -= x / d;
		x %= d;
		ans = k & 1 ? d - x : x;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3784
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1e5 + 1000, OO = 1e14 + 100, M = 1e9 + 7, P = 6151, SQ = 120, lg = 31;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
	char c;
	cin >> c;
	c++;
	cout << c << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

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

int h, w;
vector<vector<int>> field;

int cntBomb(int x, int y);

int main() {
    cin >> h >> w;
    field.resize(h, vector<int>(w));
    rep(i, h) {
        string temp;
        cin >> temp;
        rep(j, w) {
            if(temp.at(j) == '#') field.at(i).at(j) = -1;
            else field.at(i).at(j) = -2;
        }
    }
    rep(i, h) rep(j, w) {
        if(field.at(i).at(j) == -2) field.at(i).at(j) = cntBomb(i, j);
    }
    rep(i, h) {
        rep(j, w) {
            if(field.at(i).at(j) == -1) cout << "#";
            else cout << field.at(i).at(j);
        }
        cout << endl;
    }
}

int cntBomb(int x, int y) {
    int cnt = 0;
    for(int dx = -1; dx <= 1; dx++) {
        for(int dy = -1; dy <= 1; dy++) {
            if(dx == 0 && dy == 0) continue;
            if(0 <= x + dx && x + dx < h && 0 <= y + dy && y + dy < w && field.at(x + dx).at(y + dy) == -1) cnt++;
        }
    }
    return cnt;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    bool a_c = false;
    bool b_c = false;
    for (int i = 0; i < K; ++i) {
        if (A >= B) {
            B*=2;
            if (B > A) a_c = true;
            continue;
        } else {
            a_c = true;
        }
        if (B >= C) {
            C*=2;
            if (C > B) b_c = true;
            continue;
        } else {
            b_c = true;
        }
    }
    if (a_c && b_c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll d, t, s;
    cin >> d >> t >> s;
    if ((s * t) >= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;

int main(){
	string a,b,c;cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;

}


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

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

using namespace std;
using lint=long long;

int main(){
	int l[]={1,0,0,1,2,3,4,5,6,7,8,9,9,10};
	int r[]={9,9,19,29,39,49,59,69,79,89,99,99,109,119};
	vector<lint> ans;
	rep(i,14) for(int j=l[i];j<r[i];j++) {
		ans.emplace_back(stoll(to_string(j)+string(i,'9')));
	}

	int k; cin>>k;
	rep(i,k) cout<<ans[i]<<endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        q: usize,
        lr: [(usize, usize);m],
        pq: [(usize, usize);q],
    }
    let mut cur = vec![0;n+1];
    let mut seed = vec![vec![0;n+1];n+1];
    for i in 0..m{
        cur[lr[i].1]+=1;
        seed[lr[i].0][lr[i].1]+=1;
    }
    for i in 0..n+1 {
        for j in 0..n+1 {
            if j+1 > n {
                continue;
            }
            seed[i][j+1]+=seed[i][j];
        }
    }
    // println!("{:?}", seed);
    for i in 0..n+1 {
        for j in 0..n+1 {
            if i+1 > n {
                continue;
            }
            seed[i+1][j]+=seed[i][j];
        }
    }
    for i in 0..n {
        cur[i+1] += cur[i];
    }
    // println!("{:?}", cur);
    // println!("{:?}", seed);
    for &(p,q) in &pq {
        let ans = seed[q][q] - seed[p-1][q];
        println!("{}", ans);
        // println!("{} {} {} {}", p, q-1, seed[p][p], seed[q-1][p]);
    }
}

Measured memory_bytes: 11132
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

struct Node{
	int key;
	Node *parent,*left,*right;
};
int n;
Node *NIL,*root;
bool exist = false;
void insert(int k){
	Node *x = root;
	Node *y = NIL;
	Node *z;
	z = new Node();
	z->key = k;
	z->left = z->right = NIL;
	while(x != NIL){
		y = x;
		if(z->key > x->key){
			x = x->right;
		}else{
			x = x->left;
		}
	}
	z->parent = y;
	if(y == NIL){
		root = z;
	}else{
		if(z->key > y->key){
			y->right = z;
		}else{
			y->left = z;
		}
	}
}
void find(int k){
	Node *x = root;
	while(x != NIL){
		if(x->key == k){
			exist = true;
		}
		if(k > x->key){
			x = x->right;
		}else{
			x = x->left;
		}
	}
}
void inorder(Node *a){
	if(a == NIL) return;
	inorder(a->left);
	cout << " " << a->key; 
	inorder(a->right);
}

void preorder(Node *a){
	if(a == NIL) return;
	cout << " " << a->key; 
	preorder(a->left);
	preorder(a->right);	
}

int main(){
	cin >> n;
	int key;
	char s[10];
	for(int i = 0;i < n;i++){
		scanf("%s",s);
		if(s[0] == 'i'){
			cin >> key;
			insert(key);
		}else if(s[0] == 'p'){
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}else if(s[0] == 'f'){
			cin >> key;
			exist = false;
			find(key);
			if(exist){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 19972
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

	int N, K;
	cin>>N>>K;
	int ans=0;
	while(N){
		N/=K;
		ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())

def divisor(c): 
    i = 1
    table = []
    while i * i <= c:
        if c%i == 0:
            table.append(i)
            table.append(c//i)
        i += 1
    table = list(set(table))
    return table
    
x=divisor(c)
x=sorted(x)

x=[i for i in x if a<=i<b+1]
print(len(x))



Measured memory_bytes: 5604
import sys
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
keta = 0
lis = []

tt = k
num=0
while tt!=0:
    tt//=2
    num+=1

if k==0:
    num=1
num=48
for _ in range(num):
    tmp = 0
    for i in range(n):
        if a[i]%2==0:
            tmp+=1
        a[i]//=2
    lis.append([tmp,n-tmp])
    keta+=1
dp = [[0 for i in range(2)]for i in range(num+1)]
dp[0][0]=0
for i in range(1,num+1):
    jum = k>>(num-i)&1
    dp[i][0] += dp[i-1][0]+lis[num-i][1-jum]*2**(num-i)
    if dp[i-1][1] and jum==0:
        dp[i][1] += dp[i-1][1]+max(lis[num-i])*2**(num-i)
    elif dp[i-1][1] and jum==1:
        dp[i][1] += max(dp[i-1][1]+max(lis[num-i])*2**(num-i),dp[i-1][0]+lis[num-i][jum]*2**(num-i))
    elif dp[i-1][1]==0 and jum==1:
        dp[i][1] += dp[i-1][0]+lis[num-i][jum]*2**(num-i)

print(max(dp[-1]))


Measured memory_bytes: 63756
#include<stdio.h>
int main()
{
   int a,b;
   scanf("%d %d",&a,&b);
   if(a<b) {
    printf("a < b\n");
   }
   else if(a>b) {
    printf("a > b\n");
   }
   else {
    printf("a == b\n");
   }

    return 0;
}



Measured memory_bytes: 2104
#include<cstdio>
const int MAXN = 1000;
long long sum[2];
int a[MAXN + 5], ans[MAXN + 5], tot, N;
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &a[i]);
		if( a[i] >= 0 )
			sum[i&1] += a[i];
	}
	if( sum[0] == 0 && sum[1] == 0 ) {
		int Max = 1;
		for(int i=1;i<=N;i++)
			if( a[i] > a[Max] )
				Max = i;
		printf("%d\n%d\n", a[Max], N-1);
		for(int i=N;i>Max;i--)
			printf("%d\n", i);
		for(int i=1;i<Max;i++)
			printf("%d\n", 1);
		return 0;
	}
	if( sum[0] > sum[1] ) {
		printf("%lld\n", sum[0]);
		if( N % 2 == 0 && a[N] < 0 ) ans[++tot] = N;
		for(int i=N;i>=1;i--) {
			if( i % 2 == 1 ) {
				if( a[i-1] < 0 ) ans[++tot] = i-1;
				else ans[++tot] = i;
			}
		}
		if( 1 % 2 == 0 && a[1] < 0 ) ans[++tot] = 1;
		printf("%d\n", tot);
		for(int i=1;i<=tot;i++)
			printf("%d\n", ans[i]);
	}
	else {
		printf("%lld\n", sum[1]);
		if( N % 2 == 1 && a[N] < 0 ) ans[++tot] = N;
		for(int i=N;i>=1;i--) {
			if( i % 2 == 0 ) {
				if( a[i-1] < 0 ) ans[++tot] = i-1;
				else ans[++tot] = i;
			}
		}
		if( 1 % 2 == 1 && a[1] < 0 ) ans[++tot] = 1;
		printf("%d\n", tot);
		for(int i=1;i<=tot;i++)
			printf("%d\n", ans[i]);
	}
}

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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long K;
        K = sc.nextLong();
        long ans = 0;
        for (int i = 0; i < N; i++) {
           if (sc.nextInt() >= K) ans++;
        }
        System.out.println(ans);
    }
}


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

int main(void){
    int i, j, N, M, B[30], A[30][30], C, ANS=0;
    scanf("%d %d %d", &N, &M, &C);
    for(j=0; j<M; j++) scanf("%d", B+j);
    for(i=0; i<N; i++){
        for(j=0; j<M; j++) scanf("%d", &A[i][j]);
    }
    //A[i][0] に合計を代入
    for(i=0; i<N; i++){
        A[i][0] *= B[0];
        for(j=1; j<M; j++) A[i][0] += A[i][j] * B[j];
        A[i][0] += C;
        if(A[i][0] > 0) ANS++;
    }
    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz hxr
#define ll long long
#define ull unsigned ll
int n, p, a[55], cnt1, cnt2;
ll c[55][55];
int main() {
	cin>>n>>p;
	for (int i=0; i<n; i++)
		cin>>a[i];
	c[0][0]=1ll;
	for (int i=1; i<55; i++) {
		c[i][0]=c[i][i]=1ll;
		for (int j=1; j<i; j++)
			c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	for (int i=0; i<n; i++)
		if (a[i]%2==1)
			cnt1++;
		else
			cnt2++;
	ll ans=0ll;
	for (int i=0; i<=cnt1; i++) {
		for (int j=0; j<=cnt2; j++) {
			if (i%2!=p)
				continue;
			ans+=c[cnt1][i]*c[cnt2][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if (N > M)
        swap(N, M);

    if (N == 1)
        ans = max((ll)1, M - 2);
    else {
        ans = max((ll)0, (N - 2) * (M - 2));
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
*/
//#define sqr(qwert) qwert * qwert
#define eb emplace_back
#define pb push_back
#define ld long double
#define ll long long
#define f first
//#define s second
#define deb(a) cerr << #a << " = " << a << '\n';
#define fast() { \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout << fixed << setprecision(15); \
    cerr << fixed << setprecision(11); \
}

const int INF = 1e9 + 7;
const ld EPS = 1e-10;
const int MAXI = 20000;
const int MOD = 998244353;
const int MAXST = 2000000;
const int P = 62;
const ld PI = 3.14159265358979323;

int main() {
    int a, b, k;
    cin >> k >> a >> b;
    while(a <= b){
        if(a % k == 0)
            return cout << "OK\n", 0;
        else a++;
        //cout << a << ' ';
    }
    cout << "NG\n";
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll ans=MOD*MOD;
  ll N;
  cin>>N;
  vector<ll> A(N);
  cin>>A;
  ll sum=0,lf=0;
  for(auto &I:A){
    sum+=I;
  }
  for(auto &I:A){
    lf+=I;
    ll rg=sum-lf;
    if(rg!=0){ans=min(ans,abs(rg-lf));}
  }
  cout<<ans<<endl;


  return 0;
}

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

using namespace std;

int n, m, d;
char mat[105][105];

int main(){
	scanf("%d%d%d", &n, &m, &d);
	
	for(int i = 0; i < n; i++)
	scanf("%s", mat[i]);
	
	int res = 0;
	
	for(int i = 0; i < n; i++){
		int cnt = 0;
		
		for(int j = 0; j < m; j++){
			if(mat[i][j] == '#'){
				res += max(0, cnt - d + 1);
				cnt = 0;
			}
			else
			cnt++;
			
			if(j == m - 1) res += max(0, cnt - d + 1);
		}
	}
	
	for(int i = 0; i < m; i++){
		int cnt = 0;
		
		for(int j = 0; j < n; j++){
			if(mat[j][i] == '#'){
				res += max(0, cnt - d + 1);
				cnt = 0;
			}
			else
			cnt++;
			
			if(j == n - 1) res += max(0, cnt - d + 1);
		}
	}
	
	printf("%d\n", res);
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
int n, k;

int main()
{
    cin >> n >> k;
    double d = 1;
    double ans = 0;
    for (double i = n; i > 0; i--)
    {
        if (i >= k / d)
        {
            ans += k / d;
        }
        else
        {
            d *= 2;
            i++;
        }
    }
    printf("%.12f", ans / n / k);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<string> split(string str, char del) {
    int first = 0, last = str.find_first_of(del);

    vector<string> result;
    while (first < str.size()) {
        string subStr(str, first, last-first); 
        result.push_back(subStr);
        first = last + 1;
        last = str.find_first_of(del, first);
        if (last == string::npos) last = str.size();
    }
    return result;
}

int main() {
    string S; cin >> S;
    vector<string> days = split(S,'/');
    int year = stoi(days[0]), month = stoi(days[1]);
    string result = ( year > 2020 or ( year == 2019 and month >= 5 ) ? "TBD" : "Heisei" );
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int res = 0, found = 0, p = 0;

int main(){
    string str;
    cin >> str;
    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'A' && found == 0){
            res = 0;
            //cout << "test" << endl;
            found = 1;
        }
        if(str[i] == 'Z' && found != 0){
            res++;
            p = res;
        }
        else if(found != 0){
            res++;
        }

    }
    cout << p << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

vector<int> Input(510);

// factorize
vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll p = 2; p * p <= n; p++) {
    if (n %p != 0) continue;
    int num = 0;
    while (n % p == 0) {
      num++;
      n /= p;
    }
    res.push_back(make_pair(p,num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// enumerate divisors
vector<int> enum_div(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n/i);
      }
    } 
  }
  sort(res.begin(), res.end());
  return res;
}


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

  int sum = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
    sum += Input[i];
  }

  vector<int> factors = enum_div(sum);

  reverse(factors.begin(), factors.end());

  // for (auto pi: factors) {
  //   cout << pi << endl;
  // }

  
  for (auto pi: factors) {
    int sum2 = 0;
    vector<int> Temp(N, 0);
    for (int i = 0; i < N; i++) {
      Temp[i] = Input[i] % pi;
      sum2 += Temp[i];
    }
    sort(Temp.begin(), Temp.end());
    reverse(Temp.begin(), Temp.end());
    for (int i = 0; i < sum2 / pi; i++) {
      Temp[i] -=  pi;
    }
    // cout << "pi: " << pi << endl;
    // for (int i = 0; i < N; i++) {
    //   cout << Temp[i] << endl;
    // }
    int ans = 0;
    for (int i = 0; i < N; i++)  {
      ans += (Temp[i] > 0 ? Temp[i] : 0);
    }
    // cout << "ans: " << ans << endl;
    if (ans <= K) {
      cout << pi << endl;
      return 0;
    }
  }
  assert(false);
}


Measured memory_bytes: 256