akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  vector<ll> q1(n);
  vector<ll> q2(n);
  vector<ll> y(n);
  vector<ll> x(n);
  vector<string> ans(8,"........");
  for(ll i=0;i<n;i++) {
    cin >> y[i] >> x[i];
    q1[i]=y[i]-x[i];
    q2[i]=y[i]+x[i];
    ans[y[i]][x[i]]='Q';
  }
  map<ll,ll> cy;
  vector<ll> cx(8-n);
  ll count=0;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  for(ll i=0;i<8-n;i++) {
    for(ll j=0;j<n;j++) {
      if(count==y[j]) {
        count++;
      }
    }
    cy[i]=count;
    count++;
  }
  count=0;
  for(ll i=0;i<8-n;i++) {
    for(ll j=0;j<n;j++) {
      if(count==x[j]) {
        count++;
      }
    }
    cx[i]=count;
    count++;
  }

  while(1) {
    set<ll> check1;
    set<ll> check2;
    for(ll i=0;i<n;i++) {
      check1.insert(q1[i]);
      check2.insert(q2[i]);
    }
    bool flag=true;
    for(ll i=0;i<8-n;i++) {
      ll temp1=cy[i]-cx[i];
      ll temp2=cy[i]+cx[i];
      if(check1.count(temp1)||check2.count(temp2)) {
        flag=false;
        break;
      }
      else {
        check1.insert(temp1);
        check2.insert(temp2);
      }
    }
    if(flag) {
      break;
    }
    if(!next_permutation(cx.begin(),cx.end())) {
      cout << "error" << endl;
      return 0;
    }
  }
  for(ll i=0;i<8-n;i++) {
    ans[cy[i]][cx[i]]='Q';
  }
  for(ll i=0;i<8;i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  vector<vector<int>> a(m);
  for(int i=0;i<m;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int s;cin>>s;a.at(i).push_back(s);
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;i++)cin>>p[i];
  int count=0;
  for(int i=0;i<(1<<n);i++){
    bool flag=true;
    for(int j=0;j<m;j++){
      int l=0;
      for(int k=0;k<a.at(j).size();k++){
        if(i&(1<<(a.at(j).at(k)-1)))l++;
      }
      if(l%2!=p.at(j)){
        flag=false;
      }
    }
    if(flag)count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 384
n = int(input().strip())
a = list(map(int, input().split()))
b = [(a[i] - (i + 1)) for i in range(n)]
b.sort()
mid = 0
if n == 1:
    mid = b[0]
elif n % 2 == 1:
    mid = b[(n - 1) // 2]
else:
    mid = (b[(n - 1) // 2] + b[(n - 1) // 2 + 1]) // 2
ans = 0
for i in range(n):
    ans += abs(b[i] - mid)
print(ans)


Measured memory_bytes: 99668
/*
ID: jerrywcy
TASK: AtCoder ABC 104 Problem D
LINK: https://abc104.contest.atcoder.jp/tasks/abc104_d
LANG: c++
*/
#include<bits/stdc++.h>

using namespace std;

const int mod=1e9+7;

string str;
long long p[1000000+5];
long long a[1000000+5],c[1000000+5],m[1000000+5],n[1000000+5];

int main(){
	int i,j;
    p[0]=1;
    for(i=1;i<=1000000;i++)
        p[i]=p[i-1]*3%mod;
        
   	cin>>str;
    int len=str.size();
    str=" "+str;
    for(i=1;i<=len;i++){
        a[i]=a[i-1]+(str[i]=='A');
        m[i]=m[i-1]+(str[i]=='?');
    }
    for(i=len;i>=1;i--){
        c[i]=c[i+1]+(str[i]=='C');
        n[i]=n[i+1]+(str[i]=='?');
    }
    
    long long ans=0;
    for(int i=1;i<=len;i++){
        if(str[i]=='B'||str[i]=='?'){
            ans=(ans+a[i]*c[i]*p[m[i-1]%mod+n[i+1]]%mod+
                a[i]*n[i+1]%mod*p[m[i-1]+n[i+1]-1]%mod+
                c[i]*m[i-1]%mod*p[m[i-1]+n[i+1]-1]%mod+
                p[m[i-1]+n[i+1]-2]*m[i-1]%mod*n[i+1])%mod;   
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19836
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

main(){
    int n;

    while(cin >> n){
        if(n == 0) break;

        vector <int> vec;
        for(int i = 0 ; i < n ; i++){
            int q;
            cin >> q;

            vec.push_back(q);
        }

        sort(vec.begin(),vec.end());

        int sum = 0;

        for(int i = 1 ; i < n-1 ; i++){
            sum+=vec[i];
        }

        cout << sum/(n-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,r;

int main(){
  cin>>n>>r;
  if(n>=10){
    cout<<r<<endl;
  }
  else{
    cout<<r+(100*(10-n))<<endl;
  }
  return 0;
}


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

int main()
{
    ll a, b;
    cin >> a >> b;
    for(int i = 1; i <= 200000; i++)
    {
        ll f = (i*0.08);
        ll s = (i*0.10);
        if(f == a && s == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val count = mutableMapOf<Int, Int>()
    var op = 0
    for (i in 0 until n) {
        count[a[i]] = (count[a[i]] ?: 0) + 1
    }
    var two = 0
    for (m in count.values) {
        if (m % 2 == 1) {
            op += m / 2
        } else {
            op += m / 2 - 1
            two++
        }
    }
    op += (two + 1) / 2
    println(n - 2 * op)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

const double PI = acos(-1);

int main(){
    int N, L, T[3000];
    cin >> N >> L;
    for(int i=0; i<N; i++) cin >> T[i];

    double ansX = 0, ansY = 0;
    for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
        int inter = j-i-1;
        int outer = N-inter-2;
        double theta = PI * (T[i]+T[j]) / L;
        ansX += (outer - inter) * cos(theta);
        ansY += (outer - inter) * sin(theta);
    }
    int64_t comb = int64_t(N) * (N-1) * (N-2) / 6;
    ansX /= comb;
    ansY /= comb;
    cout << fixed << setprecision(15) << ansX << " " << ansY << endl;
    return 0;
}


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

int main() {
  int X; cin >> X;
  if (X == 3)
    cout << "YES" << endl;
  else if (X == 5)
    cout << "YES" << endl;
  else if (X == 7)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var arg   = input.split("\n");
  var line0 = arg[0].split(" ");
  //var line1 = arg[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var input1 = Number(line0[0]);
  var input2 = Number(line0[1]);
  var input3 = Number(line0[2]);
  var n = input1;
  var a = input2;
  var b = input3;

  var ans = "initial_answer";
  var f_max = 0;
  //console.log( "[INPUT] "+ n +" "+ a +" "+ b + "");
  
  // LOGIC //
  ans = 0;
  
  if(a*n < b)ans = a*n;
  else ans = b;

  console.log(ans);


  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

int main(int argc, char const* argv[])
{
	while(1){
		int n,m;
		cin>>n>>m;
		vector<int> hmap,wmap;
		vector<int> map;
		if(!n||!m) return 0;

		int o=0;
		for(int i=0;i<n;i++){
			int h;
			cin>>h;
			hmap.push_back(o);
			o+=h;
		}
		hmap.push_back(o);
		o=0;
		for(int i=0;i<m;i++){
			int w;
			cin>>w;
			wmap.push_back(o);
			o+=w;
		}
		wmap.push_back(o);

		int cnt=0;
		map.resize(max(hmap[n],wmap[m])+10);
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n+1;j++){
				map[hmap[j]-hmap[i]]++;
			}
		}
		for(int i=0;i<m;i++){
			for(int j=i+1;j<m+1;j++){
				int it=wmap[j]-wmap[i];
				if(map[it]>0) cnt+=map[it];
			}
		}
		
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3356
#include <iostream>
 
using namespace std;
 
int main(){
	int n,m;
	cin>>n>>m;
 	int a[n]={0};
 	int x,y;



	for(int i=0;i<m;i++){
		cin>>x>>y;
		a[x-1]++;
		a[y-1]++;
	}

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

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

#define CIN2(a,b) unsigned 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 main(){
    CIN2(n,k)
    unsigned long long v[64] = {};
    rep(i,n){
        unsigned long long tmp;cin >> tmp;
        unsigned long long filter = 1;
        rep(j,63){
            if(tmp & filter) v[j]++;
            filter <<= 1;
        }
    }
    //rep(j,64) cout << v[j] << ",";
    //cout << endl;

    bool check = true;
    unsigned long long ans = 0;
    unsigned long long filter = 1;filter <<= 63;
    for(int i = 63; i >= 0; i--){
		if (filter > k){
			ans += filter * v[i];
		} else {
			if (v[i] >= n-v[i]){
				ans += filter * v[i];
			} else {
				ans += filter * (n-v[i]);
				k -= filter;
			}
		}
        filter >>= 1;
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val Array(n, m) = StdIn.readLine.split(" ").map(_.toInt)

  val ans = (n to m).count(i => {
    ( i / 10000) == (i % 10) && (i / 1000 % 10) == (i / 10 % 10)
  })

  println(ans)
}


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

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if (C - A - B <= 0) cout << "No\n";
    else if (4*A*B < (C-A-B)*(C-A-B)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    long long a;
    long double b;
    cin >> a >> b;
    cout << (long long)floor(a * b) << endl;
    return 0;
}

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

int main() {

    int n, m;

    cin >> n >> m;

    vector<string> map1(n);
    vector<string> map2(m);

    for(int i = 0; i < n; ++i)
        cin >> map1[i];
    
    for(int j = 0; j < m; ++j)
        cin >> map2[j];


    bool isTrue = false;
    for(int i = 0; i < n - m + 1; ++i) {
        for(int j = 0; j < n - m + 1; ++j) {

            int k;
            for(k = 0; k < m; ++k) {
                
                string s = map1[i + k];
                if(map2[k] != s.substr(j, m))
                    break;

            }

            isTrue = k == m;

            if(isTrue)
                break;
        }

        if(isTrue)
            break;
    }

    if(isTrue)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

int main(){
    int N, T; cin >> N >> T;
    vector<int> c(N), t(N);
    for(int i = 0; i < N; i++) cin >> c[i] >> t[i];
    int MIN = 1e9;
    for(int i = 0; i < N; i++){
        if(t[i] <= T) MIN = min(MIN, c[i]);
    }
    if(MIN == 1e9) cout << "TLE" << endl;
    else cout << MIN << endl;
}

Measured memory_bytes: 256
while True:
    try:
        (H,W)  =  map(int,input().split())
    except:
        exit
    
    if (H == 0 and W == 0):

         break
    s = "#." * 151

    for i in range(0,H):
        print(s[i%2:W+i%2])
    print("")

    


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

LL n, a, b, x[100000];
LL ans;

int main() {
	cin >> n >> a >> b;
	inc(i, n) { cin >> x[i]; }
	
	inc(i, n - 1) {
		ans += min( (x[i + 1] - x[i]) * a, b);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

void solve(){
  int n; cin >> n;
  vector<ll> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ll ans = 0;
  if(n % 2 == 0){
    ll ma = a[n / 2 - 1] + a[n / 2], mb = b[n / 2 - 1] + b[n / 2];
    ans = mb - ma + 1;
  }
  else{
    ll ma = a[n / 2], mb = b[n / 2];
    ans = mb - ma + 1;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 6352
import java.util.*;

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

        int N = stdin.nextInt();
        int Y = stdin.nextInt();

        for (int x = 0; x <= N; x++) {
            for (int y = 0; y <= N - x; y++) {
                int z = N - x - y;
                if (10000 * x + 5000 * y + 1000 * z == Y) {
                    System.out.printf("%d %d %d", x, y, z);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23764
N = int(input())
A = []
B = []
C2 = [0] * N
C5 = [0] * N


for i in range(N):
    a = str(input())
    ok = False
    dot_idx = -1
    l = len(a)
    for j in range(l):
        if a[j] == '.':
            ok = True
            dot_idx = j
    if dot_idx == -1:
        a += ".000000000"
    else:
        while len(a) < 10+dot_idx:
            a += "0"
    tmp = ""
    for j in range(len(a)):
        if a[j] == '.':continue
        tmp += a[j]

    B.append(int(tmp))
    tmp = B[i]
    tmp2 = B[i]
    while tmp > 0:
        if tmp % 2 == 0:
            tmp //= 2
            C2[i] += 1
        else:
            break
    while tmp2 > 0:
        if tmp % 5 == 0:
            tmp //= 5
            C5[i] += 1
        else:
            break


Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[min(18, C2[i])][min(18, C5[i])]+=1

ans = 0
for i in range(N):
    if C2[i] >= 9 and C5[i] >= 9:
        ans -= 1
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]
print(ans//2)

Measured memory_bytes: 92436
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let n = s.len();
    /*
    let mut sum = 0;
    for i in 0..n {
        let mut l = i;
        let mut r = i;
        let mut cnt = 0;
        while 0 < l && r < n - 1 {
            l -= 1;
            r += 1;
            if s[l] == s[r] {
                cnt += 1;
            } else {
                break;
            }
        }
        sum += cnt;
        println!("{}:{}", i, cnt);
    }
    for i in 0..n-1 {
        let mut l = i;
        let mut r = i + 1;
        let mut cnt = 0;
        while r < n {
            if s[l] == s[r] {
                cnt += 1;
            } else {
                break;
            }
            if l == 0 {
                break;
            }
            l -= 1;
            r += 1;
        }
        sum += cnt;
        println!("{}:{}", i, cnt);
    }*/
    let mut vec: Vec<Vec<usize>> = vec![Vec::new(); 26];
    for i in 0..n {
        let j = s[i] as usize - 'a' as usize;
        vec[j].push(i);
    }

    let mut sum = 0;
    for i in 0..26 {
        if vec[i].is_empty() {
            continue;
        }
        let m = vec[i].len();
        sum += m * (m-1) / 2;
    }

    println!("{}", 1 + n * (n-1) / 2 - sum);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 12540
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Dice and Coin
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  long double p = 0.0;
  for (int i = 1; i <= n; i++) {
    int c = 0;
    for (int j = i; j < k; j <<= 1, c++);
    p += (long double)1.0 / (1 << c);
  }

  printf("%.12Lf\n", p / n);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

#define sint stack<int>

int main() {
	vector<sint> vec; int an, tn, fn1, fn2, en;
	cin >> an >> tn; vec.resize(an);
	for (int i = 0; i < tn; i++) {
		cin >> fn1;
		switch (fn1) {
		case 0: cin >> fn2 >> en; vec[fn2].push(en); break;
		case 1: cin >> fn2; 
			if (vec[fn2].empty()) continue;
			else cout << vec[fn2].top() << endl;
			break;
		case 2: cin >> fn2;
			if (vec[fn2].empty()) continue;
			else vec[fn2].pop();
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 4252
//============================================================================
// Name        : 0007.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin>>n;
	int x=100000;
	for(int i=0; i<n; i++){
		x=0.05*x+x;
		x=ceil((double)x/1000)*1000;
	}
	cout <<x<<endl;

	return 0;
}

Measured memory_bytes: 1164
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        v: [String; n],
    }
    let mut set: HashSet<String> = HashSet::new();
    for i in 0..n {
        set.insert(v[i].clone());
    }
    println!("{}", set.len());
}


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

int main()
{
	int n; cin>>n;
	n = n%26;
	string s; cin>>s;
	for(int i = 0; i<s.length(); i++)
	{
		int ch = (s[i]-'A'+n)%26;
		cout<<char('A'+ch);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{

        int i,j, a[3];
        for(i=0;i<3;i++)
        {
            scanf("%d",&a[i]);
        }

        sort(a,a+3);
        j=a[0]+a[1];
        cout<<j<<endl;


        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
int dx[] =  {1, -1, 1, -1, 2, 2, -2, -2};
int dy[] = {2, 2, -2, -2, 1, -1, 1, -1};
int main()
{
    IOS
    // READ(0test.txt);
    vector<int>v ;
    for(int i=1 ; i<=9 ; i++){
        v.pb(i) ;
    }
    int n ;
    cin >> n ;
    for(int i=1 ; i<10 ; i++){
        for(int j=1 ; j<10 ; j++){
            if(i*j==n){
                return cout<<"Yes",0;
            }
        }
    }
    cout<<"No";

}


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) { cin >> v.at(i); }
    sort(v.begin(), v.end());
    double sum = v.at(0);
    rep(i, n - 1) { sum = (sum + v.at(i + 1)) / 2.0; }

    cout << sum << endl;
}



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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    string wa;
    wa = to_string(a) + to_string(b);
    int num = stoi(wa);
    bool ok=false;
    for (int i=0;i<1000;i++){
        if (i*i==num) ok = true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

Measured memory_bytes: 256
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
L = [0] * (N+1)
R = [0] * (N+1)
L_m = [[] for _ in range(N+1)]
R_m = [[] for _ in range(N+1)]

for i in range(1, N+1):
    L[i] = L[i-1] + V[i-1]
    R[i] = R[i-1] + V[-i]
    L_m[i] = L_m[i-1].copy()
    R_m[i] = R_m[i-1].copy()
    if V[i-1] < 0:
        L_m[i].append(V[i-1])
    if V[-i] < 0:
        R_m[i].append(V[-i])

ans = 0

for i in range(K+1):
    for l in range(K+1-i):
        r = K - i - l
        if l + r >= N:
            ans = max(ans, R[-1] - sum(R_m[-1]))
            break
        if r < 0:
            break
        M = L_m[l] + R_m[r]
        M.sort()
        if len(M) >= i:
            m = sum(M[:i])
        else:
            m = sum(M)
        a = L[l] + R[r] - m
        ans = max(ans, a)

print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
dp[1] = abs(a[0] - a[1])

for i in range(2, n):
  dp[i] = min(dp[i-2] + abs(a[i-2] - a[i]) , dp[i - 1] + abs(a[i - 1] - a[i]))

print(dp[n - 1])  

Measured memory_bytes: 13908
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> >
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=2005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

struct node{int x,y;}p[N];
int n,m,res,last[N],vis[N];
char s[N][N];
bool a[N][N];

inline bool cmp(node a,node b){return a.x<b.x;}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	res=max(n,m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++)
			a[i][j]=(s[i][j]=='#');
	}
	for(int i=1;i<n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]^=a[i+1][j];
	for(int j=1;j<m;j++) last[j]=n;
	for(int i=n-1;i;i--){
		for(int j=1;j<m;j++)
			if(a[i][j]!=a[i][j+1]) last[j]=i;
		for(int j=1;j<m;j++)
			p[j]=(node){last[j],j};
		sort(p+1,p+m,cmp);
		set<int> s;s.insert(0);s.insert(m);
		clr(vis,0);vis[m]=1;
		int ans=m;
		for(int j=1;j<m;j++){
			if(p[j].x!=p[j-1].x) gmax(res,ans*(p[j].x-i+1));
			int k=p[j].y;
			if(p[j].x==n) break;
			s.insert(k);
			set<int>::iterator it=s.find(k);
			int l=*(--it);
			int r=*(++++it);
			vis[r-l]--;vis[k-l]++;vis[r-k]++;
			while(!vis[ans]) ans--;
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 8704
#include<stdio.h>
int main()
{
  int vx[8]={0,1,1, 1, 0,-1,-1,-1};
  int vy[8]={1,1,0,-1,-1,-1, 0, 1};
  int H,W;
  scanf("%d %d", &H, &W);
  char map[H][W];
  for(int i=0;i<H;i++){
      scanf("%s", map[i]);      
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
       int num=0;
       for(int l=0;l<8;l++){
         int nx=i+vx[l],ny=j+vy[l];
         if(map[i][j]=='#') continue;
         else{
          if(nx<0 || nx>=H) continue;
          if(ny<0 || ny>=W) continue;
          if(map[nx][ny]=='#') num++;
         }
       }
       if(map[i][j]=='#') printf("#");
       else printf("%d",num);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
int main()
{ 
		int n,t;
		cin>>n>>t;
		
		vector<pair<int,int>> dish(n);
		for(int i=0;i<n;i++)
		  cin>>dish[i].ff>>dish[i].ss;
		
		sort(dish.begin(),dish.end());
		
		vector<int> maxhappy(t+3000,0);
		for(auto d:dish)
		{
		  for(int i=t-1;i>=0;i--)
		  {
		    if(maxhappy[d.ff+i]<maxhappy[i]+d.ss)
		      maxhappy[d.ff+i]=maxhappy[i]+d.ss;
		  }
		}
		cout<<*max_element(maxhappy.begin(),maxhappy.end())<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i += 2) {
    ll tmp = 0;
    for (ll j = 1; j <= i; j += 2) {
      if (i%j == 0) tmp++;
    }
    if (tmp == 8) ans++;
  }
  cout << ans << endl;
}

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

class Program
{
    static void Main()
    {

        while(true){
            var line = Console.ReadLine();
            var num_array = line.Split(' ').Select(s => int.Parse(s)).ToArray();
            var x = num_array[0];
            var y = num_array[1];
            
            if(x == 0 && y == 0){
                break;
            }
            
            if(x > y){
                var tmp = x;
                x = y;
                y = tmp;
            }
            
            Console.WriteLine(x + " " + y);
        }
    }
}



Measured memory_bytes: 14268
s=int(input())
List=[s]
ns=0
bs=s
for i in range(2,10**6+1):
  if (bs%2==0):
    ns=bs//2
  else:
    ns=3*bs+1
  if (List.count(ns)>0):
    print(i)
    #print(List)
    break
  else:
    List.append(ns)
    bs=ns

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

int main(){
    int n;
    cin>>n;
    map<pair<int,int>,int> mp;
    vector<int> a(n-1),b(n-1),deg(n,0),edge(n-1);
    Graph G(n);
    vector<set<int>> st(n);
    rep(i,n-1){
        cin>>a[i]>>b[i];
        mp[P(--a[i],--b[i])]=i;
        mp[P(b[i],a[i])]=i;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        deg[a[i]]++;
        deg[b[i]]++;
    }
    int ans=0;
    rep(i,n) chmax(ans,deg[i]);
    vector<int> dist(n,-1);
    dist[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        int cnt=1;
        for(int nv:G[v]){
            if(dist[nv]!=-1) continue;
            while(st[v].count(cnt)) cnt++;
            edge[mp[P(v,nv)]]=cnt;
            st[v].insert(cnt);
            st[nv].insert(cnt);
            dist[nv]=dist[v]+1;
            que.push(nv);
        }
    }
    cout<<ans<<endl;
    rep(i,n-1) cout<<edge[i]<<endl;
}

Measured memory_bytes: 34560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {


			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var R = inputArray[0];

			//答えの出力
			var ans = 2*R* 3.1415926535;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28312
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

ll prime[MAX];

void sieve()
{
	for(ll i=2;i*i<MAX;i++)
	{
		if(prime[i]==0)
		for(ll j=i;j<MAX;j+=i)
		prime[j] = i;
	}
	prime[1] = 1;
}

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

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

//sieve();

ll n;
  cin>>n;
 ll ans = (n/500)*1000;
  n = n%500;
  ans += (n/5)*5;
  cout<<ans<<"\n";



return 0;
}


Measured memory_bytes: 256
N = int(input())
X = int(N/1.08)
if N == int((X-1)*1.08):
  print(X-1)
elif N == int((X+0)*1.08):
  print(X)
elif N == int((X+1)*1.08):
  print(X+1)
elif N == int((X+2)*1.08):
  print(X+2)
else:
  print(":(")


Measured memory_bytes: 2940
package main

// Solution for https://atcoder.jp/contests/abc175/tasks/abc175_d

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func calc(A []int, K int) int {
	N := len(A)
	D := make([]int, N*2)
	X := make([]int, N+1)
	for i := 0; i < N; i++ {
		D[i] = A[i]
		D[i+N] = A[i]
		X[N] += A[i]
	}
	E := make([]int, N*2+1)
	for i := 0; i < N*2; i++ {
		E[i+1] = E[i] + D[i]
	}
	for i := 1; i < N; i++ {
		X[i] = int(-1e10)
		for j := 0; j < N; j++ {
			if E[j+i]-E[j] > X[i] {
				X[i] = E[j+i] - E[j]
			}
		}
	}
	MAX := int(-1e10)
	for i := 1; i <= N && i <= K; i++ {
		if X[i] > MAX {
			MAX = X[i]
		}
	}
	if K > N && X[N] > 0 {
		R := K / N
		M := K % N
		if R > 1 {
			MAX += (R - 1) * X[N]
		}
		R *= X[N]
		for i := 0; i <= M; i++ {
			if R+X[i] > MAX {
				MAX = R + X[i]
			}
		}
	}
	return MAX
}

func (con *contest) main() error {
	var N, K int
	con.Scan(&N, &K)
	P := make([]int, N)
	C := make([]int, N)
	for i := 0; i < N; i++ {
		con.Scan(&P[i])
		P[i]--
	}
	for i := 0; i < N; i++ {
		con.Scan(&C[i])
	}
	V := make([]bool, N)
	MAX := int(-1e10)
	for i := 0; i < N; i++ {
		if V[i] {
			continue
		}
		x := i
		D := []int{}
		for !V[x] {
			V[x] = true
			D = append(D, C[x])
			x = P[x]
		}
		X := calc(D, K)
		if X > MAX {
			MAX = X
		}
	}
	con.Println(MAX)
	return nil
}


Measured memory_bytes: 2536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  ll n,m;cin>>n>>m;
  vector<bool> b(n+1,false);
  vector<ll> a(n+1,0);
  a[0]=1;
  rep(i,m){
    int c;cin>>c;
    b[c]=true;
  }
  reps(i,1,n+1){
    if(i==1)a[1]=1;
    else a[i]=(a[i-1]+a[i-2])%M;
    if(b[i])a[i]=0;
  }
  cout<<a[n];
}

Measured memory_bytes: 1024
from collections import Counter
s = input()
cnt_wb = Counter(s)
# 全部同じ色のとき
if cnt_wb["W"] == len(s) or cnt_wb["B"] == len(s):
    print(0)
else:
    prev = s[0]
    cnt = 0
    for i in range(1, len(s)):
        if prev != s[i]:
            prev = s[i]
            cnt += 1
    print(cnt)

Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std; 

#ifdef LOCAL
    #include "debug.h"
    #define input freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define input 4
#endif

using ll = long long;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;


signed main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }    
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        sum -= a[i];
        ans += ((a[i] % mod) * (sum % mod)) % mod;
        ans %= mod;

    }
    cout << ans << "\n";
    

}
  



Measured memory_bytes: 5208
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC161();
}

void ABC161(){
    long long int n,k;
    cin>>n>>k;
    if(k==1)cout<<0<<endl;
    else if(n%k<abs(n%k-k))cout<<n%k<<endl;
    else cout<<abs(n%k-k)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e2+5
#define W (int)1e5+5
#define f1 first
#define s2 second
#define INF -9999999
#define pb push_back
#define ll long long
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

ll wt[N],val[N],dp[N][W],n,w;

ll solve(){
	int a=0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= w; j++){
			if(i == 0 || j == 0){
				dp[i][j] = 0;
			}
			else if(wt[i-1] <= j){
				dp[i][j] = max(dp[i-1][j-wt[i-1]] + val[i-1],dp[i-1][j]);
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	return dp[n][w];
}


int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin >> n >> w;
	for(int i = 0; i < n; i++){
		cin >> wt[i] >> val[i];
	}
	//memset(dp,-1,sizeof(dp));
	cout << solve();
	return 0;
}

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

typedef long long ll;
const int N = 200005;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int d,s,t;
	cin>>d>>s>>t;
	if(d <= s*t){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  map<string, int> m;

  for(int i = 0; i < N; i++){
    string tmp;
    cin >> tmp;
    auto itr = m.find(tmp);
    if(itr != m.end()){
      m[tmp] += 1;
    } else { 
      m[tmp] = 1;
    }
  }
  int maxnum = 0;
  for(auto x : m){
    if(x.second > maxnum){
      maxnum = x.second;
    }
  }
  cerr << maxnum << endl;

  vector<string> ans;
  for(auto x : m){
    if(x.second == maxnum){
      ans.push_back(x.first);
    }
  }
  sort(ans.begin(), ans.end());

  for(auto x : ans){
    cout << x << endl;
  }


}



Measured memory_bytes: 26868
while True:
    coin=0
    n=int(input())
    if n==0:
        break
    else:
        money=1000-n
        if money//500>=1:
            coin1=int(money//500)
            money-=500*coin1
            coin+=coin1
        else:
            pass
        if money//100>=1:
            coin2=int(money//100)
            money-=100*coin2
            coin+=coin2
        else:
            pass
        if money//50>=1:
            coin3=int(money//50)
            money-=50*coin3
            coin+=coin3
        else:
            pass
        if money//10>=1:
            coin4=int(money//10)
            money-=10*coin4
            coin+=coin4
        else:
            pass
        if money//5>=1:
            coin5=int(money//5)
            money-=5*coin5
            coin+=coin5
        else:
            pass
        if money//1>=1:
            coin6=int(money//1)
            coin+=coin6
        else:
            pass
        
        print(coin)


Measured memory_bytes: 5592
n = int(input())
ass = list(map(int, input().split(' ')))

count = 1
sign = 0
for i in range(n - 1):
    if sign == 0:
        sign = (ass[i + 1] - ass[i]) 
    else:
        if (ass[i + 1] - ass[i]) * sign < 0:
            count += 1
            sign = 0
print(count)


Measured memory_bytes: 15020
# 奇数行目は(W/2)+1. 偶数行目は(W/2)+1
H, W = map(int, input().split())
block_num = H*W

if H == 1 or W == 1:
    print(1)
elif block_num % 2 == 0:
    print(int(block_num/2))
else:
    print(int(block_num/2+1))

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;

signed main() {
    cin >> n;
    cout << (n+1)/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
  string s,sub;
  cin >> s;
  sub=s;
  int n = s.size();
  int csize=1;
  vector<char>S(n);
  for(int i=0; i<n; i++){
   S[i]=s[i];
  }
  sort(S.begin(),S.end());
  for(int i=0; i<n; i++){
   if(i>0 && S[i-1]!=S[i]) csize++;
  }
  
  vector<char>chara(csize);
  vector<int>count(csize);
  int c = 0,x = 0;
  for(int i=0; i<n; i++){
    c++;
    if(S[i]!=S[i+1] || i==n-1){
      chara[x]=S[i];
      count[x]=c;
      x++;
      c = 0;
    }
  }
  
  if(count[0]==n){
   cout << 0 << endl;
   return 0;
  }
  
  int Min=1000;
  for(int i=0; i<csize; i++){
    s=sub;
    int remain=n,motion=0;
    while(remain>0){
    remain=n;
    motion++;
    for(int j=0; j<n-motion; j++){
      if(s[j]!=chara[i] && s[j+1]==chara[i]){
        count[i]++;
        s[j]=chara[i];
      }
    }
     if(s[n-motion]==chara[i]) count[i]--;
     remain=n-count[i]-motion;
    }
    Min=min(Min,motion);
  }
  
  cout << Min << endl;
  
  return 0;
  
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int outlet = 1;
  while (outlet < b) {
    --outlet;
    outlet += a;
    ++ans;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n, m;
    cin >> n >> m;
    int num[n];
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    vector<pair<int, int>> v(m);
    for(int i = 0; i < m; i++){
        cin >> v[i].second >> v[i].first;
    }
    sort(num, num+n);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int start = 0;
    for(int i = 0; i < n; i++){
        if(num[i] < v[start].first){
            num[i] =  v[start].first;
        }else{
            break;
        }
        v[start].second -= 1;
        if(v[start].second == 0){
            if(start == m - 1){
                break;
            }
            start++;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += num[i];
    }
    cout << ans;
}


Measured memory_bytes: 2560
#include <iostream>

int main() {
    int N;
    int A[100001];
    std::cin >> N;
    long long ans = 0;
    int parity = 0;
    int absmin = 1000000000;
    for (int i = 1; i <= N; ++i) {
        std::cin >> A[i];
        if (A[i] >= 0) {
        } else {
            A[i] = -A[i];
            parity = (parity == 0) ? 1 : 0;
        }
        ans += A[i];
        absmin = (A[i] < absmin) ? A[i] : absmin;
    }
    ans = ans - 2 * absmin * parity;
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)
ans = 1000
for i in range(ls-lt+1):
    count = 0
    for j in range(lt):
        if s[j+i] != t[j]:
            count += 1
    ans = min(ans,count)
print(ans)

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

int n,T,t,last,ans;

int main(){
    cin >> n >> T;
    for(int i = 1;i <= n;++i){
        scanf("%d",&t);
        int tmp = t + T - last;
        ans += tmp > T ? T : tmp;
        last = t + T;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list=list(map(int,input().split()))

MOD = 10**9+7

ans=0
for i in range(60):
    one_cnt = 0
    for a in a_list:
        one_cnt += (a & 2**i)
    one_cnt //= 2**i
    zero_cnt = n - one_cnt
    ans = (ans + (2**i * one_cnt * zero_cnt) % MOD) % MOD
print(ans)

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

int main(){
    int N, D; cin >> N >> D;
    vector<int> v[10];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            int x; cin >> x;
            v[i].push_back(x);
        }
    }

    int ans = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            int sum = 0;
            for(int d = 0; d < D; d++){
                sum += pow((v[i].at(d) - v[j].at(d)), 2);
            }
            if(pow((int)sqrt(sum), 2) == sum){ 
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi l(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int hi    = l[i] + l[j];
            int lo    = abs(l[i] - l[j]);
            auto ithi = lower_bound(l.begin(), l.end(), hi);
            auto itlo = upper_bound(l.begin(), l.end(), lo);
            int sub   = 0;
            if (l[i] < hi && lo < l[i])
                sub++;
            if (l[j] < hi && lo < l[j])
                sub++;
            ret += max(0, int(ithi - itlo) - sub);
        }
    }
    cout << ret / 3 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    uint64_t result = 0;
    for (uint64_t bit = 0; bit < (1 << in_str.length()); ++bit) {
        uint64_t sum = 0;
        uint64_t tmp1 = 0;
        for (uint64_t i = 0; i < in_str.length(); ++i) {
            if (bit & (1 << i)) {
                tmp1 = tmp1 * 10 + in_str[i] - '0';
            }
            else {
                sum += tmp1;
                tmp1 = 0;
            }
        }
        result += sum + tmp1;
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256