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

fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun solve(sc: java.util.Scanner) {
    val S = sc.next()

    if (S[2] == S[3] && S[4] == S[5]) {
        println("Yes")
    } else {
        println("No")
    }
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    vector<int> a(3);
    for(int i=0; i<3; i++){
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    cout << a[2]-a[0] << endl;

    return 0;
}

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

int main(){
	double r;
	while(cin >> r , r != 0.0){
		pair<int,int> a(9999999,999999); 
		double pi = M_PI;

		for(int i = 1 ; i < 100000 ; i++){
			for(int k = -1 ; k < 2 ; k+=2){
				for(int j = 0 ; j < 2 ; j++){
					int nu = (int)( (pi+r*k) * i) + j;
					if(abs(nu - pi*i) <= r*i){
						a = min(a,make_pair(i,nu));
					}
				}
			}
		}
		cout << a.second << "/" << a.first << endl;
	}
}

Measured memory_bytes: 0
n,m = $stdin.gets.split.map(&:to_i)
result = [0]*m
n.times do |i|
  a = $stdin.gets.split.map(&:to_i)
  a[1..-1].each do |j|
    result[j-1] += 1
  end
end

puts result.count(n)
    

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	string S;
	cin >> S;
	int N;
	N = S.length();
	char R = 'R';
	char L = 'L';
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 1&& S[i] == R) {
			ans = 1;
			break;
		}
		else if (i % 2 == 0 && S[i] == L) {
			ans = 1;
			break;
		}
	}
	if (ans == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<math.h>
    #include<string>
    #include<algorithm>
    #include<functional>
    #include<vector>
    #include<set>
    #include<map>
    #define INF 999999
    #define EPS 1.0e-6
     
    using namespace std;
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef pair<int, P> PP;
     
    int main()
    {
    	int n, k;
    	cin >> n >> k;
     
    	ll t = 1900 * k + 100 * (n - k);
    	int s = 1;
    	for (int i = 0; i < k; i++) {
    		s *= 2;
    	}
    	cout << t*s << endl;
    	return 0;
    }

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];

	ll res = 0;
	REP(i, n - 1) {
		res += a[i] / 2;
		if (a[i] % 2 && a[i+1]) {
			res++;
			a[i+1]--;
		}
	}
	res += a[n-1] / 2;
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N;
}
//=============================
void func(){}
//=============================
void solve()
{
    int ss = 0;
    bool ans = false;
    for (int i = 0; i <= N/4; ++i) {
        for (int j = 0; j <= N / 7; ++j){
            if (i*4+j*7==N){
                ans = true;
                break;
            }

        }
    }

    cout<<(ans ? "Yes" : "No")<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main() {
  unsigned int N;
  std::string S;
  std::cin >> N;
  std::cin >> S;

  std::vector<char> S_array;
  for (size_t i = 0; i < N; ++i) {
    S_array.push_back(S[i]);
  }

  const unsigned long r_num = std::count(S_array.begin(), S_array.end(), 'R');
  const unsigned long g_num = std::count(S_array.begin(), S_array.end(), 'G');
  const unsigned long b_num = std::count(S_array.begin(), S_array.end(), 'B');

  unsigned long sum = r_num * g_num * b_num;

  for (unsigned int i = 0; i < N; ++i) {
    for (unsigned int j = i + 1; j < N; ++j) {
      const unsigned int k = 2 * j - i;
      if (k >= N) {
        continue;
      }
      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
        sum -= 1;
      }
    }
  }

  std::cout << sum << std::endl;
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  for (int i = K; i < N; i++) {
    if (A[i] > A[i - K])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
import java.util.Scanner;

//AtCoder Beginner Contest 130
//C	Rectangle Cutting
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double W = sc.nextDouble();
		double H = sc.nextDouble();
		long x = sc.nextLong();
		long y = sc.nextLong();
		sc.close();

		double ans = (W * H) / 2;

		int ans2 = 0;
		if (x * 2 == W && y * 2 == H) {
			ans2 = 1;
		}

		System.out.println(ans + " " + ans2);
	}
}


Measured memory_bytes: 23124
using System;

class BuildStairs
{
    static void Main (string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] heightArr = new int[str.Length];

        // 判定用変数
        bool isFinished = false;

        for (int i = 0; i < str.Length; i++)
        {
            heightArr[i] = int.Parse(str[i]);
        }

        // マスが1つ：無条件でok
        if (str.Length == 1)
        {
            Console.WriteLine("Yes");
            return;
        } else
        // マスが2つ以上
        if (str.Length >= 2)
        {
            // 最初のマスはとりあえず1減らしておく
            heightArr[0]--;

            for(int i = 0; i < str.Length - 1; i++)
            {
                // 2つの数値が同じなら何もせずに次へ
                if (heightArr[i] == heightArr[i + 1])
                {
                    isFinished = true;
                    continue;
                }

                if (heightArr[i] < heightArr[i + 1])
                {
                    // 1へらす
                    heightArr[i + 1]--;
                    isFinished = true;
                    continue;
                }

                isFinished = false;
                break;
            }
        }

        if (isFinished)
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int w, h;
    cin >> h >> w;

    char image[h][w];
    rep(i, h){
        rep(j, w) cin >> image[i][j];
    }

    rep(i, h){
        rep(_, 2){
            rep(j, w) cout << image[i][j];
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = [int(i) for i in input().split()]

roads = [[int(i) for i in input().split()] for j in range(M)]
roads2 = [[] for i in range(N)]

for spots in roads:
    roads2[spots[0]-1].append(spots[1])
    roads2[spots[1]-1].append(spots[0])

ans = 0
for spot in range(1, N+1):
    good = True
    for i in roads2[spot-1]:
        if H[spot-1] <= H[i-1]:
            good = False
            break
    if good:
        ans += 1

print(ans)

Measured memory_bytes: 39688
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    assert!(a != 0 || b != 0);
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn divisors(n: usize) -> Vec<usize> {
    let mut m = 1;
    let mut divs = vec![];
    while m * m <= n {
        if n % m == 0 {
            divs.push(m);
            if n != m * m {
                divs.push(n / m);
            }
        }
        m += 1;
    }
    divs.sort();
    divs
}

fn prime_factor(n: usize) -> HashMap<usize, usize> {
    let mut res = HashMap::new();
    let mut n_ = n.clone();

    for i in 2..n + 1 {
        if i * i > n_ {
            break;
        }
        while (n_ % i == 0) {
            *res.entry(i).or_insert(0) += 1;
            n_ /= i;
        }
    }
    if (n_ != 1) {
        res.insert(n_, 1);
    }
    res
}

fn main() {
    input! {
        a: u64, b: u64,
    }
    let mut gcd_ = gcd(a, b);

    let pf = prime_factor(gcd_ as usize);

    println!("{}", pf.len() + 1);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

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

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int n,k;
  while(cin>>n>>k, n){

    vector<P> node[n+1];
    priority_queue<P, vector<P>, greater<P> > pque;

    REP(_t,k){
      int t;
      cin >> t;
      
      if( t == 1 ){
	int c,d,e;
	cin >>c>>d>>e;
	node[c].PB( P(d,e) );
	node[d].PB( P(c,e) );
      }
      else{
	int d[n+1];
	fill(d, d+n+1, INF);

	int a,b;
	cin >>a>>b;
	pque.push( P(0,a) );
	d[a] = 0;

	// dijkstra
	while( ! pque.empty() ){
	  P e = pque.top(); pque.pop();
	  if( d[e.second] < e.first )
	    continue;

	  vector<P> tos = node[e.second];
	  PREP(it,tos){
	    int i = (*it).first;
	    int cost = (*it).second;
	    if( d[i] > d[e.second] + cost ){
	      d[i] = d[e.second] + cost;
	      pque.push( P(d[i],i) );
	    }
	  }
	}

	if( d[b] == INF )
	  cout << -1 << endl;
	else
	  cout << d[b] << endl;
      }

    }
  }
  

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    vec x(n);
    rep(i, n) cin >> x[i];

    int res = 0;

    rep(i, n) {
        res += 2 * min(x[i], k - x[i]);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

#define N 101000
/*----------------------------------------------------------------*/
signed main(){

	int s;
	cin >> s;

    //素数列挙 Nより小さい
//arr[i] == 1  ->  i は素数
    
    int arr[N];
    for(int i = 0; i < N; i++) arr[i] = 1;
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    arr[0] = 0;
    arr[1] = 0;
    vector<int> pri;
    for(int i = 2; i < N; i++){
        if(arr[i] && i >= s){
            cout << i << endl;
            return 0;
        }
    }




	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc149.contest.atcoder.jp/tasks/abc149_b

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

int x,y,cnt;
int mas[21][21];
void move(char muki,int mv){
  for(int i=0;i<mv;i++){
    if(muki == 'N') y--;
    else if(muki == 'W') x--;
    else if(muki == 'S') y++;
    else if(muki == 'E') x++;
    if(mas[y][x] == 1){
      mas[y][x] = 0;
      cnt++;
    }
  }
}

int main(){
  char muki;
  int n,m,mo;
  while(cin >> n,n){
    memset(mas,0,sizeof(mas));
    for(int i=0;i<n;i++){
      cin >> x >> y;
      mas[20-y][x] = 1;
    }
    y = 10; x = 10;
    cnt = 0;
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> muki >> mo;
      move(muki,mo);
    }
    cout << ((cnt == n)? "Yes":"No") << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

ll evaluate(int contest, int date, vector<ll>& last, vector<ll>& c, vll& s) {
    ll point_today = 0;
    point_today += s[date][contest];
    for (ll j = 1; j <= 26; j++) {
        if(j==date){
            continue;
        }
        point_today -= c[j] * (date - last[j]);
    }
    return point_today;
}

int main(){
  ll d;
  cin >> d;//全日数
  vl c(27);
  for(ll i=1;i<=26;i++){//c_i==c[i]
    cin >> c[i];
  }
  vll s(d + 1, vl(27)); //s_d,i==s[d][i]
  for (ll i = 1; i <= d; i++){
    for (ll j = 1; j <= 26;j++){
      cin >> s[i][j];
    }
  }
  vl t;
  vl last(27, 0);//last(d,i)==last[i]
  //ll satisfy = 0;
  for (ll date = 1; date <= d;date++){
    priority_queue<pair<ll, int>> q;
    for (ll contest = 1; contest <= 26;contest++){
      q.push(mp(evaluate(contest, date, last,c,s), contest));
    }
    t.pb(q.top().S);
    //satisfy += q.top().F;
    last[q.top().S] = date;
  }
  rep(i,d){
    print(t[i]);
  }
}

Measured memory_bytes: 3744
#include <stdio.h>
#include <math.h>
int v[5120][333],a[10],i,j,n,s;
int summing(int n,int s){
    int ans=0,i,max=0,min=0,m,k;
    if(s>332)return 0;
    if(n==1){if(s<10 && a[s]==1)return 1; else return 0;}
    else{
        k=(a[0]+a[1]*2+a[2]*4+a[3]*8+a[4]*16+a[5]*32+a[6]*64+a[7]*128+a[8]*256+a[9]*512)*5+(n-1);
        if(n<6 && v[k][s]>=0)return v[k][s];
        for(i=0,m=n;m>0 && i<10;i++){if(a[i]==1){min+=m*i;m--;if(s<min)goto answer;}}
        for(i=9,m=n;m>0 && i>=0;i--){if(a[i]==1){max+=m*i;m--;if(s<=max)break;}}if(s>max)goto answer;
        for(i=0;i<10;i++){
            if(a[i]==1 && n*i<=s){
                a[i]=0;
                ans+=summing(n-1,s-n*i);
                a[i]=1;
            }
        }
        answer:
        if(n<6)v[k][s]=ans;
        return ans;
    }
}
int main(void){
    for(i=0;i<10;i++)a[i]=1;
    for(i=0;i<5120;i++){{for(j=0;j<333;j++)v[i][j]=-1;}}
    while(scanf("%d %d",&n,&s)!=EOF){printf("%d\n",summing(n,s));}
    return 0;
}

Measured memory_bytes: 7260
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([(k,v) for k,v in c.items() if m==v], key=lambda x: (-x[1], x[0]))
[print(k[0])for k in ans]

Measured memory_bytes: 62688
N, M = map(int, input().split())

ll = list()
lr = list()
for i in range (M):
    l, r = map(int, input().split())
    ll.append(l)
    lr.append(r)

ans = min(lr) - max(ll) + 1

if ans >= 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 10996
import sys;input=sys.stdin.readline
n=int(input())
s=input()
num=2**(n-1).bit_length()
def segfunc(x,y):return x|y
seg=[0]*(2*num-1)
for i in range(n):seg[i+num-1]=2**(ord(s[i])-97)
for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2])
def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r]))
for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:])))

Measured memory_bytes: 44212
import java.util.*;
public class Main{

	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		int[] list = new int[100];
		int[] at = new int[17];
		int[] s = new int[17];
		int count = 0;
		Queue<Data> que = new ArrayDeque<Data>();
		for(int i = 0; i < 1000; i++) {
			for(int j = 0; j < 17; j++) {
				at[j]--;
				if(at[j] == 0) {
					s[j] = -1;
				}
				if(at[j] == -1) {
					at[j] = 0;
					s[j] = -1;
				}
			}
			if(i % 5 == 0 && i < 500) {
				if(count % 5 == 1) {
					que.add(new Data(count,5));
				}
				else {
					que.add(new Data(count, 2));
				}
				count++;
			}
			INX:while(!que.isEmpty()) {
				Data tmp = que.peek();
				IN:for(int j = 0; j < 17; j++) {
					for(int k = 0; k < tmp.val; k++) {
						if(j + k >= 17) break INX;
						if(s[j + k] != -1) continue IN;
					}
					for(int k = 0; k < tmp.val; k++) {
						s[j + k] = tmp.num;
						at[j + k] = 17 * (tmp.num % 2) + 3 * (tmp.num % 3) + 19;
					}
					que.poll();
					continue INX;
				}
				break INX;
			}
			ArrayDeque<Data> tmp = new ArrayDeque<Data>();
			while(!que.isEmpty()) {
				list[que.peek().num]++;
				tmp.add(que.poll());
			}
			while(!tmp.isEmpty()) {
				que.add(tmp.poll());
			}
			
		}
		while(sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(list[n]);
		}
	}
	static class Data {
		int num;
		int val;
		Data(int a, int b) {
			num = a;
			val = b;
		}
	}
}

Measured memory_bytes: 18380
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>//cout<<"test 1"<<endl;
#include<algorithm>
#include<iostream>
#include<iterator>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
int m;
using namespace std;
int main()
{
    long long int x,a[3],j,i,n=0,m=0,t,p,q;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1])
    {
        if(a[0]!=a[2])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
          cout<<"No"<<endl;
        }

    }
    else if(a[1]==a[2])
    {
       if(a[0]!=a[2])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
          cout<<"No"<<endl;
        }
    }
    else
    {
      cout<<"No"<<endl;
    }

}



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

void changeChar(string &str, char from, char to) {
  for (char &ch : str) {
    if (ch == from) {
      ch = to;
    }
  }
  return;
}

void addStr(unordered_set<string> &normal, string str) {
  for (char &ch : str) {
    ch++;
  }
  normal.insert({"a" + str});
  for (char &ch : str) {
    ch--;
  }
  bool marked[26] = {false};
  for (int i = 0; i < str.size(); i++) {
    char ori = str[i];
    if (marked[ori - 'a']) continue;
    marked[ori - 'a'] = true;
    string temp = str;
    changeChar(temp, ori, 'z');
    for (char ch = ori - 1; ch >= 'a'; ch--) {
      changeChar(temp, ch, ch + 1);
    }
    changeChar(temp, 'z', 'a');
    normal.insert("a" + temp);
  }
}

int main() {
  int N;
  cin >> N;
  unordered_set<string> normal;
  normal.insert("a");
  for (int i = 2; i <= N; i++) {
    unordered_set<string> next;
    for (const string &str : normal) {
      addStr(next, str);
    }
    swap(normal, next);
  }
  set<string> order(normal.begin(), normal.end());
  for (const string &str : order) {
    cout << str << endl;
  }
  return 0;
}


Measured memory_bytes: 17456
fun main(args: Array<String>) {
    val S = readLine()!!;
    val S3 = S.toString()

    if (S3.indexOf("RRR") >= 0) {
        println(3)
      	return 
    }
    if (S3.indexOf("RR") >= 0) {
        println(2)
      	return 
    }
    if (S3.indexOf("R") >= 0) {
        println(1)
      	return 
    }

    println(0)
  	return 
}

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

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

  while (n--) {
    int t;
    vector<int> athletic;
    int up = 0, down = 0;
    cin >> t;
    for (int i = 0; i < t; i++) {
      int tmp;
      cin >> tmp;
      athletic.push_back(tmp);
    }

    for (int i = 1; i < t; i++) {
      int tmp = athletic[i] - athletic[i-1];
      if (tmp > 0) {
        up = max(up, tmp);
      } else {
        tmp *= -1;
        down = max(down, tmp);
      }
    }

    cout << up << " " << down << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector<char>c(100);
int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int C, A, N, ans = 0;
		cin >> C >> A >> N;
		for (int i = 0; i <= 1000; i++) {
			for (int j = 0; j <= 1000; j++) {
				int c = C;
				int a = A;
				int n = N;
				c -= i; a -= i; n -= i;
				c -= j * 2; a -= j;
				if (c >= 0 && a >= 0 && n >= 0) {
					ans = max(ans,i + j + c / 3);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;

ll A[100][100];

int main() {
	ll n, k;
	cin >> n >> k;
	ll d;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			int temp;
			cin >> temp;
			A[i][temp - 1] = 1;
		}
	}
	int count = 0;

	for (int i = 0; i < n; i++) {
		bool flag = true;
		for (int j = 0; j < k; j++) {
			if (A[j][i] == 1) {
				flag = false;
				break;
			}
		}
		if (flag) {
			count++;
		}
	}

	cout << count;
}

Measured memory_bytes: 3620
#define Oo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
typedef long long ll;
int main()
{
      Oo
      ll x, k, d;
      cin>>x>>k>>d;
      x=abs(x);
      ll temp=x/d;
      if (temp>=k)cout << abs(x-k*d) << endl;
      else
      {
            k-=temp;
            x=x-temp*d;
            if (k%2==0)cout << x << endl;
            else cout << abs(d-x) << endl;
      }
	return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<cstdlib>
#include<math.h>

using namespace std;

int main(){
    long long k, a, b;
    cin >> k >> a >> b;

    bool haveEn = false;
    unsigned long long bisket = 1;


    for(int i=0;i<k;i++){
        if(b-a>1){
            if(haveEn){
                haveEn = false;
                bisket += b;
            }
            else if(i<k-1 && bisket>=a){
                haveEn = true;
                bisket -= a;
            }
            else bisket++;
        }else bisket++;
        //cout << bisket << endl;
    }

    cout << bisket << endl;
}


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

a = -1
b = -1
c = -1

for i in range(n + 1):
  for t in range(i, n + 1):
    sum = 10000 * i + 5000 * (t - i)  + 1000 * (n - t)
    if sum == y:
      a = i
      b = t - i
      c = n - t
      
print(a, b, c)

Measured memory_bytes: 3060
k, s = map(int, input().split())
n = 0
for i in range(k + 1):
    if (s-i)/2 > k:
        continue
    elif i > s:
        break
    for j in range(k+1):
        z = s - i - j
        if 0<= z <= k:
            n += 1
print(n)


Measured memory_bytes: 2940
import Data.List

replace :: String -> String -> String -> String
replace _ _ [] = []
replace patA patB str@(s:sx) =
  if isPrefixOf patA str
  then replace patA patB (patB ++ (drop (length patA) str))
  else s:(replace patA patB sx)

ans :: [String] -> [String]
ans inputs =
  map (replace "Hoshino" "Hoshina") inputs

main = do
  c <- getContents
  let i = drop 1 $ lines c
      o = ans i
  mapM_ putStrLn o

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

using i64 = long long;

const int N = 2e5 + 5;

int v[N];

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant = 0;
	int n, t, mn;
	bool ok;

	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	ok = true;
	for (int i = 1; i <= n && ok; ++i)
		ok&= v[i] < i;

	if (!ok) {
		cout << -1 << endl;
		return 0; }

	ant = v[n];
	mn = v[n];
	for (int i = n - 1; i >= 1; --i) {
		mn-= 1;
		ok&= v[i] >= mn;
		if (v[i] != v[i + 1] - 1)
			ant+= v[i];
		mn = max(mn, v[i]); }

	if (!ok)
		ant = -1;
	cout << ant << endl;

	return 0; }


Measured memory_bytes: 1024
# the number of inputs
N = int(input())
# each length of edges
Ls= list(map(int, input().split()))

# searching largest one
largestL = 0
largestIndex = 0

# straightforward way
for i in range(N):
  if Ls[i] > largestL:
    largestL = Ls[i]
    largestIndex = i

sumOfSmallLs = 0
for i in range(N):
  if i != largestIndex:
    sumOfSmallLs += Ls[i]

if sumOfSmallLs > largestL:
  print('Yes')
else:
  print('No')


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

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

def main():
    mod=10**9+7
    from collections import deque
    
    N=I()
    A2=[0]*N
    for i in range(N):
        A2[i]=I()
        
    A2.sort(reverse=True)
    
    A=deque()
    B=deque()
    for i in range(N):
        A.append(A2[i])
        B.appendleft(A2[i])
    
    
    ans=0
    L=[0]*(2*N+1)
    L[N]=A.pop()
    l=N-1
    r=N+1
    
    for i in range(N-1):
        if i%4==0:
            a=A.popleft()
            L[l]=a
            ans+=abs(L[l]-L[l+1])
            l-=1
        elif i%4==1:
            a=A.popleft()
            L[r]=a
            ans+=abs(L[r]-L[r-1])
            r+=1
        elif i%4==2:
            a=A.pop()
            L[l]=a
            ans+=abs(L[l]-L[l+1])
            l-=1
        else:
            a=A.pop()
            L[r]=a
            ans+=abs(L[r]-L[r-1])
            r+=1
            
    ###
    ans2=0
    L=[0]*(2*N+1)
    L[N]=B.pop()
    l=N-1
    r=N+1
    
    for i in range(N-1):
        if i%4==0:
            a=B.popleft()
            L[l]=a
            ans2+=abs(L[l]-L[l+1])
            l-=1
        elif i%4==1:
            a=B.popleft()
            L[r]=a
            ans2+=abs(L[r]-L[r-1])
            r+=1
        elif i%4==2:
            a=B.pop()
            L[l]=a
            ans2+=abs(L[l]-L[l+1])
            l-=1
        else:
            a=B.pop()
            L[r]=a
            ans2+=abs(L[r]-L[r-1])
            r+=1
    ###        
    
    print(max(ans,ans2))
            
            
            
        
    
    
    

main()


Measured memory_bytes: 53596
s=input()
s1=s[::2]
s2=s[1::2]
for i in s1:
    if i=='R' or i=='U' or i=='D':
        pass
    else:
        print("No")
        exit(0)
for i in s2:
    if i=='L' or i=='U' or i=='D':
        pass
    else:
        print("No")
        exit(0)
print("Yes")

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

using ll = long long;

bool is_all_same(const string &s) {
  for (int i = 1; i < s.size(); i++) {
    if (s.at(0) != s.at(i)) {
      return false;
    }
  }
  return true;
}

int solve(const string &s) {
  char pre_char = '+';
  int count = 0;
  int num_to_rewrite = 0;
  for (char c : s) {
    if (c == pre_char) {
      count++;
      if(count % 2 == 0) {
        num_to_rewrite++;
      }
    } else {
      pre_char = c;
      count = 1;
    }
  }
  return num_to_rewrite;
}

int main() {
  string S;
  cin >> S;
  int K;
  scanf("%d", &K);

  if(is_all_same(S)) {
    printf("%lld", (ll)S.size() * (ll)K / 2LL);
    return 0;
  }
  
  string SS = S + S;

  int first = solve(S);
  int second = solve(SS);
  int diff = second - first;

  if (K == 1) {
    printf("%d", first);
  } else {
    printf("%lld", (ll)first + ((ll)diff * (ll)(K - 1)));
  }

  return 0;
}

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

using namespace std;

int main(void) {
        int N, T, L, B;
        double dp[128][128];

        while(cin >> N >> T >> L >> B && N+T+L+B) { //?????????????????????????????????0 0 0 0(???????????\???)?????????????????????
                int lose[128] = {0}, back[128] = {0};

                //?????????
                for(int x, i = 0; i < L; i++) {
                        cin >> x;
                        lose[x] = 1;
                }
                //?????????
                for(int x, i = 0; i < B; i++) {
                        cin >> x;
                        back[x] = 1;
                }
                //?????????
                for(int i = 0; i <= T; i++) {
                        for(int j = 0; j <= N; j++) {
                                dp[i][j] = 0;
                        }
                }
                dp[0][0] = 1.0;

                /**
                 * ?????????????????????????????????????????????????????????????????????????¢???????????´????????????????
                 * ??????????????????????¢????????????¨??????????¬??????????????¢?????????????????????????
                 * lose?????¨???????????????????????????????????????????¢?????????????????????????????¬???????????¶???????????????????
                 * back?????¨?????????0?????????????¢????????¶???????
                 **/
                for (int i = 1; i <= T; i++) {
                        for (int j = 0; j < N; j++) {
                                double p = dp[i - 1][j];
                                for (int k = 1; k <= 6; k++) {
                                        int dst = (j + k <= N ? j + k : 2 * N - j - k);
                                        if (lose[dst]) dp[i+1][dst] += p / 6;
                                        else if (back[dst]) dp[i][0] += p / 6;
                                        else dp[i][dst] += p / 6;
                                }

                        }
                }

                double ret = 0;
                for (int i = 0; i <= T; i++) ret += dp[i][N];

                printf("%f\n", ret);
        }

}

Measured memory_bytes: 3328
// ABC121_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M, C;
    cin >> N >> M >> C;
    vector<ll> vec(M), code(M);
    REP(i, M) cin >> vec[i];
    
    ll res = 0;
    REP(i, N) {
        ll sum = C;
        REP(j, M) {
            cin >> code[j];
            sum += vec[j]*code[j];
        }
        if (sum > 0) res++;
    }
    
    cout << res << "\n";
    
    return 0;
}

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

P f(int x){
  int a=x%10;
  int b=0;
  while(x){
    b=x;
    x/=10;
  }
  return P(a,b);
}

int main() {
  int n;
  cin >> n;
  ll ans=0;
  map<P,int> freq;
  for (int i=1;i<=n;i++){
    P p=f(i);
    freq[p]++;
  }
  for (int i=1;i<=n;i++){
    P p=f(i);
    P q(p.second,p.first);
    ans+=freq[q];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// ref: (https://beta.atcoder.jp/contests/agc026/submissions/2843156)

#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    map<string, int> mp;

    for (int t = 0; t < (1 << n); t++) {
        string a = "", b = "";
        for (int i = 0; i < n; i++) {
            if (t & (1 << i)) {
                a += s[i];
            } else {
                b += s[i];
            }
        }
        string c = a + "." + string(b.rbegin(), b.rend());
        mp[c]++;
    }

    long long ans = 0;
    for (int t = 0; t < (1 << n); t++) {
        string a = "", b = "";
        for (int i = 0; i < n; i++) {
            if (t & (1 << i)) {
                a += s[i + n];
            } else {
                b += s[i + n];
            }
        }
        string c = string(a.rbegin(), a.rend()) + "." + b;
        ans += mp[c];
    }

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

Measured memory_bytes: 67968
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ")
  val q = StdIn.readLine().toInt

  (0 until q).foreach { _ =>
    val qa = StdIn.readLine().split(" ").map(_.toInt)
    val buff = a.slice(qa(0), qa(1)).reverse
    buff.copyToArray(a, qa(0), qa(1))
    /*    
      buff.zipWithIndex.foreach{ case (s, index) =>
      a(qa(0) + index) = s
    }*/
  }
  println(a.mkString(" "))

}


Measured memory_bytes: 47888
#include <stdio.h>

int main(void){
    int i=0;
    long int count=0;
    scanf("%d",&i);
    for(long int j=1;j<=i;j++){
        if(j%3==0&&j%5==0){
            //printf("Fizz");
        }else if(j%3==0){
            //printf("Buzz");
        }else if(j%5==0){
            //printf("FizzBuzz");
        }else{
            //printf("%ld",j);
            count=count+j;
        }
    }
    printf("%ld",count);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int N;
    cin>>N;
    if(N<10){
        cout<<N<<endl;
    }else if(N<100){
        cout<<9<<endl;
    }
    else if(N<1000){
        cout<<9+N-99<<endl;
    }
    else if(N<10000){
        cout<<9+900<<endl;
    }else if(N<100000){
        cout<<9+900+N-9999<<endl;
    }
    else{
        cout<<90909<<endl;
    }
}


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

namespace ABC136A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

             s = c - (a - b);

            if (a - b < c)
                Console.WriteLine(s);

            else

                Console.WriteLine("0");

             Console.ReadKey();

        }
    }
}


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

public class Main {

	public static void main(String[] args)
	{
                        Scanner in = new Scanner(System.in);
			int n = in.nextInt();
			int[] tab = new int[n];
			int cptA = 0, cptB = 0;
			for(int i=0; i<n; i++)
			{
				tab[i] = in.nextInt();
			}
			for(int i = 0; i < n ; i++){
				int temp = tab[i];
				for(int j=0; j<n; j++)
				{
					if(tab[i] > tab[j])
					{
						temp = tab[j];
						tab[j] = tab[i];
						tab[i] = temp;
					}
				}
			}
			for(int i=0; i<n; i++)
			{
				if(i % 2 == 0)
					cptA += tab[i];
				else
					cptB += tab[i];
			}
			int ans = cptA - cptB;
			System.out.println(ans);
}}

Measured memory_bytes: 23764
def main():
    n = int(input())
    A,B,C = [sorted(list(map(int,input().split()))) for i in range(3)]
    ans = 0
    for b in B:
        ans += low(A,b)*(n-high(C,b))
    print(ans)


def low(A,key):
    left,right = -1,len(A)
    while right - left > 1:
        mid = (left+right)//2
        if A[mid] >= key:
            right = mid
        else:
            left = mid
    return left+1


def high(C,key):
    left,right = -1,len(C)
    while right - left > 1:
        mid = (left+right)//2
        if C[mid] <= key:
            left = mid
        else:
            right = mid
    return right


if __name__ == "__main__":
    main()


Measured memory_bytes: 24180
#include <iostream>

using namespace std;

int main(){
  int a[1000000] = {0}, b[1000000] = {0}, n;


  cin >> n;

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


  if(n % 2 == 0){
    for(int i = 0;i < n/2;i++){
        b[i] = a[n-1-i*2];
        b[i+n/2] = a[i*2];
    }
  } else{
    for(int i = 0;i <= n/2;i++){
      b[i] = a[n-1-i*2];
      b[i+n/2+1] = a[i*2+1];
    }
  }

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

  cout << endl;

  return 0;
}


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

bool is_prime(int x){
    if(x<=1) return false;
    for(int i = 2; i*i<=x;i++)
        if(x %i == 0) return 0;
    return 1;
    
}
int main(){
    int x;
    cin >> x;
    int p  = x;
    while (!is_prime(p))p++;
    cout  << p << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    int a[100010];
    map<int, int, greater<>> mp;
    long long int sum = 0;

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a] += 1;
    }

    while (m) {
        auto x = mp.begin();
        int nsub = x->first / 2;
        mp[nsub] += 1;
        x->second -= 1;
        if (x->second == 0) {
            mp.erase(x);
        }
        m--;
    }

    auto x = mp.begin();

    while (x != mp.end()) {
        if (x->second > 0) {
            sum += x->first;
            x->second -= 1;
        }
        else {
            x++;
        }
    }

    cout << sum << endl;
}


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	ll n;
	cin >> n;

	vector < ll > v(n + 5);
	v[0] = 2;
	v[1] = 1;
	for(int i = 2; i < n + 1; ++i) {
		v[i] = v[i - 1] + v[i - 2];
	}

	cout << v[n];
	return 0;
}

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

ll const mod = (ll)1e12;
#define max  1000

ll mons(ll h){
    ll i = 1 ; ll ans = 0;
    while(i<=h){
        ans += i; i = i*2;
    }
    return ans;
}
int main(){
    ll h; 
    cin>>h;
    ll ans = mons(h);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> w(n);
  rep(i, 0, n) cin >> w[i];

  int l = 0, r = accumulate(w.begin(), w.end(), 0);
  int ans = 1e9;
  rep(i,0,n){
    l+=w[i];
    r-=w[i];
    chmin(ans, abs(l-r));
  }

  cout<<ans<<endl;
}


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

int main(){
    int N; cin >> N;
    vector<string> W(N);
    rep(i, N) cin >> W[i];

    bool flag = true;
    rep(i, N)rep(j,N){
        if(i != j && W[i] == W[j]) flag = false;
    }

    rep(i, N-1){
        if(W[i+1][0] != W[i][W[i].length()-1]) flag = false;
    }

    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  ll k;
  cin >> s >> k;

  bool flg = true;
  char c;
  for (int i = 0; i < s.size() && i < k; ++i)
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }

  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
$UnionFindTree = Array.new(10001)
0.upto(10001) do |i|
  $UnionFindTree[i] = i
end

# todo: パス圧縮追加する
def root(x)
  if ($UnionFindTree[x] == x)
    x
  else
    $UnionFindTree[x] = root($UnionFindTree[x])
    $UnionFindTree[x]
  end
end

def unite(x, y)
  $UnionFindTree[root(x)] = root(y)
end

def same(x, y)
  puts (root(x) == root(y) ? "1" : "0")
end

if __FILE__ == $0
  n, q = gets.split.map(&:to_i)
  q.times do
    com, x, y = gets.split.map(&:to_i)
    com.zero? ? unite(x, y) : same(x, y)
  end
end

Measured memory_bytes: 7156
[w,h,n]=[int(x) for x in raw_input().split()]
[wn,hn]=[int(x) for x in raw_input().split()]
ans=0
for i in range(n-1):
    [wf,hf]=[int(x) for x in raw_input().split()]
    if (wf-wn)*(hf-hn)>0:
        a=min(abs(wf-wn)+abs(hf-(hn+(wf-wn))),abs(hf-hn)+abs(wf-(wn+(hf-hn))))
        ans+=a
    else:
        a=abs(wf-wn)+abs(hf-hn)
        ans+=a
    [wn,hn]=[wf,hf]
    #print a
print ans

Measured memory_bytes: 4252
import collections
n=int(input())
v=list(map(int,input().split()))
ve=v[0::2]
vo=v[1::2]

ce=collections.Counter(vo).most_common(2)
co=collections.Counter(ve).most_common(2)

if ce[0][0] != co[0][0]:
    ans = len(v)-ce[0][1]-co[0][1]
elif len(ce)==1 and len(co)==1:
    ans = len(v)//2
elif len(ce)==1:
    ans = len(v)//2 - co[1][1]
elif len(co)==1:
    ans = len(v)//2-ce[1][1]
else:
    ans = len(v)-max(ce[0][1]+co[1][1],ce[1][1]+co[0][1])
print(ans)

Measured memory_bytes: 15972
import java.util.*;
public class Main {

		static void solve() {
			Scanner sc = new Scanner(System.in);
			String s = sc.nextLine();
			int min =Integer.MAX_VALUE;
			int res = 0;
			for(int i = 0;i<s.length()-2;i++) {
				int num = nums(s,i)*100+nums(s,i+1)*10+nums(s,i+2);
					if(num>753) {
						if(num-753<min) {
							min = Math.min(num-753, min);
								}
						}
						if(num==753) {
							min = 0;
							break;
						}
						if(num<753){
							min = Math.min(753-num, min);
						}
				}
			System.out.println(min);
			sc.close();
		}
		public static int nums(String s, int index) {
			return Integer.parseInt(""+s.charAt(index));
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 21204
#include<stdio.h>
#define abs(x)  ((x) < 0 ? -(x) : (x))
int main(){
  int hotels[100002], n, m, i, res = 0, now = 1;
  hotels[1] = 0;
  scanf("%d%d",&n ,&m);
  for(i = 2;i <= n;i++){
    int si;
    scanf("%d", &si);
    hotels[i] = hotels[i - 1] + si;
  }
  for(i = 0;i < m;i++){
    int ai;
    scanf("%d", &ai);
    res += abs(hotels[now] - hotels[now + ai]);
    now += ai;
    res %= 100000;
  }
  printf("%d\n", res);
  return 0;
}

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

int main(){
    int a,b;
    std::cin >> a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)std::cout << "Alice" << std::endl;
    else if(a==b)std::cout << "Draw" << std::endl;
    else std::cout << "Bob" << std::endl;
    
}


Measured memory_bytes: 384
#include <iostream>
#include <list>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin>>n;
  list<unsigned long long int> list;
  unsigned long long int tmp;
  for (int i=0; i<n; i++) {
    cin>>tmp;
    list.push_back(tmp);
  }
  double digit = 0;
  unsigned long long int mul=1;
  for (auto it=list.begin(); it!=list.end(); ++it) {
    //cerr<<*it<<" "<<log10(*it)<<endl;
    if (*it == 0) {
      cout<<"0"<<endl;
      return 0;
    }
    digit += log10(*it);
    mul *= *it;
  }
  if (digit>18 || mul > 1000000000000000000) {
    cout<<"-1"<<endl;
    return 0;
  }
  cerr<<"digit:"<<digit<<endl;
  cout<<mul<<endl;
  return 0;
}

Measured memory_bytes: 7120
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

	    long A=gl();
	    long B=gl();
	    long C=gl();
	    long X=gl();
	    long Y=gl();

	    long a1=A*X+B*Y;
	    long a2=Math.max(X, Y)*C*2;
	    long a3=Math.min(X, Y)*C*2;
	    if(X>Y) {
	    	a3+=(X-Y)*A;
	    } else {
	    	a3+=(Y-X)*B;
	    }

		System.out.println(Math.min(a1, Math.min(a2, a3)));
	}

	// 文字列として入力を取得
	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: 35588