akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b;
  bool f=false;
  if(b<10){
    c=10*a+b;
    for (int i=1;i<=32;i++){
      if(c==i*i){
        f=true;
        break;
      }
    }
  }
  else if(b<100){
    c=100*a+b;
    for (int i=1;i<=101;i++){
      if(c==i*i){
        f=true;
        break;
      }
    }
  }
  else {
    c=1000*a+b;
    for (int i=1;i<=317;i++){
      if(c==i*i){
        f=true;
        break;
      }
    }
  }
  if(f){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
bool np[100001]={1,1};
int a[100001]={0};
int main(){
    int Q,l,r,i,j;
    for(i=2;i<=100000;i++)
        if(!np[i])
            for(j=i+i;j<=100000;j+=i)
                np[j]=1;
    for(i=1;i<=100000;i++){
        if(i&1){
            if(!np[i]&&!np[(i+1)/2])
                a[i]=a[i-1]+1;
            else a[i]=a[i-1];
        }
        else a[i]=a[i-1];
    }
    scanf("%d",&Q);
    while(Q--){
        scanf("%d%d",&l,&r);
        printf("%d\n",a[r]-a[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1024
#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;
    vector<int> a(M);
    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        while (K--)
        {
            int A;
            cin >> A;
            --A;
            a[A]++;
        }
        
    }
    
    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        if (a[i] == N)
        {
            ans++;
        }
        
    }
    
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
 
 
int main() {
  string S;
  cin >> S;
  
  reverse(S.begin(),S.end());
  for(int i=0;i<4;++i) reverse(divide[i].begin(), divide[i].end());
  
  bool can = true;
  for(int i =0 ; i < S.size() ;){
  	bool can2 = false;
    for (int j =0 ; j < 4 ; ++j){
      string d = divide[j];
      if(S.substr(i,d.size()) ==d ){
        can2 = true;
        i += d.size(); // divide できたら i を進める
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n; 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	if(n<1200)
	cout<<"ABC";
	else if(n<2800){
		cout<<"ARC";
	}
	else
	cout<<"AGC";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define Mod 1000000009 
#define MAX 4294967296  // 2^32
const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
using namespace std;

long long gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}


long long power(int x,int y){
if(y==0)return 1;
long long t=power(x,y/2);
if(y%2==1)return x*t*t;
return t*t;



}
double findMod(double a, double b) 
{ 
    double mod; 
    // Handling negative values 
    if (a < 0) 
        mod = -a; 
    else
        mod =  a; 
    if (b < 0) 
        b = -b; 
  
    // Finding mod by repeated subtraction 
      
    while (mod >= b) 
        mod = mod - b; 
  
    // Sign of result typically depends 
    // on sign of a. 
    if (a < 0) 
        return -mod; 
  
    return mod; 
} 

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll ans=INT_MIN;
void dfs(vector<int>adj[],vector<int>&vis,int i,int &f){
    vis[i]=1;

    for(auto it=adj[i].begin();it!=adj[i].end();it++){
        if(!vis[*it]){
            f++;
            dfs(adj,vis,*it,f);
        }
    }
}

int main(){



    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
   string s;
   cin>>s;
   int sum=0;
   fo(i,s.length()){
    sum+=s[i]-'0';
   }
   if(sum%9==0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;



}

Measured memory_bytes: 3784
/*  -*- coding: utf-8 -*-
 *
 * b.cc: 
 */

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

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

struct ExtUFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N], diffs[MAX_N];
  ExtUFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++)
      links[i] = i, ranks[i] = sizes[i] = 1, diffs[i] = 0;
  }

  int root(int i) {
    int i0 = i, d = 0;
    while (links[i0] != i0) d += diffs[i0], i0 = links[i0];
    diffs[i] = d;
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }
  int diff(int i, int j) { return same(i, j) ? diffs[j] - diffs[i] : INF; }
  
  int merge(int i0, int i1, int d) { // d == diffs[i1] - diffs[i0]
    int r0 = root(i0), r1 = root(i1), mr;
    int dr = d - diffs[i1] + diffs[i0];
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      diffs[r1] = dr;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      diffs[r1] = dr;
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      diffs[r0] = -dr;
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

ExtUFT euft;

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  euft.clear(n);

  while (m--) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    l--, r--;

    int dlr = euft.diff(l, r);
    if (dlr >= INF)
      euft.merge(l, r, d);
    else if (dlr != d) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int N, A;
int main() {
  int a, b;
  cin >> a >> b;
  int X = a + b;
  if ((a + b) % 2 == 1){
  X++;
  }
  else {}
  int x = X / 2;
  cout << x << endl;
}


Measured memory_bytes: 256
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
using namespace std;
int par[100001]; // 親の番号
// n 要素で初期化
void init(int n) { for (int i = 0; i < n; i++) par[i] = i; }
// 木の根を求める
int root(int x) { 
	if (par[x] == x) { // 根
		return x;
	}
	else {
		return par[x] = root(par[x]); // 経路圧縮 
	} 
}
// x と y が同じ集合に属するか否か
bool same(int x, int y) { return root(x) == root(y); } 
// x と y の属する集合を併合
void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; par[x] = y; }
int main() {
	int n, m, sum = 0;
	cin >> n >> m;
	init(n);
	vector<int> a;
	REP(i, n) { int h; cin >> h; a.pb(h); }
	REP(i, m) {
		int s, t;
		cin >> s >> t;
		unite(s, t);
	}
	for (int i = 1; i <= n; ++i) {
		if (same(a[i-1], i)) {
			sum++;
		}
	}
	cout << sum;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

long long S;

bool read() {
    if (!(cin >> S))
        return false;

    return true;
}

long long cross(long long ax, long long ay, long long bx, long long by) {
    return ax * by - bx * ay;
}

void solve() {
    cout << "0 0 ";
    auto s = static_cast<long long>(sqrtl((long double) S));
    for (; s * s < S; ++s) { }
    assert(cross(s, 1, s * s - S, s) == S);
    cout << s << ' ' << 1 << ' ';
    cout << s * s - S << ' ' << s << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        long N = long.Parse(input[0]);
        long X = long.Parse(input[1]);
        long Y = long.Parse(input[2]);
        long[] ans = new long[N];
        for(int i = 1; i <= N; i++)
        {
            for(int j = i; j <= N; j++)
            {
                ans[Math.Min(Math.Abs(i - j), Math.Abs(i - X) + 1 + Math.Abs(j - Y))]++;
            }
        }
        for(int i = 1; i < N; i++)
        {
            Console.WriteLine(ans[i]);
        }
    }
}

Measured memory_bytes: 13244
import numpy as np
n = int(input())
a = list(map(int, input().split()))
A = np.zeros(n)
for i in range(n):
  A[a[i] - 1] = i

print(str([int(A[i]) + 1 for i in range(n)]).replace('[', '').replace(']', '').replace(',', ''))

      



Measured memory_bytes: 23376
#include <stdio.h>

int pow2(int a) {
  int r = 1;
  for (int i = 0; i < a; i++) r *= 2;
  return r;
}

  
int main()
{
  int a,i,j,k,f,n,m;
  int s[10][10];
  int p[10];
  int on[10];
  for(i=0;i<10;i++)for(j=0;j<10;j++)s[i][j]=0;

  scanf("%d%d", &n, &m);
  
  for (i = 0; i < m; i++) {
    scanf("%d", &k);
    for(j=0;j<k;j++){
      scanf("%d", &a);
      s[i][a-1]=1;
	}
  }

//  for(i=0;i<10;i++){
//    for(j=0;j<10;j++){
//      printf("%d ",s[i][j]);
//    }
//    printf("\n");
//  }

  
  for (i = 0; i < m; i++) {
    scanf("%d", &p[i]);
  }
  int count=0;
  int wa;
  int light;
  for(i=0;i<pow2(n);i++){
    f=i;
    for(j=0;j<n;j++){
      on[j]=f%2;
      f/=2;
    }
//    printf("%d %d %d %d:\n",i,on[0],on[1],on[2]);
    light=1;
    for(f=0;f<m;f++){
      wa=0;
      for(j=0;j<n;j++){
        wa+=s[f][j]*on[j];
      }
      if(wa%2==p[f]) light*=1; else light*=0;
//      printf(" %d-th constraint (%d, %d) %d\n", f,wa,p[f],light);
    }
    if(light) count++;
  }
  printf("%d\n",count);
  return 0;
}


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

flag=0

for i in range(N):
  if A[i]%2==0:
    if A[i]%3>0 and A[i]%5>0:
      flag=1
      break
if flag==1:
  print("DENIED")
else:
  print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int n,s,m,x,i;
int main()
{
    cin>>n>>m;
   for(i=1;i<=m;i++)
   {
       cin>>x;
       s+=x;
   }
   if(s<=n)
    cout<<n-s;
   else
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int w, h;
long long int l;
int tesu[101][101][4];
char meiro[101][101];
vector<pair<pair<int, int>, char> > step;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
char direction[4] = {'N', 'E', 'S', 'W'};

void solve(int x, int y, int nowface, long long int stepnum)
{
    // cout << stepnum << " " << x << " " << y << " " << direction[nowface] << endl;
    if(stepnum == l){
        cout << x << " " << y << " " << direction[nowface] << endl;
        return;
    }
    step.push_back(make_pair(make_pair(x, y), direction[nowface]));
    int nx = x + dx[nowface];
    int ny = y + dy[nowface];
    while(nx < 1 || ny < 1 || nx > h || ny > w || meiro[nx][ny] == '#'){
        nowface = (nowface + 1) % 4;
        nx = x + dx[nowface];
        ny = y + dy[nowface];
        // cout << x << " " << y << " " <<  nx << " " << ny << endl;
    }
    if(tesu[nx][ny][nowface] == -1){
        tesu[nx][ny][nowface] = stepnum + 1;
        solve(nx, ny, nowface, stepnum + 1);
    } else {
        long long int tmp = stepnum + 1 - tesu[nx][ny][nowface];
        // cout << tesu[nx][ny][nowface] << endl;
        pair<pair<int, int>, char> ans = step[tesu[nx][ny][nowface] + (l - tesu[nx][ny][nowface]) % tmp];
        cout << (ans.first).first << " " << (ans.first).second << " " << ans.second << endl;
    }
    return;
}


int main()
{
    while(1){
        cin >> h >> w >> l;
        int sx, sy;
        if(w == 0 && h == 0 && l == 0) break;
        step.clear();
        for(int i = 1; i < h + 1; i++){
            for(int j = 1; j < w + 1; j++){
                cin >> meiro[i][j];
                if(meiro[i][j] != '#' && meiro[i][j] != '.'){
                    sx = i;
                    sy = j;
                }
                for(int k = 0; k < 4; k++){
                    tesu[i][j][k] = -1;
                }
            }
        }
        if(meiro[sx][sy] == 'N') solve(sx, sy, 0, 0);
        else if(meiro[sx][sy] == 'E') solve(sx, sy, 1, 0);
        else if(meiro[sx][sy] == 'S') solve(sx, sy, 2, 0);
        else solve(sx, sy, 3, 0);
    }
    return 0;
}

Measured memory_bytes: 1904
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++)cin >> b[i];
    int ret = 0;
    for (int i = 0; i < n; i++) {
        int sum = c;
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            sum += x * b[j];
        }
        if (sum > 0)ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

bool exist = false;
int ans = 0;

int main(void){
    int n = 0;{
        int k;
        while((k = getchar_unlocked() - '0') >= 0) n = 10 * n + k;
    }
    const int m = n - 1;
    for(int i = 0; i < n; ++i){
        switch(getchar_unlocked()){
            case '2':
                exist = true;
                if((m | i) == m) ans ^= 1; 
                break;
            case '3':
                if((m | i) == m) ans ^= 2;
        }
    }
    if(exist) putchar_unlocked((ans & 1) ? '1' : '0');
    else putchar((ans & 2) ? '2' : '0');
    putchar('\n');
    return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <string>
#include <iostream>

std::string solve(int n) {
  int prev_t { 0 };
  int prev_x { 0 };
  int prev_y { 0 };
  for(int i = 0; i < n; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    const auto dt { t - prev_t };
    const auto dx { abs(x - prev_x) };
    const auto dy { abs(y - prev_y) };
    const auto remaining_time { dt - (dx + dy) };
    if(0 <= remaining_time && remaining_time % 2 == 0) {
      prev_t = t;
      prev_x = x;
      prev_y = y;
    } else {
      return "No";
    }
  }
  return "Yes";
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000010
using namespace std;
struct data
{
    int x,w;
}a[N];
bool cmp(data a,data b)
{
    return a.x<b.x;
}
int n,l,t,sum;
int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].w);
        a[i].w--;
    }
    for(int i=1;i<=n;i++)
    {
        if(!a[i].w)
        {
            a[i].x+=t;
        }else{
            a[i].x-=t;
        }
        sum+=a[i].x/l;
        if(a[i].x%l<0)
        {
            sum--;
        }
        a[i].x=(a[i].x%l+l)%l;
    }
    sort(a+1,a+n+1,cmp);
    sum=(sum%n+n)%n;
    for(int i=sum+1;i<=n;i++)
    {
        printf("%d\n",a[i].x);
    }
    for(int i=1;i<=sum;i++)
    {
        printf("%d\n",a[i].x);
    }
    return 0;
}

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

bool comp(pair<int,int>a,pair<int,int>b){
	return a.second<b.second;
}

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

	pair<int,int>p[n];

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

		p[i].first = a-b;
		p[i].second = a+b;

	}

	sort(p,p+n,comp);
	int curr=INT_MIN,ans=0;
	for (int i=0;i<n;i++){
		if (curr<=p[i].first)
				ans++,curr=p[i].second;

	}
	cout<<ans<<'\n';

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..

const ll MOD = 1000000007;
ll dp[100005];
bool broken[100005];

int main(void) {
  ll n, m;
  cin >> n >> m;
  
  ll a[m];
  rep (i, m) {
    cin >> a[i];
    broken[a[i]] = true;
  }

  rep (i, m - 1) {
    if (a[i] + 1 == a[i + 1]) {
      cout << 0 << endl;
      return 0;
    }
  }

  dp[1] = (broken[1] ? 0 : 1);
  dp[2] = (broken[2] ? 0 : (broken[1] ? 1 : 2));

  for (int i = 3; i <= n; i++) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
  }
  
  cout << dp[n] % MOD<< endl;

  return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);	
		int n= stdin.nextInt();
		int m= stdin.nextInt();
		int x= stdin.nextInt();
		int up=0;
		int down=0;
		int num=0;
		for(int i=0;i<m;i++) {
			num = stdin.nextInt();
			if(num>x) {
				up++;
			}else {
				down++;
			}
			
		}
		if(up<down) {
			System.out.println(up);
		}else {
			System.out.println(down);
		}

		
		


	}

}


Measured memory_bytes: 21844
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = {2,3,5,7,11,13,17,
                   19,23,29,31,37,41,
                   43,47,53,59,61,67,
                   71,73,79,83,89,97};
        int[] pTotal = new int[p.length];
        for(int i = 0; i < p.length; i++) pTotal[i] = legendre(N, p[i]);

        int ans = 0;
        for(int i = 0; i < p.length; i++) {
            if(pTotal[i] >= 74) ans++;
        }

        for(int i = 0; i < p.length; i++) {
            for(int j = 0; j < p.length; j++) {
                if(i != j && pTotal[i] >= 2 && pTotal[j] >= 24)
                    ans++;
            }
        }

        for(int i = 0; i < p.length; i++) {
            for(int j = 0; j < p.length; j++) {
                if(i != j && pTotal[i] >= 4 && pTotal[j] >= 14)
                    ans++;
            }
        }

        int plus = 0;
        for(int i = 0; i < p.length; i++) {
            for(int j = 0; j < p.length; j++) {
                for(int k = 0; k < p.length; k++) {
                    if(i != j && j != k && k != i && pTotal[i] >= 2 && pTotal[j] >= 4 && pTotal[k] >= 4)
                        plus++;
                }
            }
        }

        ans += plus/2;

        System.out.println(ans);
    }

    static int legendre(int n, int p) {
        int c = 0;
        int m = p;
        while(m <= n) {
            c += n / m;
            m *= p;
        }
        return c;
    }
}

Measured memory_bytes: 22996
N, x = map(int,input().split(' '))
all_jar = [int(x) for x in input().split()]
first_jar_candy = all_jar[0]
c = 0
min_opr = 0
for each_jar in all_jar[1:]:
  s = first_jar_candy + each_jar
  c = min(each_jar, max(0, s - x))
  c2 = max(0, s - c - x)
  first_jar_candy = each_jar - c
  min_opr += c + c2
else:
  c += max(0, each_jar - x)
print(min_opr)

Measured memory_bytes: 14252
#include<stdio.h>
#define MAX 500000

void maxHeapify(int A[],int);

int h;

int main(){
    int i;
    int A[MAX];

    scanf("%d",&h);
    for(i=1;i<=h;i++){
        scanf("%d",&A[i]);
    }

    for(i=h/2;i>=1;i--){
        maxHeapify(A,i);
    }

    for(i=1;i<=h;i++){
        printf(" %d",A[i]);
    }
    printf("\n");

    return 0;
}

void maxHeapify(int A[],int i){
    int l,r,largest,tmp;

    l = i*2;
    r = i*2+1;
    if(l<=h && A[l]>A[i]){
        largest = l;
    }else largest = i;

    if(r<=h && A[r]>A[largest]){
        largest = r;
    }
    if(largest!=i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
    maxHeapify(A,largest);
 }
}


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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >>s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;

    return 0;
}

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

int main(){
    string o,e; cin >> o >> e;
    int n = o.size();
    int m = e.size();
    string ans="";
   if(n == m){
       for (int i = 0; i < m; i++){
           ans = ans +o[i]+e[i]; 
       }
   }
   else{
           for (int i = 0; i < m; i++){
           ans = ans +o[i]+e[i]; 
       }
       ans = ans +o[n-1];
   }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node *link;
struct node{int n;  link next; link prev;};
link setLink(link p, link q, int n){
  link x = malloc(sizeof(struct node));
  x->n = n;  x->next = p; x->prev = q;
  if(p!=NULL) p->prev = x;
  return x; 
}

int main(void){
  link head, tail, p, q;
  int n, i, x;
  tail = setLink(NULL, NULL, -1);
  head = setLink(tail, NULL, -1);
  //if(head==tail->prev) printf("same\n");
  //else printf("false\n");
  //head->next = tail; tail->prev = head;
  char com[20];
  char list[4][20] = {"insert", "delete", "deleteFirst", "deleteLast"};
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", com);
    //printf("%s",com);
    if(strcmp(com, list[0])==0){
      scanf("%d",&x);
      head->next = setLink(head->next, head, x);
    }
    else if(strcmp(com, list[1])==0){
      scanf("%d",&x);
      p=head; q = head->next;
      while(q!=tail && q->n != x){
	p = q; q = q->next;
      }
      if(q!=tail){
	p->next = q->next;
	q->next->prev = p;
      }
    }
    else if(strcmp(com, list[2])==0){
      //printf("check 2\n");
      //if(head == NULL) continue;
      head->next = head->next->next;
      head->next->prev = head;
    }
    else if(strcmp(com, list[3])==0){
      //printf("check 3\n");
      tail->prev = tail->prev->prev;
      tail->prev->next = tail;
    }
    //printf("check\n");
    //p=tail; q = tail->prev;
    //while(q!=head){
    //printf("%d->",q->n);
    //p=q; q=q->prev;
    //}
    //printf(".\n");
  }
  
  p=head; q=head->next;
  while(q!=tail){
    printf("%d",q->n);
    p=q;q=q->next;
    if(q==tail) printf("\n");
    else printf(" ");
  } 

  return 0;
}



Measured memory_bytes: 36092
N, K = map(int, input().split())

# N, K = 3, 2

ans = 0
for k in range(K, N+1+1):
    sum_min = k*(k-1)//2
    sum_max = N*k - k*(k-1)//2
    ans += sum_max - sum_min + 1

print(ans%(10**9+7))



Measured memory_bytes: 9180
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
long long a,b,c,d,m;
int main()
{
	cin>>c;
    for(a=1;a<=3500;a++)
        for(b=1;b<=3500;b++)
		{
            d=c*a*b;
            m=4*a*b-c*a-c*b;
            if(m>0&&d%m==0)
            {
            	cout<<a<<" "<<b<<" "<<d/m<<endl;
            	return 0;
			}
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define pshb(a) cin >> x;a.push_back(x)
#define fr(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
    string s , t ,ans ; 
    cin>>s>>t ; 
    ans = t+s ; 
    cout<<ans ; 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long k,n,tmp;
    vector<long long> a,b;
    
    long long dist=0,ac=0; 

    cin >> k >> n;

    for(int i=0;i<n;i++){
        cin >> tmp;
        a.push_back(tmp);
    }
    
    for(int i=0;i<n;i++){
        if(i != n-1) { 
            ac += a[i+1] - a[i]; 
            dist = max(dist, a[i+1] - a[i]);
        }
        else { 
            ac += a[0] + (k-a[i]);
            dist = max(dist, a[0] + (k-a[i]) );
        }
        
    }
    
    cout << ac - dist << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main(void) {
    int P, Q, R;
    cin >> P >> Q >> R;
    if(P < Q) {
        if(Q < R) {
            cout << P + Q << endl;
        } else {
            cout << P + R << endl;
        }
    } else if(P < R) {
        cout << P + Q << endl;
    } else {
        cout << Q + R << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define int long long

using namespace std;

const int N = 3000 + 5;

int dp[N][N];

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string a,b;
    cin >> a >> b;
    a.insert(0, 1, ' ');
    b.insert(0, 1, ' ');
    for(int i = 1;i < a.size(); ++i)
    {
        for(int j = 1;j < b.size(); ++j)
        {
            if(a[i] == b[j])
            {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j-1] + 1);
            }
            else
            {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }
    int x = dp[a.size() - 1][b.size() - 1] + 1;
    string s;
    int ind = b.size() - 1;
    for(int i = a.size() - 1;i >= 1; --i)
    {
        for(int j = ind;j >= 1; --j)
        {
            if(x == dp[i][j]+1 && a[i] == b[j])
            {
                s += a[i];
                x = dp[i][j];
                ind = j-1;
                break;
            }
        }
    }
    reverse(s.begin(), s.end());
    //int x = a.size() - 1, y = b.size() - 1;
    cout << s;
}


Measured memory_bytes: 70784
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    a, b, c, k = map(int, input().split())
    if k <= a:
        print(k)
    elif k<=a+b:
        print(a)
    else:
        print(a-(k-a-b))

resolve()

Measured memory_bytes: 61668
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	char s[8];
	int a, w, t, r;
	a = w = t = r = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%s", s);
		if (s[0] == 'A')
			a++;
		else if (s[0] == 'W')
			w++;
		else if (s[0] == 'T')
			t++;
		else
			r++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, w, t, r);
	return 0;
}

Measured memory_bytes: 1732
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n] <- readInts
  input <- getNLns n
  putStrLn $ solve input

solve :: [String] -> String
solve input = foldl (\a x -> a ++ uncurry replicate x) "" pairs
  where
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    countChar c = foldl' (\a x -> min a $ length $ elemIndices c x) 50 input
    pairs = zip (foldr (\x a -> countChar x : a) [] alphabets) alphabets

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


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

double rtod(double r) {
    return r * 180.0 / acos(-1);
}

void solve() {
    double a, b, x, r;
    cin >> a >> b >> x;
    if(a * a * b < 2 * x) r = atan(2 * (a * a * b - x) / (a * a * a));
    else r = atan(a * b * b / (2 * x));
    printf("%.10lf\n", rtod(r));
}

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


Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

// 入力値のMから選んだ要素を引いていく再帰関数
int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void) {
    int q, M, i;

    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++) {
        scanf("%d", &M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}




Measured memory_bytes: 2092
#include <stdio.h>

int main(){
	int i,imagine=0;
	char S[4];
	
	scanf("%c%c%c%c",&S[0],&S[1],&S[2],&S[3]);
	
	for(i=0;i<4;i++){
		if(S[i]=='+')	imagine++;
		else	imagine--;
	}
	
	printf("%d",imagine);
	
	
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

public class Example {
    public static void Main() {
        int[] arr = new int[100];
        while (true) {
            string str = Console.ReadLine();
            if (null == str) break;
            arr[int.Parse(str)-1]++;
        }
        int max = arr.Max();
        for (int i = 0; i < 100; i++) {
            if (arr[i] == max) {
                Console.WriteLine(i+1);
            }
        }
    }
}

Measured memory_bytes: 9296
s=input()

if 0<int(s[:2])<=12:
    if 0<int(s[2:])<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<int(s[2:])<=12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 9132
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=50;
int n;
char a[N][N];
ll f[N][N][N],s[N][N],ss,ans;
int main(){
	scanf("%d",&n);n*=2;
	fo(i,1,n)scanf("\n%s",a[i]+1),f[i][i][i]=1;
	for(int len=2;len<=n-2;len+=2)
		fo(l,2,n-len){
			int r=l+len;
			fo(j,l,r)fo(k,j,r)s[j][k]=0;
			fo(j,l,r){
				fo(q,j+1,r){
					ss=0;
					fo(k,q,r)if(a[j][k]=='1')ss+=f[q][r][k];
					fo(p,j,q)s[p][q]+=ss*f[l][p][j];
				}
			}
			fo(p,l,r)fo(q,p,r)
				fo(i,p+1,q-1)f[l][r][i]+=s[p][q]*f[p+1][q-1][i];
		}
	fo(i,2,n)if(a[1][i]=='1')ans+=f[2][n][i];
	cout<<ans;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
ll a[1000];
ll b[1000];
ll c[1000];
ll d[1000000];
ll e[3000000];
int compare_int(const void *a, const void *b){
	ll *A = (ll *)a;
	ll *B = (ll *)b;
    if(*A < *B)return 1;
    if(*A > *B)return -1;
    return 0;
}
int main(void){
    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    for(int i = 0;i < x;i++)scanf("%lld", &a[i]);
    for(int i = 0;i < y;i++)scanf("%lld", &b[i]);
    for(int i = 0;i < z;i++)scanf("%lld", &c[i]);
    int num = 0;
    for(int i = 0;i < x;i++)for(int j = 0;j < y;j++){
        d[num] = a[i] + b[j];
        num++;
    }
    qsort(d, x*y, sizeof(ll), compare_int);
    int ma = mi(k, x*y);
    num = 0;
    for(int i = 0;i < ma;i++)for(int j = 0;j < z;j++){
        e[num] = d[i] + c[j];
        num++;
    }
    qsort(e, ma*z, sizeof(ll), compare_int);
    for(int i = 0;i < k;i++)printf("%lld\n", e[i]);
    return 0;
}


Measured memory_bytes: 54920
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct edge{ll from,to,cost;};

int main(void){

  ll n,m;
  cin>>n>>m;

  struct edge es[2001];
  vector<ll> d(1001,INF);
  rep(i,m){
    struct edge e;
    cin>>e.from;
    cin>>e.to;
    cin>>e.cost;
    e.from--;
    e.to--;
    e.cost=-e.cost;
    es[i]=e;
  }

  //d[1]=0;
  d[0]=0;


  rep(cnt,n-1){
    rep(i,m){
      struct edge e=es[i];
      if(d[e.from] == INF) continue;
      if(d[e.to] > d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
      }
    }
  }
  ll ans=d[n-1];
  //rep(i,n+1) d[i]=0;
  vector<bool> neg(1001,false);

  rep(i,n){
    rep(j,m){
      struct edge e=es[j];
      if(d[e.from] == INF) continue;
      if(d[e.to] > d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
        neg[e.to]=true;
      }
      if(neg[e.from] == true) neg[e.to]=true;
    }
  }

  if(neg[n-1] == true) cout << "inf" << endl;
  else cout << -ans << endl;

  return 0;
}


Measured memory_bytes: 256
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    N, M = LI()
    A = [[]for _ in range(M)]
    C = [0]*M
    for i in range(M):
        A[i], b = LI()
        c = LI()
        for j in range(b):
            C[i] += 2**(c[j]-1)
    loop = 2**N
    dp = [[inf]*loop for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for l in range(loop):
            dp[i + 1][l] = min(dp[i + 1][l],dp[i][l])
            next = l|C[i]
            if next==l:
                continue
            dp[i+1][next] = min(dp[i+1][next],dp[i][l] + A[i])
    ans = dp[M][loop-1]
    if ans==inf:
        print(-1)
    else:
        print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examE()

"""

"""

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

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

	int x = stoi(a + b);//Point.

	for(int i = 1; i*i <= x; ++i){
		if(i*i == x){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,i,j,a[];(n=s.nextInt())>0;System.out.println(a[n]/3650+1))for(a=new int[n+3],a[1]=a[2]=a[3]=1,i=0;i<n;++i)for(j=4;j-->1;)a[i+j]+=a[i];}}

Measured memory_bytes: 12000
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s,t = input().split()
a,b = LI()
u = input()
if s == u:
    a -= 1
elif t == u:
    b -= 1
print(a,b)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x;cin>>x>>a>>b;
  string s;
  if(a>=b) s="delicious";
  if(b>a && b<=x+a) s="safe";
  if(b>x+a) s="dangerous";
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int N;
	int flag = 0;
	scanf("%d",&N);
	int t,x,y;
	int time = 0;
	int xt,yt;
	xt = yt = 0;
	while(N--)
	{
		scanf("%d %d %d",&t,&x,&y);
		int ans = t-time;
		time = t;
		int A = xt+yt;
		int B = x+y;
		int len = abs(x-xt)+abs(y-yt);
		if(ans<len)flag = 1;
		else if(A&1)
		{
			if(B&1)
			{
				if(ans&1)flag = 1;
			}
			else if(!ans&1)flag = 1;
		}
		else
		{
			if(B&1)
			{
				if(!ans&1)flag = 1;
			}
			else if(ans&1)flag = 1;
		}
		xt = x;
		yt = y;
	}
	if(flag)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<vector<ll>> dp(N,vector<ll>(N,0));
    rep(j,N) dp[0][j]=1;
    vector<ll> sum(N+1);
    rep(i,N-1){
        sum[0]=0;
        rep(j,N) sum[j+1]=(sum[j]+dp[i][j])%MOD;
        if (S[i]=='<') rep(j,N-i-1) dp[i+1][j]=(dp[i+1][j]+sum[N]-sum[j+1]+MOD)%MOD;
        else rep(j,N-i-1) dp[i+1][j]=(dp[i+1][j]+sum[j+1])%MOD;
    }
    cout << dp[N-1][0] << endl;
}

Measured memory_bytes: 70784
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
    int N, d[110];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }

    sort(d, d + N);
    int counter = 0;
    for (int i = 0; i < N; i++){
        if (d[i] == d[i+1]){
        }
        else counter++;
    }
    cout << counter << endl;
}

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

int main(){
  
  char str[222];
  scanf("%s",str);
  int len = strlen(str);

  for(int i = len-2; i; i -= 2){
    if(strncmp(str, str+i/2, i/2) == 0){
      printf("%d\n",i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 128
INF = 10**10

N, M = map(int, input().split())
costs = []
keys = []
for _ in range(M):
    A, B = map(int, input().split())
    cs = list(map(int, input().split()))
    costs.append(A)
    # 鍵を2進数化する
    key = 0
    for c in cs:
        key |= 1<<(c-1)
    keys.append(key)

# [1]の個数で分類する
maskss = [[] for _ in range(N+1)]
num1s = [0] * (2**N)
for S in range(2**N):
    num = bin(S).count('1')
    maskss[num].append(S)
    num1s[S] = num

dpAll = [INF] * (2**N)
for S in range(2**N):
    for cost, key in zip(costs, keys):
        if S & key == S:
            if cost < dpAll[S]:
                dpAll[S] = cost

dp = [INF] * (2**N)
for S in range(2**N):
    cost = dpAll[S]
    num1 = num1s[S]
    for k in range(1, (num1+1)//2+1):
        for mask in maskss[k]:
            if mask & S == mask:
                m2 = S^mask
                c2 = dp[mask] + dp[m2]
                if c2 < cost:
                    cost = c2
    dp[S] = cost

if dp[2**N-1] == INF:
    print(-1)
else:
    print(dp[2**N-1])


Measured memory_bytes: 47576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> dp(N+1, N);
  dp.at(0) = 0;
  
  vector<int> p(1, 1);
  int s = 1, n = 1;
  while( s <= N) {
    if( n <= N ) p.push_back( n*=9 );
    p.push_back( s*=6 );
  }
  
  for (int i=1; i<=N; i++){
    for (int j=0; j<p.size(); j++){
      if( i - p.at(j) >= 0 ) dp.at(i) = min(dp.at(i), dp.at(i-p.at(j)) + 1 );
    }
  }
  
  cout << dp.at(N) << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll mod=1e9+7;
vector<ll>cnt((ll)1e6+5);
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(0,i,n)cin>>a[i];
    cnt[0]=3;
    ll ans=1;
    rep(0,i,n){
        if(cnt[a[i]]>0){
            ans*=cnt[a[i]];
            ans%=mod;
            --cnt[a[i]];
            ++cnt[a[i]+1];
        }else{
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 11952
#include<stdio.h>

int main()
{
    long int a,b;
    char c;

    scanf("%ld %c %ld",&a,&c,&b);


    switch(c)
    {
    case '+':
        printf("%ld",a+b);
        break;
    default :
        printf("%ld",a-b);
    }

    return 0;

}


Measured memory_bytes: 128
from collections import deque, defaultdict

N, M = map(int, input().split())
nodes = defaultdict(set)
for _ in range(M):
    u, v = map(int, input().split())
    nodes[u].add(v)
    nodes[v].add(u)

visited = [False]*N

def dfs(x, visited, st):
    res = 0
    v = visited.copy()
    v[x-1] = True
    if st == N:
        return 1

    for node in nodes[x]:
        if not v[node-1]:
            res += dfs(node, v, st+1)
    return res

print(dfs(1, visited, 1))


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

long long power(long long x, long long n){
	long long ans = 1;
	while(n){
		if(n&1) ans *= x;
		n >>= 1;
		x *= x;
	}
	return ans;
}

long long Eulers_totient_function(int n){//1からnまでの自然数のnうちと互いに素なものの個数を求める
	int count = 1;
	for(int i = 2; i * i <= n; i++){
		int con = 0;
		while(n%i==0){
			n/= i;
			con++;
		}
		if(con) count *= (power(i,con)-power(i,con-1));
	}
	if(n != 1)count *= (power(n,1)-power(n,0));
	return count;
}



signed main(){
	int n;
	
	cin>>n;
	
	cout<<Eulers_totient_function(n)<<endl;
	
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 1e+8

int main() {
  int w = 0;
  int n = 0;
  while(cin >> w >> n, w) {
    int coins[n];
    int dp[w*10];
    for (int i = 0; i < n; i++) {
      cin >> coins[i];
    }
    dp[0] = 0;
    for (int i = 1; i <= w; i++) {
      for (int j = 0; j < n; j++) {
        if (coins[j] == i) {
          dp[i] = 1;
          goto LE;
        }
      }
      dp[i] = INF;
LE:;
    }
    for (int i = 1; i <= w; i++) {
      if (dp[i] != INF) {
        for (int j = 0; j < n; j++) {
          dp[i + coins[j]] = min(dp[i+coins[j]], dp[i] + 1);
        }
      }
    }
    cout << dp[w] << endl;
    w = 0;
    n = 0;
  }
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10^9

int main(){
    int n;
    string s;
    map<string, int> memo;
    cin >> n;
    rep(i, n){
        cin >> s;
        memo[s] += 1;
    }
    int maxv = 0;
    for(const auto& x : memo){
        int v = x.second;
        if(v > maxv) maxv = v;
    }
    for(const auto& x : memo){
        if(x.second == maxv) cout << x.first << endl;
    }

    return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
        cin >> A;
        cin >> B;
            if(A == 1 || A == 2){
                if(B == 1 || B == 2){
                    cout << 3 << endl;
                }
            }
            if(A == 1 || A == 3){
                if(B == 1 || B == 3){
                    cout << 2 << endl;
                }
            }
            if(A == 3 || A == 2){
                if(B == 3 || B == 2){
                    cout << 1 << endl;
                }
            }
    return 0;
}

Measured memory_bytes: 256
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d" @@ fun a -> a

let () = print_endline @@ if Array.for_all (fun i -> i mod 2 = 0) a then "second" else "first"

Measured memory_bytes: 6628
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int mark(char m) {
    if (m == 'S') return 0;
    else if (m == 'H') return 1;
    else if (m == 'C') return 2;
    else if (m == 'D') return 3;
}

int main(int n) {
    cin >> n;
    char M[4] = {'S','H','C','D'};
    int T[4][13] = {};
    int a;
    char m;
    for (int i = 0; i < n; i++) {
        cin >> m >> a;
        T[mark(m)][a-1] += a;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j <= 12; j++) {
            if (T[i][j] == 0) cout << M[i] << " " << j+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0,k=100;
    cin>>n;
    while(1){
        if(k>=n){
            break;
        }
        k*=1.01;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644