akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A,B,C;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin>>A>>B>>C;
  cout<<((C>=A&&C<=B)?"Yes\n":"No\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    double d,t,s;
    cin>>d>>t>>s;
	double x=d/s;
	if(t>=x)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    rep(i,(int)s.size()) {
        if ((i + 1) % 2 == 0) {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int t[4], n[4];
	int i;
	
	for (i=0; i<4; i++){
		scanf("%d %d", &t[i], &n[i]);
	}
	
	for (i=0; i<4; i++){
		if (t[i] == 1) printf("%d\n", n[i]*6000);
		if (t[i] == 2) printf("%d\n", n[i]*4000);
		if (t[i] == 3) printf("%d\n", n[i]*3000);
		if (t[i] == 4) printf("%d\n", n[i]*2000);
	}
						
	return 0;
}

Measured memory_bytes: 600
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int n,k;
//    while(cin >> n >> k){
//            if(n % k) cout << 1 << endl;
//    else cout << 0 << endl;
////        cout << n / k - n % k << endl;
//    }
//    return 0;
//}

//
//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 200000;
//bool vis[maxn];
//int main() {
//    int n;
//    while(cin >> n) {
//        memset(vis,0,sizeof(vis));
//        for(int i = 0; i < 100; i++) {
//            int sum = i * 4;
//            for(int j = 0; j < 100; j++) {
//                sum += j * 7;
//                vis[sum] = 1;
//            }
//        }
//    if(vis[n]) printf("Yes\n");
//    else printf("No\n");
//    }
//    return 0;
//}



//
//
//#include <bits/stdc++.h>
//
//using namespace std;
//
//const int maxn = 200000;
//bool vis[maxn];
//long long s[maxn];
//long long n;
//
//void Init() {
//    s[0] = 1;
//    for(int i = 1; i < 64; i++) {
//        s[i] = s[i - 1] * 2 ;
//    }
//    printf("%lld\n",s[62]);
//    return ;
//}
//int main() {
//    int n;
//    Init();
//    while(cin >> n) {
//        string ans = "";
//        if(n <  .)
//    }
//    return 0;
//}








#include <bits/stdc++.h>

using namespace std;

const int maxn = 200000;
bool vis[maxn];
map<long long,long long>mm;
int n;
long long m;
int main() {
    while(cin >> n >> m) {
        long long num,sum = 0,ans = 0;
        mm.clear();
        mm[0]++;
        for(int i = 1; i <= n; i++) {
            cin >> num;
            sum += num;
            sum %= m;
            ans += mm[sum];
            mm[sum]++;
        }
        cout << ans << endl;

    }
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "";
    if(n == 1) {
      ans = "Hello World";
    } else {
      int a = sc.nextInt();
      int b = sc.nextInt();
      ans = String.valueOf(a + b);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
//

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

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

	for (int i=0; i<K; i++) {
		cout << "ACL";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, X, Y;
	cin >> W >> H >> X >> Y;
	int res = 0;

	if (X * 2 == W && 2 * Y == H) {
		res = 1;
	}

	cout << fixed << setprecision(15) << (W*H / 2.0) << " " << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n, h;
  cin >> n >> h;
  priority_queue<int> a_queue;
  priority_queue<int> b_queue;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    a_queue.push(a);
    b_queue.push(b);
  }
  int ans = 0;
  while (h > 0 && !b_queue.empty()) {
    if (b_queue.top() > a_queue.top()) {
      h -= b_queue.top();
      b_queue.pop();
      ans++;
    } else {
      break;
    }
  }
  if (h > 0) {
    ans += h / a_queue.top();
    ans += (h % a_queue.top() != 0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1276
def mbisect(ok, ng):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok


def check(mid):
    if mid == 0:
        return False
    cnt = 0
    for i in a:
        cnt += (i + mid - 1) // mid - 1
    return cnt <= k


n, k = map(int, input().split())
a = tuple(map(int, input().split()))
print(mbisect(10 ** 9, -1))

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

const int N = (1e5) + 5;
int n, k;
char s[N];
int ac[N];
int a[N];

// claudio van
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    if ((i == 0 or s[i - 1] == '1') and s[i] == '0') {
      a[i] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    ac[i] = (i == 0? 0 : ac[i - 1]) + a[i];
  }
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    int last = (i == 0? 0 : ac[i - 1]);
    if (i != 0 and s[i - 1] == '0' and s[i] == '0') {
      last--;
    }
    int len = upper_bound(ac, ac + n, last + k) - ac;
    mx = max(mx, len - i);
  }
  printf("%d\n", mx);
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

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



Measured memory_bytes: 2620
/*
* @Author: wxyww
* @Date: 2020-03-09 19:23:54
* @Last Modified time: 2020-03-09 20:04:17
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 2010,INF = 1e9;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
char s[N];
int mn[N],mx[N],siz[N];
struct node {
	int v,nxt;
}e[N << 1];
int head[N],ejs;
void add(int u,int v) {
	e[++ejs].v = v;e[ejs].nxt = head[u];head[u] = ejs;
}

void dfs(int u,int fa) {
	siz[u] = s[u] - '0';
	int x = 0;
	for(int i = head[u];i;i = e[i].nxt) {
		int v = e[i].v;
		if(v == fa) continue;

		dfs(v,u);

		if(mx[v] + siz[v] >= mx[x] + siz[x]) x = v;
		mx[u] += mx[v] + siz[v];
		siz[u] += siz[v];
	}
	
	if((mn[x] + siz[x]) > mx[u] - mx[x] - siz[x]) {
		mn[u] = (mx[x] + siz[x]) + (mn[x] + siz[x]) - (mx[u]);
	} 
	else mn[u] = mx[u] & 1;
}

int main() {
	int n = read();
	scanf("%s",s + 1);
	for(int i = 1;i <= n;++i) s[i] - '0';

	for(int i = 1;i < n;++i) {
		int u = read(),v = read();
		add(u,v);add(v,u);
	}
	int ans = INF; 
	for(int i = 1;i <= n;++i) {
		memset(mx,0,sizeof(mx));
		memset(mn,0,sizeof(mn));
		dfs(i,0);
		if(!mn[i]) {
			ans = min(ans,mx[i] >> 1);
		}
	}
	if(ans == INF) puts("-1");
	else cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 384
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [n, m] <- fmap (map read . words) getLine :: IO [Int]
    cs     <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
    print . solve m $ cs

solve :: Int -> [[Int]] -> Int
solve m cs = purchase m scs
    where scs = sortOn fst . map (\[a, b] -> (a, b)) $ cs

purchase :: Int -> [(Int, Int)] -> Int
purchase m ((a, b) : cs) =
    if m <= b then m * a else a * b + purchase (m - b) cs
purchase _ [] = 0


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

using namespace std;

int main()
{
	for(;;){
		char str[10001];
		int joi = 0, ioi = 0, temp;
		
		if(scanf("%s",str) == EOF){
			break;
		}
		
		//JOIツ板サツ津ィ
		for(int i = 2; str[i] != '\0'; i++){
			if(str[i-2] == 'J' && str[i-1] == 'O' && str[i] == 'I'){
				joi++;
			}
		}
		for(int i = 0; str[i] != '\0'; i++){
			if(str[i-2] == 'I' && str[i-1] == 'O' && str[i] == 'I'){
				ioi++;
			}
		}
		
		cout << joi << endl;
		cout << ioi << endl;
		
	}
}

Measured memory_bytes: 0
//writer：Sakura
//problem：Antennas on Tree
//id：Petrozavodsk Contest 001--E
//from：AtCoder

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define inf 1000000007
#define N 100005
using namespace std;

typedef long long ll;

vector<ll> vec[N];
ll f[2][N];

ll dfs(ll now,ll ba){
	ll t=0,now1=0,tmp=0;
	for(int i=0;i<vec[now].size();i++){
		if(vec[now][i]!=ba){
			dfs(vec[now][i],now);
			t+=f[1][vec[now][i]];
			tmp++;
			now1=max(now1,f[1][vec[now][i]]-f[0][vec[now][i]]);
		}
	}
	f[0][now]=t-now1;
	if(tmp>=2){
		f[1][now]=f[0][now];
	}
	else if(tmp==0){
			f[1][now]=1;
		}
		else{
			f[1][now]=t;
		}
	return 0;
}

int main(){
	//freopen("anrennas.in","r",stdin);
	//freopen("anrennas.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(ll i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	} 
	for(int i=0;i<N;i++){
		f[0][i]=inf;
		f[1][i]=inf;
	}
	int now=0,ma=0;
	for(int i=0;i<n;i++){
		if(ma<vec[i].size()){
			ma=vec[i].size();
			now=i;
		}
	}
	dfs(now,-1);
	ll ans=1;
	if(f[0][now]>1){
		ans=f[0][now];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14976
#include <stdio.h>
int main(void) 
{
  int i, n;
  int oddflag = 0;
  int count = 0;
  int array[300];
  
  scanf("%d\n", &n);
  for(i = 0; i < n; i++) 
    scanf("%d", &array[i]);
  
  while(1) {
    for (i = 0; i < n; i++) 
      if (array[i] % 2 != 0)
        oddflag = 1;
        
    if (oddflag) break;
 
    for (i = 0; i < n; i++)
       array[i] /= 2;
    count++;
  };
  
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n;
double dp[400][400][400];//1,2,3
int c[3];

double rec(int i,int j,int k){
	if(i==0&&j==0&&k==0)return 0;
	if(dp[i][j][k]!=-1)return dp[i][j][k];
	double p=(i+j+k)/(double)n;
	p=1/p;
	dp[i][j][k]=0;
	if(i){
		dp[i][j][k]+=rec(i-1,j,k)*i/(i+j+k);
	}
	if(j){
		dp[i][j][k]+=rec(i+1,j-1,k)*j/(i+j+k);
	}
	if(k){
		dp[i][j][k]+=rec(i,j+1,k-1)*k/(i+j+k);
	}
	dp[i][j][k]+=p;
	return dp[i][j][k];
}
int main(){
	scanf("%d",&n);
	rep(i,n){
		int a;scanf("%d",&a);a--;
		c[a]++;
	}
	rep(i,n+1)rep(j,n+1)rep(k,n+1)dp[i][j][k]=-1;
	printf("%.12lf\n",rec(c[0],c[1],c[2]));
}

Measured memory_bytes: 376832
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
# print(N, Q)
S = li()
Alist = []
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
Aset = set(Alist)
AClist = [0]*(N+1)
for i in range(N-1):
    if i in Aset:
        AClist[i + 2] = AClist[i + 1] + 1
    else:
        AClist[i+2] = AClist[i+1]
        # print(AClist)

for i in range(Q):
    l, r = mi()
    if AClist[l - 1] != AClist[l]:
        print(AClist[r] - AClist[l])
    else:
        print(AClist[r] - AClist[l-1])


Measured memory_bytes: 57080
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd,numbers)

K=int(input())

all_sum=0
sum1=0
sum2=0
sum3=0

for i in range(1,K+1):
    # add_sum+=gcd(i,i,i)
    for j in range(i,K+1):
        for k in range(j,K+1):
            if i==j and j==k:
                sum1+=gcd(i,j,k)          
            elif i==j or j==k or i==k:
                sum2+=gcd(i,j,k)
            else:
                sum3+=gcd(i,j,k)
            # all_sum+=gcd(i,j,k)
            # print(i,j,k)

all_sum+=sum1+sum2*3+sum3*6
print(all_sum)

Measured memory_bytes: 9632
// I can !

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const ll maxn=1e6+1,mod=1e9+7;

int minus(int x){
    x--;
    return x;

}

int main(){

    sync
    
   
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    a--;
    b--;
    c--;
    d--;
    if(c<d){
        bool flag = true;
        int i = b+1;
        while(i<=d){
            if(i==d){
                if(s[i]=='#'){
                    flag = false;
                }
            }
                if(s[i]=='#'){
                    if(s[i-1]=='#'){
                        flag = false;
                    }
                }
            i++;
        }
        if(!flag){
            cout<<"No";
            return 0;
        }
        i = a+1;
        while(i<=c){
            if(i==c){
                if(s[i]=='#'){
                    flag = false;
                }
            }
                if(s[i]=='#'){
                    if(s[i-1]=='#'){
                        flag = false;
                    }
                }
            i++;
        }
        flag ? cout<<"Yes":cout<<"No";
    }
    else{
        bool flag1 = false,flag = true;
        if(s[b-1]!='#'&&s[b+1]!='#'&&s[b]!='#') flag1 = true;
        int i = b+1;
        while(i<=d){
        if(i==d){
            if(s[i]=='#') flag = false;
        }
        if(s[i]!='#'&&s[i-1]!='#'&&s[i+1]!='#'){
            flag1 = true;
        }
        if(s[i]=='#'&&s[i-1]=='#') flag = false;
        i++;
        }
        if(!flag1||!flag){
            cout<<"No";
            return 0;
        }
        i = a+1;
        while(i<=c){
            if(i==c){
                if(s[i]=='#'){
                    flag = false;
                }
            }
            if(s[i]=='#'&&s[i-1]=='#'){
                flag = false;
            }
            i++;
        }
        flag ? cout<<"Yes":cout<<"No";
    }
    
    return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names+1, ',');
    cout.write(names, comma - names) << " = " << arg1 <<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif

const int N = 1000005;
const LL MOD = 1e9 + 7;
LL dp[N][2][2];
int n;
LL call(int pos,int zero,int nine)
{
    if(pos == n + 1){
        if(zero == 1 and nine == 1)return 1;
        return 0;
    }
    if(dp[pos][zero][nine] != -1)return dp[pos][zero][nine];
    LL ret = 0;
    for(int i = 0;i <= 9;i++){
        int newzero = zero || (i == 0);
        int newnine = nine || (i == 9);
        ret = (ret + call(pos + 1,newzero,newnine)) % MOD;
    }
    return dp[pos][zero][nine]  = ret;
}
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    MEM(dp,-1);
    cin >> n;
    cout << call(1,0,0) << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 128592
n = int(input())
x = [int(x) for x in input().split()]


for i in range(min(x), max(x)):
    sum = 0
    for j in range(len(x)):
        sum = sum + (x[j]-i)**2

    if i == min(x):
        max_n = sum

    if sum <= max_n:
        max_n = sum

if len(set(x)) == 1:
    max_n = 0

print(max_n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int keta(int x){
  int sum=0;
  while(x>0){
  	sum+=x%10;
    x/=10;
  }
  return sum;
}
int main() {
  int N;
  cin >> N;
  vector<int> W(N/2);
  int a=1;
  for(;a<=N/2;a++){
    int b=N-a;
    W.at(a-1)=keta(a)+keta(b);
  }  
  sort(W.begin(), W.end());
  cout << W[0] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int n,x,t;
	cin >> n>>x>>t;
	int k=n/x;
	if((n%x)!=0)k++;
	cout << k*t;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=b&&b<=c) cout<<a<<" "<<b<<" "<<c<<endl;
    else if(a<=c&&c<=b) cout<<a<<" "<<c<<" "<<b<<endl;
    else if(b<=c&&c<=a) cout<<b<<" "<<c<<" "<<a<<endl;
    else if(b<=a&&a<=c) cout<<b<<" "<<a<<" "<<c<<endl;
    else if(c<=b&&b<=a) cout<<c<<" "<<b<<" "<<a<<endl;
    else if(c<=a&&a<=b) cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	int x, y;
	cin >> x >> y;

	if (x == y) {
		cout << 0 << endl;
		return 0;
	} else if (abs(x) == abs(y)) {
		cout << 1 << endl;
		return 0;
	}

	int ans = abs(abs(x) - abs(y));
	if (abs(x) <= abs(y)) {
		if (x < 0) ans++;
		if (y < 0) ans++;
	} else {
		if (x > 0) ans++;
		if (y > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int tmp_L, tmp_R;
  int L=1, R=N;
  int sum = 0;
  for(int j=0;j<M;j++){
    cin >> tmp_L >> tmp_R;
    if(tmp_L>L){
      L = tmp_L;
    }
    if(R>tmp_R){
      R = tmp_R;
    }
  }
  cout << max(R-L+1,0) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double a[] = new double [N];
		for(int i = 0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		double sum=0;
		for(int j= 0;j<N;j++) {
			sum+=1/a[j];
		}
		System.out.println(1/sum);

	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int K, N; cin >> K >> N;
  vi A(N); rep(i,N) cin >> A[i];
  vi B(N);
  rep(i, N-1){
    B[i] = A[i+1]-A[i];
  }
  B[N-1]=K-A[N-1]+A[0];
  int ans = 0;
  rep(i,N) ans = max(ans, B[i]);  
  cout << K-ans << endl;
  return 0;
}

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

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

  vector<int> pList;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    pList.push_back(tmp);
  }

  sort(pList.begin(), pList.end());  // 昇順

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += pList[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
def Bellman_Ford(s, g, inf=1 << 60):
    # https://tjkendev.github.io/procon-library/python/graph/bellman-ford.html
    N = len(g)
    dist = [inf] * N
    dist[s] = 0

    for _ in range(N):
        not_updated = True
        for v in range(N):
            for u, c in g[v]:
                if (dist[v] == inf) or (dist[v] + c >= dist[u]): continue
                dist[u] = dist[v] + c
                not_updated = False

        if not_updated:
            return -dist[N - 1]

    # 負閉路が存在する
    ret = dist[N - 1]
    for _ in range(N):
        not_updated = True
        for v in range(N):
            for u, c in g[v]:
                if (dist[v] == inf) or (dist[v] + c >= dist[u]): continue
                dist[u] = dist[v] + c
                not_updated = False
        if not_updated: break

    if ret == dist[N - 1]:
        return -ret
    else:
        return 'inf'


def main():
    import sys
    input = sys.stdin.readline

    sys.setrecursionlimit(10 ** 7)

    N, M = map(int, input().split())

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        g[a].add((b, -c))

    ans = Bellman_Ford(s=0, g=g)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3520
#include <stdio.h>

int main()
{
    int a, b, c, counts = 0;

    scanf("%d %d %d", &a, &b, &c);

    for (int i = a; i <= b; i++)
    {
        if ((c % i) == 0)
        {
            counts++;
        }
    }
    printf("%d\n", counts);

    return 0;
}


Measured memory_bytes: 2732
import sys

sys.setrecursionlimit(10**9)

n, K = map(int, input().split())

mo = 1000000007
ret = 1
E = [[] for _ in range(n)]

def dfs(cur, pre, cand):
    global ret
    ret = (ret % mo * (cand % mo)) % mo
    k = 0
    if pre != -1:
        k = 1
    cand = K - 1 - k
    for e in E[cur]:
        if e != pre:
            dfs(e, cur, cand)
            cand -= 1

for _ in range(n-1):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

dfs(0, -1, K)
print(ret % mo)


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

int main(){
	
	/*
	for(int i=0; i<7; i++){
		int a,b;
		cin >> a >> b;
		cout << a - b <<endl;
		*/
	/*
	for(int i=0; i<4; i++){
		int T, K;
		cin >> T >> K;
		if(T == 1){
			cout << K*6000 << endl;
		}
		else if(T == 2){
			cout << K*4000 << endl;
		}
		else if(T == 3){
			cout << K*3000 << endl;
		}
		else{
			cout << K*2000 << endl;
		}

	}
	*/
	/*
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		if(b >= 5 && p >= 2){
			cout << (x*b + y*p)*4/5 << endl;
		}

		else{
			cout << min(x*b + y*p,(x * max(b,5) + y * max(p,2))*4/5 ) << endl;
		}
	}
	*/
	/*	
	for(int data = 0; data<100; data++){
		int n;
		cin >> n;
		if(n == 0)return 0;

		int  N = n;
		bool jud = false;

		for(int i=0; i<n; i++){
			int k;
			cin >> k;
			if(k == 0) N--;
			else if(k > 1)jud = true;
		}

		if(jud == false) cout << "NA" << endl;
		else cout << N+1 << endl;


	}
	*/
	/*
	for(int D = 0; D < 100; D++){

		int n;
		cin >> n;
		if(n == 0)return 0;
		int hand[10] = {};
		int ba = 0;

		string top;
		cin >> top;

		for(int i=0; i<100; i++){
			if(top[i] == 'M') hand[i%n]++;
			if(top[i] == 'S'){
				ba += hand[i%n]+1;
				hand[i%n] = 0;
			}
			if(top[i] == 'L'){
				hand[i%n]+=ba+1;
				ba = 0;
			}
		}

		sort(hand,hand+n);

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

	}
	*/

	int q;
	cin >> q;

	for(int i=0; i<q; i++){
		int c,a,n,ans = 0;
		cin >> c >> a >> n;
		int can = min(min(c,a),n);
		//can
		ans+=can;
		c-=can;
		a-=can;
		n-=can;

		//acc
		int acc = min(c/2,a);
		ans+=acc;
		a-=acc;
		c-=acc*2;

		//ccc
		ans+=c/3;

		cout << ans << endl;

	}


	return 0;

}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N>>A>>B;
    cout<<min(A*N,B)<<endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 2) {
		cout << (double) (n/2+1) / n << '\n'; 
	} else {
		cout << (double) (n/2) / n << '\n';
	}
	return 0;
}

Measured memory_bytes: 3760
n, k = map(int, input().split())
P = list(map(int, input().split()))
L = [(p+1)/2 for p in P]
t = sum(L[:k])
ans = t
for i in range(k, n):
  t -= L[i-k]
  t += +L[i]
  ans = max(ans, t)
print(ans)

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

using namespace std;

typedef long long ll;

int main()
{
    char s[100],t[100];
    scanf("%s%s",s,t);
    for(int i=0;i<strlen(s);i++){
        if(s[i]!=t[i]) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));

//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
    fastio();
    int n,d; cin >> d >> n;
    int aux = 0;
    int ans = 0;
    if(n == 100){
        ++aux;
    }
    if(d == 0){
        ans += (n + aux);
    }else if(d == 1){
        ans += (n+aux) * 100;
    }else if(d == 2){
        ans += (n+aux) * 10000;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n)
	{
		cin >> l[i];
	}

	sort(l.begin(), l.end());
	ll ans = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
            if(l[n-1]<l[i]+l[j])
            {
                ans+=n-(j+1);
            }
            else
			for (int k = j + 1; k < n; k++)
			{
				if (l[k] < l[i] + l[j])
				{
					ans++;
				}
				else
				{
					break;
				}
			}

		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
  int a, b;
  char op;
  cin >> a >> op  >> b;
  cout << (op == '+' ? a + b : a - b) << endl;;

}

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

#define rep(i, b) for( int i = 0; i < b; i++ )
#define repi(i, a, b) for( int i = a; i < b; i++ )
#define MAX 100000
typedef vector<int> vec;

bool prime[MAX];
vec v;

void pcalc(){
    rep(i, MAX) prime[i] = i<2 ? false : true;
    repi(i, 2, MAX/2){
        if( prime[i] ){
            v.push_back(i);
            for( int j = i*2; j < MAX/2; j += i ){
                prime[j] = false;
            }
        }
    }
}

int main(){
    pcalc();
    int m, a, b;
    while( cin >> m >> a >> b, m ){
        int w, h, max = 0;
        for( int i = 0; v.size() && v[i] * v[i] <= m; i++ ){
            for( int j = i; v.size() && v[i] * v[j] <= m; j++ ){
                int p = v[i], q = v[j];
                if( p*b >= a*q && p*q > max ){
                    max = p*q;
                    w = p;
                    h = q;
                }
            }
        }
        /*
        rep(i, v.size()){
            if( v[i].first * v[i].second > ans.first * ans.second ){
                ans = make_pair(v[i].first, v[i].second);
            }
        }
        */
        cout << w << ' ' << h << endl;
    }
}

Measured memory_bytes: 1368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC124A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if (a - b >= 2)
                Console.WriteLine(a * 2 - 1);
            else if (a - b == 1)
                Console.WriteLine(a + b);
            else if (b - a == 1)
                Console.WriteLine(a + b);
            else if (a == b)
                Console.WriteLine(a + b);
            else if (b - a >= 2)
                Console.WriteLine(b * 2 - 1);
            Console.ReadKey();
 
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	ll a;
	cin>>a;
	ll ans = a + a*a + a*a*a;
	cout<<ans<<"\n";	
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

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

    int n; cin >> n;

    vector<pair<int, int> > s;
    REP(i, n) {
        int tmp; cin >> tmp;
        s.push_back(make_pair(tmp, i + 1));
    }
    sort(s.begin(), s.end());

    REP(i, n) {
        cout << s[i].second;
        if (i != n - 1) cout << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1780
use proconio::*;
use std::cmp::*;

fn main() {
    input! {
    mut a:usize,
    b:usize,
    c:isize,
    v:[isize;b],
    }
    a=0;
    for i in 0..b {
        if v[i]<c {a+=1;}
    }
    println!("{}",min(a,b-a));
}

Measured memory_bytes: 2152
import java.util.Scanner;

public class Main{    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
                
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i==0 || j==0 || i==H-1 || j==W-1){
                        System.out.printf("#");
                    }else{
                        System.out.printf(".");
                    }                  
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 62060
parseInt(x) = parse(Int,x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N,M = readline() |> split |> parseArray
  A = readline() |> split |> parseArray
  sort!(A)
  
  tmp = Array{Int}(M,2)
  for i in 1:M
	tmp[i,:] = readline() |> split |> parseArray
  end
  tmp = sortrows(tmp, by=x->x[2],rev=true)
  
  roop = 0
  D::Array{Int64} = []
  for i = 1:M
    for j = 1:tmp[i,1]
      push!(D,tmp[i,2])
      roop += 1
      if roop == length(A)
        break
      end
    end
    if roop == length(A)
        break
    end
  end
  
  if length(D) < length(A)
    for i = length(D) + 1:length(A)
      push!(D,0) 
    end
  end
  
  sort!(D,rev=true)
  
  for i = 1:length(A)
    if A[i] < D[i]
      A[i] = D[i]
    else
      break
    end
  end
  
  print(sum(A))
end
main()



Measured memory_bytes: 161444
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        
        List<Integer> listx = new ArrayList<>();
        List<Integer> listy = new ArrayList<>();      
        
       while(true){
           
            int x = sc.nextInt();
            int y = sc.nextInt();
           
            if(x == 0 && y==0) break;
            
            listx.add(x);
            listy.add(y);
           
       }
       
       for(int i=0;i<listx.size();i++){
           check(listx.get(i),listy.get(i));
       }
       

        
    }
    
    public static void check(int x,int y){
              if(x<y){
                  System.out.println(x+" "+y);
              } else if(x>y){
                  System.out.println(y+" "+x);
              }else if(x == 0 && y==0){
                  
              }else{
                  System.out.println(x+" "+y);
              }
          }
}
       




Measured memory_bytes: 36388
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0] as usize, v[1]);
    let mut a = read_vec::<i64>();
    let mut f = read_vec::<i64>();
    if a.iter().sum::<i64>() <= k {
        println!("0");
        return;
    }
    a.sort();
    f.sort();
    f.reverse();

    let h = a.iter().zip(f.iter()).map(|(x, y)| x * y).max().unwrap();
    let criterion = |goal: i64| {
        let mut k = k;
        for i in 0..n {
            if a[i] * f[i] <= goal {
                continue;
            }
            k -= (a[i] * f[i] - goal + f[i] - 1) / f[i];
        }
        k < 0
    };
    let ans = binary_search(0, h, criterion);
    println!("{}", ans.1);
}

fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> (i64, i64)
where
    F: Fn(i64) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 12800
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t S;
  cin >> S;
  // const int64_t L = static_cast<int64_t>(T.length());
  const int64_t x1 = 1e9L;
  const int64_t x2 = 1L;
  int64_t y1, y2;
  for (int64_t i = S / 1e9L; i * x1 - S <= 1e9L; ++i) {
    y1 = i * x1 - S;
    if (y1 >= 0) {
      y2 = i;
      break;
    }
  }
  cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i == 5 || i == 13) {
            cout << " ";
        } else {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3616
/// IN THE NAME OF METAL
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
const ll MAXN = 1e5 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll A[MAXN], B[MAXN], n, ans = 0, m;
bitset<MAXN / 200> C[MAXN];
    
int main() {
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= m; i++) {
        scanf("%lld%lld", &A[i], &B[i]);
    }
    for (ll i = 1; i <= n; i++) {
        C[i][i] = 1;
        for (ll j = m; j >= 1; j--) {
            if (C[i][A[j]] && C[i][B[j]]) {
                C[i].set();
                break;
            }
            C[i][A[j]] = C[i][B[j]] = (C[i][A[j]] | C[i][B[j]]);
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = i + 1; j <= n; j++) {
            if ((C[i] & C[j]).count() == 0) ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 5212
n,q = map(int,input().split())
r = [[] for i in range(n+1)]
v = [0 for i in range(n+1)]

for i in range(n-1):
    a,b = map(int,input().split())
    r[a].append(b)

for i in range(q):
    p,x = map(int,input().split())
    v[p] += x


for i in range(1,n+1):

    for y in r[i]:
        v[y] += v[i]

print(" ".join(map(str,v[1:])))

Measured memory_bytes: 58924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int a[10];
int main()
{
    for(int i=1;i<=3;i++)
        cin>>a[i];
    sort(a+1,a+4);
    int sum=0;
    for(int i=2;i<=3;i++)
    {
        sum+=a[i]-a[i-1];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        if(a>9||b>9){
            System.out.println("-1");
        }
        else{
            
            System.out.println(a*b);
        }
    }
}

Measured memory_bytes: 24020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            long[] d = new long[N];
            for (long i = 0; i < N; i++) d[i] = long.Parse(str[i]);
            Array.Sort(d);
            long mid = N / 2;
            long ans = d[mid] - d[mid - 1];
            Console.WriteLine(ans);
            Console.ReadLine();
        }
        
    }
}


Measured memory_bytes: 17504
while True:
    n = int(raw_input())
    if n == 0: break
    num = 0
    d = 0
    for i in range(n):
        p, d1, d2 = map(int, raw_input().split())
        if d < d1+d2:
            num = p
            d = d1+d2
    else:
        print num, d

Measured memory_bytes: 4444
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=998244353;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
map <string,int> f,g;
int getf (string s);
int getg (string s)
{
	if (g.find (s)!=g.end ()) return g[s];
	if (s.length ()==1) return s[0]-'0'+1;
	int ans=0,len=s.length ();
	for (int i=1; i< len; i++) if (len%i==0)
	{
		string t="";
		for (int j=0; j< i; j++)
		{
			bool fg=1;
			for (int k=0; k< len/i; k++)
				if (s[k*i+j]=='0') { fg=0; break; }
			t+=('0'+fg);
		}
		add(ans,getf (t));
	}
	return g[s]=ans;
}
int getf (string s)
{
	if (f.find (s)!=f.end ()) return f[s];
	int ans=0,len=s.length ();
	for (int i=1; i<=len; i++)
		add(ans,(LL)getg (s.substr (0,i))*getf (s.substr (i,len-i))%P);
	return f[s]=ans;
}
string s;
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	cin>>s;
	f[""]=1;
	pr(getf (s));

    return 0;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  int count = 0;

  for (int i = 100; i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
      if (count == k) {
        cout << i << endl;
        break;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 3572
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

class Main{
	static int n;
	static long ans = 1000000000;
	static int[] memo;
	static int[] dp;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] P = new int[M];
		int[] Y = new int[M];
		int[] count = new int[N];				//県ごとの市の生まれた順番を記憶
		Map<Integer, Integer> map = new TreeMap<>();
		for(int i = 0;i < M;i++){
			P[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			map.put(Y[i], i);
		}
		int num;
		for(Integer index :map.values()){
			num = P[index]-1;
			if(count[num] == 0){				//もしその県にまだ何も生まれてなかったら
				count[num] = 1;
				Y[index] = count[num];			//順番(1番目)を記憶
			}else{
				count[num]++;
				Y[index] = count[num];			//順番を記憶
			}
		}
		
		for(int i = 0;i < M;i++){
			System.out.println(String.format("%06d%06d", P[i],Y[i]));
		}


	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string a, b;
  cin >> a >> b;
  
  if(a.size() > b.size()) {
    cout << "GREATER" << endl;
    return 0;
  }
  else if(a.size() < b.size()) {
    cout << "LESS" << endl;
    return 0;
  }
  else {
    REP(i, a.size()) {
      if(a[i] > b[i]) {
        cout << "GREATER" << endl;
        return 0;
      }
      else if(a[i] < b[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
    return 0;
  }


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vector<pll> xl;
    // map<ll, vl> xl;
    for (int i = 0; i < n; ++i) {
        ll x, l;
        cin >> x >> l;
        xl.emplace_back(x + l, x - l + 1);
        // xl[x + l].push_back(x - l + 1);
    }
    sort(xl.begin(), xl.end());
    ll ret  = 0;
    ll left = -INF;
    for (int i = 0; i < n; ++i) {
        if (xl[i].second > left) {
            ret++;
            left = xl[i].first;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 2420