akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end() 
#define MOD 1000000007
#define N 100005
#define pll pair<ll,ll>
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));


void solve()
{ 
     ll ans = 0;
     ll n;
     cin >> n;
     for(ll i=1;i<=n;i++)
     {
          if(i%3==0 || i%5==0) 
          {

          }
          else
          {
               ans += i;
          }
     }
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
  ///   cin >> t;
     while(t--)
     {     
          solve();
     }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

vector<vector<int> >adj;
string a;
int vis[200005][4];
vector<pair<int,int> >temp;
char arr[4]={'A','A','B','B'};
bool flag=false;
void dfs(int ver,int x)
{
    if(flag)
        return ;
    vis[ver][x]=1;
    temp.push_back({ver,x});
    for(auto i:adj[ver])
    {
        if(vis[i][(x+1)%4]==0)
        {
            if(a[i]==arr[(x+1)%4])
            {
                dfs(i,(x+1)%4);
            }
        }
        else if(vis[i][(x+1)%4]==1)
        {
            if(a[i]==arr[(x+1)%4])
            {
                flag=true;
                return ;
            }
        }
    }
    vis[ver][x]=2;
    if(flag)
        return ;
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    cin>>a;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }    
    for(int i=0;i<n;i++)
    {
        if(vis[i][0]==0 && a[i]=='A')
        {
            temp.clear();
            dfs(i,0);
            for(auto j:temp)
                vis[j.first][j.second]=2;
        }   
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";


} 
    


Measured memory_bytes: 32156
n, _ = gets.chomp.split(' ').map(&:to_i)
dislikes = gets.chomp.split(' ')
map = Hash.new(-1)
dislikes.each { |i| map[i] = 1 }
n.upto(10 * n) do |i|
  ws = i.to_s.split('')
  ok = true
  ws.each do |j|
    ok = ok && map[j] != 1
  end
  if ok
    puts i
    exit 0
  end
end

Measured memory_bytes: 2044
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> d(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }

    ll sum = 0;
    for (ll i = 0; i < N - 1; i++)
    {
        for (ll j = i + 1; j < N; j++)
        {
            sum += d.at(i) * d.at(j);
        }
    }

    cout << sum << endl;
    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
N, Q = gets.split.map(&:to_i)
S = gets.chomp.split(//)

num = []
count = 0
S.each do |i|
  if i == "A" && S[count+1] == "C"
    num << 1
    count += 1
  else
    num << 0
    count += 1
  end
end

nums = [0]
sum = 0
num.each do |j|
  sum += j
  nums << sum
end

Q.times do
  l, r = gets.split.map(&:to_i)
  p nums[r-1] - nums[l-1]
end

Measured memory_bytes: 25604
#include <stdio.h>

int main(void){
    int n,a,b,c,check,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
     check =0;
     scanf("%d %d %d",&a,&b,&c);
     a=a*a;
     b=b*b;
     c=c*c;
     if(a==b+c||b==a+c||c==a+b)
         check =1;
     if(check)
	printf("YES\n");
     else
	printf("NO\n");
     }
   return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {

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

        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        int n3 = sc.nextInt();
        int n4 = sc.nextInt();
        int n5 = sc.nextInt();
        if (n1 == 0) {
            System.out.println(1);
        }
        if (n2 == 0) {
            System.out.println(2);
        }
        if (n3 == 0) {
            System.out.println(3);
        }
        if (n4 == 0) {
            System.out.println(4);
        }
        if (n5 == 0) {
            System.out.println(5);
        }


        sc.close();
    }

}

Measured memory_bytes: 35764
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; 
const int dx[4]={-1, 1, 0, 0}, dy[4]={0, 0, 1, -1};
int h, w, ans;
char map[101][101];
bool visited[101][101];


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


void dfs(int x, int y){
    visited[x][y] = true;
    int xx, yy;
    for(int i=0; i<4; i++){
        xx = x + dx[i]; yy = y + dy[i];
        if(check_coordinates(xx, yy) && !visited[xx][yy] && map[x][y]==map[xx][yy]){
            dfs(xx, yy);
        }
    }
    return;
}

int main(){
    //freopen("in.txt", "r", stdin);
    while(scanf("%d %d", &h, &w), h!=0 && w!=0){
        for(int i=0; i<h; i++)
            scanf("%s", map[i]);
        memset(visited, 0, sizeof(visited));
        ans = 0;
        
        for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            if(!visited[i][j]){
                ++ans;
                dfs(i, j);
            }

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


Measured memory_bytes: 3384
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);
    int N;
    string s;
    cin >> N >> s;

    int r = 0, b = 0;
    for (int i = 0; i < N; ++i)
    {
        if (s[i] == 'B')
            b++;
        else
            r++;
    }

    if (r > b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int a[100005], dp[100005];

int main(){
    int n; cin >> n;
    int res = 0;
    int acc = 1;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i > 1){
            if(a[i] <= a[i-1]) acc++;
            else {
                res = max(res, acc);
                acc = 1;
            }
        }
    }
    res = max(res, acc);
    cout << res-1 << endl;
    // a[i+1] = 1e9+5;
    // for(int i = n; i >= 1; i--)
    //     if(a[i+1] < a[i])
    //         dp[i] = dp[i+1] + 1;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
        #define endl '\n'
        #define modulo 1000000007
        #define int unsigned long long
        //#define __int128 long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
        #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(pair<int,int>a,pair<int,int>b)
        {
            if(a.second==b.second)
            return a.first<b.first;
            return a.second<b.second;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int n,m,start=0,ender=0;
            cin>>m>>n;
            int arr[n];
            for(int i=0;i<n;i++){
            cin>>arr[i];
            if(!i)
            start=arr[i];
            if(i+1==n)
            ender=arr[i];
            }
            int miner=ender-start;
            for(int i=0;i<n;i++){
            if(i+1!=n){
            miner=min(miner,m-(arr[i+1]-arr[i]));
            }
            else if(i){
            miner=min(miner,m-(arr[i]-arr[i-1]));
            }
            }
            cout<<miner;
            return 0;
        }


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

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

Measured memory_bytes: 256
N = gets.to_i
C = []
N.times{
  C << gets.chomp.split(" ").map(&:to_i)
}

ans = 0
(0...N-1).each{|i|
  (i+1...N).each{|j|
    ans += Math.sqrt((C[i][0] - C[j][0]) ** 2 + (C[i][1] - C[j][1]) ** 2)
  }
}

puts ans * 2 / N.to_f


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <string>
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long int ll;
const ll INF = 100100100100100100;
using namespace std;

ll N;
ll field[660][660];

int main(){
    cin >> N;
    rep(i,N){
        string s;
        cin >> s;
        rep(j,N){
            field[i][j] = s[j] - 'a';
            field[i+N][j] = field[i][j];
            field[i][j+N] = field[i][j];
            field[i+N][j+N] = field[i][j];
        }
    }
    ll ans = 0;
    rep(k,N){
        bool ok = true;
        rep(i,N){
            rep(j,N){
                if(field[i+k][j] != field[j+k][i]){
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
        if(ok){
            ans += N;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
S=get_nsp
if S.count("#")==N or S.count(".")==N
    puts 0
    exit
end
r=array(N,0)
l=array(N,0)
r[0]=1 if S[0]=="#"
(N-1).times do|i|
  r[i+1]=r[i]
  r[i+1]+=1 if S[i+1]=="#"
end

l[0]=1 if S[N-1]=="."
(N-1).times do|i|
    l[i+1]=l[i]
    l[i+1]+=1 if S[N-2-i]=="."
end
min=INF
N.times do|i|
  min=min(min,l[N-1-i]+r[i]-1)
end
puts min

Measured memory_bytes: 19964
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>


#ifndef _USEFUL_MACROS_
#define _USEFUL_MACROS_
#define INF 99999999
#define N_PRIME 1000000007
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
//#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x) do{}while(false)
#endif
#endif 

using namespace std;

int main(void){
    int N,W;
    cin >> N >> W;
    int v[N];
    int w[N];
    
    REP(i,N)cin >> v[i] >> w[i];
    
    int dp[W+1];    // ?????§?????????
    int ret = 0;
    REP(i,W+1)dp[i]=0;
    
    REP(i,N){
        int this_v = v[i];
        int this_w = w[i];
        RREP(j,W+1-this_w){
            dp[j+this_w] = max( dp[j] + this_v ,dp[j+this_w]);
            debug(j+this_w);
            debug(dp[j+this_w]);
        }
    }
    
    REP(i,W+1){
        ret=max(ret,dp[i]);
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3072
x, n = map(int, input().split())

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    while(1):
        if (x - i) not in p:
            print(x - i)
            break
        if (x + i) not in p:
            print(x + i)
            break
        i += 1


Measured memory_bytes: 9180
N, X, Y = map(int, input().split())
ans = [0] + [0]*(N-1)

for i in range(1, N):
  for j in range(i+1, N+1):
    diff = min(j-i, abs(i-X)+abs(j-Y)+1)
    ans[diff] += 1

for i in range(1, N):
  print(ans[i])


Measured memory_bytes: 3444
#include<stdio.h>

int main() {
	int a, b, sum;
	int i;

	while (scanf("%d %d", &a, &b) != EOF) {
		sum = a + b;
		for (i = 0; sum != 0; i++) {
			sum /= 10;
		}
		printf("%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 600
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int trie[1000010][26];
bool akhir[1000010];
string arr[200200];
vector<int> s[200200];
int now = 1;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    for(i=1;i<=n;i++) {
        cin >> arr[i];
        reverse(arr[i].begin(), arr[i].end());
        int node = 0;
        for(auto x : arr[i]) {
            s[i].push_back(node);
            if(trie[node][x-'a'] == 0) {
                trie[node][x-'a'] = now++;
            }
            node = trie[node][x-'a'];
        }
        akhir[node] = 1;
    }
    ll chaeng = 0;
    for(i=1;i<=n;i++) {
        set<int> suff;
        int sz = arr[i].size();
        for(j=sz-1;j>=0;j--) {
            suff.insert(arr[i][j]-'a');
            int node = s[i][j];
            for(auto x : suff) {
                chaeng += akhir[trie[node][x]];
            }
        }
    }
    cout << chaeng - n << endl;
    return 0;
}


Measured memory_bytes: 123768
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b)
{ return *(int *)b - *(int *)a ;}

int main()
{
  int n,i,j,k,count=0;
  int l[2002];

  scanf("%d", &n);

  for(i=0; i<n; i++)
    scanf("%d",&l[i]);

  qsort(l,n,sizeof(int),cmp);

  for(i=0; i<n-2; i++){
    for(k=i+1; k<n-1; k++){
      for(j=k+1; j<n; j++){
        if(l[i]+l[k]>l[j] && l[k]+l[j]>l[i] && l[j]+l[i]>l[k])
        count++;
      }
    }
  }

  printf("%d", count);
  return 0;
}


Measured memory_bytes: 1720
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
    int N, taroScore, hanakoScore;
    char *taroCards = new char[101];
    char *hanakoCards = new char[101];
    cin >> N;
    taroScore = 0; hanakoScore = 0;
    while(N-- > 0) {
        scanf("%s %s", taroCards, hanakoCards);
        while(true) {
            if(*taroCards > *hanakoCards) {
                taroScore += 3;
                break;
            }
            if(*taroCards < *hanakoCards) {
                hanakoScore += 3;
                break;
            }
            if(*taroCards == '\0' && *hanakoCards == '\0') {
                taroScore++;
                hanakoScore++;
                break;
            }

            if(*taroCards != '\0') taroCards++;
            if(*hanakoCards != '\0') hanakoCards++;
        }
    }

    printf("%d %d\n", taroScore, hanakoScore);

    return 0;
}

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

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

void shellSort(vector<int> A, int n){
  cnt = 0;
  vector<int> G;
  G.push_back(1);
  while(*(G.end()-1) < A.size()/3){
    //G[i+1] = G[i]*3+1;
    G.push_back(*(G.end()-1)*3+1);
  }
  unsigned int m = G.size();
  reverse(G.begin(), G.end());

  cout << m << endl;;
  for(int i = 0; i < m-1; i++){
    cout << G[i] << " ";
  }
  cout << G[m-1] << endl;

  for(int i = 0; i < m; i++){
    insertionSort(A, n, G[i]);
  }
  cout << cnt << endl;

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

}

int main(void){
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  shellSort(A, N);
  return 0;
}

Measured memory_bytes: 8856
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110];
int B[110];
int C[110];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=0;i<n;i++)cin>>B[i];
    for(int i=1;i<n;i++)cin>>C[i];

    for(int i=1;i<n;i++)
        if(A[i]==A[i-1]+1)sum+=C[A[i]-1];

    for(int i=0;i<n;i++)
        sum+=B[i];

    cout<<sum<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    rep(i,n)rep(j,i){
        int d = abs(a[i]-a[j]);
        if(d%(n-1)==0){
            cout << a[i] << " " << a[j] << endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3104
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun pascalsTriangle(size: Int): Array<LongArray> {
    val t = Array(size) { LongArray(it + 1) }
    if (size == 0) return t
    t[0][0] = 1L
    for (y in 1 until size) {
        val p = t[y - 1]
        val q = t[y]
        for (x in 0 until y) {
            val a = p[x] + q[x]
            val b = p[x] + q[x + 1]
            q[x] = if (a < 1000000007L) a else a - 1000000007L
            q[x + 1] = if (b < 1000000007L) b else b - 1000000007L
        }
    }
    return t
}

fun main(args: Array<String>) {
    val (n, k) = readInts()
    val m = n - k
    val pt = pascalsTriangle(n + 1)
    fun c(n: Int, m: Int): Long {
        if (pt.size <= n || pt[n].size <= m) return 0
        return pt[n][m]
    }
    for (i in 1..k) {
        val blue = c(k - 1, i - 1)
        val red = c(m + 1, i)
        println(blue * red % 1000000007L)
    }
}


Measured memory_bytes: 63720
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX 100000000
#define INFTY (1<<30)

int n, H[MAX];


void maxHeap(int i) {
    int left = i * 2;
    int right = i * 2 + 1;
    
    if (left > n) return;
    
    int max = left;
    if (right <= n) max = H[left] >= H[right] ? left : right;
    max = H[i] >= H[max] ? i : max;
    
    if (max != i) {
        std::swap(H[i], H[max]);
        maxHeap(max);
    }
}

void heapIncrease(int key, int i) {
    if (H[i] > key) return;
    H[i] = key;
    while (H[i/2] < H[i] && i > 1) {
        std::swap(H[i/2], H[i]);
        i = i/2;
    }
}

void insert(int key) {
    n++;
    H[n] = -INFTY;
    heapIncrease(key, n);
}


int extract() {
    if (n < 1) return -INFTY;
    int max = H[1];
    H[1] = H[n];
    n--;
    maxHeap(1);
    
    return max;
}



int main() {
    int key;
    char moji[10];
    n = 0;
    
    while (1) {
        scanf("%s", moji);
        if (moji[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else if (moji[0] == 'e' && moji[1] == 'x') {
            printf("%d\n", extract());
        } else {
            break;
        }
    }
    
    return 0;
}



Measured memory_bytes: 7020
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define double long double
    const int INF=0x3f3f3f3f;
    const ll LLINF=0x3f3f3f3f3f3f3f3fll;
    ll qread()
    {
        ll ans=0;char c=getchar();int f=1;
        while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) {num=-num;putchar('-');}
        if(num>9) write(num/10);
        putchar('0'+num%10);
    }
    void writeln(ll num){write(num);puts("");}
    #define FR first
    #define SE second
    #define MP make_pair
    #define pr pair<int,int>
    #define PB push_back
    #define vc vector
    void chmax(int &x,const int y) {x=x>y?x:y;}
    void chmin(ll &x,const ll y) {x=x<y?x:y;}
    const int MAX_N=5e3+10;
    const ll MOD=1e13;
    void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

    ll f[MAX_N];//前缀和
    int a[MAX_N];
    void main()
    {
        int n=qread(),A=qread(),B=qread();
        for(int i=1;i<=n;i++) a[qread()]=i;
        for(int i=1;i<=n;i++)
        {
            for(int j=n;j>=0;j--)
            {
                f[j]=f[j]+A*(a[i]<=j)+B*(a[i]>j);
                if(j==a[i]) chmin(f[j],f[j-1]);
                else if(j) chmin(f[j],f[j-1]+A*(a[i]<j)+B*(a[i]>j));
            }
            for(int j=1;j<=n;j++) chmin(f[j],f[j-1]);
            // puts("");
        }

        ll ans=LLINF;for(int j=0;j<=n;j++) chmin(ans,f[j]);write(ans);
    }
};
int main()
{
    srand(time(0));
    mine::main();
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const int inf = 1e9;



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

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

    int best = 0;

    for (int k=1; k<=n-1; k++) {
	int x1 = -inf, x2 = -inf;
	for (int mask=k; ; mask=(mask-1)&k) {
	    int cur=a[mask];
	    if (cur >= x1) {
		x2 = x1;
		x1 = cur;
	    } else if (cur >= x2) {
		x2 = cur;
	    }
	    best = max(best, x1+x2);
	    if (mask==0) break;
	}

	cout<<best<<"\n";
    }
    
    return 0;
}


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

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

	int whiteNum = 0;
	for (auto c : s) {
		//count white
		whiteNum += (c == '.' ? 1 : 0);
	}

	if (whiteNum == n || whiteNum == 0) {
		cout << 0 << endl;
		return 0;
	}

	int diff = 0, diffmin = 0;
	for (auto c: s) {
		diffmin = min(diffmin, diff);
		diff += (c == '#' ? 1 : -1);
	}
	diffmin = min(diffmin, diff);

	cout << whiteNum + diffmin << endl;
	return 0;
}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define dle(a,b) (equals(a,b) || a<b)
static const double PI = M_PI;

class Point {
public:
  double x,y;
  
  Point (double x=0, double y=0): x(x), y(y) {}

  Point operator+ ( Point p ) { return Point(x+p.x, y+p.y); }
  Point operator- ( Point p ) { return Point(x-p.x, y-p.y); }
  Point operator* ( double k ) { return Point(k*x, k*y); }
  Point operator/ ( double k ) { return Point(x/k, y/k); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x+y*y; }

  bool operator< ( const Point &p ) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  
  bool operator== (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;

double norm( Vector a ) { return a.x*a.x + a.y*a.y; }
double abs( Vector a ) { return sqrt(norm(a)); }
Point polar( double a, double r ) { return Point(cos(r)*a, sin(r)*a); }
double getDist( Vector a, Vector b ) { return abs(a - b); }
double dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; }

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0, Point p1, Point p2 ) {
  // about CCW
  // http://gihyo.jp/dev/serial/01/geometry/0006?page=2

  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
  if( cross(a, b) < -EPS ) return CLOCKWISE;
  if( dot(a, b) < -EPS ) return ONLINE_BACK;
  if( norm(a) < norm(b) ) return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool isConvex( Point P[4] ) {
  int c = ccw(P[0], P[1], P[2]);
  for( int i = 1; i < 4; i++) {
    if( c!= ccw(P[i], P[(i+1)%4], P[(i+2)%4]) ) return false;
  }
  return true;
}

int main() {
  char ch;
  Point P[4];

  while( cin>>P[0].x>>ch>>P[0].y) {
    for(int i=1; i<4; i++) cin >> ch >> P[i].x >> ch >> P[i].y;
    if( isConvex(P) ) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_GRL_7_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYE = ReadInt();
            int X = XYE[0];
            int Y = XYE[1];
            int E = XYE[2];

            int V = X + Y + 2;
            FordFulkerson fd = new FordFulkerson(V);
            for (int i = 0; i < E; i++)
            {
                var input = ReadInt();
                fd.AddEdge(input[0] + 2, input[1] + X + 2, 1);
            }
            for (int i = 0; i < X; i++)
            {
                fd.AddEdge(0, i + 2, 1);
            }
            for (int i = 0; i < Y; i++)
            {
                fd.AddEdge(i + X + 2, 1, 1);
            }

            var ans = fd.MaxFlow(0, 1);

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    /// <summary>
    /// 最大流　容量に注意
    /// </summary>
    class FordFulkerson
    {
        public struct Edge
        {
            public int to, cap, rev;
        }

        public List<Edge>[] G;
        bool[] used;
        int INF = 1000000009;

        public FordFulkerson(int V) //頂点数
        {
            G = new List<Edge>[V].Select(x => new List<Edge>()).ToArray();
            used = new bool[V];
        }

        public void AddEdge(int from, int to, int cap)
        {
            G[from].Add(new Edge() { to = to, cap = cap, rev = G[to].Count });
            G[to].Add(new Edge() { to = from, cap = 0, rev = G[from].Count - 1 });
        }

        int Dfs(int v, int t, int f)
        {
            if (v == t)
                return f;
            used[v] = true;

            for (int i = 0; i < G[v].Count; i++)
            {
                var e = G[v][i];
                if (!used[e.to] && e.cap > 0)
                {
                    int d = Dfs(e.to, t, Math.Min(f, e.cap));
                    if (d > 0)
                    {
                        e.cap -= d;
                        G[v][i] = e;

                        var temp = G[e.to][e.rev];
                        temp.cap += d;
                        G[e.to][e.rev] = temp;

                        return d;
                    }
                }
            }
            return 0;
        }

        public int MaxFlow(int s, int t)
        {
            int flow = 0;
            while (true)
            {
                used = new bool[used.Length];
                int f = Dfs(s, t, INF);
                if (f == 0) return flow;
                flow += f;
            }
        }
    }
}



Measured memory_bytes: 20728
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
const int N = 200005;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

inline void chkmin(int &x, int y) { x = x < y ? x : y; }

int n;
int a[N];
int stk[N], cnt[N], top;

bool Push(int nu, int x) {
	if (!nu) return false;
	if (!top) {
		stk[++top] = nu, cnt[top] = 1;
		return true;
	}

	bool flag = false;
	while (top && stk[top] > nu) --top, flag = true;

	if (top && stk[top] == nu) {
		++cnt[top];
		if (cnt[top] > x) {
			--top;
			if (!Push(nu - 1, x)) return false;
			if (!Push(nu, x)) return false;
		}
	} else {
		stk[++top] = nu, cnt[top] = 1;
		if (flag) if (!Push(nu, x)) return false;
	}
	return true;
}

inline bool check(int x) {
	top = 0;
	if (x == 1) {
		for (int i = 2; i <= n; ++i)
			if (a[i] <= a[i - 1]) return false;
		return true;
	}
	for (int i = 1; i <= n; ++i)
		if (!Push(a[i], x)) return false;
	return true;
}

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
//	freopen("log", "w", stderr);
#endif
	ios::sync_with_stdio(false);

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

	int l = 1, r = n, mid, ans;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}

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

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,x;
    cin>>k>>x;
    for(ll i=x-k+1;i<=x+k-1;i++)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7;
    }
    else if (s == "MON") {
        cout << 6;
    }
    else if (s == "TUE") {
        cout << 5;
    }
    else if (s == "WED") {
        cout << 4;
    }
    else if (s == "THU") {
        cout << 3;
    }
    else if (s == "FRI") {
        cout << 2;
    }
    else cout << 1;
}


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

int main() {
    int N, M, Q, l[200000], r[200000], p, q, map[501][501] = {}, sum_map[501][501] = {};
    cin >> N >> M >> Q;
    for (int i = 0; i < M; i++) {
        cin >> l[i] >> r[i];
        map[l[i]][r[i]]++;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            sum_map[i][j] = sum_map[i][j - 1] + map[i][j];
        }
    }

    for (int num = 0; num < Q; num++) {
        int ans = 0;
        cin >> p >> q;
        for (int i = p; i <= q; i++) ans += sum_map[i][q] - sum_map[i][p - 1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#include<cstring>
#include<string.h>
using namespace std;
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define T int t;cin>>t;while(t--)
#define MOD 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define S second n
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<int>
#define vecl vector<long long int> 
#define vec1 vector<string>
#define vec2 vector<vector<int>>
#define all(n) (n).begin(), (n).end()
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
//Author:-Avinash//
    
#define MAX 1000
 
int main()
{

    FAST
    int x;
    cin>>x;
    if(x>=30)
      cout<<"Yes";
    else
      cout<<"No";
   return 0;

 }

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

template <class T>
inline T Min(const T &a, const T &b) {return a < b ? a : b;}

typedef long long ll;

const int N = 505;
const ll INF = 1e18;

int n, a[N][N];
ll ans = INF, s1[N][N], s2[N][N], f[N][N];

int main()
{
	read(n);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++)
		if (i != j) read(a[i][j]);
	for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++)
		s1[i][j] = s1[i][j - 1] + a[j][i], s2[i][j] = s2[i][j - 1] + a[i][j];
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)
		f[i][j] = INF; f[1][1] = 0;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++)
	{
		ll cost = 0;
		for (int k = i + 1; k <= n; k++)
			f[k][i] = Min(f[k][i], f[i][j] + cost + s2[k][i - 1]),
				cost += s2[k][j - 1] + s1[k][k - 1] - s1[k][i - 1];
		ans = Min(ans, f[i][j] + cost);
	}
	return std::cout << ans << std::endl, 0;
}

Measured memory_bytes: 10512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;

public class Main {

	public static void main(String args[]) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// String str[] = br.readLine().split(" ");
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		int c = Integer.parseInt(br.readLine());
		int x = Integer.parseInt(br.readLine());

		int count = 0;

		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (x == (i * 500 + j * 100 + k * 50)) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int n,m;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    string x;
    cin>>x;
    vector<int> v;
    for(int i=0;i<=n;i++){
        if(x[i]=='0')
            v.pb(i);
    }
    int cr=v.size()-1;
    vector<int> c;
    while(cr>0){
        int mn=cr;
        for(int i=cr-1;i>=0;i--){
            if(v[cr]-v[i]<=m){
                mn=i;
            }
            else
                break;
        }
        c.pb(v[cr]-v[mn]);
        if(mn==cr){
            cout<<-1;
            return 0;
        }
        cr=mn;
    }
    //cout<<c.size()<<endl;
    for(int i=c.size()-1;i>=0;i--)
        cout<<c[i]<<' ';
    return 0;
    }


Measured memory_bytes: 1480
// Problem : C - Go Home
// Contest : AtCoder - AtCoder Beginner Contest 056
// URL : https://atcoder.jp/contests/abc056/tasks/arc070_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int ans = 1;
	while(n>0){
	    n-=ans;
	    ans++;
	}
	cout << ans-1;
	return 0;
}

Measured memory_bytes: 256
A,B = map(int, input().split())
ans = 0
if A==B: 
    print(A)
    exit()
for keta in range(1,50):
    beki = 2**(keta-1)
    if beki>A and beki>B: break
    ra,qa = A%beki,A//beki
    rb,qb = B%beki,B//beki

    if keta>1:
        tmp = 0
        if qa%2==1:  tmp+=beki-ra
        if qb%2==1:  tmp+=rb+1
        if tmp%2==1: ans += beki
    else: # keta==1
        ra,qa = A%2,A//2
        rb,qb = B%2,B//2
#         print(ra, qa)
#         print(rb,qb)
        if qb-qa>0:
            tmp = qb-qa-1 
    #         print(tmp)
            tmp += 1
            if rb==1: tmp+=1
            if tmp%2==1: ans += 1
        else:
            ans += 1
        
#     print(beki, bin(ans))
print(ans)
        

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp make_pair
#define pb push_back
#define mes(a,b) memset(a,b,sizeof(a))
#define mes0(a) memset(a,0,sizeof(a))
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define sss(a) a::iterator
#define all(a) a.begin(),a.end()

using namespace std;

typedef double DB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<long long ,int> pli;
typedef pair<int,long long > pil;
typedef pair<string,int> psi;
typedef pair<long long ,long long > pll;

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1);
const int maxn = 100000+10;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int T;
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;

    return 0;
}


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

struct process {
  string name;
  int time;
};

int main () {
  int n, q;
  int res = 0;

  cin >> n >> q;
  queue<process> que;
  string s;
  int t;
  while(cin >> s >> t) {
    que.push(process{s, t});
  }

  while(!que.empty()) {
    process p = que.front(); que.pop();
    if(p.time > q) {
      p.time -= q;
      res += q;
      que.push(p);
    } else {
      res += p.time;
      cout << p.name << " " << res << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
 int gcd(int x,int y){
   if(y==0)
     return x;
   else return gcd(y, x%y);
 }

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  bool can = true;

  if(c % gcd(a,b) != 0) can = false;
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
s_len = len(s)

if s[0] != "A":
    print("WA")
    exit()

cntc = 0

for i in range(2,s_len-1):
    if s[i] == "C":
        cntc += 1

if cntc != 1:
    print("WA")
    exit()

s = s.replace("C", "")
s = s.replace("A", "")

if s_len-2 != len(s):
    print("WA")
    exit()

for i in range(s_len-2):
    if s[i].isupper():
        print("WA")
        exit()

print("AC")

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


using namespace std;

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

uint64_t MOD = 1e9 + 7;
void go(){
   int n,m;cin>>n>>m;
   map<int, bool> broken;
   for(int i=0;i<m;i++){
      int b;cin>>b;
      broken[b]=true;
   }
   vector<uint64_t> dp(n+2, 0);
   dp[0]=0;
   dp[1]=1;
   for(int i=2;i<n+2;i++){
      if(broken[(i-2)+1]==true){
         dp[i]=0;
         continue;
      }
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
   }
   
   uint64_t ans=dp[n+1];
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

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

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

int ee(int a) {
    // to find x such that a.x = 1 (mod m)
    int x=1, y=0, m = mod;
    while(a > 1) {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q*y;
        x = t;
    }
    if(x < 0) x += mod;
    return x;
}

int modpow(int a, int b) {
    if(a==0) return 0;    
    if(b==1) return a;    
    int res = 1;
    while(b) {
        if(b%2) res = mul(res, a);
        b /= 2;
        a = mul(a, a);
    }    return res;
}

int to_int(string s) {
    int ans = 0;
    int n = s.size();
    for(int i=0; i<n; i++) {
        ans = ans*10 + (s[i] - '0');
    }    
    return ans;
}

const int N = 2e5+5;
int fac[N];
int mi[N];
int dp[N];
int sz[N];
int ans[N];
int n;
vector<int> g[N];

void pre() {
    fac[1] = fac[0] = 1;
    for(int i=2; i<N; i++) fac[i] = mul(fac[i-1], i);
    for(int i=2; i<N; i++) mi[i] = modpow(fac[i], mod - 2);
}

void rec1(int u, int par) {
    sz[u] = 1;
    dp[u] = 1;
    for(int v : g[u]) if(v != par) {
        rec1(v, u);
        sz[u] = add(sz[u], sz[v]);
        dp[u] = mul(dp[u], dp[v]);
        dp[u] = mul(dp[u], modpow(fac[sz[v]], mod - 2));
    }
    dp[u] = mul(dp[u], fac[sz[u] - 1]);
}

void rec2(int u, int par, int ua) {
    ans[u] = ua;
    for(int v : g[u]) if(v != par) {
        int va = mul(ua, sz[v]);
        va = mul(va, modpow(n - sz[v], mod - 2));
        rec2(v, u, va);
    }
}

void solve() {
	cin >> n;
    for(int i=1; i<n; i++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    pre();
    rec1(1, 0);
    rec2(1, 0, dp[1]);
    for(int i=1; i<=n; i++) cout << ans[i] << endl;
}   


signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 22512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int MIN = 2, MAX = 2;
  RREP(i, N){
    MIN = ((MIN-1)/A[i]+1)*A[i];
    MAX = MAX/A[i]*A[i]+A[i]-1;
  }

  int l = MIN, r = MAX;
  REP(i, N){
    l -= l%A[i];
    r -= r%A[i];
  }

  if(l == 2 && r == 2)
    cout << MIN << " " << MAX << endl;
  else cout << -1 << endl;

  return 0;
}

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

typedef long long ll;

const ll mod = 1000000007;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W, 0));
  A[0][0] = 1;
  rep(i, H) {
    string s;
    cin >> s;
    rep(j, W) {
      if (s[j] == '.') {
        if (j!=0) {
          A[i][j] += A[i][j-1];
        }
        if (i!=0) {
          A[i][j] += A[i-1][j];
        }
      }
      A[i][j] %= mod;
    }
  }
  cout << A[H-1][W-1] << endl;
}

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

int main() {
	int n;
	cin >> n;
	set<string>s;
	for (int i = 0; i < n; i++) {
		string x;
		cin >> x;
		s.insert(x);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 19132
from collections import defaultdict
import sys

sys.setrecursionlimit(1000000)

G = defaultdict(list)

N = int(input())
C = [0 for i in range(N)]
last = N


def rec(pos, c):
    """ 2 色で塗ることができることが保証されている """
    global C
    C[pos] = c
    for to in G[pos]:
        if C[to] == 0:
            rec(to, -c)


for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1; v -= 1
    # 無向グラフ
    if w%2 == 0:
        G[u].append(last)
        G[last].append(u)
        G[v].append(last)
        G[last].append(v)
        C.append(0)
        last += 1
    else:
        G[u].append(v)
        G[v].append(u)
rec(0, 1)
for i in range(N):
    print(0 if C[i] == -1 else 1)

Measured memory_bytes: 99452