akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e16;
#define int long long

const int MAX_N = 10;




signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	int x; cin >> x;
	int now = 0;
	for (int i = 1; ; i++) {
		now += i;
		if (x <= now) {
			cout << i << endl; return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <cstdio>
#include <map>
#include <deque>
#include <algorithm>
using namespace std;
typedef string key;

char b1[99],b2[99];
void main2(int n){
	map<key,deque<pair<key,long long>>>m;
	for(;n;n--){
		int d;
		scanf(" 1 %s = 10^%d %s",b1,&d,b2);
		string s1=b1,s2=b2;
		m[s1].emplace_back(s2,d);
		m[s2].emplace_back(s1,-d);
	}
	for(;!m.empty();){
		auto s=m.begin()->first;
		deque<pair<key,long long>>st={{s,0}};
		map<key,long long>memo={{s,0}};
		for(;!st.empty();){
			auto p=*st.begin();st.pop_front();
			auto cur=p.first;long long d=p.second;
			memo[cur]=d;
			for(auto &e:m[cur]){
				if(memo.find(e.first)==memo.end()){
					st.emplace_back(e.first,d+e.second);
				}else if(memo[e.first]!=d+e.second){
					puts("No");
					return;
				}
			}
		}
		for(auto &e:memo)m.erase(m.find(e.first));
	}
	puts("Yes");
}
int main(){int n;for(;~scanf("%d",&n)&&n;)main2(n);}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int A, B;

int main() {
    cin >> A >> B;
    cout << max(max(A+B, A-B), A*B) << endl;
}


Measured memory_bytes: 256
#include<iostream>

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

	long int n, max = 2000000000;
	std::cin >> n;
	for(int i = 0; i < n; i++){
		long int a, b;
		std::cin >> a >> b;
		if(a+b < max) {
			max = a+b;
		}
	}
	std::cout << max  << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int K, S;
    cin >> K >> S;

    int res = 0;

    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            int z = S - (x + y);
            if (z <= K && z >= 0)
            {
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	
	vector<int> p(N);
	for (int i = 0; i < N; i++) cin >> p[i];

	vector<int> flag(N);
	for (int i = 0; i < N; i++) flag[i] = (p[i] == i + 1);

	flag.emplace_back(0); //番兵
	int ans = 0, cnt = 0;
	for (int i = 0; i <= N; i++) {
		if (flag[i]) cnt++;
		else {
			if (cnt) ans += max(1, (cnt + 1) / 2);
			cnt = 0;
		}
	}

	cout << ans << "\n";

	return 0;
}

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

int solve() {
    int N, a;
    cin >> N;
    vector<vector<int>> G(N);
    for ( int i = 1; i < N; i++ ) {
        cin >> a;
        a--;
        G[i].push_back(a);
        G[a].push_back(i);
    }

    function<int(int,int)> dfs = [&](int v, int p) -> int {
        vector<int> dep;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            dep.push_back(dfs(u, v));
        }
        sort(dep.begin(), dep.end(), greater<>());
        int m = 0;
        for ( int i = 0; i < dep.size(); i++ ) {
            m = max(m, dep[i] + i + 1);
        }
        return m;
    };
    
    int ans = dfs(0,-1);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
 
int main(){
    int a,b;
    cin >> a >> b;
    while (a != 0 && b != 0){
        for(int i = 0; i < a; i++){
            for(int j = 0; j < b; j++){
                if((i+j)%2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
               
            }
            cout << endl;
        }
        cout << endl;
        cin >> a >> b;
    }
     
}


Measured memory_bytes: 3092
S = input()
sep = [0]
i=0
for i in range(len(S)-1):
    if S[i]=='<' and S[i+1]=='>': sep.append(i+1)
sep.append(i+2)

S += 'X'
ans = 0
center = 0
for i in range(len(sep)-1):
    s = S[sep[i]: sep[i+1]]
    l_max = s.count('>')
    ans += max(center, l_max)
    ans += l_max*(l_max-1)//2

    r_max = s.count('<')
    ans += r_max*(r_max-1)//2
    center = r_max

ans += center
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  int sum=0;
  map<int,int> mp;
  while(N--){
    int a;
    cin>>a;
    mp[a]++;
    sum+=a;
  }
  int Q;
  cin>>Q;
  while(Q--){
    int a,b;
    cin>>a>>b;
    sum+=mp[a]*(b-a);
    mp[b]+=mp[a];
    mp.erase(a);
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 7576
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vec_i v(n+1);
	rep(i, n){
		int a;
		cin >> a;
		v[a] = i+1;
	}
	rep(i, n){
		cout << v[i+1] << " ";
	}
	cout << endl;

}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 100100;

int N;
int arr[MAX_N+1];
int idx[MAX_N+1];

struct SEG{
	struct NODE{
		int l, r;
		int sum;
	};
	vector<NODE> seg;
	int SZ;
	void add(){
		seg.pb({-1, -1, 0});
	}
	void Init(int x){
		SZ = x; add();
		init(0, 1, SZ);
	}
	void init(int idx, int s, int e){
		if(s==e)	return;
		seg[idx].l = seg.size(); add();
		seg[idx].r = seg.size(); add();
		init(seg[idx].l, s, (s+e)/2);
		init(seg[idx].r, (s+e)/2+1, e);
	}
	void Update(int x){
		update(0, 1, SZ, x);
	}
	void update(int idx, int s, int e, int x){
		seg[idx].sum++;
		if(s==e)	return;
		if(x<=(s+e)/2)	update(seg[idx].l, s, (s+e)/2, x);
		else	update(seg[idx].r, (s+e)/2+1, e, x);
	}
	int Sum(int x, int y){
		return sum(0, 1, SZ, x, y);
	}
	int sum(int idx, int s, int e, int x, int y){
		if(x<=s && e<=y)	return seg[idx].sum;
		else if(x>e || y<s)	return 0;
		return sum(seg[idx].l, s, (s+e)/2, x, y) + sum(seg[idx].r, (s+e)/2+1, e, x, y);
	}
};

SEG Seg;

int right(int x, int y){
	int s = x, e = N, m;
	while(s<e){
		m = (s+e)/2+1;
		if(Seg.Sum(x, m)<=y){
			s = m;
		}else{
			e = m-1;
		}
	}
	return s;
}

int left(int x, int y){
	int s = 1, e = x, m;
	while(s<e){
		m = (s+e)/2;
		if(Seg.Sum(m, x)<=y){
			e = m;
		}else{
			s = m+1;
		}
	}
	return s;
}

ll ans=0;

int main(){
	cin>>N;
	Seg.Init(N);
	for(int i=1; i<=N; i++){
		scanf("%d", &arr[i]);
		idx[arr[i]] = i;
	}
	Seg.Update(idx[N]);
	for(int i=N-1; i>=1; i--){
		int now = idx[i];
		if(Seg.Sum(1, now-1)>=1){
			int k1 = left(now, 1);
			int k2 = right(now, 0);
			int k3 = left(now, 0);
			//cout<<k1<<" "<<k2<<" "<<k3<<endl;
			ans += (ll)i * (ll)(k3-k1) * (k2 - now + 1);
		}if(Seg.Sum(now+1, N)>=1){
			int k1 = left(now, 0);
			int k2 = right(now, 0);
			int k3 = right(now, 1);
			//cout<<k1<<" "<<k2<<" "<<k3<<endl;
			ans += (ll)i * (ll)(k3-k2) * (now - k1 + 1);
		}
		Seg.Update(idx[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4980
#![allow(non_snake_case)]

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let n: usize = sc.read();
        if n == 0 { break; };
        let W: usize = sc.read();
        let H: usize = sc.read();
        let mut g = vec![vec![0i32; W+1]; H+1];
        for _ in 0..n {
            let x: usize = sc.read();
            let y: usize = sc.read();
            g[y][x] += 1;
        }
        for i in 0..H+1 {
            for j in 0..W {
                g[i][j+1] += g[i][j];
            }
        }
        for i in 0..H {
            for j in 0..W+1 {
                g[i+1][j] += g[i][j];
            }
        }
        let mut ans = 0i32;
        let s: usize = sc.read();
        let t: usize = sc.read();
        for i in t..H+1 {
            for j in s..W+1 {
                if ans < g[i][j] - g[i-t][j] - g[i][j-s] + g[i-t][j-s] {
                    ans = g[i][j] - g[i-t][j] - g[i][j-s] + g[i-t][j-s];
                }
            }
        }
        println!("{}", ans);
    }
}



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

typedef long long ll;

int main()
{
   ll n;
   cin>>n;
   map<ll,ll ,greater<ll> > m;
   for(int i=0;i<n;i++)
   {
       ll temp;
       cin>>temp;
       m[temp ] ++;
   }
   ll side1 =0 , side2 = 0;
   auto it = m.begin();
   for( ;it!= m.end() ;it++ )
    {
       if( it->second >= 4 && side1 ==0 && side2 == 0 )
       {
           side1 = side2 = it->first;
           break;

       }
       if( side1 == 0 && it->second >= 2)
       {
           side1 = it->first;
           continue;
       }
       if( side1 != 0 && side2 == 0 && it->second >= 2)
       {
           side2 = it->first;
           break;
       }
    }
   cout<<side1 * side2 ;
}

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

int main()
{
    string a,b;
    cin >> a >> b;

    int l,m,c=0;
    l = a.length();
    m = b.length();

    for(int i=0;i<l;i++)
    {
        if(a[i]==b[i])
            c = c+1;
        else
            c = 0;
    }

    if(c==l)
    {
        if(m==l+1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


bool IsPrime(ll num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2){
    if(num % i == 0) return false;
  }
  return true;
}

int main() {
    ll x; cin >> x;
    Rep(i, x, INF) {
        if(IsPrime(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

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

vector<vector<int>> adj;
vector<int> dp;
vector<bool> vis;

void solve(int u)
{
	vis[u]=true;
	
	for(auto x:adj[u])
	{
		if(!vis[x])
		  solve(x);
	  dp[u]=max(dp[u],1+dp[x]);	  
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	adj.resize(n+1);
	dp.resize(n+1,0);
	vis.resize(n+1,false);
	
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
	
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		  solve(i);
	}
	cout<<*max_element(dp.begin(),dp.end())<<endl;
}

Measured memory_bytes: 11932
# AOJ 0181 Bookshelf
# Python3 2018.6.23 bal4u

INF = 0x7fffffff
while 1:
	m, n = map(int, input().split())
	if m == 0: break
	dp = [[[INF for k in range(n+1)] for j in range(n+1)] for i in range(m+1)]
	w, k = [0]*(n+1), 0
	for i in range(1, n+1):
		l = int(input())
		w[i] = w[i-1]+l
		if l > k: k = l
	if n <= m:
		print(k)
		continue
	for i in range(1, n+1): dp[1][1][i] = w[i]
	for k in range(2, m+1):
		for i in range(1, n+1):
			for j in range(i, n):
				for l in range(j, n):
					if dp[k-1][i][j] < INF:
						dp[k][j+1][l+1] = min(dp[k][j+1][l+1], max(w[l+1]-w[j], dp[k-1][i][j]))
	ans = INF
	for i in range(1, n+1):
		if dp[m][i][n] < ans: ans = dp[m][i][n]
	print(ans)


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

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for(int i=0; i<n; i++)  S[i] = sc.nextInt();
        int q = sc.nextInt();
        int[] T = new int[q];
        for(int i=0; i<q; i++) T[i] = sc.nextInt();
        int ans = 0;
        for(int key:T){
            if(binarySearch(S, key)) ans++;
        }
        System.out.println(ans);

    }
    public static boolean binarySearch(int[] A, int key){
        int left = 0;
        int right = A.length;
        while(left < right){
            int mid = (left + right) /2;
            if(A[mid] == key){
                return true;
            }else if(key < A[mid]){
                right = mid;
            }else{
                left = mid + 1;
            }

        }
        return false;
    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

    }
}



Measured memory_bytes: 50592
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
    {
        LL x,y;
        cin>>x>>y;
        LL a=0;
        LL b=0;
        if(y%2!=0){
          cout<<"No"<<endl;
        }
        if(y%2==0){
          a=y/2;
          if(y%4==0) b=y/4;
          else b=(y/4)+1;

         if(x<b || x>a){
             cout<<"No"<<endl;
         }
         else cout<<"Yes"<<endl;
        }
        
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <list>
using namespace std;

int main()
{
	int n, k;
	char s[15];
	list<int> l;

	scanf("%d", &n);

	while (n--) {
		scanf("%s", s);
		if (*s == 'i') {
			scanf("%d", &k);
			l.push_front(k);
			continue;
		}
		switch (*(s + 6)) {
		case 'F':
			l.pop_front();
			break;
		case 'L':
			l.pop_back();
			break;
		default:
			scanf("%d", &k);
			for (auto i = l.begin(), e = l.end(); i != e; i++)
				if (*i == k) {
					l.erase(i);
					break;
				}
		}
	}

	int &f = l.front();
	for (int &x: l)
		printf("%s%d", (&f == &x ? "" : " "), x);
	printf("\n");
}


Measured memory_bytes: 33988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n%2==0){
    int i=n/2-1;
    int j=n/2;
    int s1=(a[i]+a[j])/2;
    int s2=(b[i]+b[j])/2;
    int ans=s2-s1+1;
    ans*=2;
    ans--;
    if((a[i]+a[j])%2==1)ans--;
    if((b[i]+b[j])%2==1)ans++;
    cout<<ans<<endl;
  }
  else{
    int i=n/2;
    int ans=b[i]-a[i]+1;
    cout<<ans<<endl;
  }
  return(0);
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).cind(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug_v(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_incinity?numeric_limits<T>::incinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

const int MOD = 1000000007;

//{{{ modular algebra
template<int mod=MOD>
struct Num{
	int v;
	Num(int n):v(n){}
	Num():v(0){}
	operator int() const {return v;}
	operator long long() const {return v;}
	template<class T>
	Num operator =(int n){v=n;return *this;}

	template<class T>
	inline void operator *=(const T &a) {
		v = (v*(long long)a)%mod;
	}
	template<class T>
	inline Num operator *(const T &a) {
		Num n(*this);n*=a;
		return n;
	}
	template<class T>
	inline void operator+=(const T &a){
		v+=(int)a;
		if(v>=mod)v-=mod;
		//	assert(0<=v and v<mod);
	}
	template<class T>
	inline Num operator+(const T &a){
		Num n(*this);n+=a;
		return n;
	}
	inline Num operator -(){
		if(v==0)return 0;
		else return Num(mod-v);
	}
	template<class T>
	inline void operator -=(const T &a){
		v-=(int)a;
		if(v<0)v+=mod;
	}
	template<class T>
	inline Num operator -(const T &a){
		Num n(*this);n-=a;
		return n;
	}
#ifdef __GCD_H
	inline Num inv(){
		return Num(invMod(this->v,mod));
	}
	template<class T>
	inline void operator /=(const T &a){
		(*this)*=invMod((int)a,mod);
	}
	template<class T>
	inline Num operator /(const T &a){
		Num n(*this);n/=a;
		return n;
	}
#endif
};

template<class T, int mod>
T& operator <<(T &os, const Num<mod> &n){
	os<<(int)n.v;
	return os;
}

template<class T, int mod>
T& operator >>(T &is, Num<mod> &n){
	is>>n.v;
	return is;
}
//}}}
typedef Num<MOD> mod_int;

Int N;
string S;

void solve(){
	vector<int> ct(26,0);
	REP(i,N)ct[S[i]-'a']++;
	mod_int ans = 1;
	REP(i,26)ans *= ct[i]+1;
	cout<<(ans-1)<<endl;
}

//{{{ main function
int main(){
	ios::sync_with_stdio(false);
	cin >> N;
	cin >> S;
	solve();
	return 0;
}

//}}}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    string in; cin >> in;
    int n = (int)in.size();

    bool res = (n % 2 == 1);
    res ^= (in[0] == in[n - 1]);

    cout << (res ? "First":"Second") << endl;

    return 0;
}


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

int main() {
  int a,b,c,m;
  cin >> a >> b;
  c = a+b;
  m = min(a,b);
  for (int i=0;i<c-m;i++) {
  cout << m;
    }
  cout << "" << endl;
  }


Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        a = 4 * h * n - h * N - n * N
        if a == 0:
            break
        w = int((h * n * N) / a)
        if w > 0 and 4 / N == 1 / h + 1 / n + 1 / w:
            print(h, n, w)
            exit()

Measured memory_bytes: 42576
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll A, B, N;
    in >> N >> A >> B;
    ll ans = 0;

    // solution here
    if ((B - A) % 2 == 0) {
        ans = (B - A) / 2 ;
    } else {
        ans = min(A + (B-A-1)/2, N - B + 1 + (B-A-1)/2);
    }
    out << ans << endl;
    debug(ans);
    return 0;
}

int main() {
    return run(cin, cout);
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else cout << "consonant" << endl;
}


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

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

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());
  reverse(L.begin(), L.end());

  int max = L.at(0);
  int sum = 0;

  for (int i = 1; i < N; i++) {
    sum += L.at(i);
  }

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


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  preprocess();
  int a, b, c; cin>>a>>b>>c;
  c -= (a - b);
  c = max(0, c);
  cout<<c<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	int N, K;
	ll R, S, P;
	cin >> N >> K;
	cin >> R >> S >> P;
	string str;
	cin >> str;
	ll sum = 0;

	rep(i, N) {
		if (i < K) {
			if (str.at(i) == 's') {
				sum += R;
				continue;
			}
			else if (str.at(i) == 'p') {
				sum += S;
				continue;
			}
			else {
				sum += P;
				continue;
			}
		}
		if (str.at(i) == 's' && (str.at(i - K) != 's')) {
			sum += R;
			continue;
		}
		else if (str.at(i) == 'p' && (str.at(i - K) != 'p')) {
			sum += S;
			continue;
		}
		else if (str.at(i) == 'r' && (str.at(i - K) != 'r')) {
			sum += P;
			continue;
		}
		else {
			if (str.at(i) == 's') {
				str.at(i) = '*';
			}
			if (str.at(i) == 'p') {
				str.at(i) = '*';
			}
			if (str.at(i) == 'r') {
				str.at(i) = '*';
			}
		}
	}
	cout << sum << endl;
	
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;

void add(ll& a, ll b){
  a = (a+b) % MOD;
}

void mul(ll& a, ll b){
  a = (a*b) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  string s; cin>>s;
  
  ll ans=1;
  ll r=0,g=0,b=0;
  rep(i,n*3){
    if(s[i]=='R'){
      if(g==0 && b==0){
        r++;
      }else if(g!=0 && b==0){
        if(g>r) mul(ans,g-r);
        r++;
      }else if(g==0 && b!=0){
        if(b>r) mul(ans,b-r);
        r++;
      }else{
        mul(ans,min(g,b));
        g--,b--;
      }
    }else if(s[i]=='G'){
      if(r==0 && b==0){
        g++;
      }else if(r!=0 && b==0){
        if(r>g) mul(ans,r-g);
        g++;
      }else if(r==0 && b!=0){
        if(b>g) mul(ans,b-g);
        g++;
      }else{
        mul(ans,min(r,b));
        r--,b--;
      }
    }else{
      if(r==0 && g==0){
        b++;
      }else if(r!=0 && g==0){
        if(r>b) mul(ans,r-b);
        b++;
      }else if(r==0 && g!=0){
        if(g>b) mul(ans,g-b);
        b++;
      }else{
        mul(ans,min(r,g));
        r--,g--;
      }
    }
  }
  
  reps(i,n){
    mul(ans,i);
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 720
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n, m, k;
    cin>>n>>m>>k;
    vector<ll> a(n);
    vector<ll> b(m);
    for(ll& ele: a) cin>>ele;
    for(ll& ele: b) cin>>ele;
    a.insert(a.begin(), 0ll);
    b.insert(b.begin(), 0ll);
    for(ll i=1; i<a.size(); i++){
        a[i]+=a[i-1];
    }
    for(ll i=1; i<b.size(); i++){
        b[i]+=b[i-1];
    }
    ll ans = 0;
    for(ll i=0; i<a.size(); i++){
        if(a[i]>k) break;
        ll ele = k-a[i];
        auto it = upper_bound(b.begin(), b.end(), ele);
        it--;
        ll idx = it-b.begin();
        ans = max(ans, idx+i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7988
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
int main()
{
    fast();
    int n,x=1e9+7,y;
    cin>>n;
    int a[n];
    loop(n)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(abs(a[i]-(a[n-1]+1)/2)<x){
            x=abs(a[i]-(a[n-1]+1)/2);
            y=a[i];
        }
    }
    cout<<a[n-1]<<" "<<y;
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 640
class BinaryIndexedTree():
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

from sys import stdin
input = stdin.buffer.readline

N, Q = map(int, input().split())
A = tuple(map(int, input().split()))

bit = BinaryIndexedTree(N)
res = list()

for i in range(N):
    bit.add(i + 1, A[i])

for _ in range(Q):
    q, x, y = map(int, input().split())
    if q == 0:
        bit.add(x + 1, y)
    else:
        res.append(bit.sum(y) - bit.sum(x))

print('\n'.join(map(str, res)))

Measured memory_bytes: 189256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n;
  int k;
  cin >> n;
  cin >> k;
  if (n == 0) {
    cout << 0;
    return 0;
  }
  vector<int> h(n);
  vector<int> cost(n, 0);
  for (int i = 0; i < n; ++i) cin >> h[i];
  for (int i = 1; i < n; ++i) {
    int minV = -1;
    for (int j = 1; j <= k; ++j) {
      if (i - j < 0) break;
      int c = abs(h[i] - h[i - j]) + cost[i - j];
      if (minV == -1) minV = c;
      else minV = min(c, minV);
    }
    cost[i] = minV;
  }
  cout << cost[n - 1];
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println(new Main().solve());
    }
    
    // パラメタ渡しもちゃんとクラス作るのも面倒なので手抜き
    // 必要な値はここで全部取ってしまう
    Scanner sc = new Scanner(System.in);
    // 人数
    int n = Integer.parseInt(sc.next());
    // 種類
    int m = Integer.parseInt(sc.next());
    {sc.nextLine();}
    int[][] a = new int[n][];
    {
        // a[0]は使わない
        for(int i = 0; i < n; i++) {
            int k = Integer.parseInt(sc.next());
            a[i] = new int[k];
            for(int j = 0; j < k; j++) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
    }
    
    String solve() {
        List<Integer> foods = IntStream.rangeClosed(1, m).boxed().collect(Collectors.toList());
        
        // 全員に共通する要素の数を出力
        for(int[] aa: a) {
            foods.retainAll(IntStream.of(aa).boxed().collect(Collectors.toList()));
        }
        return ""+foods.size();
    }
    
}




Measured memory_bytes: 30732
#include<iostream>
using namespace std;
long T1,T2,A1,A2,B1,B2;
main()
{
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	long X=A1*T1+A2*T2,Y=B1*T1+B2*T2;
	if(X==Y)
	{
		cout<<"infinity"<<endl;
	}
	else
	{
		long d,D;
		if(X>Y)
		{
			d=B1*T1-A1*T1;
			D=X-Y;
		}
		else
		{
			d=A1*T1-B1*T1;
			D=Y-X;
		}
		if(d<0)cout<<0<<endl;
		else if(d==0)cout<<1<<endl;
		else
		{
			long ans=1;
			d-=D;
			if(d>=0)
			{
				ans+=d/D*2;
				d%=D;
				ans+=2;
				if(d==0)ans--;
			}
			cout<<ans<<endl;
		}
	}
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる

#pragma endregion

// ABC113 B -  Palace
#define _MAX 100000
int main(void) {
	int n, i, t, a, h;
	double min=_MAX;

	scanf("%d %d %d", &n,&t,&a);

	double tmp;
	int    res=0;
	for (i = 0; i < n; i++) {
		scanf("%d", &h);
	    tmp= (double)t - (double)h * 0.006;
//		printf("%llf:", tmp);
		tmp = ((double)a < tmp) ? tmp - (double)a : (double)a - tmp;
//		printf("%llf ", tmp);
		if (tmp < min) {
			res = i+1;
			min = tmp;
		}
	}

	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1688
import java.util.Scanner;

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

        StringBuilder str = new StringBuilder(scanner.nextLine());
        int q = Integer.parseInt(scanner.nextLine());

        for(int i = 0; i < q; i++){
            String command = scanner.next();
            if(command.equals("replace")){
                int start = Integer.parseInt(scanner.next());
                int end = Integer.parseInt(scanner.next()) + 1;
                String text = scanner.next();
                str.replace(start, end, text);
            }else if(command.equals("reverse")){
                int start = Integer.parseInt(scanner.next());
                int end = Integer.parseInt(scanner.next()) + 1;
                StringBuilder sub = new StringBuilder(str.substring(start, end));
                sub.reverse();
                str.replace(start, end, sub.toString());

            }else if(command.equals("print")){
                int start = Integer.parseInt(scanner.next());
                int end = Integer.parseInt(scanner.next()) + 1;
                System.out.println(str.substring(start, end));
            }
        }

        scanner.close();
    }
}



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

int main(){
int x, a, b;
cin >> x >> a >> b;
if (abs(x - a) > abs(x - b)) {
    cout << "B" << endl;
}
else if (abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl();
    cout<<((n-1)*n)/2<<endl;
    
    return 0;   
}


 
 


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = 3;
  
  if(a == b && b == c){
    ans = 1;
  }
  else if(a == b){
    ans = 2;
  }
  else if(b == c){
    ans = 2;
  }
  else if(a == c){
    ans = 2;
  }
  
  cout << ans << endl;
  
}
  

Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    string s;
    string t;
    LL ans=0;
    cin >> s;
    cin >> t;
    for(LL i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test1 {

    class ClassMain {
        public static void Main(String[] args) {
            //Console.WriteLine("Hello World!");
            while (true) {
                String[] strs = Console.ReadLine().Split(' ');
                if (strs[0] == "0") { break; }
                char[] charsA = strs[0].ToCharArray();
                char[] charsB = strs[1].ToCharArray();
                Console.WriteLine(hit(charsA, charsB) + " " + blow(charsA, charsB));

            }
        }

       static int blow(char[] charsA, char[] charsB) {
            int blowCount = 0;
            for (int i = 0; i < 4; i++) {
                char a = charsA[i];
                for (int j = 0; j < 4; j++) {
                    char b = charsB[j];
                    if (a == b && i != j) {
                        blowCount++;
                    }
                }
            }

            return blowCount;
        }

        static int hit(char[] charsA, char[] charsB) {
            int hitCount = 0;
            for (int i = 0; i < 4; i++) {
                if (charsA[i] == charsB[i]) { hitCount++; }
            }
            return hitCount;
        }

    }


}

Measured memory_bytes: 5776
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#define mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
int n;
vector<int> adj[N];
ll dp[N][2];

void dfs(int node,int p){
	ll ans1 = 1,ans2 = 1;
	for(int i:adj[node]){
		if(i!=p){
			dfs(i,node);
			ans1 = (ans1*dp[i][0])%mod;
			ans2 = (ans2*((dp[i][1] + dp[i][0])%mod))%mod;
		}
	}
	
	dp[node][0] = ans2;
	dp[node][1] = ans1;
}

int main(){
	boost;
	cin>>n;
	
	for(int i = 0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	dfs(1,-1);
	cout<<(dp[1][0]+dp[1][1])%mod;
	return 0;
}



Measured memory_bytes: 18860
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) a=max(a,b)
const int N=17;

int n,m;
int g[N][N];
int cost[1<<N];
int dp[N][1<<N],dp2[1<<N];

int main()
{
	
	cin>>n>>m;
	while(m--)
	{
		int u,v,w;
		cin>>u>>v>>w;
		u--; v--;
		g[u][v]=g[v][u]=w;
	}
	for(int mask=0;mask<(1<<n);mask++)
	for(int u=0;u<n;u++)
	for(int v=u+1;v<n;v++)
		if(mask&(1<<u) && mask&(1<<v)) cost[mask]+=g[u][v];
	memset(dp,-1,sizeof(dp));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp[0][mask]=cost[mask];
	for(int mask=1;mask<(1<<(n-1));mask+=2)
	for(int i=0;i<n-1;i++) if(dp[i][mask]!=-1)
	for(int j=0;j<n;j++)
	{
		if(!g[i][j]) continue;
		if(mask&(1<<j)) continue;
		chmax(dp[j][mask|(1<<j)],dp[i][mask]+g[i][j]);
	}
	memset(dp2,-1,sizeof(dp2));
	for(int mask=1;mask<(1<<n);mask+=2)
		dp2[mask]=dp[n-1][mask];
	for(int mask=1+(1<<(n-1));mask<(1<<n);mask+=2) if(dp2[mask]!=-1)
	for(int i=0;i<n;i++) if(mask&(1<<i))
	{
		int _=(1<<n)-1-mask;
		for(int mask2=_;mask2>0;mask2=(mask2-1)&_)
			chmax(dp2[mask|mask2],dp2[mask]+cost[mask2|(1<<i)]);
	}
	cout<<cost[(1<<n)-1]-dp2[(1<<n)-1]<<'\n';
	
	return 0;
}

Measured memory_bytes: 9600