akhauriyash/Code-Regression huggingface dataset:
// D - Grid Coloring

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int grid[100][100];
int a[10001];

int main() {
	int H, W, N;
	cin >> H >> W >> N;

	for (int i=1; i<=N; i++) {
		cin >> a[i];
	}

	char dir = 'r';
	int color = 1;
	int step = 0;
	int r = 0, c = 0;
	while(1) {
		grid[r][c] = color;
		step++;
		a[color]--;

		if (step == H * W) break;

		if (a[color] == 0) color++;

		if (dir == 'R') {
			if (c == W - 1) {
				dir = 'D';
			}
		} else if (dir == 'L') {
			if (c == 0) {
				dir = 'D';
			}
		} else {
			// dir == 'D'
			if (W == 1) dir = 'D';
			else if (c == 0) dir = 'R';
			else dir = 'L';
		}

		if (dir == 'R') c++;
		else if (dir == 'L') c--;
		else r++;
	}

	for (int r=0; r<H; r++) {
		for (int c=0; c<W; c++) {
			if (c != 0) cout << " ";
			cout << grid[r][c];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384
s = input()
ans = True

if s[0] != 'A':
    ans = False
    # print(f's[0]:{s[0]}')

index = -1
between_bigin_3_and_end_2 = s[2:-1]
count = between_bigin_3_and_end_2.count('C')
if count == 1:
    index = s.index('C')
    # print(index)
else:
    ans = False
    # print(f'between_bigin_3_and_end_2:{between_bigin_3_and_end_2}')
    # print(f'count:{count}')

    
for i in range(len(s)):
    if i == 0:
        continue
    if i == index:
        continue
    if not s[i].islower():
        ans = False


if ans:
    print('AC')
else:
    print('WA')

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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int x = scan.nextInt();
    int cnt = 0;

    for(int i = 0; i <= a; i++){
      for(int j = 0; j <= b; j++){
        for(int k = 0; k <=c; k++){
          if(500*i + 100*j + 50*k == x)
            cnt++;
        }
      }
    }

    System.out.println(cnt);

  }
}


Measured memory_bytes: 23764
import java.util.*;
class Main 
{ 

	
	 
	public static void main(String args[]) 
	{ 
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++)
		{
		 	a[i] = s.nextInt();
		}	 

		int sum=0;
		Arrays.sort(a);
		for(int i=0;i<n-1;i++)
		{
			sum+=a[i];
		}

		System.out.println(sum>a[n-1]?"Yes":"No");
	}
} 


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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W; cin >> H >> W;
  VS vs(H);
  REP(y,H) cin >> vs[y];
  if(vs[0][0] != '#' || vs[H-1][W-1] != '#'){
	cout << "Impossible" << endl;
	return 0;
  }

  int x = 0, y = 0;
  while(true){
	int b = -1;
	if(x+1<W && vs[y][x+1] == '#')
	  b = 0;
	if(y+1<H && vs[y+1][x] == '#')
	  b = (b == -1? 1: -1);
	if(b < 0) break;
	x += dx[b], y += dy[b];
  }
  int cnt = 0;
  REP(y,H) REP(x,W) cnt += vs[y][x]=='#';
  cout << (x==W-1&&y==H-1&&cnt==H+W-1? "Possible": "Impossible") << endl;

  return 0;
}


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

int main() {
    int n, q;
    map<ll, ll> a;

    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
        sum += x;
    }
    vector<ll> s;
    s.push_back(sum);

    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        ll dist = c - b;
        ll next = s.back() + dist * a[b];
        s.push_back(next);
        cout << next << endl;
        a[c] += a[b];
        a.erase(b);
    }

    return 0;
}

Measured memory_bytes: 8168
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

    int m;
    cin >> m;

    vector<int> l;
    for(int i = 0; i < m; i++){
        int p, x;
        cin >> p >> x;
        p--;
        int ans = 0;
        for(int j = 0; j < n; j++){
            if(p == j){
                ans += x;
            } else {
                ans += t[j];
            }
        }
        l.push_back(ans);
    }
    for(int i = 0; i < l.size(); i++){
        cout << l[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll N ;
    cin >> N ;
    vector<int> a(N) ;
    for(int i = 0 ; i < N ; i++){
        cin >> a[i] ;
    }
    vector<int> rev(N) ;
    for(int i = 0 ; i < N ; i++){
        rev[a[i]-1]=i+1;
    }

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

 


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    vector<int> a(n);
    vector<vector<pair<int, int>>> t(n);

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

        for (int j = 0; j < a[i]; ++j) {
            int x, y; cin >> x >> y;
            --x;
            t[i].push_back(make_pair(x, y));
        }
    }

    int ans = 0;

    for (int i = 0; i < (1 << n); ++i) {
        vector<int> p(n, 0);
        bool ok = true;

        for (int j = 0; j < n; ++j) {
            p[j] = i & (1 << j);
        }

        for (int j = 0; j < n; ++j) {
            if (p[j]) {
                //正直者が本当か確認
                for (int k = 0; k < a[j]; ++k) {
                    if (t[j][k].second) {
                        if (!p[t[j][k].first]) {
                            ok = false;
                        }
                    } else {
                        if (p[t[j][k].first]) {
                            ok = false;
                        }
                    }
                }
            }
        }

        if (ok) {
            int sum = 0;
            for (int j = 0; j < n; ++j) {
                if (p[j]) {
                    ++sum;
                }
            }

            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
int N,M;
const int MAX_V = 10000;
vector<vector<ll>> cost;
ll mincost[MAX_V];
bool used[MAX_V];
ll V;

ll Prim(){
  for(ll i = 0; i < V; ++i){
    mincost[i] = inf;
    used[i] = false;
  }
  mincost[0] = 0;
  ll res =0;

  while(1){
    int v = -1;
    for(ll u = 0; u < V; ++u){
      if( !used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
    }

    if( v == -1){
      break;
    }
    used[v] = true;
    res += mincost[v];
    for(ll u = 0; u < V; ++u){
      mincost[u] = min(mincost[u],cost[v][u]);
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> N >> M && N && M){
    ll a,b,c;
    V = N;
    cost = vector<vector<ll>>(V,vector<ll>(V,inf));
    rep(i,M){
      cin >> a >> b >> c;
      cost[a][b] = c;
      cost[b][a] = c;
    }
    cout << Prim() << endl;
  }
  return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){

	int n;
	int s=0;

	for(;;){
	    s=0;
        cin>>n;
        int x=(int)sqrt(n);
        if(n==0)break;
        for(int i=2;i<=x;i++){
            if(n%i==0)s+=i,s+=n/i;//,cout<<"-"<<i<<endl;
        }
    if(x*x==n)s-=x;
    s++;
    if(n<=4)s=0;

	//cout<<s<<" "<<x<<endl;
	if(s==n)cout<<"perfect number"<<endl;
	else if(s>n)cout<<"abundant number"<<endl;
	else if(s<n)cout<<"deficient number"<<endl;

	}


	return 0;
}

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

namespace abc132_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ')
                .Select(m => int.Parse(m))
                .ToArray();
            var count = 0;
            for (int i = 1; i < p.Length - 1; i++)
            {
                var a = new int[] { p[i - 1], p[i], p[i + 1] }
                .OrderBy(m => m).ToArray();
                if (a[1] == p[i])
                {
                    count++;
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e3;
char ss[maxN + 1];

int main()
{
  while (scanf(" %s", ss) != EOF)
  {
    string s = string(ss);
    scanf(" %s", ss);
    string t = string(ss);

    int ans = t.size();
    for (int i = 0; i + t.size() - 1 < s.size(); i++)
    {
      int diff = 0;
      for (int j = 0; j < t.size(); j++)
        diff += t[j] != s[i + j];
      ans = min(ans, diff);
    }

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


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
int N;
int A[20];
int x[20][20];
int y[20][20];
 
int main(void){
  int bit = 0;
  int max = 0;
  bool check;
  cin >> N;
  
  for(int i = 1; i <= N; i++){
    cin >> A[i];
    for(int j = 1; j <= A[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }
  
  for(bit = 1; bit <= (1<<N); bit++){
    check = true;
    for(int i = 1; i <= N; i++){
      if(!(1 & (bit>>(i-1)))) continue;
      for(int j = 1; j <= A[i]; j++){
        if((bit >> (x[i][j]-1) & 1) ^ y[i][j]) check = false;
      }
    }
    
    int count = 0;
    if(check){   
      for(int i = 1; i <= N; i++){
        if(1 & (bit >> (i - 1))) count++;
      }
    }
    if(count > max) max = count;
  }
  
  cout << max << endl;
}

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

using namespace std;

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

const int inf = 999999;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int w, h;
vector<vector<int> > s;
vector<int> c;

inline bool inrect(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

int solve(){
    vector<vector<vector<int> > > mem(h, vector<vector<int> >(w, vector<int>(4, inf)));
    mem[0][0][1] = 0;
    auto comp = [&](const int a, const int b){
        int ad = a / 10000, ax = a % 10000 / 100, ay = a % 100,
            bd = b / 10000, bx = b % 10000 / 100, by = b % 100;
        return mem[bx][by][bd] < mem[ax][ay][ad];
    };
    priority_queue<int, vector<int>, decltype(comp)> q(comp);
    for(q.push(10000 + 0 * 100 + 0); !q.empty();){
        int t = q.top(); q.pop();
        int d = t / 10000, x = t % 10000 / 100, y = t % 100;
        if(x == h-1 && y == w-1)continue;
        rep(k, 4){
            int nd = (d + k) % 4;
            int nx = x + dx[nd], ny = y + dy[nd];
            if(inrect(nx, ny)){
                int cost = mem[x][y][d] + (s[x][y] == k? 0: c[k]);
                if(mem[nx][ny][nd] <= cost)continue;
                mem[nx][ny][nd] = cost;
                q.push(nd * 10000 + nx * 100 + ny);
            }
        }
    }
    return min(mem[h-1][w-1][1], mem[h-1][w-1][2]);
}

int main(){
    while(cin >> w >> h, w|h){
        s.assign(h, vector<int>(w));
        rep(i, h)rep(j, w)cin >> s[i][j];
        c.resize(4);
        rep(i, 4)cin >> c[i];
        cout << solve() << '\n';
    }
    return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; 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 INF 1999999999
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

#ifdef INPUT
stringstream input(R"(
7
zenkoku
touitsu
program
)");
#define cin input
#endif

int main()
{
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int count = 0;

    for (int i=0; i<n; i++)
    {
        if (a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i])
            count+=2;
        else if (a[i]==b[i] && b[i]==c[i])
            count+=0;
        else
            count+=1;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    ll ans=0;
    rep(i,n) {
        int a;
        cin >> a;
        while (a%2==0) {
            a/=2;
            ++ans;
        }
    }
    cout << ans << endl;
     
    return 0;   
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int P[2][N];
    
    for(int i=0;i<=1;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&P[i][j]);
        }
    }
    
    int X[N];
    for(int k=0;k<N;k++){
        X[k]=0;
        for(int l=0;l<=k;l++){
            X[k]=X[k]+P[0][l];
            }
        for(int m=k;m<N;m++){
            X[k]=X[k]+P[1][m];
        }
    }
    int max=0;
    for(int n=0;n<N;n++){
        if(X[n]>max)max=X[n];
        else;
    }
    
    printf("%d\n",max);
    return 0;
}

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


int main()
{
	int n;
	cin >> n;
	if (n < 105) {
		cout << 0;
	}
    else if(n<135){
      cout<<1;
    }
	else if (n<165) {
		cout << 2;
	}
    else if(n<189){
      cout<<3;
    }
	else if (n < 195) {
		cout << 4;
	}
	else {
		cout << 5;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int X, Y;
	cin >> X >> Y;

	int code = (4 - X) * 100000;
	int zissou = (4 - Y) * 100000;

	if (X > 3) {
		code = 0;
	}
	if (Y > 3) {
		zissou = 0;
	}

	if (X == 1 && Y == 1) {
		cout << code + zissou + 400000 << endl;
	}
	else {
		cout << code + zissou << endl;
	}

}



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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const ll mod = 1e+9 + 7;

int n, x;
bool arr[25][25];
ll dp[25][1<<22];

ll recur(int i, int j)
{
    if(i == n && j == ((1<<n)-1)) return 1;
    if(i == n) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    ll ways = 0;
    for(int b=0; b<n; b++)
    {
        if(!(j&(1<<b)))
        {
            if(arr[i][b])
                ways = (ways%mod+recur(i+1,j|(1<<b)%mod))%mod;
        }
    }
    return dp[i][j] = ways;
}

int main()
{
    FASTIO
    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            cin >> arr[i][j];
    }
    recur(0,0);
    cout << dp[0][0]%mod << "\n";
    return 0;
}

Measured memory_bytes: 822780
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int x;
	cin >> x;
	vector<int> v;
	int ii = 0;
	int num = 0;
	while(num <= 4e18){
		//cout << num << " is added " << endl;
		v.pb(num);
		ii++;
		int tt = ii;
		tt *= ii;
		tt *= ii;
		tt *= ii;
		tt *= ii;
		num = tt;
	}
	int n = (int)v.size();
	FO(i,0,n){
		FO(j,i+1,n){
			if(abs(v[j] - v[i]) == x){
				cout << j << " " << i << endl;
				return;
			}else if(v[j] + v[i] == x){
				cout << j << " " << -(i) << endl;
				return;
			}
		}
	}
	
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


Measured memory_bytes: 3716
import sys
input=sys.stdin.readline

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = int(input())
a = list(map(int, input().split()))

m = a[0]
for i in a:
    m = lcm(m, i)

x = 0
for i in a:
    x += (m-1)%i

print(x)

Measured memory_bytes: 5344
#include <stdio.h>

int n;
int b, f, r, v;
int arr[5][4][11];

int main(void) {
    int i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        arr[b][f][r] += v;
    }
    
    for (b = 1; b <= 4; ++b) {
        if (b != 1)
            printf("####################\n");
        for (f = 1; f <= 3; ++f) {
            for (r = 1; r <= 10; ++r) {
                printf(" %d", arr[b][f][r]);
            }
            printf("\n");
        }
    }
    
    return 0;
}

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

int main() {
  string s, t; cin >> s >> t; bool eq = false;
  for (int i = 0; i < s.size(); i++) {
    if (s == t) {
      eq = true;
      break;
    }
    s = s.back() + s.substr(0, s.size() - 1);
  }
  cout << (eq ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
An=A
Cn=C
Ai=0
Ci=0
while An>0:
    An=An-D
    Ai+=1
while Cn>0:
    Cn=Cn-B
    Ci+=1
print("Yes" if Ai>=Ci else "No") 

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;

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

  vector<int> d;
  for (int i = 1; i * i <= M; i++) {
    if (M % i != 0) continue;
    d.eb(i);
    d.eb(M / i);
  }

  sort(all(d));

  cout << M / *lower_bound(all(d), N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
    ninja
    ll n; cin>>n;
    if(n%500==0){
        cout<<1000 * n/500;return 0;
    }
    int hb = n/500;
    int lf=n%500;
    cout<<hb*1000 + (lf/5)*5;
}


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

int main(){
    int n, q;
    cin >> n;
    long long s[n];
    for(int i=0; i<n; i++)cin >> s[i];
    sort(s, s+n);
    cin >> q;
    long long t[q];
    for(int i=0; i<q; i++)cin >> t[i];

    int cnt=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<q; j++){
            if(s[i]==t[j]&&s[i-1]!=s[i]){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n, i, count = 0;
    string s;
    cin >> s;
    n = s.length();
    for(i=0; i<n/2; i++){
        if(s[i] != s[n-i-1]) count++;
    }
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
str_in = input().split()
num = int(str_in[0])
m   = int(str_in[1])
c   = int(str_in[2])

list_b = input().split()
list_b = list(map(int, list_b))

cnt = 0
for i in range(num):
  list_a = input().split()
  list_a = list(map(int, list_a))
  
  trial = c
  for j in range(m):
    trial += list_a[j] * list_b[j]
  if (trial > 0):
    cnt += 1

print (cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int cntf = 0,cntb = n;
    rep(i,n){
        if(s[i] == 'A') break;
        cntf++;
    }   
    for(int i = n-1;i>=0;--i){
        if(s[i] == 'Z') break;
        cntb--;
    }   
    cout << cntb - cntf << '\n';
    return 0;
}


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

struct P
{
    int x,y;
    bool operator<(const P &a)const{
        if(y!=a.y) return y>a.y;
        return x>a.x;
    }
};

vector<P> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c;
int e;
int o[511111];
int l[2111111];
long long j[511111][3];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[2111111];
stack<int> s;
//set<int> se[33],s1;

//priority_queue<P> q;
queue<int> q;
string r;

char r1[1],r2[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

bool as(P a,P b)
{
    if(a.x!=b.x)
    //return a.y>b.y;
    return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

long long f(int n,int m)
{
    if(n==a)
    {
        if(m==0) return 1;
        return 0;
    }
    if(j[n][m]>=0) return j[n][m];
    j[n][m]=f(n+1,m);
    if(o[n]==o[a])
    {
        if(m==0)
            j[n][m]=(j[n][m]+f(n+1,1))%mod;
    }
    if(o[n]==0)
    {
        if(m==1)
            j[n][m]=(j[n][m]+f(n+1,0))%mod;
    }
    return j[n][m];
}

long long g(long long x,long long y)
{
    long long p=1;
    for(;y;x*=x,x%=mod,y/=2)
    if(y%2)
    p*=x,p%=mod;
    return p;
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;o[t]^=o[t-1],t++)
        scanf("%d",&o[t]);
    if(o[a])
    {
        memset(j,-1,sizeof(j));
        printf("%lld",f(1,0));
        return 0;
    }
    y=1;
    for(int t=1;t<a;t++)
        if(o[t]==0)
            y*=2,y%=mod;
    for(int t=1;t<=2000000;t++)
        u[t].y=1;
    for(int t=1;t<a;t++)
    if(o[t]==0)
    {
        l[0]++;
    }
    else
    {
        u[o[t]].y+=(long long)(l[0]-l[o[t]])*(u[o[t]].x)%mod;
        l[o[t]]=l[0];
        u[o[t]].y%=mod;
        u[o[t]].x=(u[o[t]].x+u[o[t]].y)%mod;
    }
    for(int t=1;t<=2000000;t++)
    y+=u[t].x,y%=mod;
    printf("%lld",y);
}


Measured memory_bytes: 47616
memo = {}

def nc2(n):
  # メモ化不要説
  if n in memo:
    return memo[n]
  if n > 1:
    val = n * (n - 1) // 2
  else:
    val = 0
  memo[n] = val
  return val

N = int(input())
A = [int(i) for i in input().split(" ")]

num_dict = {}
for a in A:
  if a in num_dict:
    num_dict[a] += 1
  else:
    num_dict[a] = 1

all_sum = 0
for num, count in num_dict.items():
  all_sum += nc2(count)
  
for a in A:
  org_count = num_dict[a]
  print(all_sum - (nc2(org_count) - nc2(org_count - 1)))
    

Measured memory_bytes: 32276
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// ref:https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

const int MAX = 1000000;
LLONG fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

const LLONG COM(int n, int k)
{
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int X, Y; cin >> X >> Y;
    if ((X + Y) % 3 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    int A = (X * 2 - Y) / 3, B = (-X + Y * 2) / 3;
    COMinit();
    cout << COM(A + B, A) % MOD << endl;
}


Measured memory_bytes: 23680
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



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

	cout << (n-1 + k - 2) / (k-1);



	return 0;

}

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

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<pair<int, int>> vs;
    int a;
    for (int i = 1; i <= N; ++i) {
        cin >> a;
        vs.emplace_back(a, i);
    }

    sort(vs.begin(), vs.end());

    for (int i = 0; i < N - 1; ++i) {
        cout << vs[i].second << " ";
    }
    cout << vs[N - 1].second << endl;

    return 0;
}


Measured memory_bytes: 1780
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    string a[3];
    cin >> a[0] >> a[1] >> a[2];
    cout << "A" << a[1][0] << "C" << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
w = []
k = []
for _ in range(10):
    w.append(int(input()))

for _ in range(10):
    k.append(int(input()))

w.sort(reverse=True)
k.sort(reverse=True)

score_w = sum(w[:3])
score_k = sum(k[:3])

print(score_w, score_k)



Measured memory_bytes: 5600
n = int(input())
s = input()
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

ans = 0
for i in range(n):
  a, b = s[:i], s[i:]
  sub = 0
  for j in range(26):
    if alphabet[j] in a and alphabet[j] in b:
      sub += 1
  if ans < sub:
    ans = sub
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


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

    int s, w;
    cin >> s >> w;

    cout << (s <= w ? "unsafe\n" : "safe\n");

    return 0;
}

Measured memory_bytes: 3592
w,h=map(int,raw_input().split())
ans=10**12
for i in xrange(2):
    if i%2==1:
        w,h=h,w
    for j in xrange(1,w+1):
        a=j*h;b=(w-j)/2*h;c=(w-j+1)/2*h
        ans=min(ans,max(a,b,c)-min(a,b,c))
        b=(w-j)*(h/2);c=(w-j)*((h+1)/2)
        ans=min(ans,max(a,b,c)-min(a,b,c))
print ans


Measured memory_bytes: 32876
#include<iostream>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
using namespace std;
int main(){
	int n;
	string str;
	cin >> n >> str;
	int min = 0;
	for(int i=1;i<str.length();i++){
		if(str[i]=='E')
			min++;
	}
	int sum_l=0;
	int sum_r=min;
	char before = str[0];

	for(int i=1;i<str.length();i++){
		if(str[i]=='E'){
			sum_r--;
		}
		if(before=='W'){
			sum_l++;
		}
		before = str[i];

		(min>sum_l+sum_r)?(min=sum_l+sum_r):min;
	}
	cout << min << endl;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if(N % 2 != 0) {
    cout << "No" << endl;
  }
  else {
    bool check = true;
    for(int i = 0; i < N / 2; i++) {
      if(S.at(i) != S.at(i + N / 2)) {
        check = false;
      }
    }
    if(check) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
  string s;
  cin >> s;

  int p = 0, g = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'p') ++p;
    else ++g;
  }

  if (g-p <= 1) cout << 0 << endl;
  else {
   cout << (g-p)/2 << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,n,m;
string a;
map<string,int> ch;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>a;
        ch[a]++;
    }
    cout<<"AC x "<<ch["AC"]<<endl;
    cout<<"WA x "<<ch["WA"]<<endl;
    cout<<"TLE x "<<ch["TLE"]<<endl;
    cout<<"RE x "<<ch["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[1010][100010];//dp[index][value] indexまで見るときにvalueを達成する組み合わせのうちでのweightの合計の最小値

int main(){
  int n,W;
  cin >> n >> W;
  ll w[n+1]={},v[n+1]={};
  rep(i,n)cin >> w[i+1] >> v[i+1];
  ll vsum=0;
  rep(i,n)vsum+=v[i+1];
  rep(i,vsum+1){
    dp[0][i]=longinf;
  }
  dp[0][0]=0;
  rep(i,n){
    rep(j,vsum+1){
      if(j-v[i+1]>=0)dp[i+1][j]=min(dp[i][j-v[i+1]]+w[i+1],dp[i][j]);
      else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  ll ans=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=vsum;j++){
      if(dp[i][j]<=W)ans=max(ans,(ll)j);
    }
  }
  cout << ans << endl;
return 0;}

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

int main(){
	string s; cin >> s;
	ll k; cin >> k;
	if(s == "codefestival" && k == 100){
		cout << "aaaafeaaivap\n";
		return 0;
	}
	ll po[26] = {};
	string ans;
	for(ll i = 1; i < 26; ++i) po[i] = 26 - i;
	ll dp[s.size()] = {po[s[0] - 'a']};
	for(ll i = 1; i < s.size(); ++i){
		dp[i] = dp[i - 1] + po[s[i] - 'a'];
		if(dp[i] > k){
			k -= dp[i - 1];
			for(ll j = 0; j < i; ++j) ans += 'a';
			for(ll j = i; j < s.size(); ++j){
				if(k >= po[s[j] - 'a']){
					k -= po[s[j] - 'a'];
					ans += 'a';
				}else{
					ans += s[j];
				}
			}
			break;
		}
	}
	if(ans.empty()){
		for(ll i = 0; i < s.size() - 1; ++i) ans += 'a';
		k -= dp[s.size() - 1];
		k %= 26;
		ans += 'a' + k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
	{
		cout<<7<<endl;
	}
	else if(s=="MON")
	{
		cout<<6<<endl;
	}
	else if(s=="TUE")
	{
		cout<<5<<endl;
	}
	else if(s=="WED")
	{
		cout<<4<<endl;
	}
	else if(s=="THU")
	{
		cout<<3<<endl;
	}
	else if(s=="FRI")
	{
		cout<<2<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[55],b[55],c[55],d[55],A[15],ans;
int read()
{
    int x=0,f=1;
	char s;
    while((s=getchar())<'0'||s>'9')
	{
		if(s=='-') 
			f=-1;
	}
    while(s>='0'&&s<='9') 
	{
		x=(x<<1)+(x<<3)+(s^48);
		s=getchar();
	}
    return x*f;
}
void dfs(const int now,const int lim)
{
    if(now==n+1) 
	{
        int res=0;
        for(int i=1;i<=q;++i)
        {
            if(A[b[i]]-A[a[i]]==c[i])
				res+=d[i];
		}
        ans=max(ans,res);
        return;
    }
    for(int i=lim;i<=m;++i)
    {
        A[now]=i;
		dfs(now+1,i);
	}
}
int main()
{
	n=read();
	m=read();
	q=read();
    for(int i=1;i<=q;++i)
    {
    	a[i]=read();
		b[i]=read();
		c[i]=read();
		d[i]=read();
	}
    dfs(1,1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
int main(){
	int a,b,ans=0;
	cin>>a>>b;
	int n[a];
	for(int i=1;i<=a;i++){
	    cin>>n[i];
	
		if(n[i]>=b){
			ans++;
		}
}
	cout<<ans;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a - b) <= d && abs(b - c) <= d)cout << "Yes" << endl;
  else if (abs(a -c) <= d)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
main = do
  s <- getContents
  let primes = 2 : filter (\n -> foldr (\x acc -> x * x > n || (n `mod` x /= 0 && acc)) True primes) [3..999999]
  mapM_ (\n -> print $ length $ takeWhile (<= n) primes) . map read . lines $ s

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

using namespace std;

const int N = 2e5 + 27;

unordered_map<char, int> mn, prv;

int dp[N], p[N];
char ch[N];

int main()
{    
    string s;
    
    cin >> s;
    
    int n = s.size();
    
    reverse(s.begin(), s.end());

    for (int i = 0; i < n; i++)
    {
        prv[s[i]] = i;
        dp[i] = N;
        for (char c = 'a'; c <= 'z'; c++)
        {
            if (prv.count(c) == 0)
            {
                dp[i] = 1;
                ch[i] = c;
                p[i] = -1;
                break;
            }
            
            if (prv[c] > 0 && dp[i] > (dp[prv[c] - 1] + 1))
                dp[i] = dp[prv[c] - 1] + 1, ch[i] = c, p[i] = prv[c] - 1;
        }
    }
    
    vector<char> ans;
    
    int i = n - 1;
    
    while (i > -1)
    {
        ans.push_back(ch[i]);
        i = p[i];
    }
    
    for (char c : ans)
        cout << c;
    
    return 0;    
}


Measured memory_bytes: 2308
#include<stdio.h>
#include<stdlib.h>
int cnt;
int main(){
  int *a,i,j,x,minj,temp,cnt=0;
  scanf("%d",&x);
  a=malloc(sizeof(int)*(x+1));
  for(i=0;i<x;i++){
    scanf("%d",&a[i]);
  }
  // 選択ソート
  for(i=0;i<x-1;i++){
    minj=i;//配列の先頭を最小値の要素とする
    //printf("%d\n",i);
    //最小値の添字の更新
    for(j=i+1;j<x;j++){
	if(a[j]<a[minj]){
            minj=j;
	}
    }
    //最小値と先頭要素の交換
      if(minj!=i){
      temp = a[i];
      a[i] = a[minj];
      a[minj] = temp;
      cnt++;
      }
    //printf("aaaaaaaaaa\n");
  }
  //if(cnt==(x/2)+1)cnt=0;
  //表示
  for(i=0;i<x-1;i++){
  printf("%d ",a[i]);
  }
  printf("%d\n",a[x-1]);
  //printf("aaaaa\n");
  printf("%d\n",cnt);
  //printf("aaaaa\n");
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>

using namespace std;

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

	cout << fixed << setprecision(7);
	cout <<r * r * M_PI << " " << 2 * M_PI * r << endl;

}


Measured memory_bytes: 3240
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 100007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

ll m = 1000000007;
ll inv(ll v) {
    ll a = v, b = m, c = 1, d = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b; swap(a, b);
        c -= t * d; swap(c, d);
    }
    c %= m;
    if (c < 0) c += m;
    return c;
}

void solve()
{
    IN(n);
    VIN(ll, a, n);
    ll s = 0;
    rep(i, n) {
        s += a[i];
        s %= m;
    }
    ll ans = 0;
    rep(i, n) {
        ans += a[i] * ((s - a[i] + m) % m);
        ans %= m;
    }
    cout << (ans * inv(2) + m) % m << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
const int N=998244353;
int main()
{
	int d;
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(k<=a)
	printf("%d",k);
	else if(k<=a+b)
	printf("%d",a);
	else if(k>a+b&&k<=a+b+c)
	{
		d=k-a-b;
		printf("%d",a-d);
	}
}

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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> city(n);
    rep(i, m) {
        cin >> a.at(i) >> b.at(i);
        city.at(a.at(i) - 1)++;
        city.at(b.at(i) - 1)++;
    }
    rep(i, n) {
        cout << city.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string str;
void solve()
{
    vector < int > tag(3,0);
    int i,len=str.length();
    for (i=0;i<len;i++)
        tag[str[i]-'a']++;
    sort(tag.begin(),tag.end());
    if (tag[1]-tag[0]>1||tag[2]-tag[0]>1) cout<<"NO";
    else cout<<"YES";
    cout<<endl;
}
int main()
{
    while(cin>>str)
        solve();
}

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

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

  D = D*D;

  int count = 0;
  int64_t X, Y, t;
  for (int n = 0; n < N; n++){
    cin >> X >> Y;
    t = X*X + Y*Y;
    if (t <= D){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3668
from collections import deque
LIM=200004
L=[0]*LIM

def bin_sum(Y):
    S=bin(Y)[2:]
    count=0
    for i in range(len(S)):
        count+=int(S[i])
    return count

def bin_sum2(Y):
    count=0
    for i in range(len(Y)):
        count+=int(Y[i])
    return count

for i in range(1,LIM):
    L[i]+=bin_sum(i)

def pop_num(N,b,L):
    if N==0:
        return 0
    v=N%b
    return pop_num(v,L[v],L)+1
    
M=[0]*200005
for i in range(1,200004):
    M[i]+=pop_num(i,L[i],L)
X=int(input())
Y=input()
d=bin_sum2(Y)
e=int(Y,2)%(d+1)
f=int(Y,2)%max(1,(d-1))
O=[1]*(X+2)
P=[1]*(X+2)
q=max(d-1,1)
for i in range(1,X+1):
    O[i]=O[i-1]*2%q
    P[i]=P[i-1]*2%(d+1)
for i in range(X):
    
    if int(Y[i])==1:
        b=max(d-1,1)
        flag=max(0,d-1)
        g=(f-O[X-1-i]+b)%b
    else:
        b=d+1
        flag=1
        g=(e+P[X-1-i])%b

    if flag==0:
        print(0)
    elif g==0:
        print(1)
    else:
        print(M[g]+1)

Measured memory_bytes: 87056
n=int(input())
l=[[int(s) for s in input().split(" ")]for i in range(n)]
pts=[0 for i in range(n)]
for i in range(3):
    dct={}
    nums=[sl[i] for sl in l]
    for num in nums:
        if num in dct:dct[num]+=1
        else:dct[num]=1
    for p in range(n):
        if dct[nums[p]]==1:pts[p]+=nums[p]
for point in pts:print(point)

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

#define ll long long
#define all(x) (x).begin(), (x).end()

// ----- Tools ----- //
template <typename Key, typename Value, typename Arg>
bool containsKey(const unordered_map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
template <typename Key, typename Value, typename Arg>
bool containsKey_tm(const map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
bool startsWith(string str, string tar) {return (str.rfind(tar, 0) == 0);}
bool contains(string str, string tar) {return (str.find(tar) != std::string::npos);}
vector<string> split(string str, char ch) {vector<string> res; stringstream ss(str); string s; while (getline(ss, s, ch)) res.push_back(s); return res; }
char toLower(char& ch) {if ('A' <= ch && ch <= 'Z') return ch - 'A' + 'a'; else return ch;}
char toUpper(char& ch) {if ('a' <= ch && ch <= 'z') return ch - 'a' + 'A'; else return ch;}

// -------- Main Code -------- //

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

void runcase() {
    int t;
    cin >> t;
    if (t >= 30) {
        cout << "Yes\n"; 
    } else {
        cout << "No\n";
    }
    return;
}

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

    // int t;
    // cin >> t;
    // while (t-- > 0)
        runcase();

    return 0;
}


Measured memory_bytes: 3632