akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

void calc(vvi &tree, vvi &add, vi &cnt, vector<bool> &checked, int n, int a) {
  cnt[n] = a; checked[n] = true;
  for (int i = 0; i < add[n].size(); i++)
    cnt[n] += add[n][i];
  for (int i = 0; i < tree[n].size(); i++)
    if (checked[tree[n][i]] == false) calc(tree, add, cnt, checked, tree[n][i], cnt[n]);
}

int main() {
  int n, q, a, b, i, p, x;
  cin >> n >> q;
  vvi tree(n+1, vi(0));
  vi cnt(n+1, 0);
  vvi add(n+1, vi(0));
  vector<bool> checked(n+1, false);
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  for (i = 0; i < q; i++) {
    cin >> p >> x;
    add[p].push_back(x);
  }
  calc(tree, add, cnt, checked, 1, 0);
  cout << cnt[1];
  for (i = 2; i <= n; i++)
    cout << " " << cnt[i];
  cout << endl;
}
    

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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    ans+=2*min(x,k-x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int n,l,r,s,m;
bool f(int l)
{
    for(register int i=1;i<n;i++)
	{
		int j=i-1;
		if(a[n+j]>l && a[n+j+1]>l) return false;
		if(a[n-j]>l && a[n-j-1]>l) return false;
		if(a[n+j]<=l && a[n+j+1]<=l) return true;
		if(a[n-j]<=l && a[n-j-1]<=l) return true;
    }
	if(a[1]<=l) return true;
	else return false;
}
int main()
{
	ios::sync_with_stdio(false);
	int o;
    cin>>n;
    o=n*2-1;
    for(register int i=1;i<=o;i++) cin>>a[i];
    l=1;
    r=o;
    while(l<r)
	{
        m=(l+r)/2;
        if(f(m)) r=m;
        else l=m+1;
    }
    cout<<r<<endl;
    return 0; 
}
/*
sdhdsshg
dahajgsa
adhdfhsg
*/

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

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

  for(int l=(s.length()-1)/2; l>=0; l--){
    if(s.substr(0, l)==s.substr(l, l)){
      ans = l*2;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

  double sum = 0;
  for (int i = 0; i < n; i++) {
    double money;
    string unit;
    cin >> money >> unit;

    if (unit != "JPY") {
      money *= 380000.0;
    }

    sum += money;
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    ll a,b,c,d=0,n=0;
    //VI a(N);
    string s,s1,s2;
    cin >> a >>b >>c ;
    if(c-(a-b)  < 0)
    cout << 0 << endl; 
    else 
    cout << c-(a-b) << endl; 
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort()
#print("XY:", XY)

answer = []
for i in range(N):
  for k in range(K, N + 1):
    if i + k - 1 >= N:
      break
    dx = XY[i + k - 1][0] - XY[i][0]
    Y = []
    for x, y in XY[i: i + k]:
      Y.append(y)
    Y.sort()
    lenY = len(Y)
    for j in range(k):
      if j + K - 1 == lenY:
        break
      dy = Y[j + K - 1] - Y[j]
      answer.append(dx * dy)

print(min(answer))

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

int main() {
    ios::sync_with_stdio(false);
    int N, M, L, R, maxL = 0, minR = INT_MAX;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> L >> R;
        maxL = max(maxL, L);
        minR = min(minR, R);
    }
    int ans = minR - maxL + 1;
    cout << ( ans > 0 ? ans : 0 );
}

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


int main(void) {
    using namespace std;

    long n, m;
    cin >> n >> m;

    vector<vector<long>> d(n, vector<long>(n, 1e9));

    vector<tuple<long,long,long>> abc(m);
    for(int i=0; i<m; i++) {
        long a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = d[b][a] = min(d[a][b], c);
        abc[i] = make_tuple(a, b, c);
    }

    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    long r = 0;
    for(auto &x: abc) {
        long a, b, c;
        tie(a, b, c) = x;
        if(d[a][b] < c) r++;
    }
    cout << r << endl;
}


Measured memory_bytes: 384
# 初期入力
from collections import deque
import sys
#input = sys.stdin.readline
N = int(input())
H = list(map(int, input().split()))

#
differ =0
ans="Yes"
max_h   =max(H)
max_index =H.index(max_h)
#最大値-1 と最大値の右側の最小値を比較,この時はfor不要
if max_index +1 <= N-1:
    if H[max_index]-1 > min(H[max_index+1:]):
        ans ="No"
        print(ans)
        sys.exit()

dq    =deque(H)
before  =dq.popleft()
for i in range(N-1):
    after   =dq.popleft()
    differ    =after - before
    #differ = H[i+1] -H[i]
    if differ <-1:      #右側が小さのは１までOK
        ans ="No"
        break
  
    else:
        before = after

print(ans)


Measured memory_bytes: 14508
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

q = sum(a)

# min(a%d, d-a%d)
ds = set()
x = 1
while x*x <= q:
    if q % x == 0:
        ds.add(x)
        ds.add(q//x)
    x += 1

ans = 0
for d in ds:
    costs = []
    for v in a:
        costs.append(v%d)

    costs.sort()
    cost = 0
    if costs[-1] > 0:
        sc = sum(costs)
        ps = 0
        for i in range(n):
            ps += costs[i]
            tps = d*(n-i-1) - (sc - ps)
            if ps == tps:
                cost = ps
                break

    if cost <= k:
        ans = max(ans, d)

print(ans)


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

bool comp(pair<long int, long int> a, pair<long int, long int> b){
    if(a.second != b.second) return a.second > b.second;
    else return a.first > b.first;
}

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

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

    vector<pair<long int,long int> > p(m,make_pair(0,0));

    for(long int i = 0; i < m; ++i){
        cin >> p[i].first >> p[i].second;
    }

    sort(p.begin(),p.end(),comp);
    sort(a.begin(),a.end());

    long long l = 0,r = 0;
    bool f = false;

    cout << endl;

    //rep(i,0,m)cout << p[i].first << " " << p[i].second << endl;
    //cout << endl;
    while(l < n && r < m){
        for(long int i = 0; i < p[r].first; ++i){
            if(a[l] < p[r].second){
                a[l] = p[r].second;
                l++;
            }else{
                f = true;
                break;
            }
        }
        if(f) break;

        r++;
    }

    unsigned long ans = 0;

    for(long int i = 0; i < n; ++i){
        ans += a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<string.h>


int main(){
  char s[11];
  scanf("%s",&s);
  int i,n;
  int ans = 0,res = 0;
  
  n = strlen(s);
  
  for(i=0;i<n;i++){
  switch(s[i]=='A' || s[i]=='C' || s[i]=='G' ||s[i]=='T'){
    case 0:res = 0;break;
    case 1:res = res + 1;break;
  }
    if(ans < res)
      ans = res;
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	ll X,Y;
	scanf("%lld %lld",&X,&Y);

	if(abs(X-Y) <= 1){

		printf("Brown\n");

	}else{

		printf("Alice\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int num[10] = {0,2,5,5,4,5,6,3,7,6};

int dp[10005];
int pr[10005];
int us[10005];

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v;
  rep(i,M){
    int a;
    cin >> a;
    v.push_back(a);
  }
  rep(i,10005){
    dp[i] = -1;
    us[i] = -1;
    pr[i] = -1;
  }
  dp[N] = 0;

  for(int i=N; i>=0; i--){
    if(dp[i] < 0) continue;
    rep(j,M){
      int nxt = i - num[v[j]];
      if(nxt >= 0){
        if(dp[nxt] < dp[i] + 1){
          dp[nxt] = dp[i] + 1;
          us[nxt] = v[j];
          pr[nxt] = i;
        }
        else if(dp[nxt] == dp[i] + 1 && us[nxt] < v[j]){
          us[nxt] = v[j];
          pr[nxt] = i;
        }
      }
    }
  }
  
  string ret = "";
  int id = 0;
  while(true){
    ret += '0' + us[id];
    id = pr[id];
    if(us[id] < 0) break;
  }

  sort(ALLOF(ret));
  reverse(ALLOF(ret));

  cout << ret << endl;
  
  
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

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




ll k,sum;
ll X[205][205][205];

int main() {
	cin >> k;
	REP(i,1, k + 1) {
		REP(j,1, k + 1) {
			REP(m,1, k + 1) {
				sum += gcd(i, gcd(j, m));
			}
		}
	}
	
	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using namespace std;
int n,t,a;
int main(){
	int bmin=1145141919,lmax=0,ans=0;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a<bmin)bmin=a;
		if(lmax==a-bmin)ans++;
		if(lmax<a-bmin)ans=1,lmax=a-bmin;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int hLong = sc.nextInt();
		int mLong = sc.nextInt();
		int hour = sc.nextInt();
		int minute = sc.nextInt();
		int mAngle = 6 * minute;
		double hAngle = 30 * hour +   0.5 * minute;
		double angleDiff = Math.abs(hAngle - mAngle);
		double result = 0;

			double aSq = Math.pow(hLong, 2) + Math.pow(mLong, 2) - 2 * hLong * mLong * Math.cos(Math.toRadians(angleDiff));
			result = Math.sqrt(aSq);

		System.out.println(result);

	}

}


Measured memory_bytes: 35772
/**
*    author:  Taichicchi
*    created: 10.09.2020 20:20:25
**/

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {

    int H, W, h, w;

    cin >> H >> W;
    cin >> h >> w;

    int ans;

    ans = H * W - (h * W + (H - h) * w);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var K = long.Parse(Console.ReadLine());
            var check = new bool[K];
            long sevens = 7;
            long result = 1;
            while (true)
            {
                if ((sevens % K) == 0) return result;
                if (check[sevens % K]) return -1;
                check[sevens % K] = true;
                sevens = (sevens * 10 + 7) % K;
                result++;
            }
        }
    }
}


Measured memory_bytes: 28272
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long n,m;
   cin>>n>>m;
   long long a[m];
   long long s =0;
   for(int i=0;i<m;i++) 
   {
   	 cin>>a[i];
   	 s+=a[i];
   }
   if(n>=s)
   cout<<n-s<<endl;
   else
   cout<<-1<<endl;
}

Measured memory_bytes: 3672
n = int(input())
ps = list(map(int, input().split()))

count = 0
for i in range(n-2):
    a = [ps[i], ps[i+1], ps[i+2]]
    b = ps[i+1]
    a.sort()
    if a[1] == b:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<stdio.h>

long long int abso(long long int a){
  if(a>=0) return a;
  else return -a;
}

long long  int min(long long int a, long long int b){
  if(a>b) return b;
  else return a;
}

int main(void){
  long long int K, D, x, div, ans;
  int i, j, k;
  
  scanf("%lld %lld %lld", &x, &K, &D);
  div=abso(x)/D;
//  printf("%lld %lld %lld %lld\n", x, K, D,div);
  if(div>=K){
    ans=abso(x)-K*D;
  } else {
    if(x>0){
      if(((K-div)%2)==0){
//        ans=min(abs(x-div*D),abs(x-div*D-D));
        ans=abso(x-div*D);
      }else
      {
        ans=abso(x-div*D-D);
      } 
    }
    else{
      if(((K-div)%2)==0){
//        ans=min(abs(x-div*D),abs(x-div*D-D));
        ans=abso(x+div*D);
      }else
      {
        ans=abso(x+div*D+D);
      }
    }
  }

  printf("%lld", ans);

  return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<int>> color(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c == '#') color.at(i).at(j) = 1;
            else color.at(i).at(j) = 0;
        }
    }
    bool possible = true;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(color.at(i).at(j) == 0) continue;
            int cnt=0;
            for(int k=-1; k<=1; k++){
                for(int l=-1; l<=1; l++){
                    if(0<=i+k && i+k<h){
                        if(0<=j+l && j+l<w){
                            if(abs(k)+abs(l) == 1){
                                cnt+=color.at(i+k).at(j+l);
                            }
                        }
                    }
                }
            }
            if(cnt==0){
                possible = false;
            }
            //cout << cnt;
        }
        //cout << endl;
    }
    if(possible) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  char s[101];
  int h,w,i;
  scanf("%d%d",&h,&w);
  for(i=0;i<w+2;i++)printf("#");printf("\n");
  for(i=0;i<h;i++){printf("#");scanf("%s",s);printf("%s#\n",s);}
  for(i=0;i<w+2;i++)printf("#");printf("\n");
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ')
                .Select(a => int.Parse(a)).ToArray();
            var W = line[0];
            var H = line[1];
            var PointTotalCount = line[2];

            int[,] array = new int[H, W];

            for (int i = 0; i < PointTotalCount; ++i)
            {
                line = Console.ReadLine().Split(' ')
                    .Select(a => int.Parse(a)).ToArray();
                switch (line[2])
                {
                    case 1:
                        for (int xLoop = 0; xLoop < line[0]; ++xLoop)
                        {
                            for (int yLoop = 0; yLoop < H; ++yLoop)
                            {
                                array[yLoop, xLoop] = 1;
                            }
                        }
                        break;
                    case 2:
                        for (int xLoop = line[0]; xLoop < W; ++xLoop)
                        {
                            for (int yLoop = 0; yLoop < H; ++yLoop)
                            {
                                array[yLoop, xLoop] = 1;
                            }
                        }
                        break;
                    case 3:
                        for (int xLoop = 0; xLoop < W; ++xLoop)
                        {
                            for (int yLoop = 0; yLoop < line[1]; ++yLoop)
                            {
                                array[yLoop, xLoop] = 1;
                            }
                        }
                        break;
                    case 4:
                        for (int xLoop = 0; xLoop < W; ++xLoop)
                        {
                            for (int yLoop = line[1]; yLoop < H; ++yLoop)
                            {
                                array[yLoop, xLoop] = 1;
                            }
                        }
                        break;
                }
            }

            // 面積計算
            var result = 0;
            for (int i = 0; i < W; ++i)
            {
                for (int j = 0; j < H; ++j)
                {
                    if (array[j, i] == 0)
                    {
                        result++;
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13604
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; ++i)
#define dow(i,j,k) for(register int i = j; i >= k; --i)
#define ll long long
#define mp make_pair
#define fi first
#define se second 
#define all(x) x.begin(),x.end()
using namespace std;

inline ll read() { 
    ll s = 0, t = 1; char c = getchar();
    while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
    while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
    return s * t;
}

const int N = 2e3+5, p = 1000000007;
inline void Max(int &x,int v) { if( v > x ) x = v; }
inline void Min(int &x,int v) { if( x > v ) x = v; }

char c[N][N]; int L[N][N], R[N][N], h[N][N], q[N];

int main() {
	int n = read(), m = read(), ans; 
	rep(i,1,n) scanf("%s",c[i]+1);
	ans = max(n,m);
	rep(i,1,n-1) h[i][1] = 1;
	rep(j,2,m) { 
		rep(i,1,n-1) { 
			if( c[i][j-1] != c[i+1][j-1] ) { 
				if( c[i][j] != c[i+1][j] ) h[i][j] = h[i][j-1] + 1;
				else h[i][j] = 1;
			} else { 
				if( c[i][j] == c[i+1][j] ) h[i][j] = h[i][j-1] + 1;
				else h[i][j] = 1;
			}
		}
		rep(i,1,n-1) { 
			int &l = L[i][j];
			l = i;
			while( l > 1 && h[l-1][j] >= h[i][j] ) { 
				Min(l,L[--l][j]);
			}
		} 
		dow(i,n-1,1) { 
			int &r = R[i][j];
			r = i;
			while( r < n - 1 && h[r+1][j] >= h[i][j] ) { 
				Max(r,R[++r][j]);
			}
		} 
		rep(i,1,n-1) { 
			Max(ans,(R[i][j]-L[i][j]+2)*h[i][j]);
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

int main()
{
	char a[105], b[105];
	while(~scanf("%s",a)){
		scanf("%s",b);
		int temp = 0,n;
		n = strlen(a) - strlen(b);
		if(n < 0){
			printf("LESS");
			continue;
		}
		else
	{
	for(int i = 0;i <= n;i++){
		if(a[i] > b[i]){
			temp = 1;
			break;
		}
		if(a[i] < b[i]){
			temp = -1;
			break;
		}
	}
	if(temp == 1) printf("GREATER");
	else if(temp == -1) printf("LESS");
	else printf("EQUAL");
	}
	}
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
# 終了時、T*P枚支払う
graph = [lr() for _ in range(M)]

def bellmanford(start, N):
    INF = 10 ** 12
    dist = [-INF] * (N+1) # 1-indexed
    dist[start] = 0
    for i in range(N+N+5):
        for pre, ne, weight in graph:
            if dist[pre] != -INF and dist[pre] + weight - P > dist[ne]:
                dist[ne] = dist[pre] + weight - P
                # n回繰り返してもスコアが更新された場合
                if i > N-1:
                    dist[ne] = INF
    if dist[N] == INF:
        return -1
    else:
        return max(0, dist[N])

answer = bellmanford(1, N)
print(answer)


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

# input
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]

# solve
ans = [0] * M
for i in range(N):
    for j in range(1, A[i][0] + 1):
        ans[A[i][j] - 1] += 1

# output
print(ans.count(N))


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;

int x[10001];
int cnt,a,b,k;

int main()
{
	scanf("%d%d%d",&a,&b,&k);
	for(register int i=0;i<k;i++)
	{
		if(a+i<=b)  x[++cnt]=a+i;
		if(b-i>=a)  x[++cnt]=b-i;
	}
	sort(x+1,x+cnt+1);
	int m=unique(x+1,x+cnt+1)-x-1;
	for(register int i=1;i<=m;i++)
		printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 128
s=input()
n=len(s)
if s[0]=="0" or s[-1]=="1" or any(s[i]!=s[n-i-2] for i in range(n-1)):
	print(-1)
	exit()
ans=[]
now=0
for i,c in enumerate(s[:-1]):
	if c=="1":
		ans.append("{} {}".format(now+1,i+2))
		now=i+1
	else:
		ans.append("{} {}".format(now+1,i+2))
print(*ans,sep="\n")

Measured memory_bytes: 13104
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

int main(){
    ll x,y,d;
    ll n ;
    cin >> x >> y;
    d = y/x;
    int cnt = 0;
    n = 1;
    while(n <= d){
        n*=2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
/*

Parallelism(https://onlinejudge.u-aizu.ac.jp/problems/0021)
前

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

//外積を計算する関数
double gaiseki(comp a, comp b)
{
	return (conj(a)*b).imag();
}

void solve(void){

	int N;
	cin >> N;
	while(N--)
	{

		double xs[4], ys[4];
		rep(4, i)
		{
			cin >> xs[i] >> ys[i];
		}

		vector <comp> ps(4);
		rep(4, i)
		{
			ps[i] = comp(xs[i], ys[i]);
		}

		//直線AB,CDに対応するベクトルl,m　回転用のr
		comp l = ps[1]-ps[0], m = ps[3]-ps[2], r = polar(1., PI/180);

		//l *= r, m *= r;

		cout << (abs(gaiseki(l, m)) < EPS ? "YES" : "NO") << endl;

	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> s;
    for(int i=0; i<n; i++) {
        int e; cin >> e;
        s.push_back(e);
    }
    sort(s.begin(), s.end());
    int q; cin>>q;
    int count = 0;
    for(int i=0; i<q; i++) {
        int e; cin>>e;
        auto result = binary_search(s.begin(), s.end(), e);
        if(result) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3232
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	cc := map[int]int{}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		cc[aa[i]]++
	}
	sort.Ints(aa)
	if aa[n-1] == 1 && n > 2 {
		fmt.Fprintln(writer, "Impossible")
		return
	}
	if aa[n-1]%2 == 0 {
		if cc[aa[n-1]>>1] != 1 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
	} else {
		if cc[aa[0]] > 2 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
	}
	for i := aa[n-1]; i > aa[n-1]>>1; i-- {
		if cc[i] < 2 {
			fmt.Fprintln(writer, "Impossible")
			return
		}
	}
	fmt.Fprintln(writer, "Possible")
}


Measured memory_bytes: 1824
'use strict';
(function(input){
  input=input.trim().split(/\n/);
  input=input.map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0];
  const M=input[0][1];
  input.shift();
  
  function Node(){
    var t=this;
    t.parent=null;
    t.size=1;
  }
  
  Node.prototype={
    
    top:function(){
      var t=this;
      if(t.parent===null)return t;
      else return t.parent.top();
    },
    
    union:function(node){
      var T=this.top();
      var t=node.top();
      if(t===T)return;
      if(T.size>t.size){
        t.parent=T;
        T.size+=t.size;
      }else{
        T.parent=t;
        t.size+=T.size;
      }
    },
  }
  
  const nodes=new Array(N+1).fill(0).map(x=>new Node());
  nodes[0]='zero';
  
  input.forEach(function(a){
    nodes[a[0]].union(nodes[a[1]]);
  });
  
  var ans=0;
  for(let i=1;i<=N;i++){
    if(nodes[i].parent===null)
      ans++;
  }
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


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

int main(){
  int n;
  cin >> n;
  if(n < 105){
    cout << 0 << endl;
  }
  else if(105 <= n && n < 135){
    cout << 1 << endl;
  }
  else if(135 <= n && n < 165){
    cout << 2 << endl;
  }
  else if(165 <= n && n < 189){
    cout << 3 << endl;
  }
  else if(189 <= n && n < 195){
    cout << 4 << endl;
  }
  else{
    cout << 5 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		for(int i = 0 ; i < m ; i++) {
			int ai = scan.nextInt();
			n -= ai;
		}
		if(n >= 0) {
			System.out.println(n);
		} else {
			System.out.println("-1");
		}
		

		scan.close();
	}

}


Measured memory_bytes: 46280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7;

ll powm(ll a,ll b)
{
	ll re=1;
	for(;b;b>>=1,a=a*a%MOD)
		if(b&1) re=re*a%MOD;
	return re;
}

ll arr[100005],inv[100005];

int main()
{jizz
	ll n,ans=0,x=1;
	cin >> n;
	for(ll i=1;i<=n;++i)
		cin >> arr[i],arr[i]=(arr[i]+arr[i-1])%MOD;
	ans=arr[n];
	inv[1]=1;
	for(ll i=2;i<=n;++i)
	{
		x=x*i%MOD;
		inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		ans=(ans+inv[i]*(arr[n]-arr[i-1]+arr[n-i+1]+MOD)%MOD)%MOD;
	}
	cout << ans*x%MOD << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#define N 200005
using namespace std;

int n, q, s[N], v[N];
vector<int> g[N];

void f(int p, int q) {
	if(v[p]) return;
	v[p] = true;
	s[p] += q;
	for(auto x:g[p]) f(x, s[p]);
}

int main() {
	int i, a, b;
	cin >> n >> q;
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(q--) {
		scanf("%d%d", &a, &b);
		s[a] += b;
	}
	f(1, 0);
	for(i=1; i<=n; i++) printf("%d ", s[i]);
	return 0;
}

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

#define lli long long int
#define pb push_back
#define f first
#define sec second

main()
{
    lli i,n,t,j,k,a,b,c,w,val;
    vector<pair<lli,lli>> v;

    lli cap;

    cin>>n>>cap;

    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        v.pb({b,a});
    }

    /*
    v.pb({89, 123});
    v.pb({90, 154});
    v.pb({95, 258});
    v.pb({100, 354});
    v.pb({90, 365});
    v.pb({79, 150});
    v.pb({50, 95});
    v.pb({10, 195});
    */

    lli dp[n+1][cap+1];

    for(i=0;i<=n;i++)
    {
        dp[i][0] = 0;
    }

    for(i=0;i<=cap;i++)
    {
        dp[0][i] = 0;
    }

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=cap;j++)
        {
            val = v[i-1].f;
            w = v[i-1].sec;
            if(j<w)
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(val+dp[i-1][j-w], dp[i-1][j]);
            }
        }
    }

    cout<<dp[n][cap];
}


Measured memory_bytes: 79104
import sys

x,n = map(int,input().split())
if n != 0:
    l = list(map(int,input().split()))
else:
    print(x)
    sys.exit()

if x not in l:
    print(x)
    sys.exit()

tmp = []
for i in range(x-60,x+60):
    tmp.append(i)

ans = []
for j in tmp:
    if j not in l:
        ans.append(j)

tmp1 = 100
for k in ans:
    tmp2 = abs(x-k)
    if tmp2 != 0:
        if tmp1 >= tmp2:
            tmp1 = tmp2

ans2 = []
for m in ans:
    a = abs(m-x)
    if a == tmp1:
        ans2.append(m)

print(min(ans2))

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,L;
  cin>>N>>L;
  ll Min=INF;
  int memo;
  ll sum=0;
  for(int i=1;i<=N;i++){
    sum+=L+i-1;
    if(Min>abs(L+i-1)){
      memo=i;
      Min=abs(L+i-1);
    }
  }
  sum-=L+memo-1;
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long
int arr[60];
int n, p;

int main() {
	ll n, maxi1 = 0, maxi2 = 0;
	cin >> n;
	map<ll, ll> mp;
	for (int i = 0; i < n; i++) {
		ll in;
		cin >> in;
		mp[in]++;
		if (mp[in] >= 2 && in > maxi1) {
			maxi2 = maxi1;
			maxi1 = in;
		}
		if (mp[in] >= 2 && in < maxi1 && in > maxi2) {
			maxi2 = max(maxi2, in);

		}
	}
	/*for (auto i: mp){
	 cout << i.first << " " << i .second << endl;
	 }*/
	//cout << maxi1 << " " << maxi2 << endl;
	if (mp[maxi1] >= 4)
		return cout << maxi1 * maxi1 << endl, 0;

	cout << maxi1 * maxi2 << endl;
}


Measured memory_bytes: 9816
#include <iostream>

int main() {
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = (1e6)+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int a[n],s[2] = {};
        for(int i=0;i<n;i++)cin>>a[i],s[i%2]+=a[i];
        int pre[n];
        for(int i=0;i<n;i++)pre[i] = a[i];
        for(int i=2;i<n;i++)pre[i]+=pre[i-2];
        int suf[n];
        for(int i=0;i<n;i++)suf[i] = a[i];
        for(int i=n-3;i>=0;i--)suf[i]+=suf[i+2];

        int ans = s[1];
        for(int i=0;i<n;i++)
        {
            int chk = pre[i];
            int fcnt = (i+2)/2;
            if(fcnt == n/2)ans = max(ans,pre[i]);
            for(int j=i+2;j<n;j++)
            {
                int ind = n-1-j;
                int bcnt = (ind+2)/2;
                if(bcnt+fcnt < n/2)break;
                else if(bcnt+fcnt == n/2)ans = max(ans,pre[i]+suf[j]);
            }
        }
        if(!(n%2))return cout<<ans,0;
        ans = max(s[0]-a[0],ans);
        ans = max(s[0]-a[n-1],ans);
        int suf1[n];
        for(int i=0;i<n;i++)suf1[i] = suf[i];
        for(int i=n-2;i>=0;i-=2)
        {
            if(i == n-2)suf1[i] = max(suf1[i],suf1[i+1]);
            else
            {
                suf1[i] = max(suf1[i],a[i]+suf1[i+2]);
                suf1[i] = max(suf1[i],suf1[i+1]);
            }
        }
        for(int i=0;i<n;i++)
        {
            int chk = pre[i];
            int fcnt = (i+2)/2;
            if(fcnt == n/2)ans = max(ans,pre[i]);
            for(int j=i+2;j<n;j++)
            {
                int ind = n-1-j;
                int bcnt = (ind+2)/2;
                if(bcnt+fcnt < n/2)break;
                else if(bcnt+fcnt == n/2)ans = max(ans,pre[i]+suf1[j]);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
/*
Test Case
*/


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

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

    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());

    int ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n;
    bool prime[1000000];

    prime[0] = false;
    for (int i = 1; i < 1000000; i++) 
        prime[i] = true;

    for (int i = 1; i < (int)sqrt(1000000); i++) {
        if (prime[i] == true)
            for (int j = i + 1; (i + 1) * j <= 1000000; j++)
                prime[(i + 1) * j - 1] = false;
    }


    while (cin >> n) {
        int cnt = 0;

        for (int i = 0; i < n; i++)
            if (prime[i] == true)
                cnt++;
        cout << cnt << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2132
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 fact_memo[200001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}
i64 fact_inv(i64 x) {
  return inv(fact(x));
}
i64 perm(i64 a, i64 b) {
  return fact(a) * fact_inv(a - b) % mod;
}
i64 conb(i64 a, i64 b) {
  return fact(a) * fact_inv(b) % mod * fact_inv(a - b) % mod;
}

i64 n, x, dp[2][100001];
vector<i64> s;
int main() {
  cin >> n >> x;
  read_n(s, n);
  sort(begin(s), end(s), greater<i64>());

  dp[0][x] = fact(n);
  for (int i = 0; i < n; ++i) {
    i64 a = inv(n - i), b = (1 - a + mod) % mod;
    int from = i % 2, to = (i + 1) % 2;
    fill(begin(dp[to]), end(dp[to]), 0);
    for (i64 j = 0; j <= 100000; ++j) {
      dp[to][j % s[i]] += dp[from][j] * a % mod;
      dp[to][j] += dp[from][j] * b % mod;
    }
    for (i64 j = 0; j <= 100000; ++j) {
      dp[to][j] %= mod;
    }
  }

  i64 e = 0;
  for (i64 x = 0; x <= 100000; ++x) {
    (e += x * dp[n % 2][x]) %= mod;
  }
  i64 ans = e;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n, m;

bool f[100100];
P es[100100];
vector<int> e[100100];

void solve(int u, int v, int now) {
	f[now] = 1;
	rep(i, e[now].size()) {
		int to = e[now][i];
		if ((now == u && to == v) || (now == v&&to == u))continue;
		if (f[e[now][i]] == 0) {
			solve(u, v, to);
		}
	}
}

int main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		es[i] = P(a, b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int ans = 0;
	rep(i, m) {
		rep(j, n + 1)f[j] = 0;
		solve(es[i].first, es[i].second, 1);
		rep(j, n) {
			if (f[j + 1] == 0) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
N,M = gets.split.map(&:to_i)

#prefs = [[pref, year],...]
prefs = []
M.times do
  prefs << gets.split.map(&:to_i)
end

prefs_sorted = prefs.sort

order = Hash.new

cur_pref = prefs_sorted[0][0]
cur_order = 1

prefs_sorted.each do |(pref,year)|
  if cur_pref == pref
    order[year] = cur_order
    cur_order += 1
  else
    order[year] = 1
    cur_order = 2
    cur_pref = pref
  end
end

prefs.each do |(pref,year)|
  str = "%#06d" % pref + "%#06d" % order[year]
  puts str
end


Measured memory_bytes: 18032
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m,r;
    cin>>n>>m>>r;
    int s[r];
    for(int i=0;i<r;i++){
        cin>>s[i];
    }
    int dp[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)dp[i][j]=0;
            else dp[i][j]=1<<29;
        }
    }
    //for(int i=0;i<200;i++){
    //    cout<<ch[i]<<endl;
    //}
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        dp[a-1][b-1]=c;
        dp[b-1][a-1]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(dp[i][j]>dp[i][k]+dp[k][j]){
                    dp[i][j]=dp[i][k]+dp[k][j];
                }
            }
        }
    }
    int ans=1<<30;
    vector<int> v;
    for(int i=0;i<r;i++){
        v.push_back(s[i]-1);
    }
    sort(v.begin(),v.end());
    do{
        int p=0;
        for(int i=0;i<r-1;i++)p+=dp[v[i]][v[i+1]];
        ans=min(ans,p);
    }while(next_permutation(v.begin(),v.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(void){
    int num,i,line[1000];
    double sum,sum1;
    for(;sum=0.0,sum1=0.0,scanf("%d",&num),num;){
        for(i=0;i<num;sum+=line[i],i++)
            scanf("%d",&line[i]);
        sum/=num;
        for(i=0;i<num;i++)
            sum1+=pow((line[i]-sum),2);
        sum1/=num;
        printf("%f\n",sqrt(sum1));
    }
    return 0;
}



Measured memory_bytes: 2148
#include <stdio.h>

int main (void)
{
	int H,W,i,a;
	
	while(1){
		scanf("%d%d",&H,&W);
		if( H==0 && W==0){
			break;
		}
		for( i=0 ; i<H ; i++){
			for( a=0 ; a<W ; a++){
				if(a==0 || a==W-1){
					printf("#");
				}else if(i==0||i==H-1){
					printf("#");
					}else{
					printf(".");
				}
			}
				printf("\n");	
		}
		printf("\n");
	}
	return 0;
}
	

Measured memory_bytes: 572
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N;
	cin >> N;
	vector<int>s(N);
	rep(i, N)cin >> s[i];

	int sum = 0;
	rep(i, N)sum += s[i];
	if (sum % 10) {
		cout << sum << endl;
		return 0;
	}
	sort(ALL(s));
	rep(i, N)if (s[i] % 10) {
		cout << sum - s[i] << endl;
		return 0;
	}
	cout << 0 << endl;


	return 0;
}





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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N, 0L);
    REP(i, N)
    {
        cin >> A[i];
    }

    priority_queue<ll> aQ;
    REP(i, N)
    {
        aQ.push(A[i]);
    }
    REP(i, M)
    {
        ll price = aQ.top();
        aQ.pop();
        ll priceHalf = price / 2;
        aQ.push(priceHalf);
    }

    ll ans = 0;
    while(!aQ.empty())
    {
        ans += aQ.top();
        aQ.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 2168
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    out(800*n-n/15*200);

    return 0;
}

Measured memory_bytes: 256