akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  vector<int> ABC(3);
  for (auto & abc : ABC)
    cin >> abc;
  sort(ABC.begin(), ABC.end());
  ABC.erase(unique(ABC.begin(), ABC.end()), ABC.end());
  cout << ((2 == ABC.size()) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?(テァツクツョテ・ツーツ湘ァツ可?

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

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

int W, H;
int board[60][60];
bool used[60][60];

signed main() {
    while(cin >> W >> H, W || H) {
        memset(used, false, sizeof(used));
        rep(i,0,H) rep(j,0,W) cin >> board[i][j];

        int ans = 0;
        rep(i,0,H) rep(j,0,W) {
            if(used[i][j] || board[i][j] == 0) continue;
            ans++; used[i][j] = true;

            queue<pii> q;
            q.push(pii(i, j));

            while(!q.empty()) {
                pii t = q.front(); q.pop();
                int x = t.first, y = t.second;
                rep(k,0,8) {
                    int nx = x + dx[k], ny = y + dy[k];
                    if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                    if(used[nx][ny] || board[nx][ny] == 0) continue;
                    used[nx][ny] = true;
                    q.push(pii(nx, ny));
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 50; i++){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1) {
                break;
            }
            if (m == -1 || f == -1){
                System.out.println("F");
            }else if(m + f >= 80) {
                System.out.println("A");
            }else if(m + f >= 65) {
                System.out.println("B");
            }else if(m + f >= 50) {
                System.out.println("C");
            }else if(m + f >= 30) {
                if(r >= 50) {
                    System.out.println("C");
                }else {
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }

    }
}



Measured memory_bytes: 26252
n = int(input())
num = [0] * (n+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            res = x**2 + y**2 + z**2 + x*y + y*z + z*x 
            
            if res < n+1:
                num[res] += 1
                
            else:
                continue
                
for i in num[1:]:
    print(i)

Measured memory_bytes: 69548
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

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

using namespace std;

struct Event {
    int s, type, x;  
    bool operator<(const Event &rhs) const {
        if (s == rhs.s) return type < rhs.type;
        return s < rhs.s;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<Event> E; 
    for(int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        E.push_back((Event){s - x, 1, x});
        E.push_back((Event){t - x, -1, x});    
    }
    sort(all(E), [](Event &a, Event &b){return a.s < b.s;});
    
    vector<int> D(Q);
    for(int i = 0; i < Q; i++) {
        cin >> D[i];
    }
    
    map<int, int> xs; // x, cnt
    auto prev = D.begin();
    for(int i = 0; i < E.size(); i++) {
        
        auto now = lower_bound(all(D), E[i].s);
        while(prev < now) {
            if (xs.size() == 0) {
                cout << -1 << endl;
            } else {
                cout << (*xs.begin()).first << endl;
            }
            prev++;
        }
        
        if (E[i].type == -1) {
            xs[E[i].x]--;
            if (xs[E[i].x] == 0) {
                xs.erase(E[i].x);
            }
        } else {
            xs[E[i].x]++;
        }
    }
    while(prev < D.end()) {
        if (xs.size() == 0) {
            cout << -1 << endl;
        } else {
            cout << (*xs.begin()).first << endl;
        }
        prev++;
    }
    
    
    return 0;
}

Measured memory_bytes: 16492
#include <cstdio>
int n, x, d;
int main()	{
	scanf("%d%d", &n, &x);
	if(x==1 || x==2*n-1) {puts("No"); return 0;}
	puts("Yes");
	d = n-x;
	n += n-1;
	for(int i=0; i<n; i++) printf("%d\n", (i-d+n)%n+1);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	vector <int> a(3);
	for (int i=0;i<3;i++) cin >> a[i];
	sort(a.rbegin(),a.rend());
	cout << a[0] * 10 + a[1] + a[2] << endl;
	return 0;
}


Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i)
k = gets.to_i

max = a
max = b if max < b
max = c if max < c
max2 = max

k.times do
	max += max
end

if max2 == a
	puts max + b + c
elsif max2 == b
	puts max + a + c
else
	puts max + a + b
end
		


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

int main() {
  string S,T,U="";
  cin>>S>>T;
 
  for(int i=0;i<S.size();i++){
    U+=T[i];
  }
  
  if(S==U && S.size()+1==T.size()) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3592
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;



int main(){
    long long a, b, x;
    cin >> x;
    int absMax = pow(x, 0.25) + 1;
    for(a = -absMax; a!= absMax; a++)
        for(b = -absMax; b!= absMax; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                goto endloop;
            }
        }
    endloop: cout << a << " " << b << endl;
    return 0 ;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;


int main() {
  int n,d,x;
  cin>>n>>d>>x;
  vector<int> a(n);
  frn(i,n) cin>>a[i];
  int ans = x;
  frn(i,n) {
    int mul = 0;
    int day;
    do {
      day = a[i]*mul + 1;
      // dbg(day); nl;
      if(day <= d) ans++;
      mul++;
    } while(day <= d);
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int i,ans=0;
    for(i=1;i<=n;i++)
    {
        int ct=0,r;
        int x=i;
        while(x>0)
        {
            ct++;
            x/=10;
        }
        if(ct&1)
            ++ans;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
s = input()
h = int(s[0:2])
t = int(s[2:4])
#print(h, t)
h_mm = 0
t_mm = 0
if 1 <= h <= 12:
  h_mm = 1
if 1 <= t <= 12:
  t_mm = 1
  
print(["NA", "YYMM", "MMYY", "AMBIGUOUS"][h_mm * 2 + t_mm])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
ll x,k,d;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>x>>k>>d;
	x=abs(x);
	ll a=x/d;
	if(k<=a){
		cout<<x-k*d;
		re 0;
	}
	if((k-a)%2){
		cout<<abs(x-a*d-d);
		re 0;
	}
	cout<<abs(x-a*d);
	re 0;
}


Measured memory_bytes: 3584
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()

ANS = [[] for _ in range(N+1)]

for i in range(1,N+1):
    if i == 1:
        ANS[i].append('a')
    else:
        for a in ANS[i-1]:
            for j in range(97,ord(max(a[k] for k in range(i-1)))+2):
                ANS[i].append(a+chr(j))
print(*ANS[N],sep='\n')


Measured memory_bytes: 89744
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;
	
int main(){
	int n,l;
	cin >> n >> l;
	vector<string> s;
	
	string now;
	for(int i=0;i<n;i++){
		cin >> now;
		s.push_back(now);
	}
	
	sort(s.begin(),s.end());
	
	for(int i=0;i<n;i++){
		cout << s[i];
	}
	cout << endl;
	
	return 0;
}


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

typedef long long ll ;
using namespace std;

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

void solve(){
    int n;
    cin >> n;

    ll M = (ll)1e9 + 7;
    ll ans = 1;

    vector<ll> p(n + 1);
    p[0] = 1;
    for (int i = 1; i <= n; i++) {
        p[i] = 2 * p[i - 1];
        p[i] %= M;
    }

    map<pair<ll, ll>, int> m;
    ll a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        long long _gcd = gcd(abs(a), abs(b));
        if(a==0 && b==0) m[{0, 0}]++;
        else if(b==0)m[{-1,0}]++;
        else if(a==0)m[{0,1}]++;
        else if(b>0){
            m[{a/_gcd, b/_gcd}]++;
        }
        else if(b<0){
            m[{-a/_gcd, -b/_gcd}]++;
        }
    }

    for(auto itr=m.begin();itr!=m.end();itr++){
        long long r1 = itr->first.first;
        long long n1 = itr->first.second;
        long long r2, n2;
        if (r1 == 0 && n1 == 0) continue;
        if(r1<0){
            r2 = -r1;
            n2 = n1;
        }
        else {
            r2 = r1;
            n2 = -n1;
        }
        int m1 = itr->second;
        int m2 = m[{n2, r2}];
        m[{r1, n1}] = 0;
        m[{n2, r2}]=0;
        ans = (((p[m1]-1 + p[m2]-1 + 1)%M) * ans)%M;
    }

    ll zero = (ll)m[{0, 0}];
    ans = (ans + zero) % M;
    ans = (ans -1 + M) % M;
    cout <<ans << endl;
}

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

    solve();

    return 0;
}


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

using namespace std;

int main(){
        char c[4];
        for(int i=0; i<4; i++) cin>>c[i];
        sort(c,c+4);
        if((c[0]==c[1])&&(c[2]==c[3])&&(c[1]!=c[2])) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
}

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

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

using namespace std;

typedef long long ll;

bool is_kaibun(int x) {
  string s = to_string(x);
  for (int i = 0; i < s.length()/2; i++) {
    if (s[i] != s[s.length()-i-1])  {
      return false;
    }
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int a, b;
  cin >> a >> b;

  int ans = 0;
  for (int x = a; x <= b; x++) {
    if ( is_kaibun(x) ) { ans++; }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

                int a= sc.nextInt();
                char op=sc.next().charAt(0);
                int b= sc.nextInt();
                if(op !='?'){
                    if(op=='+'){
                    System.out.println(a+b);
                }else if(op=='-'){
                    System.out.println(a-b);
                }else if(op=='*'){
                    System.out.println(a*b);
                }else if(op=='/'){
                    System.out.println(a/b);
                }
            
                }
                else{
                break;    
                }   
            }    
        }
    }
    


Measured memory_bytes: 26436
#include <iostream>
 using std::cin;
 using std::cout;
 using std::endl;

 #include <map>
 using std::map;

 #include <string>
 using std::string;

 map<string, int> memo;

 int main (void) {
 int n;

 scanf("%lld", &n);
 for (int i = 0; i < n; i++) {
 string s;
 cin >> s;

 memo[s] += 1;
 }

 int maxv = 0;
 for (const auto& x : memo) {
 int v = x.second;
 if (v > maxv) maxv = v;
 }
 for (auto it = memo.begin(); it != memo.end(); it++) {
 if (it->second == maxv) {
 cout << it->first << endl;
 }
}

 return 0;
 }

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;

ll n, k, a[1008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k;
	rep(i, 1, n){cin >> a[i];}
	a[0] = 0LL;
	rep(i, 1, n){a[i] += a[i-1];}
	
	vector<ll> v;
	rep(i, 1, n){
		rep(j, i, n){
			v.push_back(a[j]-a[i-1]);
		}
	}
	//sort(v.rbegin(), v.rend());
	//for(ll i = 0; i < v.size(); i++){print(v[i])}
	ll ans = 0LL;
	rrep(b, 40, 0){
		ll bit = (1LL << b);
		//print(bit)
		ll cnt = 0;
		vector<ll> u;
		for(ll i = 0; i < v.size(); i++){
			if((v[i] & bit) == bit){
				cnt++;
				u.push_back(v[i]-bit);
			}
		}
		if(cnt >= k){
			ans += bit;
			v.swap(u);
		}
	}
	print(ans)
	//for(ll i = 0; i < v.size(); i++){print(v[i])}
	return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <cmath>
#include <algorithm> 
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int sum=0;
	if(a<=0 && b>=0)
	cout <<"Zero" <<endl;
	else if (a>=0 && b>=0)
	cout <<"Positive" <<endl;
	else if(a<=0 && b<=0)
	{
	for ( int i=a; i<=b; i++)
	{
		if (i<=b) sum++;
	} 
		if (sum % 2 == 0) cout <<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

ll get(ll n, ll i)
{
    ll lim = 1ll<<i;
    
    ll cnt = ((n+1)/(lim*2))*lim;
    
    if(((n)/lim)%2 == 0)
        return cnt;
    if((n+1)%lim == 0)
        return cnt;    
    ll temp = (n+1)%lim;
    return temp + cnt;
}

int main()
{
   FAST/**/
   
   ll a,b;
   cin>>a>>b;
   ll ans = 0;
   for(ll i=0;i<63;i++)
   {
       ll r = get(b,i);
       r-=get(a-1,i);
       
      // cout<<" bit "<<i<<" = "<<r<<"\n";
       
       if(r%2 == 0)
            continue;
       ans+=1ll<<i;        
   }
   
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int cnt2 = 0,cnt4 = 0;
  for ( int i = 0; i < N; i++ ) {
    int a; cin >> a;
    if ( a % 4 == 0 ) {
      cnt4++;
    } else if ( a % 4 != 0 && a % 2 == 0 ) {
      cnt2++;
    }
  }

  if ( cnt4 == 0 ) {
    if ( cnt2 == N ) cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
  }

  if ( cnt4 + cnt2/2 >= N/2 ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
#define pb push_back
#define mod 1e9+7;
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,start,end) for(int i=start; i<=end; i++)
#define repd(i,start,end) for(int i=start; i>=end; i--)
void solve()
{
   string s;
   cin>>s;
   int c=0,m=0;
   rep(i,3)
   {
       if(s[i]=='R'&&s[i+1]=='R')
       {
           c++;
       }
       else if(s[i]=='R')
       {
           m++;
       }
   }
    if(m==0)
    {
        cout<<m<<endl;
    }
    else
    {
        cout<<c+1<<endl;
    }
}

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



 




Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
s = input().rstrip("\n")
t = input().rstrip("\n")
flg = False

for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        #print(s[i+j],t[j])
        if s[i+j] == t[j] or s[i+j] == '?':
            cnt+=1
        #print(cnt,len(t))
    if cnt == len(t):
        temp=i
        flg = True
        #print(cnt)
 
if not flg:
    print("UNRESTORABLE")
else:
    li = list(s.replace("?","a"))
    #print(li)
    for j in range(len(t)):
        #print(li[cnt+j], t[j])
        li[temp+j] = t[j]
    print("".join(li))


Measured memory_bytes: 2568
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a,b,c,d;
		int l,kokugo,sugaku;
		l = sc.nextInt();//??¬???????????\??°
		a = sc.nextInt();//????????????????????°
		b = sc.nextInt();//??°?????????????????°
		c = sc.nextInt();//??????1??\?????§
		d = sc.nextInt();//??°???1??\?????§
		kokugo = (int)Math.ceil(a/c);
		sugaku = (int)Math.ceil(b/d);
		if(kokugo > sugaku)System.out.println(l - kokugo);
		else System.out.println(l-sugaku);
	}
}

Measured memory_bytes: 26088
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int keta(int x) {
  int ten = 100000;
  int ans = 0;
  while(ten>0) {
    ans += x/ten;
    x %= ten;
    ten /= 10;
  }
  return ans;
}

int main() {
  int N, A, B;
  cin>>N>>A>>B;
  int ans = 0;
  for(int i=1;i<=N;++i) {
    if(A<=keta(i) && keta(i)<=B) ans += i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

template <class T>
std::vector<std::vector<T>> Imos2D(const std::vector<std::vector<T>>& a) {
    int h = (int)a.size(), w =(int) a[0].size();
    std::vector<std::vector<T>> s(h + 1, std::vector<T>(w + 1, 0));
    rep(i, h) rep(j, w) s[i + 1][j + 1] = a[i][j];
    rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
    rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
    return s;
}

template <class T>
int sum(const std::vector<std::vector<T>>& s, int i, int j, int h, int w) {
    swap(j,h);
    h-=i;
    w-=j;
    return s[i + h][j + w] - s[i][j + w] + s[i][j] - s[i + h][j];
}
int main(){
    int n,k;
    cin >> n >> k;
    int cnt = 0;
    int cnt2 = 0;
    vector<vector<int>>a(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>s(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>aa(2*k+5,vector<int>(2*k+5,0));
    vector<vector<int>>ss(2*k+5,vector<int>(2*k+5,0));
    rep(i,n){
        int x,y;
        char c;
        cin >> x >> y >> c;
        x = x%(2*k);
        y = y%(2*k);
        if(c == 'W'){
            a[x][y]++;
            cnt2++;
        }else{
            aa[x][y]++;
            cnt++;
        }
    }
    s = Imos2D(a);
    ss = Imos2D(aa);
    int ans = 0;
    for(int i = 0;i <= k; i++){
        for(int j = 0; j <= k; j++){
            int temp = 0;
            int temp2 = 0;
            temp += sum(s,i,i+k,j,j+k);
            temp2 += sum(ss,i,i+k,j,j+k);
            if(i>0 and j > 0){
                temp += sum(s,0,i,0,j);
                temp2 += sum(ss,0,i,0,j);
            }
            if(i > 0 and j!=k){
                temp += sum(s,0,i,j+k,2*k);
                temp2 += sum(ss,0,i,j+k,2*k);
            }
            if(j > 0 and i!=k){
                temp += sum(s,i+k,2*k,0,j);
                temp2 += sum(ss,i+k,2*k,0,j);
            }
            if(i!=k and j!=k){
                temp += sum(s,i+k,2*k,j+k,2*k);
                temp2 += sum(ss,i+k,2*k,j+k,2*k);
            }
            //cout << i << " "  << j << " " << temp << " " << temp2 << endl;
            int mitasu = max(temp + (cnt-temp2),temp2 + (cnt2-temp));
            ans = max(ans,mitasu);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cfloat>
#include <algorithm>
#include <memory>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define l_double long double
#define vtr vector
#define PB push_back
#define EB emplace_back
#define gcd __gcd
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define TEST uint _ {}; cin >> _; while (_--)
#define PIE (3.1415926535897932384626433832795)
#define MOD 1'00'00'00'007
using namespace std;

template<typename T>
void vtrS(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<" "; cout<<endl; }

template<typename T>
void vtrV(const vector<T> &ARR) { for (auto const &val: ARR) cout<<val<<endl; }

ull lcm (ull a, ull b) { return ((a*b)/gcd(a, b)); }
ull countDigits(const ull &N) { return (floor(log10(N)) + 1); }
bool isPowOfTwo(ull const &N) { return (N && (!(N&(N-1)))); }
// ---------------------------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<boolalpha<<fixed<<setprecision(3); 
    // --------------------------------------
    
    int n {}, m {};
    cin >> n >> m;

    double ttl {};
    vtr<int> arr (n);
    for (auto &val: arr) {
        cin >> val;
        ttl += val;
    }
    double thres {ttl/(4*m)};
    int selected {};
    for (auto const &val: arr) {
        if (val >= thres) ++selected;
    }
    if (selected >= m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int a[100010], b[100010], c[100010];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];

    int q;
    cin >> q;

    rep(i, q) cin >> b[i] >> c[i];

    ll ans = 0;
    rep(i, n) ans += a[i];

    map<int,int> mp;

    rep(i, n) mp[a[i]]++;

    rep(i, q){
        if (mp[b[i]]>0){
            ll delta = mp[b[i]] * (c[i] - b[i]);
            ans += delta;
            mp[c[i]] += mp[b[i]];
            mp[b[i]] = 0;
        }
        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

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

signed main () {
  int n;
  cin >> n;
  vector<int> a;
  if(n == 0) {
    cout << 0 << endl;
    return 0;
  }
  while(n != 0) {
    a.pb(abs(n) % 2);
    n = -((n - (abs(n) % 2)) / 2);
  }
  reverse(a.begin(), a.end());
  REP(i, a.size()) cout << a[i];
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

string s;

void solve()
{
	for(int i=0;i+1<s.length();++i){
		if(s[i]==s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return;
		}
	}
	for(int i=0;i+2<s.length();++i){
		if(s[i]==s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return;
		}
	}
	cout << -1 << " " << -1 << endl;
}

int main()
{
	cin >> s;
	solve();
	return 0;
}

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

int main() {
	int n=0;
	double m=0;
	double sum=0;
	int flag=0;
    double ans=0;
	cin>>n>>m;
	vector<int> v(n);
	for(int i=0;i<n;i++)
	{
	    cin>>v[i];
	    sum+=v[i];
	}
	sort(v.begin(),v.end(),greater<int>());
    ans=sum/(4*m);
	if(v[m-1]>=ans)
	{
	    flag=1;
	}
	if(flag==1)
	{
	    cout<<"Yes"<<endl;
	}
	else if(flag==0)
	{
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const x = parseInt(input.split(' ')[0])
    const y = parseInt(input.split(' ')[1])
    const g = [
        [1,3,5,7,8,10,12],
        [4,6,9,11],
        [2],
    ]

    let xi = 0
    let yi = 0

    g.forEach((v, i) => {
        v.forEach(vv => {
            if(vv == x){
                xi = i
            }
            if(vv == y){
                yi = i
            }
        })
    })

    if(xi === yi){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=3e5+5,Mo=1e9+7;

int f[N][3][2][2][2],n;
char s[N];

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

// f[i][j][a][b][c]
// 做到第i位
// 已经确定的a[p]=0,a[q]=0的状态为j
// 上一位为a，当前连续的0的奇偶性b，当前在a中的奇偶性c

int main() {
	scanf("%s",s);n=strlen(s);s[n]='1';
	f[0][0][1][0][0]=1;
	fo(i,0,n) fo(j,0,2) fo(a,0,1) fo(b,0,1) fo(c,0,1) {
		if (!f[i][j][a][b][c]) continue;
		int now=f[i][j][a][b][c];
		if (s[i]=='1'||s[i]=='?') {
			if (a) {
				if (c) inc(f[i+1][j>=1?2:0][1][0][c^1],now);
				else inc(f[i+1][max(j,1)][1][0][c^1],now);
			} else {
				if (b) inc(f[i+1][j][1][0][c],now);
				else inc(f[i+1][j][1][0][c^1],now);
			}
		}
		if (s[i]=='0'||s[i]=='?') inc(f[i+1][j][0][b^1][c],now);
	}
	int ans=0;
	fo(a,0,1) fo(b,0,1) fo(c,0,1) inc(ans,f[n+1][2][a][b][c]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 28544
a,b=map(int,input().split())
c=-1
d=-1
e=-1
x=b//10000
for i in range(0,x+1,1):
  y=(b-10000*i)//5000
  for j in range(0,y+1,1):
    k=(b-10000*i-5000*j)//1000
    if i+j+k==a:
      c=i
      d=j
      e=k
print(c,d,e)

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

int dp[305][305], w[305];

int rec(int l, int r){
    if(r-l==1) return 0;
    if(r-l==2){
        if(abs(w[r-1]-w[l])<=1) return 2;
        else return 0;
    }

    if(dp[l][r]>-1) return dp[l][r];
    if(abs(w[r-1]-w[l])<=1 && rec(l+1, r-1)==r-l-2) return dp[l][r] = r - l;

    int res = 0;
    for(int i=l;i<r-1;i++){
        res = max(res, rec(l, i+1)+rec(i+1, r));
    }
    return dp[l][r] = res;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    while(true){
        int N;cin>>N;
        if(!N)return 0;
        for(int i=0;i<N;i++)cin>>w[i];
        for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) dp[i][j] = -1;
        printf("%d\n", rec(0, N));
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(int i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main(){
  ios::sync_with_stdio(false);
  
  int R;
  cin>>R;
  
  cout<<fixed<<setprecision(5)<<2*R*3.1415926535;
  
}

Measured memory_bytes: 3808
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

var pri = fmt.Println
var scan = fmt.Fscanln
var scanone = fmt.Fscan

func main() {
	if os.Getenv("DEBUG") != "" {
		fname := "input.txt"
		f, err := os.Open(fname)
		if err != nil {
			log.Fatal(err)
		}
		r := bufio.NewReader(f)
		for {
			solve(r)
			if r.Buffered() == 0 {
				break
			}
		}
	} else {
		f := os.Stdin
		r := bufio.NewReader(f)
		solve(r)
	}
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

func mustint(a string) int {
	i, _ := strconv.Atoi(a)
	return i
}

type P struct {
	x, y int
}

func (p *P) add(q *P) *P {
	return &P{p.x + q.x, p.y + q.y}
}

func solve(r io.Reader) {
	var n, m int
	scan(r, &n, &m)
	c := make([]int, m)
	for i := 0; i < m; i++ {
		scanone(r, &c[i])
	}
	sort.IntSlice(c).Sort()

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = 1 << 30
	}
	dp[0] = 0
	for i := 1; i < n+1; i++ {
		for _, v := range c {
			if i-v >= 0 {
				dp[i] = min(dp[i], dp[i-v]+1)
			}
		}
	}
	pri(dp[n])
}



Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    cin >> n;
    map<string,int>q;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(q[s]==0){
            cnt++;
            q[s] = 1;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 19200
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	cin >> N;
	vll A, B;
	ll i, j;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	for (i = 0; i < N; i++){
		ll b;
		cin >> b;
		B.push_back(b);
	}
	ll ans = 0;
	for (i = 0; i < N; i++){
		ll ans_tmp = 0;
		ans_tmp += accumulate(A.begin(), A.begin() + i + 1, 0);
		ans_tmp += accumulate(B.begin() + i, B.end(), 0);
		ans = max(ans, ans_tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
const int D=998244353,MAXN=300005;
ll n,a,b,k,x,y,ans;
ll ifac[MAXN],fac[MAXN];
ll power_(ll x,ll k)
{
	ll ret=1;
	while(k)
	{
		if(k&1) ret=(ret*x)%D;
		x=(x*x)%D;
		k>>=1;
	}
	return ret;
}
void first_()
{
	fac[0]=fac[1]=1;
	for(int i=2;i<=n;i++) fac[i]=(fac[i-1]*i)%D;
	ifac[n]=power_(fac[n],D-2);
	for(int i=n;i>=1;i--)
		ifac[i-1]=(ifac[i]*i)%D;
}
ll C(ll aa,ll bb)
{
	if(bb<aa) return 0;
	return (fac[bb]*ifac[aa]%D*ifac[bb-aa])%D;
}
int main()
{
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	first_();
	for(int i=0;;i++)
	{
		if(a*i>k) break;
		if((k-a*i)%b==0)
		{
			x=i;
			y=(k-a*i)/b;
			ans=(ans+C(x,n)*C(y,n)+D)%D;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
def main():
    A, B, C, X, Y = map(int, input().split())

    if X <= Y:
        print(min((Y - X) * B + C * 2 * X, 2 * C * Y, A * X + B * Y))
    else:
        print(min((X - Y) * A + C * 2 * Y, 2 * C * X, A * X + B * Y))



main()

Measured memory_bytes: 38384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  int m;
  cin >> m;
  while(m--){
    string str;
    set<string> cantrain;
    cin >> str;
    FOR(i,1,SZ(str)){
      string
	f(str.begin(),str.begin()+i),
	b(str.begin()+i,str.end()),
	rb(str.rbegin(),str.rend()-i),
      	rf(str.rend()-i,str.rend());
      cantrain.insert(f+b);
      cantrain.insert(b+f);
      cantrain.insert(f+rb);
      cantrain.insert(rb+f);
      cantrain.insert(rf+b);
      cantrain.insert(b+rf);
      cantrain.insert(rf+rb);
      cantrain.insert(rb+rf);
    }
    cout << SZ(cantrain) << endl;
  }
  return 0;
}

Measured memory_bytes: 1296
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;
use text_io::read;

fn main() {
    let n: usize = read!();
    let k: usize = read!();

    let mut snuke = vec![0; n];

    for i in 0..k {
        let di: usize = read!();
        for j in 0..di {
            let ai: usize = read!();
            snuke[ai - 1] = 1;
        }
    }

    let ans = snuke.iter().filter(|&n| *n == 0).count();
    println!("{}", ans);
}


Measured memory_bytes: 2128
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
    int h,w;
    cin>>h>>w;
    V<string> s(h);
    for(int i=0;i<h;i++)cin>>s[i];
    V<V<char>> a(h,V<char>(w,'.')),b(h,V<char>(w,'.'));
    for(int i=0;i<h;i++)a[i][0]='#';
    for(int i=0;i<h;i++)b[i][w-1]='#';
    for(int i=0;i<h;i++){
        if(i%2==0){
        for(int j=0;j<w-1;j++){
            a[i][j]='#';
        }
        }
        else{
         for(int j=1;j<w;j++){
            b[i][j]='#';
          }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                a[i][j]='#';
                b[i][j]='#';
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<a[i][j];
        }
        cout<<"\n";
    }
    cout<<"\n";
for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<b[i][j];
        }
        cout<<"\n";
    }
}

Measured memory_bytes: 1536
# D
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = max(a)
ans = [1 for _ in range(max_a + 1)]
b = -1#存在しない数
#エラトステネスの篩･･･有名な素数判別法

# 1  2  3  4  5  6  7  8  9 
# 11 12 13 14 15 16 17 18 19
#    ×　   ×  ×  ×     ×
#             :

for j in a:
    if b == j:  #行ったところはもう行かない
        ans[j] = 0
    divided = j + j
    while divided < max_a + 1:#jの倍数を0として記録する
        ans[divided] = 0
        divided += j
    b = j

count = 0
for i in a:
    if ans[i] == 1:
        count += 1
print(count)

Measured memory_bytes: 32168
#include <stdio.h>

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


Measured memory_bytes: 2144
#include<iostream>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  int leader[100001];
  int size[100001];
  int A[100001];
  int B[100001];
  for (int i = 0; i < N; i ++) {
    leader[i] = i;
    size[i] = 1;
  }
  for (int i = 0; i < M; i ++) {
    cin >> A[i] >> B[i];
    A[i] --;
    B[i] --;
  }
  long long ans[100001];
  ans[M - 1] = (long long) N * (N - 1) / 2;
  for (int i = M - 1; i > 0; i --) {
    int k = leader[A[i]];
    int j = leader[B[i]];
    while(leader[k] != k) k = leader[k];
    while(leader[j] != j) j = leader[j];
    ans[i - 1] = ans[i];
    if (k != j) {
      ans[i - 1] -= (long long)size[k] * size[j];
      if (size[k] > size[j]) swap(k, j);
      leader[k] = leader[j];
      size[j] += size[k];
    }
  }
  for (int i = 0; i < M; i ++) cout << ans[i] << endl;
}
  


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

int n,k,f[100001],ans,d[100001];
vector<int> point[100001];

void dfs(int u){
	d[u]=1;for(int v:point[u])dfs(v),d[u]=max(d[u],d[v]+1);
	if(d[u]>=k&&f[u]!=1)d[u]=0,++ans;
}

int main(){
	scanf("%d%d",&n,&k);for(int i=1;i<=n;++i){scanf("%d",f+i);if(i!=1)point[f[i]].push_back(i);}
	for(int v:point[1])dfs(v);
	printf("%d",ans+(f[1]!=1));
}

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

int main(){
    long long int H, N; cin >> H >> N;
    bool exist = false;
    for (long long int i = 0; i < N; i++)
    {
        long long int tmp; cin >> tmp;
        H -= tmp;
        if(H <= 0){
            exist = true;
            break;
        }
    }
    if(exist) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>t(n+1);
    vector<int>x(n+1);
    vector<int>y(n+1);
    for(int i=1;i<=n;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    t[0]=0;
    x[0]=0;
    y[0]=0;
    bool judge=true;
    for(int i=1;i<=n;i++){
        int time=t[i]-t[i-1];
        int dx=abs(x[i]-x[i-1]);
        int dy=abs(y[i]-y[i-1]);
        if(time<(dx+dy)||time%2!=(dx+dy)%2){
            judge =false;
        }
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4440
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,f,g;
	cin>>a>>b>>c>>d;
	f=c-a,g=d-b;
	for(int i=0;i<g;i++)cout<<"U";
	for(int i=0;i<f;i++)cout<<"R";
	for(int i=0;i<g;i++)cout<<"D";
	for(int i=0;i<f+1;i++)cout<<"L";
	for(int i=0;i<g+1;i++)cout<<"U";
	for(int i=0;i<f+1;i++)cout<<"R";
	cout<<"DR";
	for(int i=0;i<g+1;i++)cout<<"D";
	for(int i=0;i<f+1;i++)cout<<"L";
	cout<<"U"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, b, f, r, v;
	int cou1, cou2, cou3, cou4;

	int da [4] [3] [10];

	for(cou1 = 0; cou1 < 4; cou1++){
		for(cou2 = 0; cou2 < 3; cou2++){
			for(cou3 = 0; cou3 < 10; cou3++){
				da [cou1] [cou2] [cou3] = 0;
			}
		}
	}

	scanf("%d", &n);

	for(cou1 = 0; cou1 < n; cou1++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		da [b - 1] [f - 1] [r - 1] += v;
	}

	for(cou1 = 0; cou1 < 4; cou1++){
		for(cou2 = 0; cou2 < 3; cou2++){
			for(cou3 = 0; cou3 < 10; cou3++){
				printf(" %d", da [cou1] [cou2] [cou3]);
			}
			printf("\n");
		}
		if(cou1 < 3) printf("####################\n");
	}

	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, L;
    cin >> N >> L;
    int WA = 0;
    for (int i = 1; i <= N; i++) {
        WA += L + i - 1;
    }

    int mi = 1<<30;
    int po = 0;
    for (int i = 1; i <= N; i++) {
        int d = abs(WA - (WA - (L + i - 1)));
        if (d < mi) {
            mi = d;
            po = i; 
        }
    }
    cout << (WA - (L + po - 1))  << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
    ll k;
    cin >> k;
    ll answer = 0;
    FOR(i,1,k+1){
        FOR(j,1,k+1){
            FOR(l,1,k+1){
                ll tmp = gcd(i,j);
                tmp = gcd(tmp,l);
                answer += tmp;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3636
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.random;

void main() {
    const tmp = readln.split.to!(long[]);
    auto N = tmp[0], M = tmp[1];
    auto ps = readln.split.to!(long[]);
    auto pairs = M.iota.map!(_ => readln.split.to!(long[])).array;

    auto nodeFromIndex = new Node[N];
    auto nodeFromValue = new Node[N];
    foreach (i; 0..N) {
        auto n = new Node(i);
        nodeFromIndex[i] = n;
        nodeFromValue[ps[i]-1] = n;
    }

    foreach (i; 0..M) {
        nodeFromIndex[pairs[i][0]-1].unite(nodeFromIndex[pairs[i][1]-1]);
    }

    long cnt;
    foreach (i; 0..N) {
        if (nodeFromIndex[i].find(nodeFromValue[i]))
            cnt++;
    }
    writeln(cnt);
}

class Node {
    long value;
    Node parent;

    this(long value) {
        this.value = value;
    }

    void unite(Node n) {
        if (this.find(n)) return;
        n.root.parent = this.root;
    }

    bool find(Node n) {
        return this.root.value == n.root.value;
    }

    Node root() {
        if (parent is null) return this;
        auto res = parent.root;
        this.parent = res;
        return res;
    }
}


Measured memory_bytes: 24636
#include<bits/stdc++.h>
#include<cstring>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int           long long
#define umapii        unordered_map<int,int>
#define ps(x,y)       fixed<<setprecision(y)<<x // sets precision upto required digits
#define arr(a,n)      int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define outarr(a,n)   for(int i=0;i<n;i++){cout<<a[i]<<" ";}
#define mod           1000000007
#define ff            first
#define big           1e15
#define ss            second
#define add           push_back
#define remove        pop_back
#define mapii         map<int,int>
#define large         *max_element
#define small         *min_element
#define float         double
#define pqi           priority_queue<int>
#define mpqi          priority_queue<int,vector<int>,greater<int>>
#define in(n)         int n;cin>>n;
#define w(t)          int t;cin>>t;while(t--)
#define vi            vector<int>
#define vivi          vector<vector<int>>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;




int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output3.txt", "w", stdout);
#endif

    int n, k;
    cin >> n >> k;
    umapii m;
    while (k--) {
        in(d);
        int a[d];
        for (int i = 0; i < d; i++) {
            cin >> a[i];
            m[a[i]]++;
        }
    }
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (!m.count(i) > 0) {
            count++;
        }
    }
    cout << count << endl;


}

Measured memory_bytes: 3636
ab = [list(map(int, input().split())) for _ in range(3)]
road = [0] * 4
for a, b in ab:
    road[a-1] += 1
    road[b-1] += 1
road.sort()
if road[0]==road[1] and road[2]==road[3]: print("YES")
else: print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  bitset<2002001> b;
  b.set(0);
  int s = 0;
  FOR(i, 0, n){
    int a;
    cin >> a;
    s += a;
    b |= b<<a;
  }
  FOR(i, (s+1)/2, s+1) if(b[i]){
    cout << i << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

llong max3(llong*,llong);

int main(){
	int N,K;
	cin >> N >> K;
	int P[N],C[N];
	rep(i,0,N){
		cin >> P[i];
		P[i] -= 1;
	}
	rep(i,0,N) cin >> C[i];
	
	llong ans=-1000000000;
	rep(i,0,N){
		int n = i;
		llong score = 0,max = C[P[n]];
		rep(j,1,K+1){
			n = P[n];
			score += C[n];
			max = _max(max,score);
			if( n == i ){
				if( score < 0 ) break;
              	max = _max(max,max+score*((K/j)-1));
				score *=(K/j);
				j = (K/j)*j;
			}
		}
		ans = _max(ans,max);
	}
	
	cout << ans;
}


Measured memory_bytes: 3672
using System;

class Program
{
  static int Count(bool evenOne, string s) {
    int total = 0;
    for (int i = 0; i < s.Length; ++i) {
      if (s[i] == (i % 2 == 0 ? (evenOne ? '1' : '0') : (evenOne ? '0' : '1'))) {
        continue;
      }
      total++;
    }
    return total;
  }
  
  static void Main(string[] args)
  {
    var tiles = Console.ReadLine();
    Console.WriteLine(Math.Min(Count(true, tiles), Count(false, tiles)));
  }
}

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

const int N = 3000;
double p[N], f[N][N];

double prob(int n){
	double ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			f[i][j] = f[i-1][j] * (1 - p[i-1]);
			if(j-1 >= 0) f[i][j] += f[i-1][j-1]*p[i-1];
		}
	}

	for(int i = n/2+1; i <= n; i++){
		ans += f[n][i];
	}
	return ans;
}

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

	for(int i = 0; i < n; i++) cin >> p[i];
	for(int i = 0; i <= n; i++) f[0][i] = 0;
	f[0][0] = 1;
	cout << setprecision(10) << prob(n);
}

Measured memory_bytes: 74060
def is_prime(x):
    if x == 1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            return False
    return True

def solve():
    ck = False
    x = X-1
    while not ck:
        x += 1
        ck = is_prime(x)
    print(x)

if __name__ == "__main__":
    X = int(input())
    solve()  


Measured memory_bytes: 9340
import numpy as np

N, M = map(int, input().split())
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])
for i in range(N):
    del A[i][0]

cnt = 0
for i in A[0]:
    flg = True
    for j in range(1,N):
        if not i in A[j]:
            flg = False
            break
    if flg:
        cnt +=1
print(cnt)

Measured memory_bytes: 12448