akhauriyash/Code-Regression huggingface dataset:
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner scanner;

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

	    int L=gi();
	    int R=gi();
	    int d=gi();
	    
	    int c=0;
	    for(int i=L; i<=R;i++) {
	    	if (i%d==0) {
	    		c++;
	    	}
	    }

	    
        System.out.print(c);

//        if (m%2==0) {
//        	System.out.println(m/2);
//        }else{
//        	System.out.println((m+1)/2);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35584
import sys

h,w,m = map(int, sys.stdin.readline().split())
num_in_h = [0] * h
num_in_w = [0] * w
targets = set()
for _ in range(m):
    t_h, t_w = map(lambda x: int(x)-1, sys.stdin.readline().split())
    num_in_h[t_h] += 1
    num_in_w[t_w] += 1
    targets.add((t_h, t_w))

max_h = max(num_in_h)
max_w = max(num_in_w)
max_h_set = set([i for i, v in enumerate(num_in_h) if v == max_h])
max_w_set = set([i for i, v in enumerate(num_in_w) if v == max_w])
ans = max_h + max_w - 1

flag = False
for i in max_h_set:
    for j in max_w_set:
        if (i, j) not in targets:
            flag = True
            break
    if flag: break

print(ans+1 if flag else ans)


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

using namespace std;
#define ll long long int

ll f[2020];
int main()
{
    string s;
    cin >> s;
    f[0]=1;
    ll ans = 0, mod = 0;
    ll curr = 1;
    for(int i=s.length()-1;i>=0;i--){
        mod = (mod+curr*(s[i]-'0'))%2019;
        curr = (curr*10)%2019;
        ans+=f[mod];
        f[mod]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  int ans=1;
  REP(i,n){
    if(i==0) continue;
    if(s[i-1]!=s[i]) ans++;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

constexpr int size = 100001;
bool visited[size] = {false};
int ans[size*2];
int l = size, r = size + 1;

int main() {
    int N, M, a, b;
    scanf("%d %d\n", &N, &M);
    vector<vector<int>> G(N + 1, vector<int>(0));
    REP(i, M) {
        scanf("%d %d\n", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int s = 1, t = G[s][0];
    ans[l] = s; ans[r] = t;
    visited[s] = visited[t] = true;
    bool fs = true, ft = true;
    while(fs || ft) {
        if(fs) {
            fs = false;
            for(auto& x : G[s]) {
                if(!visited[x]) {
                    s = x; fs = true;
                    ans[--l] = s;
                    break;
                }
            }
            visited[s] = true;
        }
        if(ft) {
            ft = false;
            for(auto& x : G[t]) {
                if(!visited[x]) {
                    t = x; ft = true;
                    ans[++r] = t;
                    break;
                }
            }
            visited[t] = true;
        }
    }
    printf("%d\n", r - l + 1);
    while(l <= r) printf("%d ", ans[l++]);
    printf("\n");
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<long> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
  	for(int i = n-1; i >= 1; i--) {
    	if(h[i] - h[i-1] == -1) {
        	h[i-1]--; 
        } else if(h[i] - h[i-1] < -1) {
        	cout << "No" << endl;
          	return 0;
        } 
    }
	cout << "Yes" << endl;
	
}


Measured memory_bytes: 1024
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>

long long floor_sum(long long n, long long m, long long a, long long b) {
	long long ans = 0;
	if (a >= m) {
		ans += (n - 1) * n * (a / m) / 2;
		a %= m;
	}
	if (b >= m) {
		ans += n * (b / m);
		b %= m;
	}

	long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
	if (y_max == 0) return ans;
	ans += (n - (x_max + a - 1) / a) * y_max;
	ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
	return ans;
}
int main() {
	int t; std::cin >> t;
	for (auto i = 0; i < t; ++i) {
		int n, m, a, b; std::cin >> n >> m >> a >> b;
		std::cout << floor_sum(n, m, a, b) << '\n';
	}
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		sc.close();
		
		int ans = 0;
		for(int i=0; i<n-1; i++) {
			if(a[i] == a[i+1]) {
				ans++;
				i++;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
s = input()
f1, f2 = False, False
if int(s[2:]) < 13 and int(s[2:]) > 0:
  f1 = True
if int(s[:2]) < 13 and int(s[:2]) > 0:
  f2 = True
if not f1 and not f2:
  print("NA")
elif f1 and f2:
  print("AMBIGUOUS")
elif f1:
  print("YYMM")
else:
  print("MMYY")


Measured memory_bytes: 3060
a = list(map(int,input().split()))
if a[1] > a[0]:
  if a[1] < a[2] or a[2] < a[0]:
    print("No")
  else:
  	print("Yes")
else:
  if a[1] > a[2] or a[2] > a[0]:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 3060
def f(a, b, c):
    return max(a, b, c) - min(a, b, c)


h, w = map(int, input().split())
if (w % 3 == 0 or h % 3 == 0):
    print(0)
else:
    ans = min(h, w)
    for i in range(1, h):
        ans = min(ans, f(i * w, (h - i) * (w // 2), (h - i) * ((w + 1) // 2)))
    for i in range(1, w):
        ans = min(ans, f(i * h, (w - i) * (h // 2), (w - i) * ((h + 1) // 2)))
    print(ans)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    priority_queue<int> a;
    rep(i, n) {
        int x;
        cin >> x;
        a.push(x);
    }

    rep(i, m){
        int tmp = a.top();
        a.pop();
        tmp /= 2;
        a.push(tmp);
    }

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N;
    cin >> N;
    for(int i=1; i<10; i++){
        if(i*111 >= N){
            cout << i*111;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main() 
{
    int a,b,c,x;
    scanf("%d %d %d", &a, &b,&c);
    if (a > b)
    {
        x = b;
        b = a;
        a = x;
    }
    if (b > c)
    {
        x = c;
        c = b;
        b = x;
    }
    if (a > b)
    {
        x = b;
        b = a;
        a = x;
    }
    printf ("%d %d %d\n", a, b, c);
    return 0;
}

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

using namespace std;

ll f(ll h){
    if(h==1) return 1;
    ll a =f(h/2);
    return 2*a+1;
}

int main()
{
    ll h;
    cin>>h;
    cout<<f(h)<<endl;
   return 0;
}

Measured memory_bytes: 3584
from itertools import permutations as perm

N = int(input())
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
for indexes in perm(list(range(N))):
    xys = [XYS[i] for i in indexes]
    x0, y0 = xys[0]
    for x1, y1 in xys:
        s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
        x0 = x1
        y0 = y1

nf = 1
for i in range(1, N+1):
    nf *= i
ans = s / nf

print(ans)

Measured memory_bytes: 9408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

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

using namespace std;

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

void solve_A(){
    string s;
    cin >> s;

    if(s[1] == 'B') cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

void solve_B(){
    int n, k;
    cin >> n >> k;

    int d[k];

    int ans[n];
    REP(i,n) ans[i] = 0;
    int ctr = 0;
    REP(i,k){
        cin >> d[i];
        REP(j, d[i]){
            int a[d[i]];
            cin >> a[j];
            ans[a[j]-1]++;
        }
    }

    REP(i,n){
        if(ans[i] == 0) ctr++;
    }
    cout << ctr << endl;
}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 3628
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){

    }else{
      val map = Map("A"->"T", "T"->"A","G"->"C", "C"->"G")
      println(map(io.Source.stdin.getLines().mkString("\n").trim()))
    }
  }
}

Measured memory_bytes: 27216
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

vector<int> split(string s) {
  vector<int> v;
  int old = 0;
  while(true) {
    int pos = s.find(',', old);
    v.push_back(stoi(s.substr(old)));
    if (pos == string::npos) {
      return v;
    } else {
      old = pos + 1;
    }
  }
}

int main() {
  int a[100][100];
  string s[100];
  int i = 0;
  while(cin) {
    cin >> s[i];
    ++i;
  }
  i--;
  int n = (i + 1) / 2;
  for (int j = 0; j < n; ++j) {
    auto v = split(s[j]);
    for (int k = 0; k <= j; ++k) {
      a[j-k][k] = v[k];
    }
  }
  for (int j = n; j < i; ++j) {
    auto v = split(s[j]);
    for (int k = 0; k <= i - j - 1; ++k) {
      a[n-k-1][j-n+1+k] = v[k];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if(i>0&&j>0)
        a[i][j] = max(a[i-1][j],a[i][j-1])+a[i][j];
      else if(i>0)
        a[i][j] = a[i-1][j]+a[i][j];
      else if(j>0)
        a[i][j] = a[i][j-1]+a[i][j];
    }
  }
  cout << a[n-1][n-1] << endl;
  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
int a[123];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
    cin>>n>>m;
    int sm =0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sm+=a[i];
    }
    int tot = 0;
    for(int i=0;i<n;i++){
        if(4*m*a[i]>=sm)tot++;
    }
    if(tot<m)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false)
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
    return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 2e5+5;
int n, a[maxn];
ll cnt[maxn], prod[maxn];

int main(){
	scanf("%d", &n);
	for(int i = 0; i<n; i++) scanf("%d", &a[i]), cnt[a[i]]++;
	for(int i = 1; i<=n; i++) prod[i] = (cnt[i]*(cnt[i]-1ll))/2ll;
	ll sum = 0;
	for(int i = 1; i<=n; i++) sum += prod[i];
	for(int i = 0; i<n; i++){
		int x = a[i];
		ll ans = sum - prod[x];
		ans+= ((cnt[x]-1ll)*(cnt[x]-2ll))/2ll;
		printf("%lld\n", ans);
	}
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    int K, X;

    cin >> K >> X;

    if(500 * K >= X){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <stack>
#include <string>
#include <climits>
#include <algorithm>
#include <functional>
#include <string.h>
#include <numeric>
#include <math.h>

#define LOOP(N) for(int i=0; i<(N); ++i)
#define REP(i, N) for(int i=0; i<(N); ++i)
#define FOR(i, start, end) for(int i=(start); i<(end); ++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using Graph = vector< vector<int> >;

const ll MOD = 1000000007;

void sayYes() {cout << "Yes" << endl;}
void sayNo() {cout << "No" << endl;}


int main() {
    int N; cin >> N;
    string s; cin >> s;
    if (s[0] == 'W') {
        cout << 0;
        return 0;
    }
    
    bool is_L = true;
    int l_num = 1;
    int factor = 1;
    ll result = 1;
    FOR(i, 1, 2*N) {
        is_L = (s[i-1]==s[i]) ? !is_L : is_L;
        if (is_L) {
            ++l_num;
            ++factor;
        }
        else {
            result = result * factor % MOD;
            --factor;
        }
        // cout << i << " " << (is_L ? 'L' : 'R') << " " << l_count << " " << r_count << endl;
    }
    if (l_num != N) {
        cout << 0;
        return 0;
    }

    FOR(i, 1, N) {
        result = result * i % MOD;
    }
    cout << result * N % MOD;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define PI 3.1415926535897932384626433
using namespace std;
int main(){
    double a;
    while(cin>>a){
        a=a*a/19.6;
        cout<<(int)a/5+2<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
import heapq

def main():
  X,Y,Z,K=map(int,input().split())
  A=list(reversed(sorted(map(int,input().split()))))
  B=list(reversed(sorted(map(int,input().split()))))
  C=list(reversed(sorted(map(int,input().split()))))
  q=[(-A[0]-B[0]-C[0],0,0,0)]
  queued={(0,0,0)}
  for i in range(K):
    v,s,t,u=heapq.heappop(q)
    print(-v)
    for e,f,g in [(s,t,u+1),(s,t+1,u),(s+1,t,u)]:
      if e>=X or f>=Y or g>=Z:
        continue
      if (e,f,g) in queued:
        continue
      heapq.heappush(q,(-(A[e]+B[f]+C[g]),e,f,g))
      queued.add((e,f,g))
      
if __name__=="__main__":
  main()

Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define lld         long long int
#define llf         long double
#define pb          push_back
#define mp          make_pair
#define IN          insert
#define loopN(n)    for(lld i=0;i<n;i++)
#define loop(p,n)   for(lld i=p;i<=n;i++)
#define rloop(p,n)  for(lld i=n;i>=p;i--)
#define loop2(p,n)  for(lld j=p;j<=n;j++)
#define all(v)      v.begin(),v.end()
#define F1          first
#define F2          second
#define INF         2e18
#define FILE        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI          2*acos(0.0)
#define ISO         ios::sync_with_stdio(false);cin.tie(0)
#define mem(a,b)    memset(a,b,sizeof(a))
using namespace std;

lld mod=1e9+7;
vector <lld > prime;
map<lld,lld>z;
void findPrime (int n)
{
    bool a[n+1];
    for( int i=0; i<=n; i++)
    {
        a[i]=1;
    }
    for(int i=2; i*i<=n; i++)
    {
        if(a[i]==1)
        {
            for(int j=i*i; j<=n; j+=i)
            {
                a[j]=0;
            }
        }

    }
    for(int i=2; i<=n; i++)
    {
        if(a[i])
        {
            prime.push_back(i);
        }
    }

    loopN(prime.size())
    {
        z.IN({prime[i],0});
    }


}


void primefact(lld n)
{
  for(int i=0; i<prime.size(); i++)
    {
        if(n==1)
        {
            break;
        }
        while(n%prime[i]==0)
        {
            z[prime[i]]++;
            n/=prime[i];
        }

    }
    if(n!=1)
    {
        z[n]++;
    }

}


int main()
{
    ISO;
    findPrime(1000);

    lld n;
    cin>>n;
    loop(2,n)
    {
        primefact(i);
    }

    lld ans=1;


    for(auto i:z)
    {
        ans*=(i.F2+1)%mod;
        ans=ans%mod;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3652
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*4
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
int N;
struct Edge
{
    int v,next;
}edge[MaxM];
int cont,head[MaxN];
void add(int u, int v)
{
    edge[cont].v = v, edge[cont].next = head[u], head[u] = cont++;
}

int DFS(int u, int pre)
{
    int flag = 0;
    for(int i=head[u];i!=-1;i=edge[i].next)
    {
        int v = edge[i].v;
        if(v==pre) continue;
        flag ^= (DFS(v,u)+1);
    }
    return flag;
}
void solve()
{
    if(DFS(1,0)) puts("Alice");
    else puts("Bob");
}

void init()
{
    cont = 0;
    MST(head,-1);
}
int main()
{
    //std::ios::sync_with_stdio(false);
    while(scanf("%d", &N)!=EOF)
    {
        init();
        int a,b;
        for(int i=1;i<N;i++)
        {
            scanf("%d%d", &a, &b);
            add(a,b);add(b,a);
        }
        solve();
    }
    //system("pause");
    //printf("%lld\n", (x%mod+mod)%mod );
}


Measured memory_bytes: 6912
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    if (m == -1 || f == -1) {
      cout << 'F' << endl;
      continue;
    }
    m = max(0LL, m);
    f = max(0LL, f);
    r = max(0LL, r);
    if (80 <= m + f) {
      cout << 'A' << endl;
      continue;
    }
    if (65 <= m + f) {
      cout << 'B' << endl;
      continue;
    }
    if (50 <= m + f) {
      cout << 'C' << endl;
      continue;
    }
    if (30 <= m + f) {
      cout << (r >= 50 ? 'C' : 'D') << endl;
      continue;
    }
    cout << 'F' << endl;
  }
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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 ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, d;
  cin >> n >> d;
  d = 2 * d + 1;
  cout << (n + d - 1) / d << endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
s_orig = s.clone

while !s.match(/\(\)/).nil?
  s.sub!(/\(\)/, "")
end

begin_count = s.chars.select{|w| w=="("}.count
end_count = s.chars.select{|w| w==")"}.count

left_insert = ""
right_insert = ""
begin_count.times{|i| right_insert += ")" }
end_count.times{|i| left_insert += "(" }

puts  left_insert + s_orig + right_insert


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

typedef long long ll;
const int N = 354;

int mod;
int n, R;
int C[N][N];
int f[N], B1[N];

inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}

void init(int n) {
	int i, j;
	for (*C[0] = i = 1; i <= n; ++i)
		for (*C[i] = j = 1; j <= n; ++j)
			add(C[i][j] = C[i - 1][j], C[i - 1][j - 1]);
}

void Exp(int *a) {
	int i, j; memcpy(B1, a, n << 2);
	for (i = 0; i <= n; ++i)
		for (j = 0; j < i; ++j)
			a[i] = (a[i] + (ll)B1[j] * a[i - j - 1] % mod * C[i][j]) % mod;
}

int main() {
	scanf("%d%d%d", &n, &R, &mod), init(++n);
	for (std::fill(f, f + n, 1); --R; Exp(f));
	return printf("%d\n", f[--n]), 0;
}

Measured memory_bytes: 640
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    char c;
    cin >> c;
    if (c > 95)
        cout << 'a';
    else
        cout << 'A';
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

static const int N = 100;

int main(){
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i-1] >> p[i];  //  M[i]がp[i-1]*p[i]の行列となるような1次元配列
    }

    for(int i = 1; i <= n; i++) m[i][i] = 0;
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for(int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;

  int ans = 0;
  for ( int i = l; i <= r; i++ ) {
    if ( i%d == 0 ) { ans++; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
s = gets.chomp
words = %w[dream dreamer erase eraser]

dp = Array.new(s.size, false)
dp[0] = true
(0..(s.size - 1)).each do |i|
    next unless dp[i]

    words.each do |w|
        dp[i + w.size] = true if s.slice(i, w.size) == w
    end
end

puts dp.last ? 'YES' : 'NO'

Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    cout << 800*n - 200*(n/15) << endl;
    return 0;
}

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(const string& S, const string& T)
{
    int N = (int) S.size(), M = (int) T.size();
    int ans = N + 1;

    for (int i = 0; i <= N - M; ++i)
    {
        int dist = 0;

        for (int j = 0; j < M; ++j)
            dist += (S[i + j] != T[j] ? 1 : 0);

        ans = min(ans, dist);
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    string S, T;
    cin >> S >> T;

    auto ans = solve(S, T);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3608
/* YOU LOST THE GAME */
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
  string s, t;
  cin >> s >> t;

  vvl poss (26);

  FOR (i, 0, s.size ())
  {
    poss[s[i] - 'a'].pb (i + 1);
  }
  
  ll res = 0;
  ll posis = 0;

  ll ssiz = s.size ();

  FOR (i, 0, t.size ())
  {
    if (posis == ssiz)
    {
      posis = 0;
    }
    vl &ds = poss[t[i] - 'a'];
    ll d = -1;
    if (ds.size () == 0)
    {
      cout << "-1" << endl;
      return 0;
    }
    auto it = upper_bound (all (ds), posis);
    if (it == end(ds))
    {
      res += ssiz - posis;
      posis = 0;
      it = upper_bound (all (ds), posis);
    }
    d = *it - posis;
    posis += d;
    res += d;
  }

  cout << res << endl;

  return 0;
} //cin.tie(0) bei schnellem Wechseln



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

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    using pa = pair<ll,ll>;
    vector<pa> ba(N,pa(0,0));
    rep(i,N){
        cin>>A>>B;
        ba.at(i).fi = B;
        ba.at(i).se = A;
    }
    sort(ba.begin(),ba.end());
    ll time = 0;
    rep(i,N){
        time += ba.at(i).se;
        if(time > ba.at(i).fi) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>

double Dis(int D, int X[D], int Y[D]){
  int i;
  double s;
  s = 0.;
  for(i = 0;i < D;i++) s += pow(X[i] - Y[i], 2);
  return sqrt(s);
}

void Do(int N, int D){
  int i, j, c, id;
  int X[N][D];
  double d;
  for(i = 0;i < N;i++) for(j = 0;j < D;j++) scanf("%d", &X[i][j]);
  c = 0;
  for(i = 0;i < N;i++){
    for(j = i + 1;j < N;j++){
      id = d = Dis(D, X[i], X[j]);
      if(id == d) c++;
    }
  }
  printf("%d\n", c);
}

int main(void){
  int N, D;
  scanf("%d %d", &N, &D);
  Do(N, D);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
string s;
int ans = 0;
vi houses;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> K >> N;
    houses.resize(N);
    rep(i, N) {
        cin >> houses[i];
    }

    ans = houses[N-1] - houses[0];
    rep1(i, N-1) {
        ans = min(ans, K - (houses[i] - houses[i-1]));
    }

    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int a, b; cin >> a >> b;
	cout << a - b - 1 << endl;
	return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

struct edge{
    ll from,to,cost;
};

bool ng = false;

vector<ll> bellman_ford(ll V, vector<edge> edges){
    //edges:0-indexed
    vector<ll> dist(V,INF);
    vector<bool> isNegative(V,false);
    vector<bool> canGo(V,false);
    canGo[0] = true;
    dist[0] = 0;
    rep(i,0,3*V){
        vector<ll> nxt_dist = dist;
        for(edge e: edges){
            if(nxt_dist[e.to] > dist[e.from] + e.cost){
                nxt_dist[e.to] = dist[e.from] + e.cost;
                if(i >=V-1){
                    isNegative[e.to] = true;
                }
            }
            if(canGo[e.from])canGo[e.to]=true;
            if(isNegative[e.from] && canGo[e.from])isNegative[e.to] = true;
        }
        dist = nxt_dist;
    }
    
    ng = isNegative[V-1];
    return dist;
}

int main(){
    ll N,M,P;
    cin>>N>>M>>P;
    vector<edge> edges(M);
    vector<ll> dist;

    rep(i,0,M){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        edges[i].from = a;
        edges[i].to = b;
        edges[i].cost = -(c-P);
    }

    dist = bellman_ford(N,edges);
    if(ng){
        cout<<-1;
    }
    else{
        if(-dist[N-1] < 0)cout<<0;
        else cout<<-dist[N-1];
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int d[n][2];
    rep(i, n) cin >> d[i][0] >> d[i][1];

    int ans=0;
    int ma=0;
    rep(i, n){
        if(d[i][0]==d[i][1]) ma++;
        else ma=0;

        ans=max(ans, ma);
    }

    if(ans>=3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

more:
  int h, w; cin >> h >> w;
  cin.ignore();
  if (!h && !w) return 0;

  char f[h][w];
  rep (i, h) {
    rep (j, w) {
      char c = getchar();
      f[i][j] = c;
      if (! (c == '.' || c == 'v' || c == '^' || c == '<' || c == '>') ) {
        trace(cons(cons(i,j), c));
      }
      assert(c == '.' || c == 'v' || c == '^' || c == '<' || c == '>');
    }
    cin.ignore();
  }

  vector<pair<int, int>> history;

  int i = 0, j = 0;
  for (; f[i][j] != '.'; ) {
    switch (f[i][j]) {
      case '>': ++j; break;
      case '<': --j; break;
      case 'v': ++i; break;
      case '^': --i; break;
    }

    for (auto&x : history) {
      if (car(x) == i && cdr(x) == j) {
        cout << "LOOP" << endl;
        goto more;
      }
    }
    history.push_back(cons(i, j));
  }
  cout << (j) << ' ' << (i) << endl;

  goto more;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int week = scan.nextInt();
        int debt = 100000;
        for(int i = 0; i < week; i++) {
            debt *= 1.05;
            debt = (int)(debt * 0.001 + 0.999) * 1000;
        }
        System.out.println(debt);
    }
}

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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)
#define MAX(p,q)((p)>(q)?(p):(q))
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long lli;

int main(){
    int a[5];
    rep(i,5){
        cin >> a[i];
    }
    int k;cin >> k;
    if(a[4]-a[0]>k) cout << ":(\n";
    else cout << "Yay!\n";
}



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

int solve(int i) {
    if(dp[i] != -1) return dp[i];
    if(i == 1) return 0;
    else if(i == 2) return abs(h[i] - h[i-1]);
    else return dp[i] = min(abs(h[i] - h[i-1]) + solve(i-1), abs(h[i] - h[i-2]) + solve(i-2));
}

int main() {
    int N;
    cin >> N;
    h.resize(N+1);
    dp.resize(N+1);
    for(int i = 1; i <= N; i++) cin >> h[i];
    fill(dp.begin(), dp.end(), -1);
    cout << solve(N) << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val r = arrayListOf<Long>()
    (1..sc.nextInt()).forEach() {
        r.add(sc.nextInt().toLong())
    }
    println("${r.min()} ${r.max()} ${r.sum()}")
}



Measured memory_bytes: 44004
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sum_time = 0
now_read_book = 0
ans = 0
now_A = -1

for i in range(N):
  if sum_time + A[i] <= K:
    sum_time += A[i]
    now_read_book += 1
    now_A = i
  else:
    break
ans = now_read_book

for i in range(M):
  if sum_time + B[i] > K:
    while sum_time + B[i] > K and now_A >= 0:
      sum_time -= A[now_A]
      now_A -= 1
      now_read_book -= 1
  if sum_time + B[i] <= K:
    sum_time += B[i]
    now_read_book += 1
  else:
    break
  if now_read_book > ans:
    ans = now_read_book
print(ans) 


Measured memory_bytes: 40692
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		int count = 1;
		int q = 0;
		A[0] = sc.nextInt();
		for (int i = 1; i < N; i++) {
			A[i] = sc.nextInt();
			if (A[i -1] != A[i]) {
				if (q == 0) {
					if (A[i -1] > A[i]) {
						q = -1;
					} else if (A[i -1] < A[i]) {
						q = 1;
					}
				} else if (q == 1) {
					if (A[i -1] > A[i]) {
						count++;
						q = 0;
					}
				} else {
					if (A[i -1] < A[i]) {
						count++;
						q = 0;
					}
				}
			}
		}
		System.out.printf("%d\n", count);
	}
}


Measured memory_bytes: 59916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;

  vector<int> a(n);
  vector<int> dp(k + 1, 1);

  REP(i, n) {
    cin >> a[i];
  }

  REP(i, k) {
    if (dp[i] == 0) continue;
    EACH(v, a) {
      if (i + v <= k) {
        dp[i + v] = 0;
      }
    }
  }

  if (dp[k]) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }

}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 640
n,m = map(int,input().split())
# pyに入力の順番も一緒に記録しておく。
py = [list(map(int,input().split()))+[i] for i in range(m)]

#まずソート
py.sort()
#print(py) [[1, 12, 2], [1, 32, 0], [2, 63, 1]]

#id生成関数. 00000p00000y
def id(p_num,y_num):
  p_num,y_num = str(p_num),str(y_num)
  n1 = len(p_num)
  n2 = len(y_num)
  str_id = "0"*(6-n1)+str(p_num)+"0"*(6-n2)+str(y_num)
  return str_id
  
ID = [[] for _ in range(m)]
#初期値 [['000001000001', 2], [], []]
ID[0] = [id(py[0][0],1), py[0][2]] 
#print(ID)

#ソートしたものを、前から[ココ, , ]を見ながらID作る
cnt = 1
for i in range(1,m):
  #前と同じ県なら
  if py[i-1][0] == py[i][0]:
    cnt += 1
    ID[i] = [id(py[i][0],cnt), py[i][2]]
  else:
    cnt = 1
    ID[i] = [id(py[i][0],cnt), py[i][2]]

ID.sort(key=lambda x: x[1])
for i in range(m):
  print(ID[i][0])

Measured memory_bytes: 41740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,n,a,b;
    int count=0,count1=0,count2=0,count3=0;
    string s,s1;
    cin>>n;
    for(i=0;i<n;i++)
    {

        cin>>s;
        if(s=="AC") count++;
        if(s=="WA") count1++;
        if(s=="TLE") count2++;
        if(s=="RE") count3++;
    }

    cout<<"AC x "<<count<<endl;
    cout<<"WA x "<<count1<<endl;
    cout<<"TLE x "<<count2<<endl;
    cout<<"RE x "<<count3<<endl;
}


Measured memory_bytes: 3628
n=gets.to_i
array=gets.split.map(&:to_i)

countarray=Array.new(n,0)
selectarray=Array.new(n,0)
answerarray=Array.new(n,0)

array.map{|value|
    countarray[value-1]+=1
}

countarray.map.with_index{|value,index|
    selectarray[index]=value*(value-1)/2
}

sum=selectarray.inject(:+)

answerarray.map.with_index{|value,index|
    if countarray[index]==0
        answerarray[index]
    else
    answerarray[index]=sum-selectarray[index]+(countarray[index]-1)*(countarray[index]-2)/2
    end
}


i=0
n.times{
    puts answerarray[array[i]-1]
    i+=1
}

Measured memory_bytes: 29452
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  int x; cin >> x;
  int ans;
  if(x<600) ans = 8;
  else if(x>=600&&x<800) ans = 7;
  else if(x>=800&&x<1000) ans = 6;
  else if(x>=1000&&x<1200) ans = 5;
  else if(x>=1200&&x<1400) ans = 4;
  else if(x>=1400&&x<1600) ans = 3;
  else if(x>=1600&&x<1800) ans = 2;
  else ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(){
    int i, j, k;
    int red=0, blue=0, N;
    char s[110];

    scanf("%d", &N);
    scanf("%s", &s);

    for(i=0; i<N; i++){
        if(s[i] == 'R'){
            red++;
        }else{
            blue++;
        }
    }

    if(blue < red){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

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

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

typedef long long ll;
#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 vi vector<int>
#define vii vector< vector<int> >

int N;
int P[220000];

int main() {

	cin >> N;
	rep(i, N) cin >> P[i];

	int ans = 0;
	int mini = 220000;
	rep(i, N) {
		if (P[i] <= mini) {
			ans += 1;
			mini = P[i];
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<set>



using namespace std;

using ll = long long;

struct UFT{
  int * p;
  
  UFT(int N):p(new int[N]){fill(p,p+N,-1);}  
  ~UFT(){delete[] p;}  
  int par(int a)   { if( p[a] >= 0 ){ p[a] = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a) == par(b); }
  void unite(int a, int b){
    a = par(a);  b = par(b);
    if( a == b ) return;
    if( size(a) < size(b) )a^=b^=a^=b;
    p[a] -= size(b);
    p[b] = a;
  }
};


int main(){
  int n, m; cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  for(int i = 0; i < m; i++){
    cin >> x[i] >> y[i] >> z[i];
  }
  UFT uft(n);
  for(int i = 0; i < m; ++i){
    uft.unite(x[i]-1,y[i]-1);
  }
  set<int> st;

  for(int i = 0; i < n; ++i)st.insert(uft.par(i));
  cout << st.size() << endl;
  return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a%2 == 1 & b%2 == 1){
        cout << "Odd" << endl;
    }
    else{
        cout << "Even" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N,cnt=0;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int t;
		scanf("%d",&t);
		if(i%2==1 && t%2==1)
			cnt++;
	}
	printf("%d\n",cnt);
	return 0; 
}

Measured memory_bytes: 3732
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# あるbit列に対するコストの計算
def count(zerone):
    one = 0
    cnt = 0
    for i in range(N):
        flag = True
        if zerone[i] == 1:
            one += 1
            for j in range(len(A[i])):
                if A[i][j][1] != zerone[A[i][j][0]-1]:
                    flag = False
                    break
        if flag:
            cnt += 1
    if cnt == N:
        return one
    else:
        return 0

# bit列の列挙
def dfs(bits):
    if len(bits) == N:
        return count(bits)
    res = 0
    for i in range(2):
        bits.append(i)
        res = max(res, dfs(bits))
        bits.pop()
    return res

# main
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for _ in range(a):
        A[i].append([int(x) for x in input().split()])

ans = dfs([])
print(ans)

Measured memory_bytes: 9164
n = int(input())
s = list(input())

cnt = 0
res = ''
for i in range(n):
    if s[i] == '(':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            res = '('+res
    res += s[i]

for j in range(cnt):
    res += ')'
print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int n,a,i,r,c,o;
    while(cin>>n)
    {
        c=0,r=0,o=0;
        for(i=0; i<n; i++)
        {
            cin>>a;
            if(o>=a)
                c++;
            else
            {
                r=max(r,c);
                c=0;
            }
            o=a;
        }
        cout<< max(r,c)<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,i;
	int money=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		money+=(money*5)/100;
		if(money%1000>0){
			money+=1000-(money%1000);
	}
	}
	
	printf("%d\n",money);
	
	return 0;
}

Measured memory_bytes: 1776
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        int a = 1;
        int b = 0;

        while(a<kazu){
            a*=10;
        }
        a/=10;
        b=kazu-a;
        
        int count = 0;
        while(a>0 || b>0){
            count += a%10 + b%10;
            a/=10;
            b/=10;
//            WriteLine("{0} {1} {2}",count,a,b);
        }
        WriteLine(count);
    }
}

Measured memory_bytes: 11092