akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MAXN = 500010;

int deg[MAXN];
int far[MAXN];
int pre[MAXN << 1], to[MAXN << 1], head[MAXN], wcnt;
int q[MAXN], ql, qr;
inline void addedge(int u, int v) {
    wcnt++;
    pre[wcnt]=head[u];
    head[u]=wcnt;
    to[wcnt]=v;
  int qwq=1;
}
int n,m,u,v;
int main() {
	int a=9;
    scanf("%d %d", &n, &m);
    a++;
    for(int i=1; i<=n-1+m; i++){
        scanf("%d %d", &u, &v);
        deg[v]++;
        addedge(u, v);
        a--;
    }
    a=a*2;
    ql=1;
    qr=0;
    a++;
    for(int i=1; i<=n; i++) if(!deg[i]) q[++qr]=i;
    while(ql<=qr){
        u=q[ql++];
        for(int i=head[u]; i; i=pre[i]){
            deg[v=to[i]]--;
            far[v]=u;
            if(!deg[v]){
                q[++qr]=v;
                a+=a*2;
            }
        }
    }
    for(int i=1; i<=n; i++) printf("%d\n", far[i]);
    a=1;
    return 0;
}

Measured memory_bytes: 13440
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	vector< int > H(N);
	rep(i, N) cin >> H[i];
	int ans = 0;
	sort(H.begin(), H.end());
	rep(i, N - K) ans += H[i];
	cout << ans << endl;
	return 0;
}

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

const ll MOD = 998244353;

ll DP[3030][3030];

//A の部分集合 T、Tの部分集合U で数える
int main(){
  int N, S;
  cin >> N >> S;
  vector<ll> A(N);
  REP(i,N) cin >> A[i];

  DP[0][0] = 1;
  REP(i,N) REP(j,S+1) {
    // Ai が T に選ばれない場合
    DP[i+1][j] += DP[i][j];
    // Ai が T には選ばれているけど、Uには選ばれてない場合
    DP[i+1][j] += DP[i][j];
    DP[i+1][j] %= MOD;
    // Ai が選ばれた場合
    if ( A[i] + j <= S ) 
      DP[i+1][j+A[i]] += DP[i][j];
    DP[i+1][j] %= MOD;
  }
  cout << DP[N][S] << endl;
}


Measured memory_bytes: 74580
# coding: utf-8
# Your code here!

n = int(input())
#wsv = [[0,0,0]] + [[int(i) for i in input().split()] for _ in range(n)]
wsv = [[int(i) for i in input().split()] for _ in range(n)]
wsv.sort(key = lambda x: x[0]+x[1]) #sでソート
#print(wsv)

smax = 10000
dp = [0]*(smax*2+1)
for i, (w,s,v) in enumerate(wsv):
    for i in range(s,-1,-1):
        if dp[i] != 0 or i == 0:
                dp[i+w] = max(dp[i+w], dp[i]+v)

print(max(dp))
    

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

int main() {
    int a, b;
    cin >> a >> b;
    for (double i = 0; i <= 1000; i++) {
        if ((int)(i * 0.08) == a and (int)(i * 0.10) == b) {
            cout << (int)i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3644
s = input()
N, X = s.split()
N = int(N)
X = int(X)
m = []

for i in range(N):
    cost = input()
    cost = int(cost)
    X = X - cost 
    m.append(cost)

mn = min(m)

d = X//mn
    
print(N+d)

Measured memory_bytes: 3060
s = input() 

if s == "MON" :
	print(6)
elif s == "TUE" :
	print(5)
elif s == "WED" :
	print(4)
elif s == "THU" :
	print(3)
elif s == "FRI" :
	print(2)
elif s == "SAT" :
	print(1)
elif s == "SUN" :
	print(7)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#define N 5
using namespace std;
int find(int,int);
int map[N][N];
int main(){
  int m,r,maxv;
  cin >> m;
  for(int i=0;i<m;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
	cin >> map[j][k];
      }
    }
    maxv=0;
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
	r=find(j,k);
	if(r==1) maxv=max(maxv,j*k);
      }
    }
    cout << maxv << endl;
  }
  return 0;
}
int find(int y,int x){
  int flag=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(map[i][j]==1){
	int flag1=0;
	if(y+i<=N&&x+j<=N){
	  for(int k=i;k<y+i;k++){
	    for(int l=j;l<x+j;l++){
	      if(map[k][l]==0) flag1=1;
	    }
	  }
	}else flag1=1;
	if(flag1==0){
	  flag=1;
	  break;
	}
      }
    }
    if(flag==1) break;
  }
  if(flag==1) return 1;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)

int main(void){
    int N;
    cin >> N;
    vector<ll> L(N+10);
    REP(i,N){
        cin >> L[i];
    }
    ll cnt = 0;
    REP(i,N){
        FOR(j,i+1,N){
            if(L[i] == L[j]) continue;
            FOR(k,j+1,N){
                if(k == i || k == j) continue;
                if(L[k] == L[i] || L[k] == L[j]) continue;
                if(L[i]+L[j] <= L[k]) continue;
                if(L[i]+L[k] <= L[j]) continue;
                if(L[j]+L[k] <= L[i]) continue;
                cnt++;

            }
        }
    }
    cout << cnt << endl;
    return 0;  
}

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

using namespace std;

int main() {
	string a;
	cin >> a;
	if (a[0] == 'S') {
		cout<<"Cloudy";
	}
	else if (a[0] == 'C') {
		cout<<"Rainy";
	}
	else {
		 cout<< "Sunny";
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, x;
	
	scanf("%d%d%d", &a, &b, &c);
	if(a > b){
		x = a;
		a = b;
		b = x;
	}
	if(b > c){
		x = b;
		b = c;
		c = x;
	} 
	if(a > b){
		x = a;
		a = b;
		b = x;
	}
	printf("%d %d %d\n", a, b, c);
	
	return(0);
}



Measured memory_bytes: 1848
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll mod = (ll)1e9 + 7;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;
int vis[111];
int main()
{
    fast;
     int n;
     cin>>n;
     int ara[n];
     for(int i=1;i<=n;i++) cin>>ara[i];
     int c=0;
     for(int i=1;i<=n;i++)
     {
         if(ara[i]!=i) c++;
     }
     if(c>2)
        pr(0);
     else
        pr(1);
}




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

double th = M_PI * 60.0 / 180.0;

struct Point {
    double x;
    double y;
};

void printP(Point p){
    cout << fixed << setprecision(8) << p.x << " ";
    cout << fixed << setprecision(8) << p.y << endl;
}

void koch(int n, Point a, Point b){
    if(n == 0)  return;

    Point s, t, u;

    s.x = (2.0*a.x + 1.0*b.x) / 3.0;
    s.y = (2.0*a.y + 1.0*b.y) / 3.0;
    t.x = (1.0*a.x + 2.0*b.x) / 3.0;
    t.y = (1.0*a.y + 2.0*b.y) / 3.0;
    u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
    u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;
    
    koch(n-1, a, s);
    printP(s);
    koch(n-1, s, u);
    printP(u);
    koch(n-1, u, t);
    printP(t);
    koch(n-1, t, b);
}

int main(){
    Point a, b;
    int n;

    cin >> n;

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printP(a);
    koch(n,a,b);
    printP(b);

    return 0;
}


Measured memory_bytes: 3436
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int X;
    cin >> X;
    int mul=360;
    while(true){
        if(mul%X==0){
            cout << mul/X << endl;
            break;
        }
        mul+=360;
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll dp[60][60][2500];

int main(){
   ll N,A;cin >> N >> A;
   vector<ll> X(N);
   rep(i,N) cin >> X[i];
   dp[0][0][0] = 1;
   rep(i,N){
       rep(j,N+1){
           rep(k,2501){
               dp[i+1][j+1][k+X[i]] += dp[i][j][k];
               dp[i+1][j][k] += dp[i][j][k];
           }
       }
   }
   ll ans = 0;
   FOR(i,1,N+1) rep(k,2501){
       if(A * i == k) ans += dp[N][i][k];
   }
   cout << ans << endl;
}



Measured memory_bytes: 60544
N = int(input())
A = list(map(int,input().split()))
a = A[0]
for i in range(1,N):
    if i%2==0:
        a += A[i]
    else:
        a -= A[i]
X = [0 for _ in range(N)]
X[0] = a//2
for i in range(1,N):
    X[i] = A[i-1]-X[i-1]
X = [2*X[i] for i in range(N)]
print(*X)

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

using namespace std;

int n,m,q;

vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;
int ans;

void dfs(vector<int> A){

    int tmp=0;
    if(A.size() == n+1){
        for(int i = 0; i < q; i++) {
            if(A[b[i]-1]-A[a[i]-1]==c[i]){
                tmp+=d[i];
            }
        }
        ans = max(tmp,ans);
        return;
    }
    
    A.push_back(A.back());

    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}

int main() {

    cin >> n >> m >> q;

    a = b = c = d = vector<int>(q);

    for(int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i]; 
    }

    dfs(vector<int>(1,1));
   
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main ()
{
  int X,res=1;
  cin >> X;

  for (int b = 1; b <= X; b++)
    for (int p = 2; p <= X; p++)
      if (pow (b,p) <= X && pow (b,p) > res)
        res = pow (b,p);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512
import std.stdio,
	std.conv,
	std.algorithm,
	std.range,
	std.string,
	std.numeric;

void main() {
	size_t a,b;
	auto n = readln.chomp.to!size_t - 1;
	auto ary = readln.chomp.split.to!(size_t[]);
	a = ary[0];
	b = ary[1];
	foreach(cnt;0..n){
		auto tmp = readln.chomp.split.to!(size_t[]);
		auto inp_x = tmp[0];
		auto inp_y = tmp[1];
		immutable ratio = max((a-1)/inp_x+1,(b-1)/inp_y+1);
		a = inp_x * ratio;
		b = inp_y * ratio;
	}
	writeln(a+b);
}


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

int main(){
  int n,sum=0;
  cin >> n;
  vector<int> v(n*2,0);
  r(i,n*2)cin >> v.at(i);
  sort(v.begin(),v.end());
  r(i,n*2){
    if(i%2==0)sum+=v.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    int x = 0;
    String str = scan.next();
    
    for (int i = 0; i <= 3; i++) {
      char ch = str.charAt(i);
      
      if (ch == '+') {
        x = x + 1;
      }
      
      if (ch == '-') {
        x = x - 1;
      }
    }
    
    System.out.println(x);
  }
}


Measured memory_bytes: 35364
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();

      for(int i = 1;i<10;i++){
        for(int j = 1;j<10;j++){
          if(N==i*j){
            System.out.println("Yes");
            System.exit(0);
          }
        }
      }
      System.out.println("No");


                   }
}


Measured memory_bytes: 21844
n = int(input())
r = 0
for p in range(2, int(n**0.5)+1):
    e = 0
    while n%p == 0:
        e += 1
        n /= p
    i = 1
    while e >= i:
        e -= i
        r += 1
        i += 1
if n != 1:
    r += 1
print(r)


Measured memory_bytes: 9440
n = int(input())
arr = list(map(int,input().split()))
acc = [0 for i in range(n)]
acc[0] = arr[0]

for i in range(1,n):
    acc[i] = acc[i-1]+arr[i]

ans = 10000000000000
for i in range(n-1):
    l = acc[i]
    r = acc[-1]-acc[i]
    # print(l,r)
    if abs(l-r) < ans:
        ans = abs(l-r)

print(ans)

Measured memory_bytes: 24824
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000003;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
long long inv[1100000];
long long finv[1100000];
long long fact[1100000];
int main(){
	inv[1]=finv[0]=fact[0]=1;
	for(int i=2;i<1000003;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<1000003;i++){
		finv[i]=finv[i-1]*inv[i]%mod;
		fact[i]=fact[i-1]*i%mod;
	}
	int a;scanf("%d",&a);
	while(a--){
		long long x,d,n;
		scanf("%lld%lld%lld",&x,&d,&n);
		if(d==0){
			printf("%lld\n",pw(x,n));
			continue;
		}
		long long L=x*inv[d]%mod;
		long long R=(L+n-1)%mod;
		if(L>R||n>=mod){
			printf("0\n");continue;
		}
		long long ret=fact[R];
		if(L)ret=ret*finv[L-1]%mod;
		printf("%lld\n",ret*pw(d,n)%mod);
	}
}


Measured memory_bytes: 25728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,M = 0,x,ans = 1,count = 0;
cin >> n;
for (int i = 1; i < n+1; i++)
{   x = i;
    int sum = 0;
    while(1){
        if (x%2 != 0)
        {
            break;
        }
        x /= 2;
        sum++;
    }
    M = max(sum,M);
}
while (count < M)
{
    ans *= 2;
    count++;
}

cout << ans << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  int k[M];
  int s[M][N];
  for (int i = 0; i < M; i++) {
    scanf("%d",&k[i]);
    for (int j = 0; j < k[i]; j++) {
      scanf("%d",&s[i][j]);
      s[i][j]--;
    }
  }

  int p[M];
  for (int i = 0; i < M; i++) {
    scanf("%d",&p[i]);
  }

  int ans = 0;
  int flag[N];
  for (int i = 0; i < 1<<N; i++) { //zenntannsaku
    int ok = 0;
    for (int j = 0; j < N; j++) {  //syokika
      flag[j] = 0;
    }
    for (int j = 0; j < N; j++) {  //on or off
      flag[j] = (i>>j)&1;
    }
    for (int j = 0; j < M; j++) {  //dennkyuumiru
      int cnt = 0;
      for (int x = 0; x < k[j]; x++) {
        if(flag[s[j][x]]) cnt++;   //swichmiru
      }
      if(cnt%2 != p[j]) break;
      else ok++;
    }
    if(ok == M) ans++;
  }

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

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define re register
#define int long long
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,a[100002],m,p,v,l,r;
signed main(){
	n=read();
	m=read();
	v=read();
	p=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);
	l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		int tmp=a[mid]+m,num=m*(v-mid),cnt=mid;
		while(cnt<=n&&tmp>=a[cnt]){
			++cnt;
			if(tmp>=a[cnt]&&cnt<=n)
			num-=(tmp-a[cnt]);
		}
		num-=(n-cnt+1)*m;
		while(num>0&&cnt>=1)--cnt,num-=m-(tmp-a[cnt]);
		//cout<<cnt<<endl;
		//cout<<l<<" "<<r<<" "<<tmp<<" "<<mid<<" "<<a[mid]<<" "<<cnt<<endl;	
		if(cnt>n-p+1)r=mid;
		else l=mid+1;
	}
	printf("%lld",n-r+1);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int n,r;
    cin>>n>>r;

    if(n>9) {
        cout<<r<<endl;
    }
    else
    {
        cout<<r+(100*(10-n))<<endl;
    }
    
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3644
C = [list(map(int,input().split())) for i in range(3)]

flag = False

for i in range(C[0][0]+1):
    a_1 = i
    b_1 = C[0][0] - i
    b_2 = C[0][1] - i
    b_3 = C[0][2] - i
    a_2 = C[1][0] - b_1
    a_3 = C[2][0] - b_1
    if (a_2 + b_2) == C[1][1] and (a_2 + b_3) == C[1][2] and (a_3 + b_2) == C[2][1] and (a_3 + b_3) == C[2][2]:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

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

    ll ans = (n/(a+b))*a;
    ans += min(a, n%(a+b));

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


Measured memory_bytes: 256
from itertools import product
INFTY = 10**4
H,W,K = map(int,input().split())
S = [list(map(int,list(input()))) for _ in range(H)]
cmin = INFTY
for x in product((0,1),repeat=H-1):
    cur = 0
    cnt = 0
    h = sum(x)+1
    A = [0 for _ in range(h)]
    for j in range(W):
        ind = 0
        A0 = [0 for _ in range(h)]
        for i in range(H):
            if i<H-1 and x[i]==1:
                A0[ind] += S[i][j]
                ind += 1
            else:
                A0[ind] += S[i][j]
        B = [A[i]+A0[i] for i in range(h)]
        if max(A0)>K:
            cnt = INFTY
            break
        if max(B)>K:
            cur = j
            cnt += 1
            A = A0[:]
        else:
            A = B[:]
    cmin = min(cmin,cnt+sum(x))
print(cmin)            

Measured memory_bytes: 53852
#include <stdio.h>

#define MAX_NODE 200

typedef struct {
	int dest_num;
	int dest[MAX_NODE];
	int pass_flag;
} node_t;

node_t nodes[MAX_NODE];

int get_depth(int start, int cur_depth)
{
	int i;

	if(nodes[start].pass_flag) {
		return cur_depth;
	} else {
		int max_depth = cur_depth + 1;

		nodes[start].pass_flag = 1;

		for(i = 0; i < nodes[start].dest_num; i++) {
			int partial_depth = get_depth(nodes[start].dest[i], cur_depth + 1);

			if(partial_depth > max_depth) max_depth = partial_depth;
		}

		nodes[start].pass_flag = 0;
		return max_depth;
	}
}

int main(void)
{
	while(1) {
		int i, str_num, src, dest;

		scanf("%d", &str_num);

		if(str_num == 0) break;

		for(i = 0; i < MAX_NODE; i++) {
			nodes[i].dest_num = 0;
		}

		for(i = 0; i < str_num; i++) {
			scanf("%d%d", &src, &dest);

			nodes[src].dest[nodes[src].dest_num++] = dest;
			nodes[dest].dest[nodes[dest].dest_num++] = src;
		}

		int max_depth = 0;

		for(i = 0; i < MAX_NODE; i++) {
			nodes[i].pass_flag = 0;
		}

		for(i = 0; i < MAX_NODE; i++) {
			int partial_depth;

			partial_depth = get_depth(i, 0);

			if(max_depth < partial_depth) max_depth = partial_depth;
		}

		printf("%d\n", max_depth);
	}

	return 0;
}

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

typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 1e9;
  for (int x = -200; x <= 200; ++x){
    int val = 0;
    for (int i = 0; i < n; ++i){
      int t = abs(a[i] - x);
      val += t * t;
    }
    ans = min(ans, val);
  }
  cout << ans;
}



Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d %d", $a, $b, $q);
$S = [PHP_INT_MIN];
for ($i = 0; $i < $a; ++$i) {
    $S[] = intval(trim(fgets(STDIN)));
}
$S[] = PHP_INT_MAX;
$T = [PHP_INT_MIN];
for ($i = 0; $i < $b; ++$i) {
    $T[] = intval(trim(fgets(STDIN)));
}
$T[] = PHP_INT_MAX;
$X = [];
for ($i = 0; $i < $q; ++$i) {
    $X[] = intval(trim(fgets(STDIN)));
}


for ($i = 0; $i < $q; ++$i) {
    $x = $X[$i];

    $l = 0;
    $r = $a + 2;
    while ($r - $l >= 1) {
        $mid = intdiv($r + $l, 2);
        if ($S[$mid] > $x) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }
    $start_s = $r;

    $l = 0;
    $r = $b + 2;
    while ($r - $l >= 1) {
        $mid = intdiv($r + $l, 2);
        if ($T[$mid] > $x) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }
    $start_t = $r;

    /* echo "start_s: $start_s, start_t: $start_t", PHP_EOL; */

    $min = PHP_INT_MAX;
    foreach ([$S[$start_s], $S[$start_s - 1]] as $s) {
        foreach ([$T[$start_t], $T[$start_t - 1]] as $t) {
            $d1 = abs($x - $s) + abs($s - $t);
            $d2 = abs($x - $t) + abs($s - $t);

            $min = min($min, $d1, $d2);
            /* echo "s: $s, t: $t, d1: $d1, d2: $d2, min: $min", PHP_EOL; */
        }
    }

    echo $min, PHP_EOL;
}


Measured memory_bytes: 18928
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MAX=1e5,mo=1e9+7;
vector<int>v[MAX+5];
int a[MAX+5],fa[MAX+5],k;
void dfs(int x)
{
	int i;
	for(i=0;i<v[x].size();i++)
	{
		int u=v[x][i];
		if(u==fa[x]) continue;
		fa[u]=x;
		dfs(u);
	}
}
void dfs1(int x,int cur)
{
	int i;
	int f=0;
	for(i=0;i<v[x].size();i++)
	{
		int u=v[x][i];
		if(u==fa[x]){
			f=1;
			continue;
		}
		
		int temp=min(cur+1,2);
		a[u]=k-temp-i+f;
		if(a[u]<0) a[u]=0;
		dfs1(u,cur+1);
	}
}
int main()
{
	int n,i;
	cin>>n>>k;
	for(i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	fa[1]=1;
	dfs(1);
/*	for(i=1;i<=n;i++)
		cout<<fa[i]<<" ";
	cout<<endl;*/
	a[1]=k;
	dfs1(1,0);
/*	for(i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;*/
	
	long long ans=1;
	for(i=1;i<=n;i++)
		ans=(ans*a[i])%mo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9984
n = int(input())
h = list(map(int, input().split()))
ans = 'Yes'

for i in range(1,n):
    if h[i-1] <= h[i]:
        if h[i-1] <= h[i]-1:
            h[i] = h[i] - 1
    else:
        ans = 'No'
        break
print(ans)


Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i] = sc.nextInt();
        for(int i=n-1;i>0;i--)System.out.print(a[i]+" ");
        System.out.println(a[0]);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24272
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int K, N, maxdis = 0, edge, ans = 0, check;
  cin >> K >> N ;
  int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  sort(A,A+N) ;
  for(int i=0;i<(N-1);i++){
    if(maxdis < (A[i+1] - A[i])) maxdis = (A[i+1] - A[i]) ;
  }
  edge = A[0] + (K - A[N-1]) ;
  if(maxdis < edge) maxdis = edge ;
  ans = K - maxdis ;
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

struct UF{
    vector<int> par, sz;
    void init(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    UF uf;
    uf.init(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            uf.unite(x, y);
        }else{
            cout << (uf.same(x, y) ? 1: 0) << endl;
        }
    }
}

Measured memory_bytes: 1400
/*s1190073  Rina Sato
  File name: prog10b.c
  This is a program that finds the number of scalar multiplications to compute the product of the matrix. 
*/

#include <stdio.h>
#include <stdlib.h>

int MatrixChainOrder(int n,int p[]){
  int i,l,j,k,q;
  int m[103][103];

  for(i = 1 ; i <= n ; i++){//
    m[i][i] = 0;
  }
  for(l = 2 ; l <= n ; l++){//
    
    for(i = 1 ; i <= n-l+1 ; i++){//
      j = i+l-1;
      m[i][j] = 1000000000;
  
      for(k = i ; k <= j-1 ; k++){//
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	
	if(q < m[i][j]){
	  m[i][j] = q;
	}
	
      }
      
    }
    
  }

  return m[1][n];
}

int main(void){
  int r[101],c[101],p[101];
  int cost,n,i;

  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&r[i],&c[i]);
  }
  
  for(i = 0 ; i < n ; i++){
    p[i] = r[i];
  }
  p[n] = c[n-1];
  
  cost = MatrixChainOrder(n,p);

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

Measured memory_bytes: 0
# 全部非再帰に書き換え

def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def eular_tour(G, root):
    # G は破壊的に有向木にされる
    # グラフは 1-indexed が良い
    n = len(G)
    stack = [root]
    tour = [0] * 0
    firsts = np.full(n, -100, dtype=np.int64)
    lasts = np.full(n, -100, dtype=np.int64)
    parents = np.full(n, -100, dtype=np.int64)
    while stack:
        v = stack.pop()
        if firsts[v] >= 0:
            lasts[v] = len(tour)
            tour.append(-v)  # 帰りがけの辺の表現をマイナス以外にしたい場合ここを変える
            continue
        firsts[v] = len(tour)
        tour.append(v)
        stack.append(v)
        for u in G[v]:
            G[u].remove(v)
            parents[u] = v
            stack.append(u)
    tour = np.array(tour, dtype=np.int64)
    return tour, firsts, lasts, parents

def solve(N, C, AB):
    G = [[0]*0 for _ in range(N+1)]
    for i in range(N-1):
        a, b = AB[i]
        G[a].append(b)
        G[b].append(a)
    tour, firsts, lasts, parents = eular_tour(G, 1)
    Siz = lasts - firsts + 1 >> 1

    Cnt = np.zeros(N+1, dtype=np.int64)
    Ans = np.zeros(N+1, dtype=np.int64)
    Cnt_old = np.empty_like(Cnt)
    Siz_tmp = np.full_like(Cnt, 1)
    for v in tour:
        if v >= 0:
            p = parents[v]
            if p != -100:
                Cnt[C[p]] = N - Siz[v]  # 上を塞ぐ

            color = C[v]
            Cnt_old[v] = Cnt[color]
        else:
            v = -v
            Ans[C[v]] += N - Siz_tmp[v] + 1 - Cnt_old[v]
            Cnt[C[v]] = Cnt_old[v] + Siz_tmp[v]

            p = parents[v]
            if p != -100:
                Siz_tmp[p] += Siz[v]
                Ans[C[p]] += Siz[v] * (N - Siz_tmp[p] + 1 - Cnt_old[p])

    return Ans[1:]


numba_compile([
    [eular_tour, "Tuple((i8[:],i8[:],i8[:],i8[:]))(List(List(i8)),i8)"],
    [solve, "i8[:](i8,i8[:],i8[:,:])"],
])


import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(505050)
N = int(input())
C = np.array(["0"] + input().split(), dtype=np.int64)
AB = np.array([list(map(int, input().split())) for _ in range(N-1)], dtype=np.int64)
Ans = solve(N, C, AB)
print("\n".join(map(str, Ans)))


Measured memory_bytes: 94820
s = gets.chomp
n = s.length
base = ["A", "G", "C", "T"]
ans = 0
cur = 0
n.times do |i|
  if base.include?(s[i])
    cur += 1
  else
    ans = [ans, cur].max
    cur = 0
  end
end
ans = [ans, cur].max
puts ans

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

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  int ans=0,tmp=0;
  for(int i=0;i<n;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      tmp++;
    }else{
      ans=max(ans,tmp);
      tmp=0;
    }
  }
  ans=max(ans,tmp);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string a,b,c;
int ans;
int main(void){
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&b[i]==c[i]){
            
        }else if(a[i]==b[i]){
            ans++;
        }else if(b[i]==c[i]){
            ans++;
        }else if(a[i]==c[i]){
            ans++;
        }else{
            ans+=2;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3636
a,b,c,d = map(int,input().split())
s =[a*c,a*d,b*c,b*d]
num = max(s)
if (a <= 0 and b >=0) or (c <=0 and d>=0):
  cum =0
  if cum > num:
    num =cum
print(num)

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, M, X;	cin >> N >> M >> X;
	vector<int> A;
	int inputA;
	int big = 0;
	int small = 0;
	int answer = 0;
	for (int i = 0; i < M; ++i) {
		cin >> inputA;
		A.push_back(inputA);
	}
	for (int i = 0; i < M; ++i) {
		if (A[i] >= X) {
			big += M - i;
			break;
		}
		++small;
	}
	if (small > big) {
		cout << big << endl;
		cin >> N;
		return 0;
	}
	cout << small << endl;
	cin >> N;
	return 0;
}

Measured memory_bytes: 256
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n;
  int maybe = 0;
  scanf("%d", &n);
  for (int i = 0; i <= n / 4; i++)
  {
    for (int j = 0; j <= n / 7; j++)
    {
      maybe = 4 * i + 7 * j;
      if (maybe == n)
      {
        puts("Yes");
        return 0;
      }
    }
    maybe = 0;
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void out(vector<int> &v){
    rep(i,v.size()){
        if(i)cout << " ";
        cout << v[i];
    }
    cout << endl;
}

long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : a;}
long long lcm(long long m, long long n ){if((0 == m )||( 0 == n ))return 0;
    return ((m / gcd(m, n)) * n);
}
signed main(){
    int a,b; cin >> a >> b;
    cout << gcd(a,b) << endl;
}





Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) YES();
  else NO();
}


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

using namespace std;
typedef long long ll;

char S[301][301];
int flag[301][301];

int main(void) {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) scanf("%s", S[i]);

    ll ans = 0;
    for(int a=0; a<n; a++) for(int b=0; b<n; b++) {
        if(flag[a][b] != 0) continue;
        for(int i=0; i<n; i++) for(int j=0; j<n; j++) {
            if(S[(i+a)%n][(j+b)%n] != S[(j+a)%n][(i+b)%n]) {
                i = j = n;
                for(int k=0; a+k < n && b+k < n; k++) flag[a+k][b+k] = 1;
            }
            if(i == n-1 && j == n-1) {
                for(int k=0; a+k < n && b+k < n; k++) {
                    flag[a+k][b+k] = 1;
                    ans++;
                }
            }
        }
    }

    return !printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int X, N, p, ans=0; cin >> X >> N; map<int, bool> c;
REP(i, N){ cin >> p; c[p]=true; }
REP(i, 100){ 
  int a=X-i, b=X+i;
  if(!c[a]){ cout << a << "\n"; return 0; }
  if(!c[b]){ cout << b << "\n"; return 0; }
}
}


Measured memory_bytes: 3640
n = int(input())
v = list(map(int,input().split()))

import collections


'''
奇数番目の数列
'''
v_odd = []
for i in range(0,n,2):
  v_odd.append(v[i])

c_odd = collections.Counter(v_odd)
c_common_odd = c_odd.most_common()


'''
偶数番目の数列
'''
v_even = []
for i in range(1,n,2):
  v_even.append(v[i])

c_even = collections.Counter(v_even)
c_common_even = c_even.most_common()


'''
後処理

下記の4種類でパターン別に出力
また、各パターンごとに一番カウント数が大きい数字を比較する。

a.奇数・偶数共に数字が２種類以上
b.奇数については数字が一種類
c.偶数については数字が一種類
d.両方の数字がそれぞれ一種類
'''

# a.奇数・偶数共に数字が２種類以上
if len(c_common_odd) >= 2 and len(c_common_even) >= 2:
  # 一番多くカウントした数字が異なる
  if c_common_odd[0][0] != c_common_even[0][0]:
    ans = n - c_common_odd[0][1] - c_common_even[0][1]
  # 一致する
  else:
    # 奇数の方がカウント数が大きい
    ans_1 = n - c_common_odd[1][1] - c_common_even[0][1]
    ans_2 = n - c_common_odd[0][1] - c_common_even[1][1]
    ans = min(ans_1, ans_2)

# b.奇数については数字が一種類
elif len(c_common_odd) < 2 and len(c_common_even) >= 2:
  # 一番カウント数が大きい数字が一致している
  if c_common_odd[0][0] == c_common_even[0][0]:
    ans = int(n / 2) - c_common_even[1][1]
  else:
    ans = int(n / 2) - c_common_even[0][1]

# c.偶数については数字が一種類
elif len(c_common_odd) >= 2 and len(c_common_even) < 2:
  # 一番カウント数が大きい数字が一致している
  if c_common_odd[0][0] == c_common_even[0][0]:
    ans = int(n / 2) - c_common_odd[1][1]
  else:
    ans = int(n / 2) - c_common_odd[0][1]

# d.両方の数字がそれぞれ一種類
else:
  if c_common_odd[0][0] == c_common_even[0][0]:
    ans = int(n / 2)
  else:
    ans = 0

print(ans)

Measured memory_bytes: 21824
import java.util.Scanner;
import java.lang.Math;

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

    for(int i=0; i<100; i++) {
      if(Math.pow(K, i) <= N && N < Math.pow(K, i+1)) {
        System.out.println(i + 1);
        break;
      }
    }
  }
}

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef pair<string, int> P;
typedef long long ll;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    string s;cin>>s;
    int x,y;cin>>x>>y;
    vector<int> f,fx,fy;
    int cnt=0;
    for(int i=0;i<(int)s.size();++i){
        if(s[i]=='F') cnt++;
        else{
            f.push_back(cnt);
            cnt=0;
        }
    }
    if(cnt>0) f.push_back(cnt);
    for(int i=0;i<(int)f.size();++i){
        if(i%2==0) fx.push_back(f[i]);
        else fy.push_back(f[i]);
    }
    int n=(int)fx.size(),m=(int)fy.size();
    vector<vector<bool> > dpx(n+1,vector<bool>(16005,false)),dpy(m+1,vector<bool>(16005,false));
    dpx[0][8000]=true;dpy[0][8000]=true;
    for(int i=0;i<n;++i){
        for(int j=0;j<=16000;++j){
            if(dpx[i][j]){
                if(i==0) dpx[i+1][j+fx[i]]=true;
                else dpx[i+1][j+fx[i]]=dpx[i+1][j-fx[i]]=true;
            }
        }
    }
    for(int i=0;i<m;++i){
        for(int j=0;j<=16000;++j){
            if(dpy[i][j]){
                dpy[i+1][j+fy[i]]=dpy[i+1][j-fy[i]]=true;
            }
        }
    }
    if(dpx[n][8000+x]&&dpy[m][8000+y]){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}

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

int cnt;

void generalizedInsertionSort(int A[], int n, int g) {
  for (int i = g; i < n; i++) {
    int key = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > key) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = key;
  }
}

void shellSort(int A[], int n) {
  vector<int> G;
  int g = (n / 2 == 0) ? 1 : n / 2;
  while (g > 0) {
    G.push_back(g);
    g /= 2;
  }

  for (int g : G) {
    generalizedInsertionSort(A, n, g);
  }
  
  cout << G.size() << endl;
  for (int g : G) cout << g << " ";
  cout << endl;
}

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

  shellSort(A, n);
  cout << cnt << endl;

  for (int i = 0; i < n; i++) cout << A[i] << endl;
}



Measured memory_bytes: 6996