akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 #include <iomanip>
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int w,s;

void solve(istream& cin, ostream& cout) {
	ll X;
	cin >> X;
	ll deposit = 100;
	int ans = 0;
	while(deposit < X) {
		deposit = (deposit*1.01); 
		ans++;
	}
	cout <<ans<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3160
N=int(input())
tasks=[]
for _ in range(N):
    A,B=map(int,input().split())
    tasks.append((A,B))
tasks.sort(key=lambda x:x[1])

time=0
for task in tasks:
    time+=task[0]
    if task[1]-time>=0:
        pass
    else:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 31804
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  mi=i
  for j in range(i,n):
    if a[j]<a[mi]:
      mi=j
  if a[i]!=a[mi]:
    v=a[i]
    s=a[mi]
    a[i]=s
    a[mi]=v
    ans+=1
print(" ".join(map(str,a)))
print(ans)


Measured memory_bytes: 5596
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = 998244353;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		//FastReader sc = new FastReader();
		String st = sc.next();
		if((st.charAt(2)==st.charAt(3)) && (st.charAt(4)==st.charAt(5)))
			System.out.println("Yes");
		else System.out.println("No");
		
		
	}
  
	
	public static class pair{
		long bal;
		long wt;
		long diff;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}
		
	static class FastReader 
		{ 
		final private int BUFFER_SIZE = 1 << 16; 
		private DataInputStream din; 
		private byte[] buffer; 
		private int bufferPointer, bytesRead; 
  
		public FastReader() 
		{ 
			din = new DataInputStream(System.in); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public FastReader(String file_name) throws IOException 
		{ 
			din = new DataInputStream(new FileInputStream(file_name)); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public String readLine() throws IOException 
		{ 
			byte[] buf = new byte[64]; // line length 
			int cnt = 0, c; 
			while ((c = read()) != -1) 
			{ 
				if (c == '\n') 
					break; 
				buf[cnt++] = (byte) c; 
			} 
			return new String(buf, 0, cnt); 
		} 
  
		public int nextInt() throws IOException 
		{ 
			int ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do
			{ 
				ret = ret * 10 + c - '0'; 
			}  while ((c = read()) >= '0' && c <= '9'); 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public long nextLong() throws IOException 
		{ 
			long ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public double nextDouble() throws IOException 
		{ 
			double ret = 0, div = 1; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
  
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
  
			if (c == '.') 
			{ 
				while ((c = read()) >= '0' && c <= '9') 
				{ 
					ret += (c - '0') / (div *= 10); 
				} 
			} 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		private void fillBuffer() throws IOException 
		{ 
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
			if (bytesRead == -1) 
				buffer[0] = -1; 
		} 
  
		private byte read() throws IOException 
		{ 
			if (bufferPointer == bytesRead) 
				fillBuffer(); 
			return buffer[bufferPointer++]; 
		} 
  
		public void close() throws IOException 
		{ 
			if (din == null) 
				return; 
			din.close(); 
		} 
	} 
}



Measured memory_bytes: 22612
card = []
for i in range(3):
    card.append(list(map(int,input().split())))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k] == b[i]:
                card[j][k] = 0
flag = 'No'
if card[0][0] == card[0][1] == card[0][2] == 0:
    flag = 'Yes'
if card[1][0] == card[1][1] == card[1][2] == 0:
    flag = 'Yes'
if card[2][0] == card[2][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][0] == card[2][0] == 0:
    flag = 'Yes'
if card[0][1] == card[1][1] == card[2][1] == 0:
    flag = 'Yes'
if card[0][2] == card[1][2] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][2] == card[1][1] == card[2][0] == 0:
    flag = 'Yes'
print(flag)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	int S;
	int h;
	int m;
	int s;
	scanf("%d", &S);
	
	h = S/3600;
	m = S%3600/60;
	s = S%3600%60;
	
	printf("%d:%d:%d\n", h, m, s);
	return(0);
}

Measured memory_bytes: 592
import java.io.*;
import java.util.*;

public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        long x = sc.nextLong();
        for(int i=-1000; i<=1000; i++){
            for(int j=-1000; j<=1000; j++){
              long A = (long)Math.pow(i,5);
              long B = (long)Math.pow(j,5);
              if((A-B)==x){
                  out.println(i+" "+j);
                  return;
              }
            }
        }
    }
    private static int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }
    private static long helper(long x){
        long ans = (x * (x-1))/2;
        return ans;
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    long x;
    long y;
    Pair(long x, long y){
        this.x  =x ;
        this.y =y;
    }
}


Measured memory_bytes: 36940
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int x,y;
  cin >> x >> y;
  ll ans=0;
  if(x==1 && y==1)ans+=400000;
  if(x<=3){
    ans+=100000*(4-x);
  }
  if(y<=3){
    ans+=100000*(4-y);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[3][3];
bool flag[3][3] = {false};

bool check(bool flag[3][3]) {
	int i, j;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (!flag[i][j]) break;
		}
		if (j == 3) return true;
	}
	for (j = 0; j < 3; j++) {
		for (i = 0; i < 3; i++) {
			if (!flag[i][j]) break;
		}
		if (i == 3) return true;
	}
	
	if (flag[0][0] && flag[1][1] && flag[2][2]) return true;
	if (flag[0][2] && flag[1][1] && flag[2][0]) return true;
	return false;
}

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	
	int n, cnt = 0;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == x) flag[i][j] = true;
			}
	    }
	}
	
	if (check(flag)) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int pch(ll H) {
	ll i = 2;
	while (i * i <= H) {
		if (H % i == 0) {
			return -1;
		}
		i++;
	}
	return H;
}



int main() {
	ll X;
	cin >> X;
	while (pch(X) == -1) {
		X++;
	}
	cout << X << endl;
	
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define ll long long

int main(void)
{
    string c;
    cin >> c;
    if(c == "SSS")
        cout << 0;
    if(c == "RSS" || c == "SRS" || c == "SSR" || c == "RSR")
        cout << 1;
    if(c == "RRS" || c == "SRR")
        cout << 2;
    if(c == "RRR")
        cout << 3;
}

Measured memory_bytes: 3596
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <iostream>
using namespace std;	
int main(){
	int h,w;
	while(cin>>w>>h){
	if(w==0 && h==0) break;
	int dp[200][200][4]={},ans=0;
	//0　１つ前で曲がらずに下から来て	
	//1   曲がって下から
	//2  １つ前で曲がらずに左から来る
	//3   曲がって左から
	for(int y=1;y<=h;y++){
		for(int x=1;x<=w;x++){
			if((x==1 && y==1) || (x==1 && y==2) || (x==2 && y==1)){
				dp[1][1][0]=1;
				dp[1][1][1]=1;
				dp[1][1][2]=1;
				dp[1][1][3]=1;
				dp[2][1][0]=1;
				dp[1][2][2]=1;
			}
			else{
				 dp[y][x][0] = dp[y-1][x][0]%100000 + dp[y-1][x][1]%100000;
           			 dp[y][x][1] = dp[y-1][x][2]%100000;
           			 dp[y][x][2] = dp[y][x-1][2]%100000 + dp[y][x-1][3]%100000;
          			 dp[y][x][3] = dp[y][x-1][0]%100000; 
			}
		}
	}
	ans=dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3];
	cout<<ans%100000<<endl;
	}
	}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <math.h>
using namespace std;

const double PI = acos(-1.0);
struct Point{
    double x,y;
};

void koch(int n, Point a, Point b) {
    // 递归结束
    if (n == 0)
        return;
    // 三等分点s,t ，(u 是 s,t 上方的点)
    Point s, t, u;
    // 角度从度转成弧度
    double th = PI * 60.0 / 180.0;
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;


    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}
int main(){
    Point a, b;
    int n;
    scanf("%d", &n);

    // 初始化
    a.x = a.y = 0;
    b.x = 100, b.y = 0;
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    char a; cin>>a;
    if(a>='A' and a<='Z') cout<<"A\n";
    else cout<<"a\n";
    
    
    
    
}




int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

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

int main() {
  int A,B;
  cin >> A;
  cin >> B;
  if ( A == 1 && B == 2 ) {
    cout << 3 << endl;
  }
  if ( A == 1 && B == 3 ) {
    cout << 2 << endl;
  }
  if ( A == 2 && B == 1 ) {
    cout << 3 << endl;
  }
  if ( A == 2 && B == 3 ) {
    cout << 1 << endl;
  }
  if ( A == 3 && B == 2 ) {
    cout << 1 << endl;
  }
  if ( A == 3 && B == 1 ) {
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		String s=sc.next();
		long start=s.indexOf('A');
		long last=s.lastIndexOf('Z');
		long result=last-start+1;
		System.out.println(result);
	}

}

Measured memory_bytes: 14516
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for (p3, p2, p1), n in pre.items():
            for cur in 'AGCT':
                new = p2 + p1 + cur
                if new in ['AGC', 'GAC', 'ACG']:
                    continue
                if p3 + p1 + cur == 'AGC':
                    continue
                if p3 + p2 + cur == 'AGC':
                    continue
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print(main())

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MAX_N = 1e7+1;
ll can_div[MAX_N] = {};

void init_prime()
{
  for (ll i = 2; i < MAX_N; i++)
  {
    if (can_div[i] != 0)
      continue;
    for (ll j = i + i; j < MAX_N; j += i)
      can_div[j] = i;
  }
}

inline bool is_prime(ll n)
{
  if (n <= 1)
    return false;
  return !can_div[n];
}

void factorization(int n, unordered_map<ll, int> &res)
{
  if (n <= 1)
    return;
  if (!can_div[n])
  {
    ++res[n];
    return;
  }
  ++res[can_div[n]];
  factorization(n / can_div[n], res);
}
int main(){
ll n;
cin>>n;
ll ans = 0;
init_prime();
for (ll i = 1;i<=n;i++){
    unordered_map<ll, int> table;
    factorization(i, table);
    ll x = 1;
    for (auto j : table){
        x *= (j.second + 1);
    }
    ans += i * x;
}
cout << ans << endl;
}

Measured memory_bytes: 81760
#include <bits/stdc++.h>
#include <string>
#include <iostream>
using namespace std;
int main(){
    int score = 0;
    for(int i = 0; i < 4; ++i){
        char a;
        cin >> a;
        if( a == '+'){score = score + 1;}
        if( a == '-'){score = score - 1;}
    }
    cout << score << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M; cin >> N >> M;
    vector<ll> a(N), b(N), c(M), d(M);
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];
    rep(i, N){
        ll m = INF;
        ll ans = -1;
        rep(j, M){
            int tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(tmp < m){
                m = tmp;
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
    return 0;
}




Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		while (sn.hasNext()) {
		    String str = sn.next();
		    list.add(Integer.parseInt(str));
		}

		// hh1
		int hh1 = list.get(0);
		// mm1
		int mm1 = list.get(1);
		// hh2
		int hh2 = list.get(2);
		// mm2
		int mm2 = list.get(3);
		// stM
		int stM = list.get(4);

		int hToM = (hh2 - hh1 -1) * 60;
		int sumM = (60 - mm1) + mm2;

		int stMM = (hToM + sumM) - stM;

		if (stMM <= 0 ) {
			System.out.print(0);

		}else {
			System.out.print(stMM);
		}

	}
}

Measured memory_bytes: 35560
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class UnionFind{
		int size;
		int[] dat;
		
		public UnionFind(int n){
			size = n;
			dat = new int[n];
			clear();
		}
		
		public int find(int x){
			if(dat[x] == x){
				return x;
			}else{
				return dat[x] = find(dat[x]);
			}
		}
		
		public void union(int x, int y){
			if(same(x, y)){
				return;
			}else{
				dat[find(y)] = find(x);
			}
		}
		
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		
		public final void clear(){
			for(int i = 0; i < size; i++){
				dat[i] = i;
			}
		}
	}
	
	public static class Edge implements Comparable<Edge>{
		int from, to, cost;
		
		public Edge(int from, int to, int cost){
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Edge arg0) {
			return this.cost - arg0.cost;
		}		
	}

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

		while (true) {
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			ArrayList<Edge> list = new ArrayList<Edge>();
			for(int i = 0; i < m; i++){
				list.add(new Edge(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt()));
			}
			
			Collections.sort(list);
			
			UnionFind uf = new UnionFind(n);
			int min = Integer.MAX_VALUE;
			for(int start = 0; start < m; start++){
				uf.clear();
				
				int min_cost = Integer.MAX_VALUE, max_cost = Integer.MIN_VALUE;
				int count = 0;
				for(int cur = start; cur < m && count < n - 1; cur++){
					Edge edge = list.get(cur);
					
					//System.out.println(edge.from + " " + edge.to + " " + edge.cost + " " + uf.find(edge.from) + " " + uf.find(edge.to));
					
					if(!uf.same(edge.from, edge.to)){
						uf.union(edge.from, edge.to);
						count++;
						min_cost = Math.min(min_cost, edge.cost);
						max_cost = Math.max(max_cost, edge.cost);
					}
				}
				
				//System.out.println(min_cost + " " + max_cost);
				
				if(count == n - 1){
					min = Math.min(min, max_cost - min_cost);
				}
			}
			
			System.out.println(min == Integer.MAX_VALUE ? -1 : min);
		}
	}

}

Measured memory_bytes: 68812
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=401234;

int n,nw,nx=1;
vector<string> v2[2];

int main()
{
    scanf("%d",&n);
    v2[nw].pb("");
    for(int i=0; i<n; ++i)
    {
        for(int k=0; k<=i; ++k)
        {
            char tmp='a'+k;
            for(int j=0; j<v2[nw].size(); ++j)
            {
                v2[nx].pb(v2[nw][j]+tmp);
            }
        }
        nx=nw;
        nw=1-nw;
        v2[nx].clear();
    }
    for(int j=0; j<v2[nw].size(); ++j)
    {
        char tmp='a';
        int flg=0;
        for(int i=0;i<n;++i){
            if(v2[nw][j][i]-tmp>1){
                flg=1;
                break;
            }
            else if(v2[nw][j][i]-tmp>0)
                tmp=v2[nw][j][i];
        }
        if(flg==0)
            v2[nx].pb(v2[nw][j]);
    }
    sort(v2[nx].begin(),v2[nx].end());
    for(int j=0; j<v2[nx].size(); ++j)
        cout<<v2[nx][j]<<endl;
    return 0;
}


Measured memory_bytes: 227036
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            String X = sc.next();
            String Y = sc.next();
            int lenX = X.length();
            int lenY = Y.length();
            
            int[][] lcs = new int[lenX+1][lenY+1];
            
            for(int x = 1; x <= lenX; x++) {
                for (int y = 1; y <= lenY; y++) {
                    if (X.charAt(x-1) == Y.charAt(y-1)) {
                        lcs[x][y] = lcs[x-1][y-1] + 1; 
                    } else {
                        lcs[x][y] = Math.max(lcs[x-1][y], lcs[x][y-1]);
                    }
                }
            }
            System.out.println(lcs[lenX][lenY]);
        }
    }
}


Measured memory_bytes: 64448
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int N, K;
	cin >> N >> K;

	vector<ll> V(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}

	//A,Bを全探索
	ll total_value;
	ll minus_total;
	ll max_value = 0;
	vector<ll> V_minus(0);
	for (int A = 0; A <= K; A++) {
		for (int B = 0; B <= K; B++) {
			if (A + B > N || A + B > K) {//宝石が空なのに拾ってもしゃーない
				break;
			}

			//拾う
			total_value = 0;
			V_minus.clear();

			for (int i = 0; i < A; i++) {
				total_value += V[i];
				if (V[i] < 0) {//負なら負の価値の宝石の配列にadd
					V_minus.push_back(V[i]);

				}
			}

			for (int i = 0; i < B; i++) {
				total_value += V[N - 1 - i];
				if (V[N - 1 - i] < 0) {//負なら負の価値の宝石の配列にadd
					V_minus.push_back(V[N - 1 - i]);
				}
			}

			//負の宝石を昇順ソート
			sort(V_minus.begin(), V_minus.end());

			//K-(A+B)だけ捨てる。それ以下なら全部捨てることになるね。
			minus_total = 0;
			for (int i = 0; i < K - (A + B); i++) {
				if (i == V_minus.size()) { break; }//負の宝石を使い切ったらbreak
				minus_total += V_minus[i];
			}

			//負の宝石を捨てる（＝その分足す）
			if (max_value < total_value - minus_total) {
				max_value = total_value - minus_total;
			}
		}
	}

	cout << max_value;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int x, happy=0;
	scanf("%d", &x);
	while (x >= 500) {
		x -= 500;
		happy += 1000;
	}
	while (x >= 5) {
		x -= 5;
		happy += 5;
	}
	printf("%d", happy);
	return 0;
}

Measured memory_bytes: 128
import math
n, d = map(int, input().split())
x = [[int(e) for e in input().split()] for _ in range(n)]
result = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    t = math.sqrt(sum((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]) for k in range(d)))
    if t == math.ceil(t):
      result += 1
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> X(N), v;
    for (int i = 0; i < N; i++) cin >> X[i];
    v = X;
    sort(v.begin(), v.end());
    int a = v[N/2-1], b = v[N/2];
    for (int i = 0; i < N; i++) {
        if (X[i] <= a) {
            cout << b << endl;
        }
        else {
            cout << a << endl;
        }
    }
}

Measured memory_bytes: 3712
n, m = map(int, input().split())
a = [0] * n

for i in range(m):
    k, *s = list(map(int, input().split()))
    for j in range(k):
        a[s[j] - 1] |= 1 << i

p = 0
_p = list(map(int, input().split()))
for i in range(m):
    p |= _p[i] << i

ans = 0
for s in range(1 << n):
    t = 0
    for i in range(n):
        if s >> i & 1:
            t ^= a[i]
    if t == p:
        ans += 1
print(ans)


Measured memory_bytes: 3064
import java.util.*;
 
class Main{
    public static void main(String[] args){
		int n;
		double avr = 0.0;
		double ans = 0.0;
		Scanner scan = new Scanner(System.in);
		while((n = scan.nextInt()) != 0){
			int[] arr = new int[n];
			int sum1 = 0;
			avr = 0.0;
			for(int i=0; i<n; i++){
				int tmp = scan.nextInt();
				arr[i] = tmp;
				sum1 += tmp;
			}
			avr = (double)sum1 / n;
			double sum2 = 0.0;
			for(int i=0; i<n; i++){
				sum2 += (arr[i] - avr) * (arr[i] - avr);
			}
			ans = Math.sqrt(sum2 / n);
			System.out.println(ans);
		}
    }
}

Measured memory_bytes: 30992
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  string s;
  cin>>s;
  ll n=s.size();

  ll ans=n*(n-1)/2;

  vector<ll> p(26,0);
  rep(i,n){
    p[(int)(s[i]-'a')]++;
  }

  rep(i,26){
    ans-=p[i]*(p[i]-1)/2;
  }

  cout << ans+1 << endl;

}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;


int main() {
    long long S;
    scanf("%lld",&S);
    long long W;
    scanf("%lld",&W);

    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3616
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint
import itertools
import fractions

A, B, C, D = [ int(x) for x in input().split() ]
#B = [ int(x) for x in input().split() ]
lcm = int(C * D // fractions.gcd(C, D))

def not_devide_num(n):
    return n - (n // C + n // D - n // lcm)

print (not_devide_num(B) - not_devide_num(A - 1))



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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> abc(n, vector<int>(3));

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            cin >> abc[i][j];
        }
    }

    vector<vector<int>> dp(n, vector<int>(3));

    for(int i = 0; i < 3; i++)
    {
        dp[0][i] = abc[0][i];
    }

    for(int i = 1; i < n; i++)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + abc[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2];
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

    return 0;
}

Measured memory_bytes: 14344
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double d = h * 360/12 + 0.5 * m - m * 360/60;
  if(d<0)d = -d;
  if(d>180)d = 360 - d;
  double ret = a * a + b * b - 2 * a * b * cos(d*acos(-1) /180);
  ret = sqrt(ret);
  printf("%.12f\n",ret);
  return 0;
}

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

int a[4];
char op[] = {'+','-','*'};
int f(int n, int m, int ch)
{
	switch(ch){
	  case 0:
		return n + m;
	  case 1:
		return n - m;
	  case 2:
		return n * m;
	}
	return 0;
}

void solve()
{
	int count = 0;
	do{
		for(int i = 0; i < 27; ++i){
			int l = i/9, c = i/3%3, r = i%3;
			if(f(f(f(a[0],a[1],l),a[2],c),a[3],r) == 10){
				printf("(((%d %c %d) %c %d) %c %d)\n",a[0],op[l],a[1],op[c],a[2],op[r],a[3]);
				return;
			}
			else if(f(a[0],f(a[1],f(a[2],a[3],r),c),l) == 10){
				printf("(%d %c (%d %c (%d %c %d)))\n",a[0],op[l],a[1],op[c],a[2],op[r],a[3]);
				return;
			}
			else if(f(f(a[0],a[1],l),f(a[2],a[3],r),c) == 10){
				printf("((%d %c %d) %c (%d %c %d))\n",a[0],op[l],a[1],op[c],a[2],op[r],a[3]);
				return;
			}
			else if(f(f(a[0],f(a[1],a[2],c),l),a[3],r) == 10){
				printf("((%d %c (%d %c %d)) %c %d)\n",a[0],op[l],a[1],op[c],a[2],op[r],a[3]);
				return;
			}
			else if(f(a[0],f(f(a[1],a[2],c),a[3],r),l) == 10){
				printf("(%d %c ((%d %c %d) %c %d))\n",a[0],op[l],a[1],op[c],a[2],op[r],a[3]);
				return;
			}
		}
	}while(next_permutation(a,a+4));
	cout << 0 << endl;
}

int main()
{
	while(cin >> a[0] >> a[1] >> a[2] >> a[3],a[0]|a[1]|a[2]|a[3]){
		sort(a,a+4);
		solve();
	}
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, a; cin >> n;
    map<int, int> mp;
    rep(i,n) {
        cin >> a;
        ++mp[a];
    }

    int ans = 0;
    for(auto p : mp) {
        int dif = p.second - p.first;
        if(dif < 0) dif = p.first;
        chmin(dif, p.second);
        ans += dif;
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 4736
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf = 1e18+7;
//LLONG_MIN

/*

*/

int main(void){
	double b[1010];
	ll n,t,a,ans=1;
	cin>>n>>t>>a;
	reg(i,1,n){
		ll h;
		cin>>h;
		b[i]=t-0.006*h;
		if(abs(b[ans]-a)>abs(b[i]-a)){
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
vector<ll> v[100001];
ll n;
ll dp[100001][2];
ll solve(ll ver,ll f,ll p)
{
	if(dp[ver][f]!=-1) return dp[ver][f];
	dp[ver][f]=1;
	for(ll i=0;i<v[ver].size();i++)
	{
		if(v[ver][i]!=p)
		{
			if(f==0)
			{
				dp[ver][f]=(dp[ver][f]*((solve(v[ver][i],0,ver)+solve(v[ver][i],1,ver))%M))%M;
			}
			else
			{
				dp[ver][f]=(dp[ver][f]*((solve(v[ver][i],0,ver))%M))%M;
			}
		}
	}
	return dp[ver][f];
}
int main()
{
	boost
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(ll i=0;i<n-1;i++)
	{
		ll a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	cout<<(solve(1,0,-1)+solve(1,1,-1))%M<<endl;
	return 0;
}

Measured memory_bytes: 18432
while 1:
    nums = int(input())
    if nums != 0:
        d = {}
        stars = list(map(int,input().split()))
        for x in stars:
            if x not in d:
                d[x] = 1
            else:
                d[x] += 1

        key = list(d.keys())
        val = list(d.values())
        m = int(max(val))
        if m > nums/2:
            res = key[val.index(m)]
            print(res)
        else:
            print("NO COLOR")
    else:break

Measured memory_bytes: 126788
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  long long a, b, k; cin >> a >> b >> k;
  if (a > k) {
    cout << a-k << " " << b << endl;
    return 0;
  }
  k -= a;
  a = 0;
  cout << a << " " << max(0ll, b-k) << endl;


  return 0;
}

// EOF


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	puts(a==b?"=":a<b?"<":">");
}

Measured memory_bytes: 128
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
#define Y1 b1[0]-'a'
#define X1 b1[2]-'1'
#define Y2 b2[0]-'a'
#define X2 b2[2]-'1'
#define INF (1<<20)
using namespace std;
int dy[]={0,-1,0,1},dx[]={1,0,-1,0};
int m,n,ds,ns,nc,nj,sy,sx,gy,gx,t,
S[20][20],D[20][20][20][20]; bool V[20][20][101][4]; char ch,tmp;
void dfs( int y, int x, int t, int d ){
   V[y][x][t][d] = true;
   int ny, nx, nt;
   for ( int nd = 0; nd < 4; nd++ ){
       if ( (d+2)%4 == nd ) continue;
       ny = y + dy[nd];
       nx = x + dx[nd];
       if ( !ck(ny,m) || !ck(nx,n) ) continue;
       if ( D[y][x][ny][nx] == INF ) continue;
       nt = t + D[y][x][ny][nx];
       if ( nt > 100 ) continue;
       if ( S[ny][nx] > 0 ){
           if ( nd % 2 == 0 ){
               if ( (nt/S[ny][nx])%2 != 1 ) continue;
           } else {
               if ( (nt/S[ny][nx])%2 != 0 ) continue;
           }
       }
       if ( V[ny][nx][nt][nd] ) continue;
       dfs( ny, nx, nt, nd );
   }
}
int main(){
	while(cin>>m>>n,m){
		cin>>ds; rep(y,m)rep(x,n){
			S[y][x]=0; rep(d,4){
				int ny=y+dy[d],nx=x+dx[d];
				if(ck(ny,m)&&ck(nx,n))D[y][x][ny][nx]=D[ny][nx][y][x]=ds;
			}
		}
		int x1,x2,y1,y2,k;
		cin>>ns; rep(i,ns){
			cin>>ch>>tmp>>x1>>k; x1--;
			S[ch-'a'][x1]=k;
		}
		cin>>nc; rep(i,nc){
			cin>>ch>>tmp>>x1; y1=ch-'a'; x1--;
			cin>>ch>>tmp>>x2; y2=ch-'a'; x2--;
			D[y1][x1][y2][x2]=D[y2][x2][y1][x1]=INF;
		}
		cin>>nj; rep(i,nj){
			cin>>ch>>tmp>>x1; y1=ch-'a'; x1--;
			cin>>ch>>tmp>>x2>>k; y2=ch-'a'; x2--;
			D[y1][x1][y2][x2]+=k,D[y2][x2][y1][x1]+=k;
		}
		cin>>ch>>tmp>>sx; sy=ch-'a'; sx--;
		cin>>ch>>tmp>>gx; gy=ch-'a'; gx--;
		
		rep(i,m)rep(j,n)rep(t,101)rep(d,4)V[i][j][t][d]=0;
		rep(d,4)dfs(sy,sx,0,d);
		rep(t,101)rep(d,4)if(V[gy][gx][t][d]){
			cout<<t<<endl; goto END;
		}
		END:;
	}
	return 0;
}

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

int INF = 1000000000;
typedef pair<int, int> P;
vector<vector<int> > G(200001);
vector<int> d(200001);

void dijkstra(int s){
  for(int i = 0; i < d.size(); i++){
    d[i] = INF;
  }
  priority_queue<P, vector<P>, greater<P> > que;
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    for(int i = 0; i < G[v].size(); i++){
      int nextv = G[v][i];
      if(d[nextv] > d[v] + 1){
        d[nextv] = d[v] + 1;
        que.push(P(d[nextv], nextv));
      }
    }
  }
}

void showD(int n){
  for(int i = 0; i <= n; i++){
    cout << "d[" << i << "] = " << d[i] << endl;
  }
  cout << endl;
}

void showG(int n){
  for(int i = 0; i < n; i++){
    cout << "G[" << i << "] = ";
    for(int j = 0; j < G[i].size(); j++){
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

int main(){
  int N = 0, M = 0;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    
  }
  dijkstra(1);
  if(d[N] <= 2) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 13936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int count = 0;
		for(int i = 1; i <= N; i++) {
			int yaku = 0;
			if(i % 2 == 1) {
				for(int j = 1; j <= N; j++) {
					if(i % j == 0) {
						yaku++;
					}
				}
				if(yaku == 8) {
					count++;
				}
			}else {
				continue;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int A,B,K;
  cin >> K >> A >> B;

  int r=0;
  for(int i=A; i<=B; i++){
    if(i%K==0) r=1; 
  }
  if(r==1) cout << "OK" << endl;
  else cout << "NG" << endl;

  return 0;
}


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

using namespace std;

int n, m;
pair<int, int> tab[1000005];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &tab[i].second, &tab[i].first);
    }
    sort(tab + 1, tab + 1 + m);
    int last = 1;
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        int from = tab[i].second;
        int to = tab[i].first;
        if (from >= last) {
            last = to;
            ans++;
        }
    }
    printf("%d\n", ans);
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b;
    cin >> a >> b;
    cout << a + b / 2 << endl;
    return 0;
}


Measured memory_bytes: 256