akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
struct S{
    string St;
    int ten;
    int Num;
};
bool cmp(const S &a, const S &b){
    if(a.St != b.St){
        return a.St < b.St;
    }else if(a.ten != b.ten){
        return a.ten > b.ten;
    }else
        return a.Num < b.Num;
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N;
    vector <S> P;
    S tmp;
    cin >> N;
    FOR(i,0,N){
        cin >> tmp.St >> tmp.ten;
        tmp.Num = i+1;
        P.push_back(tmp);
    }
    sort(P.begin(),P.end(),cmp);
    FOR(i,0,N){
        cout << P[i].Num << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long int 
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     vvi				vector<vector<int>>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'


void solve(){

	int n;
	cin>>n;
	if(n >= 30) cout<<"Yes";
	else cout<<"No";


}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;
    int t = 1;

    solve();
    // t(){
    // 	cout<<"Case #"<<t<<": ";
    // 	solve();
    // 	t++;
    // }


}








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

int main(){
    int a,b,c=0;
    string s;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        s=to_string(i);
        for(int j=0;j<(s.size()+1)/2;j++){
            if(s[j]!=s[s.size()-j-1]) break;
            if(j==(s.size()-1)/2) c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
s_r = s[::-1]
ans = "No"
if s == s_r:
    ss = s[:int((len(s) - 1) / 2)]
    ss_r = ss[::-1]
    if ss == ss_r:
        sss = s[int((len(s) + 3) / 2) - 1:]
        sss_r = sss[::-1]
        if sss == sss_r:
            ans = "Yes"
print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
  bitset<64>b(0);
  //cout<<b<<endl;
  //cout<<(~b)<<endl;
  //cout<<(b<<1)<<endl;
  //cout<<(b>>1)<<endl;
  //cout<<(a&b)<<endl;
  //cout<<(a|b)<<endl;
  //cout<<(a^b)<<endl;
  int q,x,y;
  cin>>q;
  while(q--){
    cin>>x;
    if(x<4)cin>>y;
    if(x==0) cout<<b.test(y)<<endl;
    if(x==1) b.set(y);
    if(x==2) b.reset(y);
    if(x==3) b.flip(y);
    if(x==4) cout<<b.all()<<endl;
    if(x==5) cout<<b.any()<<endl;
    if(x==6) cout<<b.none()<<endl;
    if(x==7) cout<<b.count()<<endl;
    if(x==8) cout<<b.to_ullong()<<endl;
  }
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int n,m,table[1000],sum;

	while(true){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0)break;

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

		for(int i = 1; i <= n-1; i++){
			for(int k = n-1; k >= i; k--){
				if(table[k] > table[k-1])swap(table[k],table[k-1]);
			}
		}

		sum = 0;

		for(int i = 0; i < n; i++){
			if(i%m != m-1){
				sum += table[i];
			}
		}
		printf("%d\n",sum);
	}

	return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())


int main() {
    /*
    int N,M; cin >> N >> M;
    if (N == M) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }*/
    int a, b; cin >> a >> b;

    int c = 0, d = 0;
    FOR(i,b-1) {
        c += a;
        c *= 10;
    } c += a;
    FOR(i,a-1) {
        d += b;
        d *= 10;
    } d += b;
    cout << max(c,d) << endl;




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(){

	int n,a,b,c,x;
	int y[101];

	while(cin>>n>>a>>b>>c>>x&&!(n==0&&a==0&&b==0&&c==0&&x==0)){
		queue<int> q;
		int hit[10001];
		fill(hit,hit+10001,0);
		int num=0;
		for(int i = 0; i < n; i++){
			cin>>y[i];
			hit[y[i]]++;
			num++;
			q.push(y[i]);
		}
		int i=0;
		int cn=q.front();
		q.pop();
		for(i = 0; i <= 10000; i++){
			if(x==cn){
				if(q.size()==0)
					break;
				cn=q.front();
				q.pop();
				//hit[x]--;
				//num--;
			}
			x=(a*x+b)%c;
		}
		if(i==10001)
			cout<<-1<<endl;
		else
			cout<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll vis[100005];
bool dp[100005];
bool dp2[100005];
ll col[100005];
ll par[100005];
vector<ll> v[100005];
bool rec(ll ver,ll pa)
{
	vis[ver]=1;
	par[ver]=pa;
	if(v[ver].size()==1&&ver!=1)
	{
		dp[ver]=true;
		return true;
 
	}
	int f=1;
		int f2=1;
	
	for(int i=0;i<v[ver].size();i++)
	{
		
		if(v[ver][i]!=pa&&col[v[ver][i]]!=col[ver])
			f2=0;
		if(vis[v[ver][i]]==0)
		{
			if(rec(v[ver][i],ver)==false)
			{
				f=0;
			}
			
		}
	}
	if(f)
		dp[ver]=true;
	if(dp[ver]&&f2)
	{
		dp2[ver]=false;
		return true;
	}
	dp2[ver]=true;
	return false;
 
 
 
}
int ans=-1;
void dfs2(int ver,int p)
{
	if(dp[ver])
	{
		ans=ver;

	}
	for(int i=0;i<v[ver][i];i++)
	{
		int v1=v[ver][i];
		if(v1!=p)
		{
			bool temp1=dp[ver];
			bool temp2=dp[v1];
			if(dp2[ver]&&dp[v1])
				dp[v1]=true;
			if(dp[v1]==false)
			{

			}
		}
	}
} 
 
int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
		
	}
	cout<<dp[n-1];
	
 
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << scientific << ((double)N / 2 / N) << endl;
    } else {
        cout << scientific << ((double)(N + 1) / 2 / N) << endl;
    }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    bool tf = true;
    if (t.size() == s.size() + 1) {
        for (int i = 0; i < s.size(); i++) {
            if (t.at(i) != s.at(i)) {
                tf = false;
                break;
            }
        }
    } else {
        tf = false;
    }
    if (tf) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.next();
		out.println(s.replace(",", " "));
	}

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

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21332
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def main():
  N,T = map(int, input().split())
  Tn = list(map(int, input().split()))
  Tn += [Tn[-1]+T]
  ans = 0
  for i in range(1,N+1):
    ans += min(Tn[i]-Tn[i-1],T)
  return ans


if __name__ == "__main__":
  ret = main()
  print(ret)


Measured memory_bytes: 85328
int preorder[40],inorder[40];
void recover(int fp,int lp,int fi,int li){
    int root=fi;
    for(;root<li;root++)if(preorder[fp]==inorder[root])break;
    if(fi<root)recover(fp+1,fp+(root-fi)+1,fi,root);
    if(root<li-1)recover(fp+(root-fi)+1,lp,root+1,li);
    printf(inorder[root]==preorder[0]?"%d\n":"%d ",inorder[root]);
}
main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",preorder+i);
    for(i=0;i<n;i++)scanf("%d",inorder+i);
    recover(0,n,0,n);
    return 0;
}
 

 

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

int main(){
  int n;cin>>n;
  vector<int> v(n), c(n);
  rep(i,n)cin>>v[i];
  rep(i,n)cin>>c[i];
  int ans = 0;
  rep(i,n)ans+=max(0, v[i]-c[i]);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

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

  vector<int> v(n);
  for (auto i = 0; i != n; ++i) {
    cin >> v[i];
  }

  const auto threshold = accumulate(begin(v), end(v), 0.) / (4 * m);
  cout << (m <= count_if(begin(v), end(v),
                         [&](int x) { return x >= threshold; })
               ? "Yes"
               : "No")
       << endl;
  return 0;
}


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

int main(){
  
  int N, M, i;
  double SumT=0, D=1;
  cin>>N>>M;
  
  int T=1900;
  double p=pow(0.5, M), q=1-p;
  int cnt=1;
  while(D>0.01){
    D=(T*M+(N-M)*100)*p*cnt*pow(q, cnt-1);
    SumT+=D;
    cnt++;
  }
  cout<<(int)SumT+1<<endl;
  return 0;
}

Measured memory_bytes: 4092
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    string s;
    cin >> s;
    if (s.size() < 26) {
        set<char> st;
        rep(i, 0, s.size()) {
            st.insert(s[i]);
        }
        for (char c = 'a'; c <= 'z'; c++) {
            if (st.find(c) == st.end()) {
                string ans = s;
                ans += c;
                cout << ans << endl;
                return 0;
            }
        }

    } else {
        if (s == "zyxwvutsrqponmlkjihgfedcba") {
            cout << -1 << endl;
            return 0;
        }
//        char min_c = s.back();
        set<char> app;
        app.insert(reinterpret_cast<char &&>(s.back()));
        for (int i = s.size() - 2; i >= 0; i--) {
            if(app.upper_bound(s[i]) == app.end()){
                app.insert(s[i]);
            }else{
                string ans = s.substr(0,i);
                char ad = *app.upper_bound(s[i]);
                ans += ad;
                cout << ans << endl;
                return 0;
            }
//            if(s[i] < min_c){
//                string ans = s.substr(0,i);
//                ans += min_c;
//                cout << ans << endl;
//                return 0;
//            }else{
//                if(min_c > s[i]){
//                    min_c = s[i];
//                }
//            }
        }


    }


    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int c[110000];
long long sum[210000];
long long sum2[210000];
long long tot[210000];
void add(int a,int b){
	sum2[a]++;
	sum2[b]--;
	sum[b+1]-=b-a;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
		c[i]--;
	}
	long long val=0;
	for(int i=0;i<a-1;i++){
		val+=(c[i+1]-c[i]+b)%b;
		add((c[i]+1),c[i]+(c[i+1]-c[i]+b)%b);
	}
	long long ret=val;
	long long now=0;
	long long dx=0;
	long long ddx=0;
//	for(int i=0;i<2*b;i++)printf("%lld %lld\n",sum[i],sum2[i]);
	for(int i=0;i<2*b;i++){
		now+=dx;
		dx+=sum[i]+ddx;
		ddx+=sum2[i];
		tot[i%b]+=dx;
//		ret=min(ret,val-dx);
	}
	for(int i=0;i<b;i++)ret=min(ret,val-tot[i]);
	printf("%lld\n",ret);
}

Measured memory_bytes: 4480
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
k = [0]
a = [[0]*(n+1)]*(n+1)
for i in range(1,n+1):
    raw = list(map(int,input().split()))
    k.append(raw[0])
    tmp = [0] + raw[1:]
    a[i] = tmp

all_a = []
for i in range(1,n+1):
    all_a += a[i]

all_a.sort()
rev_a = all_a[:]
rev_a.reverse()
ans = 0

for i in range(1,m+1):
    try:
         if n == (len(all_a) - rev_a.index(i)) - all_a.index(i):
             ans += 1
    except ValueError:
         pass

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll x;
  cin>>x;
  cout<<x/11*2+x%11/7+(x%11+10)/11;
}


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

const int MAXN = 100001;
typedef long long ll;

ll n, a[MAXN], s[MAXN], L, R, f[MAXN * 2 + 10], b[MAXN], c[MAXN * 2 + 10];

void add(ll x) {
	while (x <= 2 * MAXN)f[x]++, x += x & -x;
}

ll query(ll x) {
	ll tot = 0;
	while (x > 0)tot += f[x], x -= x & -x;
	return tot;
}

bool check(ll x) {
	memset(f, 0, sizeof f);
	for (ll i = 1; i <= n; i++) {
		if (a[i] >= x)c[i] = 1; else c[i] = -1;
		c[i] += c[i - 1];
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++)ans += (query(c[i] + MAXN)), add(c[i] + MAXN);
	return ans >= n * (n + 1) / 4 ? true : false;
}

int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++)cin >> a[i], s[i] = a[i];
	sort(s + 1, s + n + 1);
	L = 1, R = n;
	while (L <= R) {
		ll mid = L + R >> 1;
		if (check(s[mid]))L = mid + 1; else R = mid - 1;
	}
	cout << s[R] << endl;

	return 0;
}

Measured memory_bytes: 4480
import java.util.*;

public class Main {
  public static boolean isNum(String s) {
    try {
      int n = Integer.parseInt(s);
      return true;
    } catch(NumberFormatException e) {
      return false;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Long> stack = new ArrayList<>();
    while(sc.hasNext()) {
      String s = sc.next();
      if(isNum(s)) {
        stack.add(Long.parseLong(s));
      } else {
        if(s.equals("+")) {
          long a = stack.get(stack.size() - 2) + stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else if(s.equals("-")) {
          long a = stack.get(stack.size() - 2) - stack.get(stack.size() - 1);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        } else {
          long a = stack.get(stack.size() - 1) * stack.get(stack.size() - 2);
          stack.remove(stack.size() - 1);
          stack.set(stack.size() - 1, a);
        }
      }
    }
    System.out.println(stack.get(0));
  }
}



Measured memory_bytes: 26304
fun main(args: Array<String>){
    val(n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    val cumSum = mutableListOf(0)
    for(i in 1..(n - 1)){
        if(s.substring(i - 1, i + 1) == "AC") cumSum.add(cumSum[i - 1] + 1)
        else cumSum.add(cumSum[i - 1])
    }
    for(i in 1..q){
        val(l, r) = readLine()!!.split(" ").map(String::toInt)
        println(cumSum[r - 1] - cumSum[l - 1])
    }
}

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

typedef long long int llint;

int n, m;

struct P
{
  int a, b;
  P() {}
  P(int a, int b) : a(a), b(b) {}

  bool operator < (const P &c) const {
    return c.a > a;
  }
};

P ab[100001];
bool flg[100001];

int main()
{
  cin>> n >> m;
  for(int i = 0; i < m; i++) {
    cin>> ab[i].a >> ab[i].b;
  }

  int mn = 0;

  sort(ab, ab + m);

  for(int i = 0; i < m; i++) {

    if(flg[i]) continue;
    flg[i] = true;

    int l = ab[i].a;
    int r = ab[i].b;
    for(int j = i + 1; j < m; j++) {
      int ll = ab[j].a;
      int rr = ab[j].b;

      if(r <= ll) break;
      else flg[j] = true;
      if(l < ll) l = ll;
      if(r > rr) r = rr;
      
    }

    mn++;
  }

  cout<< mn <<endl;
  
  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;


static class AT {
    static void Main() {
        string s = Console.ReadLine();
        bool a = true;
        if (ch(s, "S") && !ch(s, "N")) {
            a = false;
        }
        if (!ch(s, "S") && ch(s, "N")) {
            a = false;
        }
        if (ch(s, "E") && !ch(s, "W")) {
            a = false;

        }
        if (!ch(s, "E") && ch(s, "W")) {
            a = false;

        }
        if (a) {
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }

    }
    static bool ch(string s, string ch) {
        string st = s.Replace(ch, "");
        if (s.Length - st.Length > 0) {
            return true;
        }
        else {
            return false;
        }
    }
}


Measured memory_bytes: 2648
import numpy as np

def rotation(x, t, deg = True):
    if deg == True:
        t = np.deg2rad(t)
    a = np.array([[np.cos(t), -np.sin(t)],
                  [np.sin(t),  np.cos(t)]])
    ax = np.dot(a, x)        
    return ax

def check():
    x1,y1,x2,y2 = [int(i) for i in input().split()]
    
    vertex1 = np.array([x1-x2,y1-y2])
    vertex2 = np.array([x2-x1,y2-y1])
    x3,y3 = map(int,map(round,rotation(vertex1, -90)))
    x4,y4 = map(int,map(round, rotation(vertex2, 90)))

    print(x3+x2,y3+y2,x4+x1,y4+y1)
    
check()

Measured memory_bytes: 14464
N= int(input())
H= list(map(int, input().split()))
maxi=0
now=0
before=H.pop(0)
for i in H:
    if before>=i:
        now+=1
        before=i
    else:
        maxi=max(maxi,now)
        now=0
        before=i
maxi=max(maxi,now)
print(maxi)

Measured memory_bytes: 14224
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <functional> // std::greater <int> ()
#define inf 1000000000000000001

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

//variables
int n, temp;

//functions
void input(){
	cin >> n;
}

void solve(){
	for(int i=1; i<=n; i++){
		cin >> temp;
		if(temp%2!=0){
			cout << "first";
			return;
		}
	}
	cout << "second";
}

void output(){
}

int main(){
//  freopen(".INP", "r", stdin);
//  freopen(".OUT", "w", stdout);
	input();
	solve();
	output();
	return 0;
}
//  Author: NamSPro

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long long int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a + b - c < 0){
        a = 0;
        b = 0;
    }else if(a < c){
        b = b - (c - a);
        a = 0;
    }else{
        a = a - c;
    }
    printf("%lld %lld\n",a,b);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=0,i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(s[i]=='7') n++;
    }
    if(n>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3600
// SingleSourceShortestPath by Bellman - Ford
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
//
//

#include<iostream>

using namespace std;

#define EDGES 500000
#define VERTICES 100000


int V, E, r, S[EDGES+10], T[EDGES+10], D[EDGES+10];
const int INF = 10000*100000+100;
int C[VERTICES + 1];

void solve();

int main(){
    cin >> V >> E >> r;

    for(int i = 0; i < E; ++i){
        cin >> S[i] >> T[i] >> D[i];
    }

    solve();
}

void solve(){
    for(int i = 0; i < V; ++i){//距離リストの初期化
        C[i] = INF;
    }

    C[r] = 0;

    for(int i = 1; i < V; ++i){
        bool update = false;
        for(int j = 0; j < E; ++j){
            int u = S[j], v = T[j];
            if(C[v] > (C[u] + D[j])) {
                C[v] = C[u] + D[j];
                update = true;
            }
        }
        if (!update) break; //一巡して更新が無くなるまで続ける
    }

    for(int i = 0; i < V; ++i){//距離リストの出力
        if(C[i] == INF) 
            cout << "INF" << endl;
        else
            cout << C[i] << endl;
    }
}


Measured memory_bytes: 9180
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

const ll inv=500000004;

ll mod_pow(ll a,ll x){
    ll ret=1;
    if(a==0){return 0;}
    while(x>0){
        if(x&1){ret*=a; ret%=MOD;}
        a*=a;
        a%=MOD;
        x>>=1;
    }
    return ret;
}


int main(){
    ll n,q;
    cin>>n>>q;
    vector<ll> a(n);
    for(auto &i:a){cin>>i;}
    vector<vector<ll>> dp(n,vector<ll>(n));
    for(int i=0;i<n;i++){
        for(int t=0;t<n;t++){
            if(a[i]>a[t]){dp[i][t]=1;}
        }
    }
    for(int i=0;i<q;i++){
        ll x,y;
        cin>>x>>y;
        x--; y--;
        for(int i=0;i<n;i++){
            if(x==i || y==i){continue;}
            (dp[x][i]*=inv)%=MOD;
            (dp[y][i]*=inv)%=MOD;
            (dp[x][i]+=dp[y][i])%=MOD;
            dp[y][i]=dp[x][i];
            (dp[i][x]*=inv)%=MOD;
            (dp[i][y]*=inv)%=MOD;
            (dp[i][y]+=dp[i][x])%=MOD;
            dp[i][x]=dp[i][y];
        }
        (dp[x][y]*=inv)%=MOD;
        (dp[y][x]*=inv)%=MOD;
        (dp[x][y]+=dp[y][x])%=MOD;
        dp[y][x]=dp[x][y];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int t=i+1;t<n;t++){
            ans+=dp[i][t];
        }
    }
    ans%=MOD;
    cout<<ans*mod_pow(2,q)%MOD<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 72704
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X, N, *P = map(int, read().split())

nums = list(range(-10, 110))

for p in P:
    nums.remove(p)

answer = min(nums, key=lambda x: (abs(x - X), x))
print(answer)

Measured memory_bytes: 9180
/*
                ******
		
        Author: Nguyen Phuc Chuong

                ******
*/

#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> graph;
int n, m;
vector<bool> vis;

int dfs(int x)
{	
	vis[x] = true;
	int cnt = 1;
	for (int i = 0; i < (int)graph[x].size(); i++)
	{
		if (!vis[graph[x][i]])
			cnt += dfs(graph[x][i]);		
	}
	return cnt;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	graph = vector<vector<int>>(n, vector<int>(0));
	vis = vector<bool>(n, false);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (!vis[i])
			ans = max(ans, dfs(i));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 23520
#include <cstdio>

using namespace std;

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

typedef long long ll;

const int N_MAX = 200000;

int N;
int A[N_MAX];

void solve() {
  ll ans = 0;
  int s = 0;
  int t = 0;
  int f = 0;
  while (true) {
    // printf("s: %d, t: %d, f: %d\n", s, t, f);
    while (t < N && !(f & A[t])) {
      f |= A[t++];
      // printf(" s: %d, t: %d, f: %d\n", s, t, f);
    }
    ans += t - s;
    f &= ~A[s++];
    if (s >= N) break;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

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


Measured memory_bytes: 1024
#include<stdio.h>
signed main(){
    int sum, ans;
    sum = 0;
    int i=0;
    int X[10];
    for(i=0; i < 5; i++){
    scanf("%d",&X[i]); 
    }
    for(i=0; i<5; i++){
        sum = sum + X[i];
    }
    ans = 15 - sum;
    printf("%d\n",ans);
}

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

int main(){
    int n,a,b; cin >> n >> a >> b;
    if(n*a<b) cout << n*a << endl;
    else cout << b << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s;
    cin >> s;
    ll sum = 0;
    for (char c : s) sum += (c - '0');
    if (sum % 9 == 0) 
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3716
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, L;
char S[5050];
unsigned int dp[5050][5050];
int C[5050][5050];

int main()
{
	scanf("%d%s", &N, S);
	L = strlen(S);

	dp[0][0] = 1;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (i == 0 && j == 0) continue;
			dp[i][j] = ((i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? (2 * dp[i][j - 1]) : 0)) % MOD;
		//	printf("%d %d %lld\n", i, j, dp[i][j]);
		}
	}
	C[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= N; ++j) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}

	i64 ans = 0;
	for (int i = 0; L + 2 * i <= N; ++i) {
		i64 tmp = dp[L + i - 1][i];
		//for (int j = 0; j < i; ++j) tmp = tmp * 2 % MOD;
		i64 tmp2 = 0;

		int rem = N - (L + 2 * i);
		for (int b = 0; b <= rem; ++b) {
			int c = rem - b;
			if (c <= b) ADD(tmp2, dp[b][c]);
		}
	//	printf("%d %d: %lld %lld\n", i, rem, tmp, tmp2);
		ADD(ans, tmp * tmp2);
	}
	printf("%lld\n", ans);

	return 0;
}


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

int main()
{
    int x, y, a, b, poi = 0;
    cin >> x >> y >> a >> b;
    double re = 0.500000 * x * y;
    if(0.5 * x == a && 0.5 * y == b && (x % 2 == 0) && (y % 2 == 0)) poi = 1;
    cout << setprecision(6) << fixed << re << " " << poi;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
	//#include <algorithm>
	//#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;


int main() {

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

	if (a == b && b == c) {
		cout << "No";
	}

	else if ((a == b || b == c) || c==a) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}

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

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int h[n],f[n],A,B;
    for(int i=0;i<n;i++){
      cin>>h[i]>>A>>B;
      f[i]=A+B;
    }
    int ans=f[0];
    for(int i=0;i<n;i++){
      ans=max(ans,f[i]);
    }
    for(int i=0;i<n;i++){
      if(f[i]==ans){
        cout<<h[i]<<" "<<ans<<endl;
      }
    }
  }  
}


Measured memory_bytes: 3188
h,w,k=map(int,input().split())
c=[input() for i in range(h)]

ans=0
for i in range(2**h):
    for j in range(2**w):
        ch=[0]*h
        cw=[0]*w
        blk=0
        for l in range(h):
            if (i>>l)&1:
                ch[l]=1
        for m in range(w):
            if (j>>m)&1:
                cw[m]=1
        for a in range(h):
            for b in range(w):
                if ch[a]==1 and cw[b]==1:
                    if c[a][b]=='#':
                        blk+=1
        if blk==k:
            ans+=1
print(ans)

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

#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define endl "\n"
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define deb(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define MAX 1000000000000000001
#define mod 1000000007
#define PI 3.1415926535897932384626

int mod_exp(int x, int y);

//ofstream fout("file.out");
//ifstream fin("file.in");

void solve(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

int32_t main(){
    tezi;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

int mod_exp(int x, int y){
    y %= mod;
    int res = 1;
    while(y > 0){
        if(y % 2 != 0) res = (res * x) % mod;
        x = (x * x) % mod;
        y /= 2;
    }
    return res;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll bestsat = -1;

    srand(time(NULL));
    vector<ll> best(d,0);
    ll times = 100000;
    while(times--){
        ll sat = 0;
        vector<ll> ans(d,0);
        rep(i,d){
            ans.at(i) = (rand() % 26) + 1;
        }
            for(int i=1;i<=d;i++){
                ll t = ans.at(i-1);
                t--;
                last.at(t) = i;
                sat += s.at(i-1).at(t);
                for(int j=0;j<26;j++){
                    sat -= c.at(j) * (i - last.at(j));
                }
                //cout << sat << endl;
                if(sat>bestsat){
                    bestsat = sat;
                    best = ans;
                }
            }
    }

    rep(i,d){
        cout << best.at(i);
        if(i<d-1) cout << endl;
    }
  
    //cout << bestsat << endl;

    /*
    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
int main(){
    int i;

int n,m;
cin>>n>>m;
for(i=1;i<=n;i++)
    a[i]=1;
int cou=1;
b[1]=1;
int cur=1;
for(i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    if(b[x]){
     
     a[x]--;
     a[y]++;
     if(b[y]==0)
     {
         b[y]=1;
         cou++;
     }
     if(a[x]==0)
     {cou--;
     b[x]=0;}
      
    }
    else
    {
        a[x]--;
        a[y]++;
    }


}

cout<<cou<<endl;


return 0;}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define inf             LLONG_MAX
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
bool sortbysec(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
	if(a.first.first==b.first.first)
		return a.first.second > b.first.second;
    return (a.first.first < b.first.first); 
} 
bool checkValidity(ll a, ll b, ll c) 
{ 
    // check condition 
    if (a + b > c && a + c > b && b + c > a) 
        return false; 
    else
        return true; 
} 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,d=0;
       cin>>n;
       vector<ll>A(n);
       for(ll i=0;i<n;i++)
       {
           cin>>A[i];
       }
       for(ll i=0;i<n-2;i++)
       {
           for(ll j=i+1;j<n-1;j++)
           {
               for(ll k=j+1;k<n;k++)
               {
                   if(A[i]!=A[j] && A[i]!=A[k] && A[k]!=A[j]){
                   bool m=checkValidity(A[i],A[j],A[k]);
                   //cout<<m<<" ";
                   if(!m)
                   {
                       //cout<<i+1<<" "<<j+1<<" "<<k+1<<" "<<endl;
                       d++;
                   }
                   }
               }
           }
       }
       cout<<d;
         
    } 
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n;
	cin >> n;
	int r[n];
	int min = INF, max = -INF;

	REP(i, n){
		cin >> r[i];
		if (max < r[i] - min) max = r[i] - min;
		if (min > r[i]) min = r[i];
	}

	cout << max << endl;
}


Measured memory_bytes: 3904
#include <iostream>
using namespace std;
 
int main() {
	char a[5];
	int th;
	th=0;
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	for(int i=0;i<4;i++){
		if(a[i]=='+'){
			th++;
		}
		if(a[i]=='-'){
			th--;
		}
	}
	cout<<th<<endl;
}

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

using namespace std;

int main(void)
{
    char N[11];

    cin >> N;

    int sum = 0;
    for (int i = 0; i < strlen(N); i++) {
        int t = N[i] - '0';
        sum += t;
    }

    long long n;
    n = atol(N);
    if (n % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

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

// 構造体を宣言
struct Node {
    // 自分のなまえ
    int key;
    // 子(右) 子(左) 親 のポインタ
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    // 構造体yに構造体NILを代入
    Node *y = NIL;
    // 構造体xに構造体rootを代入
    Node *x = root;
    // 構造体zを出す
    Node *z;

    // 構造体zと構造体分のメモリを確保して新しく宣言した構造体を対応させる
    z = (Node *)malloc(sizeof(Node));
    // 構造体zのkeyにkを入力する
    z->key   = k;
    // 構造体zの子を両方NILにする
    z->left  = NIL;
    z->right = NIL;

    // 一番下に行くまで(番兵が出るまで)分岐して行く
    while(x != NIL) {
        // 構造体yに構造体xを代入する
        y = x;
        // 参照するキーより小さかったら左に、大きかったら右の子へ移動する
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

/////////////////////////////////////////////////////
    // parentは実際このプログラムにはいらない
    // 構造体yを構造体zのparentに入れる
    z->parent = y;
/////////////////////////////////////////////////////

    // 構造体yがNILだった場合(木が空の場合)rootにzを代入する
    if(y == NIL) {
        root = z;
    }
    // 挿入するところのノードと挿入するやつでどっちが大きいかによって左右分ける
    // 挿入するやつの方が小さかったら左、大きかったら右
    else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    // 一番下に行くか、kが見つかるまで回す
    while(u != NIL && k != u->key) {
        // kが今参照しているキーより小さい場合は左の子に移る
        // 大きかった場合は右の子に移る
        if(k < u->key) u = u->left;
        else u = u->right;
    }

    return u;
}

// 中間順巡回 (Inorder Tree Walk)
void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
// 先行順巡回 (Preorder Tree Walk)
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(void) {
    int n, i, x;
    // 文字列を取得するための配列を宣言
    char com[16];
    // ノードの個数を取得
    scanf("%d",&n);

    for(i=0;i<n;i++) {
        // 文字列を取得
        scanf("%s",com);

        // 探すとき
        if(com[0] == 'f') {
            // 探すものを取得
            scanf("%d",&x);
            // 探し始める
            Node *t = find(root,x);
            // 返り値が空(NIL)だったらno、なんかあったらyes
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }
        // 文字列がinsertだった場合
        else if(!strcmp(com,"insert")) {
            // 挿入する数字を取得
            scanf("%d",&x);
            // 挿入する
            insert(x);
        }
        // 文字列がprintだった場合
        else if(!strcmp(com,"print")) {
            // 中間順巡回(inorder tree walk)を出力
            inorder(root);
            printf("\n");
            // 先行順巡回(preorder tree walk)を出力
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}

/*
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
*/


Measured memory_bytes: 20452
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

typedef long long ll;

using namespace std;

int main(){

    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;

    vector<ll> a(n,0);
    for(ll i=0;i<n-1;i++){
        a[i+1]+=a[i];
        if(s[i]=='A' && s[i+1]=='C'){
            a[i+1]++;
        }
    }

    vector<ll> b;
    for(ll i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;

        b.push_back(a[r-1]-a[l-1]);
    }

    for(ll i=0;i<q;i++){
        cout<<b[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 2676
/*
 * 0612.cc: Sandcastle
 */

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

/* constant */

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_GN = MAX_H * MAX_W;

const int dxs[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dys[] = {0, -1, -1, -1, 0, 1, 1, 1};

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;

/* global variables */

int ids[MAX_H][MAX_W], dists[MAX_H][MAX_W];
int xs[MAX_GN], ys[MAX_GN], ps[MAX_GN], flds[MAX_GN];
vi nbrs[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;

  int gn = 0;
  
  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++) {
      if (s[x] == '.') ids[y][x] = -1;
      else {
	ids[y][x] = gn;
	flds[gn] = s[x] - '0';
	xs[gn] = x, ys[gn] = y;
	gn++;
      }
    }
  }
  //printf("gn=%d\n", gn);

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      for (int di = 0; di < 8; di++) {
	int vx = x + dxs[di], vy = y + dys[di];
	if (vx >= 0 && vx < w && vy >= 0 && vy < h && ids[vy][vx] >= 0)
	  nbrs[y][x].push_back(ids[vy][vx]);
      }

  queue<pii> q;
  int maxd = 0;
  
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++)
      if (ids[y][x] < 0) q.push(pii(x, y));
  //printf("%lu\n", q.size());

  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ux = u.first, &uy = u.second;

    int vd = dists[uy][ux] + 1;
    vi &nbr = nbrs[uy][ux];
    for (vi::iterator vit = nbr.begin(); vit != nbr.end(); vit++) {
      int &v = *vit, &vx = xs[v], &vy = ys[v];
      if (dists[vy][vx] == 0 && ++ps[v] >= flds[v]) {
	dists[vy][vx] = vd;
	if (maxd < vd) maxd = vd;
	q.push(pii(vx, vy));
      }
    }
  }

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

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,M;
  cin>>N>>M;
  int cnt[100001] = {0};
  for(int i(0);i<M;i++){
    int a,b;
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }
  for(int i(1);i<=N;i++){
    if(cnt[i]%2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
//package reedeka;
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long n;
		n = sc.nextLong();
		long i;
		long c = 1000000007;
		long ans = 1;
		for(i=1; i<=n; i++) {
			ans = ((ans%c)*(i%c))%c;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		if(num == 25) System.out.println("Christmas");
		else if(num == 24) System.out.println("Christmas Eve");
		else if(num == 23) System.out.println("Christmas Eve Eve");
		else if(num == 22) System.out.println("Christmas Eve Eve Eve");
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
constexpr int inf = 1 << 30;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> W(N), E(N);
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'W') W[i] = 1;
        else E[i] = 1;

        if (i > 0) {
            E[i] += E[i - 1];
            W[i] += W[i - 1];
        }
    }
    int ans = min(E[N - 1] - E[0], W[N - 2]);
    for (int i = 1; i < N - 1; ++i) {
        ans = min(ans, W[i - 1] + (E[N - 1] - E[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3068
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    while (sc.hasNext()) {
        val list = Array(2, { sc.nextLong() })
        println(String.format("%d %d",gcd(list[0], list[1]),lcm(list[0], list[1])))
    }
    sc.close()
}

fun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == (0).toLong()) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)


Measured memory_bytes: 25652
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

int main(){
	int n, imax, vmax, ileft, iright, t;
	long long cnt = 0;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	priority_queue<pair<int, int>> pq;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		cin >> b[i];
		if(b[i] != a[i]){
			pq.push({b[i], i});
		}
	}

	while(!pq.empty()){
		//cout << pq.top().first << endl;
		vmax = pq.top().first;
		imax = pq.top().second;
		pq.pop();

		if(imax != n-1){
			iright = imax+1;
		}else{
			iright = 0;
		}
		if(imax != 0){
			ileft = imax-1;
		}else{
			ileft = n-1;
		}

		if((vmax-a[imax])%(b[ileft]+b[iright])==0){
			cnt += (vmax-a[imax])/(b[ileft]+b[iright]);
			b[imax] = a[imax];
			continue;
		}

		//if(vmax == 8){
		//	cout << a[imax] << endl;
		//	cout << b[ileft] << endl;
		//	cout << b[iright] << endl;
		//}
		if(vmax-a[imax] <= (b[ileft]+b[iright])){
			cout << -1 << endl;
			return 0;
		}
		
		t = (vmax-a[imax])/(b[ileft]+b[iright]);
		cnt += t;
		b[imax] -= t*(b[ileft]+b[iright]);
		pq.push({b[imax], imax});
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3956