akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        String[] w = {"Sunny", "Cloudy", "Rainy"};
        int index = 0;
        for (int i=0; i < w.length; i++) {
            if (s.equals(w[i]))
                index = i;
        }

        out.println(w[(index + 1) % 3]);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

}


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

typedef unsigned long long int ll;

int n;
ll t[101];
ll a, b, c;
ll temp;

ll gcd(ll a, ll b) {
  while (b > 0) {
    c = b;
    b = a % b;
    a = c;
  }
  return a;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main(void){
    // Here your code !
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%lld\n", &t[i]);
    }
    temp = 1;
    for (int i = 0; i < n; ++i) {
      temp = max(temp, lcm(temp, t[i]));
    }
    printf("%lld\n", temp);
}

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

// int MAX = 2000000;
// vector<int> s(MAX, -1);
// int n;

// void max_heapify(int i) {
//     int l = 2 * i, r = l + 1;
//     int largest = i;
//     if (r <= n) {
//         if (s[i] < max(s[l], s[r])) {
//             if (s[l] < s[r]) largest = r;
//             else largest = l;
//         }
//     } else if (l <= n) {
//         if (s[i] < s[l]) largest = l;
//     }
//     if (largest != i) {
//         swap(s[i], s[largest]);
//         max_heapify(largest);
//     }
// }

// void insert(int k) {
//     s[n] = k;
//     int i = n;
//     while (i > 0 && s[i] > s[i/2]) {
//         swap(s[i], s[i/2]);
//         i /= 2;
//     }
//     n++;
// }

// int extract() {
//     if (n == 0) return -1;
//     int max_v = s[0];
//     s[0] = s[n-1];
//     s[n-1] = -1;
//     n--;
//     max_heapify(0);
//     return max_v;
// }

int main() {
    priority_queue<int> pq;
    while (1) {
        string s;
        cin >> s;
        if (s == "insert") {
            int k;
            scanf("%d", &k);
            pq.push(k);
        } else if (s == "extract") {
            printf("%d\n", pq.top());
            pq.pop();
        } else if (s == "end") break;
    }
}


Measured memory_bytes: 7044
N,W = map(int,input().split())
k,l = 0,0
lv = [0] * N
lw = [0] * N
for i in range(N):
    lw[i],lv[i] = map(int,input().split())
V = sum(lv)
dp = [[float("inf") for i in range(V+1)] for j in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for sv in range(V+1):
        if sv-lv[i] < 0:
            dp[i+1][sv] = dp[i][sv]
        else:
            dp[i+1][sv] = min(dp[i][sv],(dp[i][sv-lv[i]]+lw[i]))

a = V
while a >= 0:
    if dp[-1][a] <= W:
        print(a)
        a = -1
    else:
        a -= 1


Measured memory_bytes: 319352
#include<cstdio>

using ll=long long;

int main(void)
{
	char s[100+2];
	ll k;

	while(scanf("%100[1-9]%lld\n", s, &k)==2)
	{
		int ans='?';
		for(int i=0;s[i] && i<k;i++)
		{
			ans=s[i];
			if(s[i]!='1') break;
		}
		printf("%c\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	static final int[] HAIKU = { 5, 7, 5, 7, 7 };

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			int[] w = new int[n];
			for (int i = 0; i < n; i++)
				w[i] = scan.next().length();

			int count = 1;
			int index = 0;
			for (int i = 0; i < n; i++) {
				int sum = 0;
				int j = i;
				while (j < w.length) {
					sum += w[j];
					if (sum >= HAIKU[index])
						break;
					j++;
				}
				if (sum == HAIKU[index]) {
					i = j;
					index++;
				} else {
					i = count - 1;
					count++;
					index = 0;
				}
				if (index == HAIKU.length) {
					System.out.println(count);
					break;
				}
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 32020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F0R(i, a) for (int i=0; i<(a); i++)
int main() {
	int N, K, Q; cin >> N >> K >> Q;
	int counts[N];
	F0R(i, N) counts[i] = 0;
	int req = Q-K;
	F0R(i, Q) {
		int X; cin >> X; X--;
		counts[X]++;
	}
	F0R(i, N)
		cout << (counts[i] > req ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1024
//usr/bin/env node $0 $@;exit
var hypot=function(a,b){
	//return Math.hypot(a,b);
	return Math.sqrt(a*a+b*b);
}
var main=function(){
	var arg;
	for(;(arg=readline().split(' ').map(Number))[0];){
		var a=arg[0],b=arg[1];
		print(Math.min.apply(null,Array.apply(null,{length:1+(a/2^0)}).map(function(_,i){return Math.abs(b-hypot(i,a-i));})));
	}
};

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

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

int main(){
	// sengen
	int k,n;

	// nyuryoku
	cin >> k >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	// keisan
	int max = k-a[n-1]+a[0];
	for(int i=1;i<n;i++){
		if(a[i]-a[i-1] > max){
			max = a[i]-a[i-1];
		}
	}
	cout << k-max << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  LCIN(N, M);
  ll ans = M * 1900 + (N - M) * 100;
  ans *= (1 << M);
  cout << ans << endl;

  return 0;
}



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

int main(){
	int n, ans = 1;
	cin >> n;
	vector<int> d(n);
	for(int i=0; i < n; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	int min = d.at(0);
	for(int i=1; i < n; i++) {
		if(min < d.at(i)) {
			min = d.at(i);
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int A = 0;
		int B = 0;
		int C = 0;
		String s;
		Scanner sc = new Scanner(System.in);
		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		C = Integer.parseInt(sc.next());
		if((A<C&&C<B)||(B<C&&C<A)){
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 23252
N = int(input())
card_values = list(map(int, input().split(" ")))
 
card_values_sorted = sorted(card_values, reverse=True)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]
 
print(Alice_score - Bob_score)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  ans += min(A[i],B[i])
  ans += min(A[i+1],B[i] - min(A[i],B[i]))
  A[i+1] -= min(A[i+1],B[i] - min(A[i],B[i]))
print(ans)

Measured memory_bytes: 18624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define findmax(a,b) (a)>(b)?(a):(b)
#define findmin(a,b) (a)<(b)?(a):(b)
#define inout freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define swap(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b)
#define quicksort(a,n) qsort(a,n,sizeof(a[0]),cmp)
#define inputarr(a,n) for(int i=0;i<n;i++){scanf("%d",&a[i]);}
#define printarr(a,n) for(int i=0;i<n;i++){printf("%d ",a[i]);}puts("");
int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}

int main() {
    //inout;

    int n;

    scanf("%d", &n);

    printf("%d", n + n * n + n * n* n);

    

}

Measured memory_bytes: 1684
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    v=LI()
    v.sort()
    ans=v[0]
    for i in range(1,N):
        ans=(ans+v[i])/2
    print(ans)

main()


Measured memory_bytes: 61508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String day = scan.next();
		
		int year = Integer.parseInt(day.substring(0,4));
		int mon = Integer.parseInt(day.substring(5,7));
		
		if(year>=2019 && mon >=5) {System.out.println("TBD");}
		else System.out.println("Heisei");
		
	}

}


Measured memory_bytes: 21972
from collections import defaultdict

n=int(input())
counter=defaultdict(int)

for x in map(str,range(1,n+1)):
    head=x[0]
    tail=x[-1]
    counter[(head,tail)]+=1

ans=0
items=list(counter.items())
for (head, tail), cnt in items:
    ans+=cnt*counter[(tail, head)]

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    set<string> sset;
 
    rep(i, n){sset.insert(s[i]);}

    cout << sset.size() << endl;

}



Measured memory_bytes: 25168
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e50)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    H = l_inpl()

    for i in range(1, N):
        if H[i] > H[i-1]:
            H[i] = H[i] - 1
        elif H[i] == H[i-1]:
            pass
        else:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()


Measured memory_bytes: 64476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d;
    cin >> n;
    
    int cheap = 4 * q;
    if(cheap > h * 2) {
        cheap = h * 2;
    }
    if(cheap > s) {
        cheap = s;
    }
    
    if(cheap * 2 > d) {
        if(n % 2 == 0) {
            SHOW(d * (n / 2));
        }
        else {
            SHOW((d * (n / 2)) + cheap);
        }
    }
    else {
        SHOW(cheap * n);
    }
    
    return 0;
}




Measured memory_bytes: 256
X = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
def solve(N):
    N = [int(c) for c in N][::-1]
    p = 0
    b = 0
    for i in range(len(N)):
        c = N[i] + b
        p += X[c]
        if c == 5:
            b = 0 if i == len(N)-1 or N[i+1] < 5 else 1
        elif c > 5:
            b = 1
        else:
            b = 0
    return p + b

print(solve(input()))


Measured memory_bytes: 21444
import java.util.*;
class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int d=n%10;
        if(d==2||d==4||d==5||d==7||d==9)
        System.out.println("hon");
        else if(d==0||d==1||d==6||d==8)
        System.out.println("pon");
        else
        System.out.println("bon");
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (u.at(i) == "BTC") {
      x.at(i) *= 380000;
    }
  }
  double Y = 0.0;
  for (int i = 0; i < N; i++) {
    Y += x.at(i);
  }
  cout << Y << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && B == C && A == C)cout << "No" << endl;
    else if(A != B && B != C && A != C)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

struct edge{int to,cap,rev;};

class FF
{
public:
  vector<vector<edge>>G;
  vector<bool> used;
  FF(int maxv)
  {
    G.resize(maxv);
    used.resize(maxv);
  }
  void add_edge(int from,int to,int cap,bool directed=1)
  {
    G[from].push_back({to,cap,(int)G[to].size()});
    G[to].push_back({from,cap*(!directed),(int)G[from].size()-1});
  }
  int dfs(int v,int t,int f)
  {
    if(v==t)return f;
    used[v]=1;
    for(auto &nv:G[v])
    {
      if(!used[nv.to] && nv.cap>0)
      {
        int d=dfs(nv.to,t,min(f,nv.cap));
        if(d>0)
        {
          nv.cap-=d;
          G[nv.to][nv.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }
  int solve(int s,int t)
  {
    int res=0;
    while(1)
    {
      for(int i=0;i<used.size();i++)used[i]=0;
      int f=dfs(s,t,(1<<30)-1);
      if(f==0)break;
      res+=f;
    }
    return res;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;
  cin>>h>>w;
  vector<string>hw(h);
  rep(i,h)cin>>hw[i];
  int s,t;
  FF ff(h*w*2);
  rep(i,h*w)
  {
    ff.add_edge(i*2,i*2+1,1,0);
  }
  rep(i,h)
  {
    vector<int>leaf;
    leaf.clear();
    rep(j,w)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        if(hw[i][j]=='S')s=num+1;
        if(hw[i][j]=='T')t=num;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,200,1);
          ff.add_edge(num+1,k,200,1);
        }
        leaf.push_back(num);
      }
    }
  }
  rep(j,w)
  {
    vector<int>leaf;
    leaf.clear();
    rep(i,h)
    {
      if(hw[i][j]!='.')
      {
        int num=(i*w+j)*2;
        for(auto k:leaf)
        {
          ff.add_edge(k+1,num,200,1);
          ff.add_edge(num+1,k,200,1);
        }
        leaf.push_back(num);
      }
    }
  }

  ll res=ff.solve(s,t);
  if(res>=200)
  {
    res=-1;
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 61952
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define		    MOD			    1000000007


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}

ll SUM[999999];

int main()
{
    fast;
    int n;
    cin>>n;
    vector<ll>v(n);
    rep(i,n)cin>>v[i];
    SUM[0] =v[0];
    for(int i=1;i<n;i++)
    {
		SUM[i]+=SUM[i-1] + v[i];
	}
	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		ll sum = SUM[n-1] - SUM[i];
		ll mul = v[i]%MOD;
		mul=mul*(sum%MOD);
		mul=mul%MOD;
		ans=(ans%MOD) + mul;
	}
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6444
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n,t,a,i,h,ans;cin >> n >> t >> a;double count,z;
  count = 10000000;
  for (i=0;i<n;i++){
    cin >> h;
    z = abs(a-(t-h*0.006));
    if (z<count){
      count = z;ans = i;
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    vector<vector <int > > room(N); 
    bool seen[N]={};
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;a--;b--;
        room[a].push_back(b);
        room[b].push_back(a);
    }
    queue<int > que;
    int ans[N];
    for(int i=0;i<N;i++){
        ans[i]=-1;
    }
    que.push(0);
    seen[0]=true;
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(auto next:room[now]){
            if(seen[next]){
                continue;
            }
            ans[next]=now;
            que.push(next);
            seen[next]=true;
        }
    }
    for(int i=1;i<N;i++){
        if(ans[i]==-1){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10280
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    cout<<a/b<<" ";
    cout<<a%b<<" "<<flush;
    cout<<fixed<<setprecision(6);
    cout<<(double)a/(double)b<<endl;
}



Measured memory_bytes: 3276
#include <stdio.h>

int main(void){
	int a, b;
	int area, circum;
	
	scanf("%d %d", &a, &b);
	area = a * b;
	circum = (a + b) * 2;
	
	printf("%d %d\n", area, circum);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

ll mod_add(ll a, ll b) {
	return (a % DIV + b % DIV) % DIV;
}

ll mod_mul(ll a, ll b) {
	return ((a % DIV) * (b % DIV)) % DIV;
}

int main() {
	int N, S; cin >> N >> S;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<vector<ll>> dp(N + 1, vector<ll>(S + 1));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= S; j++) {
			//not take
			dp[i + 1][j] = mod_add(dp[i+1][j],mod_mul((ll)2,dp[i][j]));
			//take
			if (j + a[i] <= S)
			dp[i+1][j+a[i]]= mod_add(dp[i + 1][j+a[i]], dp[i][j]);
		}
	}
	cout << dp[N][S] << endl;
}

Measured memory_bytes: 73748
using System;

class Program
{
    static void Main()
    {
        var n = Console.ReadLine();
        if ((n[0] == n[1] && n[1] == n[2]) || (n[3] == n[2] && n[1] == n[2]))
        {
            Console.WriteLine("Yes");

        }
        else
        {
            Console.WriteLine("No");

        }
    }
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    for (int i = 1; i < N; i++) {
        string str1 = S.substr(0, i);
        string str2 = S.substr(i);
        int cnt = 0;
        for (char ch = 'a'; ch <= 'z'; ch++) {
            bool check1 = false;
            for (int j = 0; j < (int)str1.size(); j++) {
                if (str1[j] == ch) check1 = true;
            }
            bool check2 = false;
            for (int j = 0; j < (int)str2.size(); j++) {
                if (str2[j] == ch) check2 = true;
            }
            if (check1 && check2) cnt++;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;

using Graph = vector<vector<int>>;

int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que;
    vector<int> pre(N, -1);
  
    que.push(0);
    while(!que.empty()) {
    	int v = que.front();
        que.pop();
      
        for (int nv : G[v]) {
        	if (pre[nv] != -1) continue;
            pre[nv] = v;
            que.push(nv);
        }
      
    }
    cout << "Yes" << endl;
    for (int i=1; i < N; ++i) {
        int ans = pre[i];
        ans++;
    	cout << ans << endl;
    }

}

Measured memory_bytes: 10076
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define ll long long
const int maxn=105;
const int maxv=1e5+5;
ll w[maxn],minn[maxv];
int v[maxn];
int main()
{
    int N;
    ll W;
    scanf("%d%lld",&N,&W);
    int sum=0;
    for(int i=1;i<=N;i++)
    {
        scanf("%lld%d",&w[i],&v[i]);
        sum+=v[i];
    }
    memset(minn,0x3f,sizeof(minn));
    minn[0]=0;
    for(int i=1;i<=N;i++)
        for(int j=sum;j>=v[i];j--)
            minn[j]=min(minn[j],minn[j-v[i]]+w[i]);
    int ans=0;
    for(int i=sum;i>=1;i--)
        if(minn[i]<=W)
        {
            ans=i;
            break;
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4540
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    if (a%2==1){
      System.out.println(a*2);
    } else {
      System.out.println(a);
    }
  }
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  string s;
  cin >> s;
  rep(i, s.length()) {
    if (i % 2 && !(s[i] == 'L' ||s[i] == 'U' ||s[i] == 'D')) {
      cout << "No" << endl;
      return 0;
    }
    if (!(i % 2) && !(s[i] == 'R' ||s[i] == 'U' ||s[i] == 'D')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, big;
	cin  >> a >> b;
	big = Max((a+b), (a-b));
	big = Max((big), (a*b));
	cout << big << endl;
	return 0;
}


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

using namespace std;

int main() {
    const int MAX_N = 100, MAX_W = 10000;
    int N, W, v[MAX_N], w[MAX_N];
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }
    int dp[MAX_N + 1][MAX_W + 1];
    memset(dp[0], 0, sizeof(dp[0]));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int cnt[4]={0};
    rep(i,3){
        int a,b;
        cin>>a>>b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
    }
    sort(cnt, cnt+4);
    if(cnt[0]==1 && cnt[1]==1 && cnt[2]==2 && cnt[3]==2)
        YES;
    else NO;
    
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
d = deque()
for _ in range(n):
    x = input().split()
    if x[0][0] == 'i':
        d.appendleft(int(x[1]))
    elif x[0] == 'delete':
        try:
            d.remove(int(x[1]))
        except ValueError:
            pass
    elif x[0][6] == 'F':
        d.popleft()
    else:
        d.pop()
print(*d)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;
    cin>>n;
    string s;cin>>s;
    int c=0;
    int ma=0;
    rep(i,s.size()){
        if(s[i]=='I')c++;
        else c--;
        chmax(ma,c);
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;
        if (a>b) {
            result += a;
            a--;
        }
        else {
            result += b;
            b--;
        }
      
        if (a>b) {
            result += a;
            a--;
        }
        else {
            result += b;
            b--;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
int x[105],a[105];
int main(void)
{
    int n;
    scanf("%d" ,&n);
    for(int i=1;i<=n;i++)
        scanf("%d" ,&x[i]);
    for(int i=1;i<=100;i++)
        for(int j=1;j<=n;j++)
            a[i]+=(x[j]-i)*(x[j]-i);
    printf("%d" ,*min_element(a+1,a+101));
    return 0;
}


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

using namespace std;

int n, mod = 1000000007;
string s;

int main() {

    cin >> n >> s;

    vector<int> fq(26);
    for (auto c: s) fq[c-'a']++;

    int res = 1;
    for (auto t: fq) res = (1LL * res * (t+1)) % mod;
    res = (res - 1 + mod) % mod;

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 512
from sys import stdin
import math

data = stdin.readline().rstrip().split()
N = int(data[0])

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

div_list = sorted(make_divisors(N))
count = 0

for i in div_list:
    if i == 1:
        continue
    tmp_N = N
    while(1):
        if tmp_N % i == 0:
            tmp_N = tmp_N // i
        else:
            r = tmp_N % i
            if r == 1:
                count += 1
            break
            

div_list_2 = sorted(make_divisors(N-1)) 
        
print(count + len(div_list_2) - 1)
        

Measured memory_bytes: 3316
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = inp()
b = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
print(b[a-1])

Measured memory_bytes: 66156
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 100010
#define inf 1000000007
#define mod 1000000007
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,N,M,s,t;
int P[maxn],Q[maxn];
int idp[maxn],idq[maxn];
void dfs1(int x)
{
    if(idp[x])  return;
    idp[x]=N;
    dfs1(P[x]);
}
void dfs2(int x)
{
    if(idq[x])  return;
    idq[x]=M;
    dfs2(Q[x]);
}
int res;
int head[maxn*2],nxt[maxn*2],to[maxn*2],c[maxn*2],tot=1;
void add(int u,int v,int x)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
    c[tot]=x;
}
int dep[maxn*2];
queue<int>q;
void bfs()
{
    for(int i=1;i<=t;i++)  dep[i]=-1;
    q.push(s);dep[s]=0;
    while(q.size())
    {
        int now=q.front();q.pop();
        for(int i=head[now];i;i=nxt[i])
        {
            if(dep[to[i]]<0&&c[i])
            {
                dep[to[i]]=dep[now]+1;
                q.push(to[i]);
            }
        }
    }
}
int cur[maxn*2];
int dfs(int u,int t,int dist)
{
    if(u==t)  return dist;
    for(int &i=cur[u];i;i=nxt[i])
    {
        if(dep[to[i]]==dep[u]+1&&c[i])
        {
            int di=dfs(to[i],t,min(dist,c[i]));
            if(di>0)
            {
                c[i]-=di;
                c[i^1]+=di;
                return di;
            }
        }
    }
    return 0;
}
int Dinic()
{
    int res=0;
    while(true)
    {
        bfs();
        if(dep[t]<0)  return res;
        for(int i=1;i<=t;i++)  cur[i]=head[i];
        while(int d=dfs(s,t,inf))  res+=d;
    }
    return res;
}
int main()
{
    n=read();res=n;
    for(int i=1;i<=n;i++)  P[i]=read()+1;
    for(int i=1;i<=n;i++)  Q[i]=read()+1;
    for(int i=1;i<=n;i++)
      if(!idp[i])  ++N,dfs1(i);
    for(int i=1;i<=n;i++)
      if(!idq[i])  ++M,dfs2(i);
    s=N+M+1;t=N+M+2;
    for(int i=1;i<=n;i++)
    {
        if(P[i]==Q[i])
        {
            if(P[i]==i)  res--;
            else{
                add(idp[i],idq[i]+N,1);
                add(idq[i]+N,idp[i],1);
            }
        }
        else if(P[i]==i)
        {
            add(idq[i]+N,t,1);
            add(t,idq[i]+N,0);
        }
        else if(Q[i]==i)
        {
            add(s,idp[i],1);
            add(idp[i],s,0);
        }
        else{
            add(idq[i]+N,idp[i],1);
            add(idp[i],idq[i]+N,0);
        }
    }
    printf("%d\n",res-Dinic());
    return 0;
}

Measured memory_bytes: 7552
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int INF = 1e9;

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

  int N, M, R; cin >> N >> M >> R;
  vector<int> r(R); rep(i, R) {cin >> r[i]; --r[i];}
  sort(all(r));

  int dis[N][N];
  rep(i, N){
    rep(j, N) {
      if (i == j) dis[i][j] = dis[j][i] = 0;
      else dis[i][j] = dis[j][i] = INF;
    }
  }

  rep(i, M){
    int a, b, c; cin >> a >> b >> c;
    --a; --b;
    dis[a][b] = dis[b][a] = c;
  }

  rep(k, N){
    rep(i, N){
      rep(j, N){
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  int ans = 1e9;

  do{
    int temp = 0;
    for (int i = 1; i < R; ++i){
      temp += dis[r[i - 1]][r[i]];
    }
    ans = min(ans, temp);
  } while(next_permutation(all(r)));

  print(ans);

  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue> 
#include<cmath>
#include<utility>
#include<set>
using namespace std;
bool compare(int a, int b)
{
  return a > b;
}
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n, x;
  cin >> n;
  int nb=0, mi=n+1;
  for(int i = 0; i < n; i++)
  {
  	cin >> x;
  	if(x < mi)
  	{
  		mi=x;
  		nb++;
  	}
  }
  cout << nb << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  int N , M; cin >> N >> M;
  vector<P1> a(M); rep(i,M) cin >> a[i].fi >> a[i].sc.fi; rep(i,M) a[i].sc.sc = i;
  SORT(a);

  vector<int> ans(M + 10);
  int cnt = 1;
  ans[0] = cnt;
  rep(i,M){
    if(a[i].fi == a[i + 1].fi) ans[i + 1] = ++cnt;
    else{
      cnt = 1;
      ans[i + 1] = cnt;
    }
  }

  vector<P1> tmp(M);
  rep(i,M){
    tmp[i].fi = a[i].sc.sc;
    tmp[i].sc.fi = a[i].fi;
    tmp[i].sc.sc = ans[i];
  }

  SORT(tmp);

  rep(i,M){
    printf("%06d", tmp[i].sc.fi);
    printf("%06d", tmp[i].sc.sc);
    cout << endl;
  }
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
using namespace std;
string s;
long long ans;
int cur;
long long suu(){
  string num = "";
  while(cur < s.size() && '0' <= s[cur] && s[cur] <= '9' ){
	fflush(stdout);
	num += s[cur];
	cur++;
  }

  return stoll(num);
}
long long kou(){
  long long res = suu();
  if(cur < s.size() && s[cur] == '*'){
	cur++;
	res *= kou();
  }
  return res;
}
long long siki(){
  long long res = kou();	
  if(cur < s.size() && s[cur] == '+'){
	cur++;
	res += siki();

  }
  return res;
}
long long left_siki(){
  long long res = suu();
  char op;
  while( cur < s.size() && ((op = s[cur]) == '+' || (op == '*') ) ){
	cur++;
	if(op == '+'){
	  res += suu();
	}else if(op == '*'){
	  res *=  suu();
	}
  }
  return res;
}
int main(){
  cur = 0;
  cin >> s >> ans;
  long long res1 = siki();

  cur = 0;
  long long res2 = left_siki();
  
  int flag = 0;
  if(res1 == ans){
	flag = 1;
  }
  if(res2 == ans){
	flag |= 2;
  }

  if(flag == 0)cout << "I" << endl;
  else if(flag == 3)cout << "U" << endl;
  else if(flag == 1) cout << "M" << endl;
  else if(flag == 2) cout << "L" << endl;
  
  return 0;
  
}

Measured memory_bytes: 1216
#include <stdio.h>
#define N 101
int A[N][N],d[N]={0},f[N]={0},n,cnt=0;

void find(u){
	int v;
  cnt++;
  d[u] = cnt;
  for(v=0; v<n; v++){
    if(A[u][v]==1 && d[v] == 0)
      find(v);
  }
  cnt++;
  f[u] = cnt;
}

int main(){
	int i,j,u,k,x;

  scanf("%d",&n);

  for(i=0; i<n; i++)
    for(j=0; j<n; j++)
      A[i][j] = 0;

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d",&x);
      A[u-1][x-1] = 1;
    }
  }

  for(i=0; i<n; i++){
    if(d[i] == 0)
      find(i);
  }

  for(i=0; i<n; i++)
    printf("%d %d %d\n",i+1,d[i],f[i]);

  return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int l1 = 10000000;
const int l2 = 25500000;
const int yzh = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }
 
int s, f[l2+5];
 
int quick_pow(int a, int b) {
    int ans = 1;
    while (b) {
    if (b&1) ans = 1ll*ans*a%yzh;
    a = 1ll*a*a%yzh, b >>= 1;
    }
    return ans;
}
int count1(int n) {
    int ans = 0, r = 0, cnt = 0;
    for (int i = 1; i < l1; i++) {
    cnt -= f[i-1];
    while (cnt+f[r+1] <= s && r < l2) cnt += f[++r];
    if (cnt == s) ++ans;
    if (r == l2) break;
    }
    return ans;
}
int count2(int n) {
    int lim = n/8, ans = lim;
    for (int t = 1; t <= lim; t++)
    if (n%t == 0) {
        int len = n/t;
        (ans += (1ll*quick_pow(10, len-1)*9%yzh-t)%yzh) %= yzh;
    }
    return ans;
}
void work() {
    for (int i = 1, r = 10, cnt = 1; i < l1; i++, i = r, r = r*10, cnt++)
    for (int j = i; j < r; j++) f[j] = cnt;
    for (int k = l1; k <= l2; k++) f[k] = 8;
    read(s);
    writeln(((count1(s)+count2(s))%yzh+yzh)%yzh);
}
int main() {
    work();
    return 0;
}

Measured memory_bytes: 99840
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI 3.141592653589793238462643383279
#define EPS 10e-8

using namespace std;

int main()
{
	int m, n;

	int sum;
	vector <double> sa, sb;
	for (;; ){
		cin >> m;
		if (!m )
			break; 
		vector <int> a (m, 0 );
		sum = 0;
		rep (i, m - 1 ){
			cin >> a[i];
			sum += a[i];
		} // end rep
		a[m-1] = 360 - sum;
		cin >> n;
		vector <int> b (n, 0 );
		sum = 0;
		rep (j, n-1 ){
			cin >> b[j];
			sum += b[j];
		} // end rep
		b[n-1] = 360 - sum;

		double s = 0.0, t = 0.0;
		rep (i, m )
			s += sin ((double)a[i]*PI/180. );
		sa.push_back (s );
		rep (j, n )
			t += sin ((double)b[j]*PI/180. );
		sb.push_back (t );

	} // end while

	int size = sa.size();
	rep (i, size ){
		sa[i] = fabs (sa[i] ); sb[i] = fabs (sb[i] );
		if (sa[i] > sb[i]+EPS ){
			cout << '1' << endl;
		}else if (sa[i]+EPS < sb[i] ){
			cout << '2' << endl;
		}else{
			cout << '0' << endl;
		} // end if 
	} // end for

	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  int a, z;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      a = i;
      break;
    }
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'Z') {
      z = i;
      break;
    }
  }
  cout << z - a + 1 << '\n';
}


Measured memory_bytes: 3732
n, k = (int(i) for i in input().split())
d = []
A = []
for i in range(k):
    d.append(int(int(input())))
    A.append(list(map(int,input().split())))

x = [0] * n
for a in A:
    for i in a:
        x[i-1] += 1

ans = 0
for i in x:
    if(i == 0):
        ans += 1
print(ans)


Measured memory_bytes: 9144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();

		if(r < 1200) {
			System.out.println("ABC");
		} else if(r >= 1200 && r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

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

int main(){
    bool cards[4][14];
    int n, rank;
    char suit;
    
    
    for( int s = 0; s < 4; s++ ){
        for(int r = 1; r <= 13; r++){
            cards[s][r] = 0;
        }
    }
    
    
         
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> suit >> rank;
        if(suit == 'S')cards[0][rank] = 1;
        if(suit == 'H')cards[1][rank] = 1;
        if(suit == 'C')cards[2][rank] = 1;
        if(suit == 'D')cards[3][rank] = 1;
    }
    
    
    for(int s = 0; s < 4; s++){
        for(int r = 1; r <= 13; r++){
            if(cards[s][r])continue;
            if(s == 0)suit = 'S';
            if(s == 1)suit = 'H';
            if(s == 2)suit = 'C';
            if(s == 3)suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3096