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

/**
 * 2019/06/16
 * AtCoder Beginner Contest 130
 * 
 * B - Bounding
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int X = sc.nextInt();
		int L[] = new int[N];
		for(int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		
		int cnt = 1;
		int D[] = new int[N + 1];
		D[0] = 0;
		for(int i = 1; i < N + 1; i++) {
			D[i] = D[i - 1] + L[i - 1];
			if(D[i] <= X) {
				cnt++;
			} else {
				break;
			}
		}

		System.out.println(cnt);
	}
	
}


Measured memory_bytes: 21844
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int N;
	int ans=0;

	cin >> N;

	vector<int> l(N);
	vector<int> r(N);

	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
	}

	for (int i = 0; i < N; i++) {
		ans += (r[i] - l[i]) + 1;
	}

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
if s == "SSS":
    print(0)
if s == "SSR":
    print(1)
if s == "SRS":
    print(1)
if s == "SRR":
    print(2)
if s == "RSS":
    print(1)
if s == "RSR":
    print(1)
if s == "RRS":
    print(2)
if s == "RRR":
    print(3)

Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

class UnionFind
{
public:
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<ll> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<ll> sizes;
    UnionFind(int n) : par(n), sizes(n, 1)
    {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
        }
    }
    // データxが属する木の根を得る
    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]);
        // 根を張り替えながら再帰的に根ノードを探す
    }
    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y)
    {
        // データの根ノードを得る
        x = find(x);
        y = find(y);
        // 既に同じ木に属しているならマージしない
        if (x == y)
            return;
        // xの木がyの木より大きくなるようにする
        if (sizes[x] < sizes[y])
            swap(x, y);
        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    // データxが含まれる木の大きさを返す
    int size(int x)
    {
        return sizes[find(x)];
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<ll> a(m), b(m);
    for (ll i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<ll> ans(m + 1, 0);
    ans[m] = n * (n - 1) / 2;
    for (ll i = m - 1; i >= 0; i--)
    {
        if (uf.same(a[i], b[i]))
        {
            ans[i] = ans[i + 1];
        }
        else
        {
            int as = uf.size(a[i]);
            int bs = uf.size(b[i]);
            ans[i] = ans[i + 1] - as * bs;
        }
        uf.unite(a[i], b[i]);
    }
    for (int i = 1; i <= m; i++)
    {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 5248
A = "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"
L = [int(s) for s in A.split(", ")]
K = int(input())
print(L[K-1])

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<bool> Vb;
typedef vector<int> Vi;

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

void init();
int rec(int x);

int n;
Vi opt, memo;
const int inf = 1 << 25;

int main()
{
	init();

	cout << rec(n) << endl;
}

void init()
{
	cin >> n;
	memo.resize(n + 1, inf);
	memo[0] = 0;

	int x = 6;
	while (x <= n)
	{
		opt.PB(x);
		x *= 6;
	}

	x = 9;
	while (x <= n)
	{
		opt.PB(x);
		x *= 9;
	}
	opt.PB(1);
	sort(ALL(opt), greater<>());
}

int rec(int x)
{
	if (memo[x] < inf)
		return memo[x];

	int ret = inf;

	for (int y : opt)
		if (x >= y)
			chmin(ret, rec(x - y) + 1);

	return memo[x] = ret;
}

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

int main()
    {
        ll t{},n{};
        string p;
        cin>>t>>n;
        std::vector<string> v(t) ;
        for(int i=0;i<t;i++){
            cin>>v[i];
        }
        sort(v.begin(),v.end());
        for(int i=0;i<t;i++){
            cout<<v[i];
        }
        return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

bool isprime[10000001];

void sieve(ll N){
  
  fill(isprime,isprime+10000001,true);
  isprime[0]=isprime[1]=false;
  
  for(ll i=2;i*i<=N;i++){
    if(isprime[i]){
      for(ll j=i*i;j<=N;j+=i){
	isprime[j]=false;
      }
    }
  }
}

int main(void){

  sieve(10000000);

  int res[10001];
  fill(res,res+10001,0);
  res[1]=2;
  for(int i=2,j=0;j<10001;i++)
    if(isprime[i])res[j+1]=res[j++]+i;

  int a;
  while(cin >> a,a){
    cout << res[a] << endl;
  }

  return 0;
}

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

int main(void) {
    int n;
    std::cin >> n;

    std::vector<int> vec{};
    for (int i = 0; i < n; ++i) {
        int a;
        std::cin >> a;
        vec.push_back(a);
    }

    int q;
    std::cin >> q;

    for (int j = 0; j < q; ++j) {
        int com, b, e;
        std::cin >> com >> b >> e;

        switch (com) {
            case 0:
                std::cout << *std::min_element(vec.begin() + b, vec.begin() + e)
                          << std::endl;
                break;
            case 1:
                std::cout << *std::max_element(vec.begin() + b, vec.begin() + e)
                          << std::endl;
                break;
            default:
                std::cerr << "com: ?";
        }
    }
}


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

int main () {

    int A, B, C;
    cin >> A >> B >> C;

    int max_num = max(A, max(B, C));
    int diff = (max_num - A) + (max_num - B) + (max_num - C);

    if (diff % 2 == 0) cout << diff / 2 << endl;
    else cout << (diff + 3) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
Ha = gets.chomp.split(" ").map { |s| s.to_i }
last_h = 0
Ha.each do |h|
  if last_h == h
    # do nothing
  elsif last_h <= h-1
    last_h = h - 1 # なるべく高さを下げる戦略
  else
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,K,count;
    count=0;
    cin>>A>>B>>C>>K;
    if(A>K){
        count+=K;
    }
    else if(A+B>=K){
        count+=A;
    }
    else if(K>A+B){
        count+=A-K+A+B;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
    int main()
    {
        int r,g,b;
        scanf("%d %d %d",&r,&g,&b);

        int num = r*100 + g*10 + b;

        if(num%4 == 0) {
            printf("YES");
        }else{
            printf("NO");
        }
    }



Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
    char a[20];
    scanf("%s",a);
    int k=0,l,i,j=0,c=0;
    l=strlen(a);
    if(a[0]=='A') k++;
    for(i=2;i<l-1;i++)
    {
        if(a[i]=='C') j++;
        if(a[i]>='a') c++;
    }
    //printf("%d\n",k);
    if(j==1) k++;
    //printf("%d\n",k);
    if(a[1]>='a'&&a[l-1]>='a') c+=2;
    if(c==l-2) k++;
    //printf("%d\n",k);
    if(k==3) printf("AC\n");
    else printf("WA\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define maxn -20000000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1e16
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;


int main()
{
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	ll ind=lower_bound(v.begin(),v.end(),0LL)-v.begin();
	ind=max(0LL,ind-1);
	
	ll ans=v[ind];
	//cout<<ind<<" "<<ans<<endl;
	vector<pair<ll,ll> > res;
	ll i;
	for(i=ind+1;i+1<n;i++)
	{
		res.pb({ans,v[i]});
		ans=ans-v[i];
	}
	if(ind!=(n-1)){
	res.pb({v[i],ans});
	ans=v[i]-ans;}
	for(i=0;i<ind;i++)
	{
		res.pb({ans,v[i]});
		ans=ans-v[i];
	}
	cout<<ans<<endl;
	for(auto j:res)
	{
		cout<<j.fi<<" "<<j.se<<endl;
	}

	
}



Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
string s;
ll ans;
int len;
void dfs(int cur,ll num,ll x)
{
	if(cur==len)
	{
		ans+=x+num;
	//	cout<<num<<' '<<x<<endl;
		return;
	}
	ll y=s[cur]-'0';
	dfs(cur+1,num*10+y,x);
	if(num!=0)
	dfs(cur+1,y,x+num);
	
}
int main()
{
	while(cin>>s)
	{
		ans=0;
		len=s.length();
		dfs(0,0,0);
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

int ar[100005];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    ar[x] = i + 1;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", ar[i]);
  }
  return 0;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

int N;
pair<int,int> P[2020];
ll dp[2020][2020];

int main() {
	cin >> N;
  vector<pair<int, int> > P(N);
	for(int i = 0; i < N; i++) {
    int x;
		cin >> x;
		P[i] = make_pair(x, i);
	}
	
	sort(P.begin(), P.end(), greater<pair<int, int> >());
	
	for(int x = 0; x < N+1; x++) {
    for(int y = 0; y < N+1; y++) {
      dp[x][y] = -1LL<<60;
    }
  }

	dp[0][0] = 0;
  // i: すでに配置した人数
	for(int i = 0; i < N; i++) {
		ll  k = P[i].first;
		int r = P[i].second;
    // x: 左端に配置した人数
		for(int x = 0; x <= i; x++) {
      // 右端に配置するときの位置
			int y = i - x;

      // なるべく左端に置く
			dp[x+1][y] = max(dp[x+1][y], dp[x][y] + abs(r-(x)) * k);

      // なるべく右端に置く
			dp[x][y+1] = max(dp[x][y+1], dp[x][y] + abs(r-(N-1-y)) * k);
		}
	}

	ll ret = -1LL<<60;
	for(int x = 0; x < N+1; x++) {
    ret = max(ret, dp[x][N-x]);
  }

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

Measured memory_bytes: 35204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C;
  int count=0;
  cin>>N>>M>>C;
  
  vector<int> A(M);
  vector<vector<int>> B(N,vector<int>(M));
  
  for(int i=0;i<M;i++){    
    cin>>A.at(i);
     }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>B.at(i).at(j);
    }
  }
  
  for(int i=0;i<N;i++){
     int sum=0;
    for(int j=0;j<M;j++){
     
      sum+=(A.at(j))*(B.at(i).at(j));
    }
    if(sum+C>0){
      count++;
    }
  }
  cout<<count<<endl;
}

  
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long x=gl();
         long y=gl();

         long ans=0;
         if((2*x-y) % 3==0 && (2*y-x) % 3==0) {
             long a=(2*x-y)/3;
             long b=(2*y-x)/3;
             long c=a+b;
             if(a>=0 && b>=0) {
             ans=1;
             if(a<b) {
                 while(c>b) {
            	     ans=(ans*c)%1000000007;
            	     c--;
                 }
                 while(a>0) {
                	 ans=(ans*modpow(a,1000000005, 1000000007))%1000000007;
                	 a--;
                 }
             } else {
            	 while(c>a) {
            	     ans=(ans*c)%1000000007;
            	     c--;
                 }
                 while(b>0) {
                	 ans=(ans*modpow(b,1000000005, 1000000007))%1000000007;
                	 b--;
                 }
             }
             }
         }

         System.out.println(ans);
     }
     
  // a^nをmodで割ったあまり
 	public static long modpow(long a, long n, long mod) {
 		long res=1;
 		while(n>0) {
 			if((n & 1) == 1) res=res*a%mod;
 			a=a*a%mod;
 			n=n>>1;
 		}

 		return res;
 	}


     // 文字列として入力を取得
     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: 35580
main = do
    a <- readLn
    b <- readLn
    print $ solve a b

solve :: Int -> Int -> Int
solve 1 2 = 3
solve 2 1 = 3
solve 2 3 = 1
solve 3 2 = 1
solve 3 1 = 2
solve 1 3 = 2

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll luc[100],a;
inline ll setup()
{
    luc[0]=2;
    luc[1]=1;
    for(register int i=2;i<=86;i++)
    {
        luc[i]=luc[i-1]+luc[i-2];
    }
}
int main()
{
    setup();
    cin>>a;
    cout<<luc[a];
}

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

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=3e5+9;
int n;
ll a[MX];
ll ans=0,sum=0,mx=100000000000,ans1=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]<0)sum++;
        ans+=abs(a[i]);
        mx=min(mx,abs(a[i]));
    }
    if(sum%2==0){
        cout<<ans<<endl;
    }
    else cout<<ans-2*mx<<endl;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	public void solve() {
		N = nextInt();
		out.println((N + 1) * (N) / 2);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 7892
#include <stdio.h>

int main(void)
{
    int i,N,m,p[50]={0};

    scanf("%d",&N);

    for(i=0;i<N;i++)
       scanf("%d",&p[i]);

    m = 0;
    for(i=0;i<N;i++)
       if (p[i] != i+1) m++;

    if(m==2 || m==0) printf("YES");
    else if(m>2)     printf("NO");

    return 0;
}


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

int main(){
    int N, ans=2147483647; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = -100; i <= 100; i++){
        int sum=0;
        for(int j = 0; j < N; j++) sum += (i-a[j]) * (i-a[j]);
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



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

ll f(ll n,ll x){
    if(n==-1) return 0;
    else return n/x+1;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		boolean result = false;

		for (int i=1; i<=9; i++){
			for (int j=1; j<=9; j++){
				if (N == (i*j)){
					result = true;
					break;
				}
			}
		}
		if (result){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23124
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(max(x), X)
min_y = min(min(y), Y)

if max_x < min_y:
	print('No War')
else:
	print('War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
struct cunchu{
	char m[10];
}st[maxn];
bool cmp(cunchu l,cunchu r)
{
	if(strcmp(l.m,r.m)!=0)
	return strcmp(l.m,r.m)<0;
}
char a[10],test1[10],test2[10];
int n,k=0;
int vis[100]={0};
void dfs(ll t)
{
	memset(vis,0,sizeof(vis));
	if(t==n)
	{
		strcpy(st[k++].m,a);
		k++;
		return;
	}
	for(int i=t;i<n;i++)
	{
		if(vis[i]==0)
		{
			vis[i]=1;
			char temp=a[i];a[i]=a[t];a[t]=temp;
			dfs(t+1);
			temp=a[i];a[i]=a[t];a[t]=temp;
			vis[i]=0;
		}
	}
}
int main()
{
	int x,y,i,j;
	memset(vis,0,sizeof(vis));
	scanf("%d",&n);
	for(i=0;i<n;i++)
		a[i]=i+1+48;
	for(i=0;i<n;i++)
	{
		scanf("%d",&x);
		test1[i]=x+48;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&y);
		test2[i]=y+48;
	}
	dfs(0);
	//printf("%d\n",k);
	sort(st,st+k,cmp);
	int ans1,ans2;
	for(ll i=0;i<k;i++)
	{
		if(strcmp(st[i].m,test1)==0)
		{
			ans1=i;
		}
		if(strcmp(st[i].m,test2)==0)
			ans2=i;
	}
	printf("%d",abs(ans1-ans2));
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N;
	vector<int> x = { 111,222,333,444,555,666,777,888,999 };

	cin >> N;

	int diff;
	int ans = 0;
	int min = 999;
	for (int i = 0; i < x.size(); i++) {
		diff = abs(N - x[i]);
		if (x[i] >= N && diff < min) {
			min = diff;
			ans = x[i];
		}
	}

	cout << ans << endl;

	return 0;
}



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

#define rep(i, e) for( int i = 0; i < e; i++ )
#define eps 1e-10
typedef vector<int> vec;

int main(){
    int N, M = 256;
    while( cin >> N, N){
        vec I(N);
        rep(i, N) cin >> I[i];
        int S, A, C;
        double H = 1000000;
        rep(s, 16){
            rep(a, 16){
                rep(c, 16){
                    int R = s, O, x[256] = {0};
                    //O[0] = ( I[0] + R[0] ) % M;
                    double h = 0;//-( O[0] / N ) * log(O[0] / N);
                    rep(i, N){
                        R = (a*R+c) % M;
                        O = (I[i] + R) % M;
                        x[O]++;
                    }
                    rep(i, M){
                        if( !x[i] ) continue;
                        double t = (double)x[i] / N;
                        h -= (t * log(t));
                    }
                    if( h+eps < H ){
                        H = h;
                        S = s;
                        A = a;
                        C = c;
                        //cout << H << ' ' << s << ' ' << a << ' ' << c << endl;
                    }
                }
            }
        }
        cout << S << ' ' << A << ' ' << C << endl;
    }
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> fibonacci(ll n){
	vector<ll> dp(max(2LL,n+1),0);
	dp[0] = 0;
	dp[1] = 1;
	for(int i=2;i<n+1;i++){
		dp[i] = dp[i-1] + dp[i-2];
	}
	return dp;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int X=in(),Y=in();
	if(!X && !Y){
		out(1);
		return 0;
	}
	auto F=fibonacci(40);
	int LX=0,LY=0,RX=1,RY=1;

	int C=0;
	REP(i,39){
		C = (C+1)%3;
		int M=i%4;
		if(M==0){
			RX += F[i+2];
		}
		else if(M==1){
			RY += F[i+2];
		}
		else if(M==2){
			LX -= F[i+2];
		}
		else{
			LY -= F[i+2];
		}
		if(LX<=X && X<RX && LY<=Y && Y<RY){
			out(C+1);
			return 0;
		}
	}

	return 0;
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//for dfs, I prepare container(tree) at global
vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1){
	for(int u: to[v]){
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

//#define int int64_t
signed main()
{
	int n, q; cin >> n >> q;
	for(int i = 0, i_len = (int)n-1; i < i_len; ++i){
		int a, b;
		cin >> a >> b;
		--a;--b;
		to[a].emplace_back(b);
		to[b].emplace_back(a);		
	}
	ans.resize(n);
	for(int i = 0, i_len = (int)q; i < i_len; ++i){
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);

	for(int i = 0, i_len = (int)n; i < i_len; ++i){
		cout << ans[i] << "\n";
	}

}


Measured memory_bytes: 23552
package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list {
		buf.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	buf.Write([]byte("\n"))
	buf.Flush()
}

//solve
//単純な場合
func fibonacci_(n int) int {
	if n == 0 || n == 1 {
		return 1
	}
	return fibonacci_(n-2) + fibonacci_(n-1)
}

//メモ再帰の利用
func fibonacci(n int) int {
	if n == 0 || n == 1 {
		F[n] = 1
	}
	//F[n]が計算済みの場合
	if F[n] > 0 {
		return F[n]
	}
	F[n] = fibonacci(n-2) + fibonacci(n-1)
	return F[n]
}

const MAX = 50

var F [MAX]int

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println(fibonacci(n))

}



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

#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)a.size())

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  char c;
  scanf(" %c", &c);
  if (string("aeiou").find(c) != string::npos) {
    puts("vowel");
  } else {
    puts("consonant");
  }
  return 0;
}



Measured memory_bytes: 764
#include<cstdio>
bool check(int x)
{
	char temp[10];
	sprintf(temp,"%d",x);
	if(temp[0]==temp[4]&&temp[1]==temp[3])
		return 1;
	return 0;
}
int main()
{
	int A,B,ans=0;
	scanf("%d %d",&A,&B);
	for(int i=A;i<=B;i++)
		if(check(i)) ans++;
	printf("%d\n",ans);
	return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;

signed main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    int min_m = 1e9;
    for (int i = 0; i < (1 << n); i++)
    {
        vector<int> temp(m, 0);

        int sum_m = 0;
        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                sum_m += c[j];
                rep(l, m)
                {
                    temp[l] += a[j][l];
                }
            }
        }

        bool s = true;

        rep(j, m)
        {
            if (temp[j] < x)
            {
                s = false;
                break;
            }
        }
        if (s)
        {
            min_m = min(min_m, sum_m);
        }
    }

    if (min_m == 1e9)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << min_m << endl;
    }
    return 0;
}


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

int number_of_partitions(int n,int m,int mod){
	int dp[m+1][n+1]={};
	dp[0][0] = 1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j-i >= 0){
				dp[i][j] = (dp[i-1][j]+dp[i][j-i]) % mod;
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	return dp[m][n];
}


int main(){
	int n,m;
	cin >> n >> m;
	cout << number_of_partitions(n,m,int(1e9+7)) << endl;
}


Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int get_num_vertices() const{
        return n;
    }

    unsigned int size() const{
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};

vector<int> topologicalSort(Graph g){
    int n = g.size();
    vector<int> h(n, 0);

    for(int i = 0; i < n; i++){
        for(auto e: g[i]){
            h[e.vertice]++;
        }
    }

    stack<int> st;
    for(int i = 0; i < n; i++){
        if(h[i] == 0){
            st.push(i);
        }
    }

    vector<int> ans;
    while(!st.empty()){
        int v = st.top(); st.pop();    // 次数が0の頂点を取り出す
        ans.push_back(v);
        for(auto e: g[v]){
            if(--h[e.vertice] == 0){
                st.push(e.vertice);
            }
        }
    }

    return ans;
}


int main(){
    int n, m;   cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int s, t; ll w;
        cin >> s >> t;
//        s--; t--;
        g.add_edge(s, t);
//        g.add_edge(t, s);
    }

    vector<int> ans = topologicalSort(g);
    for(auto x: ans){
        cout << x << endl;
    }

    return 0;
}



Measured memory_bytes: 5460
K = int(input())
arr = '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'.split(',')

print(arr[K-1])

Measured memory_bytes: 2940
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(_n, k; usize);
    scan!(array; Vec<usize>);

    let mut array = array;

    array.sort();

    let s:usize = (&array[..k]).iter()
        .map(|&v| v)
        .sum();

    println!("{}", s);
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define jRep(i, init, n) for (int i = init; i < (int)(n); i++)

const int64_t FPN_GE_10E9 = 10e9 + 7;
const int64_t FPN_LE_10E9 = 998244353;

int64_t mod64p(int64_t a, int64_t b) { return a - b * (a >= 0 ? a / b : a / b - 1); }

class UnionFind {
public:
    vector<int> roots;
    int n;

    explicit UnionFind(int n) {
        this->n = n;
        rep(i, n) roots.push_back(i);
    }

    int root(int x) {
        if (roots.at(x) == x) return x;
        return roots.at(x) = root(roots.at(x));
    }

    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            roots.at(ry) = rx;
        }
    }
};

int main() {
    const string MSG_YN[] = {"No", "Yes"};
    const string MSG_ON[] = {"NG", "OK"};
    int N, M, ret = -1;
    cin >> N >> M;
    UnionFind unionFind(N);
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        unionFind.merge(--x, --y);
    }
    rep(i, N) {
        if (unionFind.roots.at(i) == i) ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3928
X = int(input())

l = [i**5 for i in range(10**3)]

ans_a = 0
ans_b = 0

finish = 0

for b in range(10**3):
    for a in range(b, 10**3):
        sa = l[a] - l[b]
        wa = l[a] + l[b]
        if sa > X:
            continue
        if sa == X:
            ans_a = a
            ans_b = b
            finish = 1
            break
        if wa == X:
            ans_a = a
            ans_b = -b
            finish = 1
            break
    if finish:
        break

print(ans_a, ans_b)


Measured memory_bytes: 9212
import java.util.*;

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


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  vector<Int> a(999);
  Int x,y;cin >> x >> y;
  Int ans = 0;
  for(int i=1;i<=999;i++){
    ans += i;
    a[i-1] = ans;
  }
  for(int i=0;i<998;i++){
    if(a[i]>=x&&a[i+1]>=y){
      if((a[i]-x)==(a[i+1]-y)){
        ans = a[i]-x;
        cout << ans << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

   while(1){
      int N, M;
      cin>> N>> M;
      if(!(N||M)) break;

      int h[N], w[M];
      for(int i=0; i<N; i++) cin>> h[i];
      for(int i=0; i<M; i++) cin>> w[i];

      int p[1000*1500+1]={};
      for(int i=0; i<N; i++){
         int s=0;
         for(int j=i; j<N; j++){
            s+=h[j];
            p[s]++;
         }
      }
      int q[1000*1500+1]={};
      for(int i=0; i<M; i++){
         int s=0;
         for(int j=i; j<M; j++){
            s+=w[j];
            q[s]++;
         }
      }

      int s=0;
      for(int i=0; i<1000*1500+1; i++){
         s+=p[i]*q[i];
      }

      cout<< s<< endl;
   }

   return 0;
}

Measured memory_bytes: 14804
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <iomanip>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)
#define ld long double
#define ll long long

using namespace std;

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


int main(){
  int A,B,C;
  int ans=0;
  cin >> A >> B >> C;
  ans=min(C,A+B+1)+B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

Measured memory_bytes: 75096
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if(n>=m/2){
    ans+=m/2;
  }
  else{
    ans+=n;
    m-=2*n;
    ans+=m/4;
  }
  COUT(ans);
}

Measured memory_bytes: 256
cnt = int(input())
taro = 0
hanako = 0
for i in range(cnt):
    li = list(input().split())
    if li[0]>li[1]:
        taro +=3
    elif li[0]==li[1]:
        taro +=1
        hanako +=1
    else:
        hanako +=3
print(taro,hanako)


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

#define ll long long
#define mii make_pair<int ,int>
#define mll make_pair<ll, ll>
#define pii pair<int ,int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector <int>
#define vvi vector <vector <int> >
#define vl vector <ll>
#define vvl vector <vector <ll> >
#define vb vector <bool>
#define vvb vector <vector <bool> >

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

    int a, b, c;
    cin >> a >> b >>c;
    int t = a;
    a = b;
    b = t;
    t = a;
    a = c;
    c = t;
    cout << a << ' ' << b << ' ' << c;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

mp = []
for _ in range(H):
  mp.append(list(map(int, input().split())))

rlt = []
  
f = 0
for i in range(H):
  if i % 2 == 0:
    for j in range(W):
      if mp[i][j] % 2 == 1:
        f = (f + 1) % 2
      if f == 1:
        if j < W -1:
          rlt.append((i+1,j+1,i+1,j+2))
        else:
          rlt.append((i+1,j+1,i+2,j+1))
  else:
    for j in range(W-1,-1,-1):
      if mp[i][j] % 2 == 1:
        f = (f + 1) % 2
      if f == 1:
        if j > 0:
          rlt.append((i+1,j+1,i+1,j))
        else:
          rlt.append((i+1,j+1,i+2,j+1))
  
if f == 1:
  rlt.pop(-1)
  
print(len(rlt))
for t in rlt:
  print(" ".join(map(str, t)))

Measured memory_bytes: 98876
/*input
100 50 4
*/
#include <bits/stdc++.h>

using namespace std;

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int c = 0;
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	vector<int> aa;
	for (int i = 1; i <= min(a, b); i++) {
		if (a % i == 0 && b % i == 0) {
			aa.push_back(i);
		}
	}
	printf("%d\n", aa[(int) aa.size() - k]);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];

            int ans = 0;
            for (int i = A; i <= B; i++)
            {
                string tmp = i.ToString(); 
                if (tmp[0] == tmp[4] && tmp[1] == tmp[3])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }
}


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

#define	score	first
#define	id		second

using namespace std;

typedef	pair<int,int>	pii;

bool cmp(const pii& a,const pii& b)
{
	if(a.score>b.score)	return true;
	if(a.score==b.score && a.id<b.id)	return true;
	return false;
}

int main()
{
	int n;

	for(int k=0;cin>>n,n;k++){
		if(k>0)	cout<<endl;

		vector<pii> scvec;
		map<int,string> namemap;

		for(int i=0;i<n;i++){
			string name;
			int w,l,d;
			cin>>name>>w>>l>>d;
			scvec.push_back(make_pair(3*w+d,i));
			namemap[i]=name;
		}

		sort(scvec.begin(),scvec.end(),cmp);

		for(int i=0;i<scvec.size();i++){
			cout<<namemap[scvec[i].id]<<","<<scvec[i].score<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<int> c(N + 1, 0);
  c[0] = 3;

  LL v = 1;
  int index = 0;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    LL y = c[x];
    v = (v * y) % kMod;

    --c[x];
    ++c[x+1];

#if 0
    index = max(index, x + 1);
    cout << x << ":";
    for (int i = 0; i <=index; ++i) cout << c[i] << " ";
    cout << "->" << y << endl;
#endif
  }
  cout << v << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int index = 0;
    long long int result = 1;
    long long int mod = 1000000007;
    int prev = -1;
    vector<long long int> dp(n, 1);
    for(; index < n;)
    {
        if(s1[index] == s2[index])
        {
            //縦
            index++;
            if(prev == -1)
            {
                //最初
                result = (result * 3) % mod;
            }else if(prev == 0)
            {
                //前が縦
                result = (result * 2) % mod;
            }
            prev = 0;
        }else{
            //横
            index += 2;
            if(prev == -1)
            {
                //最初
                result = (result * 6) % mod;
            }else if(prev == 0)
            {
                //前が縦
                result = (result * 2) % mod;
            }else if(prev == 1)
            {
                //前が横
                result = (result * 3) % mod;
            }
            prev = 1;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll n;
vector<ll> vec1(10000),vec2(10000);
ll calc(ll k){
  ll t1 = k;
  ll ans = 1;
  while(1){
    bool can = false;
    rep(i,n){
      if(vec1[i] % t1 == 0){
        vec1[i] /= t1;
        can = true;
      }
    }
    if(can){
      ans *= k;
    }else{
      break;
    }
  }
  //cout << k << " " << ans << endl;
  return ans;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}

ll MAX = 1000000;
int main(){
  cin >> n;
  vec1.resize(n);
  rep(i,n){
    cin >> vec1[i];
    vec2[i] = vec1[i];
  }
  vector<ll> vec(1000000,0);
  vec[0] = 1;
  ll sq = (ll)sqrt(2000000);
  vector<ll> sosu,sosucou;
  REP(i,2,sq){
    ll t1 = 2 * i;
    while(t1 <= 1000000){
      vec[t1-1] = 1;
      t1 += i;
    }
  }
  rep(i,sq){
    if(vec[i] == 0){
      sosu.push_back(i+1);
    }
  }
  ll len = sosu.size();

  ll gca = 1;
  ll ans = 0;
  rep(i,len){
    //cout << sosu[i] << " ";
    gca *= calc(sosu[i]);
    gca %= mod;
  }
  sort(all(vec1));
  //cout << gca << endl;
  rep(i,n){
    if(i == 0 || vec1[i] != vec1[i-1]){
      gca *= vec1[i];
      gca %= mod;
    }
  }
  //cout << gca << endl;

  //cout << gca << endl;
  rep(i,n){
    ans += gca * modinv(vec2[i],mod);
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8192
#include<stdio.h>
int main(){
	int a,b,c,d,e,f,g,h,s,t;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	scanf("%d %d %d %d",&e,&f,&g,&h);
	 s = a+b+c+d;
	 t = e+f+g+h;
	 if(s>=t){
	 	printf("%d\n",s);
	 }else if(s<t){
	 	printf("%d\n",t);
	 }
	 return 0;
}

Measured memory_bytes: 0
N = int(input())
A = []
for i in range(N):
    a,b = map(str,input().split())
    X = []
    X.append(a)
    X.append(-int(b))
    X.append(i+1)
    A.append(X)
A.sort()
for i in range(N):
    print(A[i][2])

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
 
int main(){
    int N;
    int min = 1000;
    int max = 0;
  
    cin >> N;

    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a < min){
            min = a;
        }
        if(a > max){
            max = a;
        }
    }

    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::{input,fastout};

#[fastout]

fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[isize; d]; n],
    }
    let mut cnt = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            let mut m = 0;
            for k in 0..d {
                m += (x[i][k] - x[j][k]).pow(2);
            }
            let l = (m as f64).sqrt().round() as isize;
            if l * l == m {cnt += 1;}
        }
    }
    println!("{}",cnt);
}


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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

ll dfs(int ind, vector<int> adj[], vector<int> &vis) {
	ll ans = 1;
	vis[ind]=1;
	fl(i,0,adj[ind].size()) {
		if(vis[adj[ind][i]]==0) {
			ans += dfs(adj[ind][i], adj, vis);
		}
	}
	return ans;
}

void decrypt() {
	ll n, m, u, v, ans, count;
	cin>>n>>m;
	vector<int> vis;
	vector<int> adj[n];
	ans = 0;
	fl(i,0,n) {
		vis.pb(0);
	}
	fl(i,0,m) {
		cin>>u>>v;
		adj[u-1].pb(v-1);
		adj[v-1].pb(u-1);
	}
	fl(i,0,n) {
		if(vis[i]==0) {
			count = dfs(i, adj, vis);
			if(ans<count) {
				ans = count;
			}
		}
	}
	cout<<ans<<ln;
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 24236
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let x: String = read(&mut stdin_lock, &mut buf, b' ');
    let y: String = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = if x < y {
        "<"
    } else if x > y {
        ">"
    } else {
        "="
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352