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

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        int[] button = new int[N+1];
        boolean[] isLighting = new boolean[N+1];
        for(int i=1; i<=N; i++){
            button[i] = Integer.parseInt(sc.next());
        }
        
        
        int num = 1;
        int ans = 0;
        while(true){
            if(isLighting[num] == true){
                System.out.println(-1);
                break;
            }else{
                isLighting[num] = true;
                num = button[num];
                ans++;
                if(num == 2){
                    System.out.println(ans);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 49604
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int main(){
    int X;
    cin >> N >> M >> X;
    int A[M];
    int sum[101] = {0};
    rep(i, M){
        cin >> A[i];
        sum[A[i]]++;
    }
    int ans = 0;
    for(int i = X; i >= 0; i--){
        ans += sum[i];
    }
    int Ans = 0;
    for(int i = X; i <= N; i++){
        Ans += sum[i];
    }
    cout << min(ans, Ans) << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

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

const int OO = (int) 2e9;
const double eps = 1e-9;

const int mod = 1e9 + 7;

int n;
string s;
int cnt[26];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> s;
	ll res = 1;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		(res *= (cnt[i] + 1)) %= mod;
	}
	res = (res - 1 + mod) % mod;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        // ボールの総数
        long n = sc.nextLong();

        // 末尾に加えた青いボールの数
        long a = sc.nextLong();

        // 末尾に加えた赤いボールの数
        long b = sc.nextLong();

        // 青いボールを加えた回数
        long num = Math.floorDiv(n, (a + b)) * a;

        // それ以外の青いボールの数
        long rem = n % (a + b);

        num += Math.min(a, rem);

        // 出力
        System.out.println(num);
    }
}

Measured memory_bytes: 21972
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]
        
    def query(self, top_num, front_num):
        self.save_data = [i for i in range(6)]
        for i in range(6):
            self.save_data[i] = self.number[i]
            
        ret = -1
        
        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break
            
        for i in range(6):
            self.number[i] = self.save_data[i]
            
        return ret



dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

num_query = int(input())
for loop in range(num_query):
    top_num, front_num = map(int, input().split())
    print("%d" %(dice.query(top_num, front_num)))



Measured memory_bytes: 6396
"""
初期状態でpiにいる数が、pi番目にたどり着けるかを判定すればよい。
unionFind木が使える
"""
N,M = map(int,input().split())
P = list(map(int,input().split()))
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
            self.size[xRoot] += self.size[yRoot]
            self.size[yRoot] = 0
        else:
            self.parents[xRoot] = yRoot
            self.size[yRoot] += self.size[xRoot]
            self.size[xRoot] = 0
tree = UnionFind(N)
for _ in range(M):
    x,y = map(int,input().split())
    tree.unite(x,y)
cnt = 0
for i in range(N):
    p = P[i]
    if tree.find(i+1)==tree.find(p):
        cnt += 1

print(cnt)

Measured memory_bytes: 90896
#include <iostream>

using namespace std;

int main()
{
    string inp;
    int cnt_j, cnt_i;

    while (cin >> inp) {

        cnt_j = cnt_i = 0;
        for (int i = 0; i < inp.size() - 2; i++) {
            if (inp.substr(i, 3) == "JOI")
                cnt_j++;
            else if (inp.substr(i, 3) == "IOI")
                cnt_i++;
        }
        cout << cnt_j << '\n' << cnt_i << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
char a[N];
int k,n;
LL dp[111][2][4];
LL dfs(int pos,int lim,int s){
  if(dp[pos][lim][s]!=-1)return dp[pos][lim][s];
  if(pos==n+1){
    if(s==k)return 1;
    return 0;
  }
  int r=lim?(a[pos]-'0'):9;
  LL ans=0;
  for(int i=0;i<=r;i++){
    if(!i){
      ans+=dfs(pos+1,lim&&(i==r),s);
    }else{
      if(s==k)break;
      ans+=dfs(pos+1,lim&&(i==r),s+1);
    }
  }
  dp[pos][lim][s]=ans;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>k;
  memset(dp,-1,sizeof dp);
  n=strlen(a+1);
  cout<<dfs(1,1,0)<<'\n';
  return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
li_p = input().split()
li_q = input().split()

li_p = tuple(li_p)
li_q = tuple(li_q)

li_min = sorted(li_p)
list_all = []

for i in itertools.permutations(li_min):
    list_all.append(i)

for i in range(0, len(list_all)):
    if list_all[i] == li_p:
        count_p = i
    if list_all[i] == li_q:
        count_q = i

print(abs(count_p - count_q))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  vi a(n);
  V<pii> b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i].se >> b[i].fi;
  sort(ALL(a));
  sort(rALL(b));
  int id = 0;
  bool fl = false;
  REP(i,m){
     REP(j,b[i].se){
       if(id>=n) fl = true;
       if(a[id]<b[i].fi) a[id++] = b[i].fi;
       else{
         fl = true;
         break;
       }
     }
     if(fl) break;
  }
  cout << accumulate(ALL(a),0LL) << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int H, A[100000 + 1] = {0}, id, k, pk, lk, rk, i;

  scanf("%d", &H);
  for(i = 1; i <= H; i++)
    scanf("%d", &A[i]);

  for(id = 1; id <= H; id++){
    printf("node %d: ", id);
    k = A[id];
    printf("key = %d, ", k);
    if(id / 2 != 0)
      printf("parent key = %d, ", A[id / 2]);
    lk = rk = id * 2;
    rk++;
    if(lk <= H){
      printf("left key = %d, ", A[lk]);
    }
    if(rk <= H){ 
      printf("right key = %d, \n", A[rk]);
    }
    if(lk > H || rk > H){
      printf("\n");
    }
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl '\n'
#define len(x) (int)x.size()
#define rep(a, b, i) for (int i = a; i < b; i++)
#define repi(a, b, i) for (int i = a; i > b; i--)
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define binary_search
#define mem(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define __                                                                                                             \
    ios_base::sync_with_stdio(false);                                                                                  \
    cin.tie(0);                                                                              
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const ld PI = 3.141592653589793;
const int MAXN = 2e5+1;

int n, k, c;
string s;


int32_t main() {
    __;
	cin >> n >> k >> c >> s;
	
	vi a;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'o') {
			a.pb(i+1);
			i += c;
			if (len(a) == k) break;
		}
	}

	vi b;
	for (int i = n-1; i >= 0; i--) {
		if (s[i] == 'o') {
			b.pb(i+1);
			i -= c;
			if (len(b) == k) break;
		}
	}

	for (int i = 0; i < k; i++) {
		if (a[i] == b[k-i-1])
			cout << a[i] << "\n";
	}

    return 0;
}


















Measured memory_bytes: 3468
#include<cstdio>
#include<cmath>

using namespace std;


bool like_2017(int n){
    for(int i = 2; i <= sqrt((double)n); i++){
        if (n % i == 0) return false;
    }
    for(int i = 2; i <= sqrt((double)n); i++){
        if (((n + 1) / 2) % i == 0) return false;
    }    
    return true;
    
}

int main(){
    int a[100000];
    int sm = 0;
    for(int i = 2; i <= 100000; i++){
        int n = i;
        if (like_2017(n)) {
            a[i-1] = sm;
            sm++;
        } else a[i-1] = 0;
    }
    // for(int i = 0; i < 10000; i++)
    // {
    //     printf("%d ", a[i]);
    // }
    
    int q;
    scanf("%d", &q);
    int l[q];
    int r[q];
    for(int i = 0; i < q; i++){
        scanf("%d %d", &l[i], &r[i]);
    }
    for(int i = 0; i < q; i++){
    
        int L = l[i];
        int R = r[i];
        while(a[L-1] == 0 && L < R) L++;
        while(a[R-1] == 0 && L < R) R--;
        if (a[L-1] !=0) printf("%d\n", a[R-1] - a[L-1] + 1);
        else puts("0");
        // printf("%d %d\n", L, R);

    }

    
}

Measured memory_bytes: 1664
from math import radians
from cmath import exp

a, b, h, m = map(int, input().split())

# 時針は一時間あたり360/12 = 30度
# 時針は一分あたり30/60 = 0.5度
# 分針は一分あたり360/60 = 6度
hdeg = radians(h * 30 + m * 0.5)
mdeg = radians(m * 6)

# オイラーの公式
hz = a * exp(complex(0, hdeg))
mz = b * exp(complex(0, mdeg))

# 複素数平面における二点間の距離
dist = abs(hz - mz)

print(dist)

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

const int MOD = 1000 * 1000 * 1000 + 7;

void solve_test() {
	int n;
	cin >> n;
	vector<LL> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	int sum = 0;
	for (int i = 0; i < 60; i++) {
		int zero = 0;
		for (int j = 0; j < n; j++)
			if ((a[j] & (1LL << i)) == 0)
				zero++;
		int one = n - zero;
		sum = (sum + (1LL << i) % MOD * one % MOD * zero % MOD) % MOD;
	}
	cout << sum << '\n';
}

int main() {
	int T;
	T = 1;
	for (int t = 1; t <= T; t++)
		solve_test();

	return 0;
}


Measured memory_bytes: 5556
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main(){
	int n; cin >> n;
	int a[200000];
	rep(i, n) {
		cin >> a[i];
	}
	if (n % 2) {
		for (int i = n - 1; i >= 0; i -= 2) {
			if (i != n - 1)cout << " ";
			cout << a[i];
		}
		for (int i = 1; i < n; i += 2)cout << " " << a[i];
		cout << endl;
	}
	else {
		for (int i = n - 1; i >= 0; i -= 2) {
			if (i != n - 1)cout << " ";
			cout << a[i];
		}
		for (int i = 0; i < n; i += 2)cout << " " << a[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
class Graphs{

public:
  vector<vector<int>> graph;
  vector<int> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graphs(int n){
    graph.resize(n);
    init(n);
  }
  ~Graphs(){}

  void addedge(int u, int v){
    u--; v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.assign(n, false);
    dist.assign(n, -1);
  }

  void reset_dist(){
    rep(i,dist.size()){
      dist[i]=-1;
    }
  }

  void dfs(int v){
    check[v] = true;

    for(auto next_v : graph[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v){
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graph[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }
};

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

  Graphs g(n);
  rep(i,n-1){
    g.addedge(i+1, i+2);
  }
  int x, y;
  cin >> x >> y;
  g.addedge(x, y);
/*
  prt("edge");
  rep(i,n){prt2("---from : ", i);rep(j,g.graph[i].size()){prt(g.graph[i][j]);}}
*/
  vecll ans(n-1);
  rep(i,n-1){
    g.reset_dist();
    g.bfs(i);
    REP(j,i+1,n){
      ans[g.dist[j]-1]++;
      //prt3(i,j,g.dist[j]-1);
    }
  }

  rep(i,n-1){
    prt(ans[i]);
  }
}


Measured memory_bytes: 384
N = int(input())
P = [int(i) for i in input().split()]
c = 0
for i in range(N-2):
  p1 = P[i]
  p2 = P[i+1]
  p3 = P[i+2]
  if p1 <= p2 <= p3 or p3 <= p2 <= p1:
    c += 1
print(c)

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

int main() {
  string Sa, Sb, Sc;
  cin >> Sa >> Sb >> Sc;
  int a=0, b=0, c=0;
  int next=0;
  while (true) {
    if (next==0) {
      if (++a>Sa.size()) {
        cout << 'A' << endl;
        break;
      } else
        next = Sa.at(a-1) - 'a';
    } else if (next==1) {
      if (++b>Sb.size()) {
        cout << 'B' << endl;
        break;
      } else
        next = Sb.at(b-1) - 'a';
    } else {
      if (++c>Sc.size()) {
        cout << 'C' << endl;
        break;
      } else
        next = Sc.at(c-1) - 'a';
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    int count=0;
    char[] B = A.toCharArray();
    for(int i=0;i<A.length();i++){
      if(B[i]=='2'){
      	count++;
      }
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define M 1000000007ll
ll para(ll a,ll b) {
	if (a==b) return a;
	if (a<b) swap(a,b);
	if (a%b==0ll) {
		ll k=a/b;
		return (2ll*k-1ll)*b;
	}
	ll k=a/b;
	return 2ll*k*b+para(b,a%b);
}
int main() {
	ll n,x;
	cin>>n>>x;
	printf("%lld\n", n+para(x,n-x));
}

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

int main() {
  int a,b,x;
  string s;
  cin >> a >> b;
  cin >> s;
  x = 0;
  if(s.size() != a+b+1){
    x++;
    goto here;
  }
  
  if(s.at(a) != '-'){
    x++;
    goto here2;
  }
  
  for(int i=0;i<a;i++){
    if(s.at(i) == '-'){
      x++;
    }
  }
  for(int i=a+1;i<a+b+1;i++){
    if(s.at(i) == '-'){
      x++;
    }
  }
  here2 :
  here :
  if(x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<vector<int>> G;
ll ans[200010];

void dfs(int v,int p=-1){
    for(auto nv : G[v]){
        if(nv==p) continue;
        ans[nv]+=ans[v];
        dfs(nv,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    G.resize(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i,q){
        int p;
        ll x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }

    dfs(0);

    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}



Measured memory_bytes: 28276
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
using namespace std;

int n;
vector<int> v;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    v.push_back(a);
  }
  int ans=n;
  sort(v.begin(),v.end());
  for(int i=0;i<(int)v.size();){
    if(v[i]==v[i+1]){ans-=2;i+=2;}
    else i++;
  }
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    ll m = 1e9 + 7;
    ll powm(ll b, ll p)
    {
      if (p == 0)
      return 1;
      if (p % 2 == 1)
      return b * powm(b, p - 1) % m;
      else
      {
        ll t = powm(b, p / 2);
        return t * t % m;
      }
    }
    int main()
    {
      int n;
      cin >> n;
      vector<int> a(n);
      map<int, int> flcm;
      vector<map<int, int>> b(n);
      for (int i = 0; i < n; i++)
      cin >> a[i];
     
      for (int i = 0; i < n; i++)
      {
        int t = a[i];
        for (ll j = 2; j * j <= t; j++)
        {
          while (t % j == 0)
          {
            b[i][j] += 1;
            t /= j;
          }
          if (b[i][j] > flcm[j])
          flcm[j] = b[i][j];
        }
        if (t != 1)
        {
          b[i][t]++;
          if (flcm[t] == 0)
          flcm[t] = 1;
        }
      }
      ll ans = 0;
      ll lcm = 1;
      for (auto x : flcm)
      {
        lcm = lcm * powm(x.first, x.second) % m;
      }
      for (int i = 0; i < n; i++) {
      	ans += lcm * powm(a[i], m - 2) % m;
      }
      cout << ans%m << endl;
    }

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int64 N, C;
	cin >> N >> C;
	vector<int64> x(N), v(N);
	REP(i, N) cin >> x[i] >> v[i];
	vector<int64> tol(N+1, -INF_LL), tor(N+1, -INF_LL);
	tol[0] = 0; tor[0] = 0;
	int64 sum = 0;
	int64 res = 0;
	for(int32 i = N-1;i >= 0;i--){
		int32 in = N-i;
		sum += v[i];
		tol[in] = max(tol[in-1], sum-2*(C-x[i]));
	}
	res = max(res, sum-C+x[0]);
	sum = 0;
	for(int32 i = 0;i < N;i++){
		int32 in = i+1;
		sum += v[i];
		tor[in] = max(tor[in-1], sum-2*x[i]);
		res = max(res, sum-x[i]+tol[N-in]);
	}
	res = max(res, sum-x[N-1]);
	sum = 0;
	for(int32 i = N-1;i >= 0;i--){
		int32 in = N-i;
		sum += v[i];
		res = max(res, sum-(C-x[i])+tor[N-in]);
	}
	cout << res << endl;

}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;

const int open_tag = 1;
const int close_tag = 2;
const int toggle_tag = 3;
union event_t {
    struct { int tag; int t; } common;
    struct { int tag; int l, i; } open; // [l, r)
    struct { int tag; int r, i; } close; // [l, r)
    struct { int tag; int p; } toggle;
};
bool operator < (event_t a, event_t b) { return a.common.t > b.common.t; } // weak struct ordering
int main() {
    // init
    int n, m; cin >> n >> m;
    priority_queue<event_t> que;
    repeat (i,n) {
        int s, t; cin >> s >> t;
        event_t el = { open_tag };
        event_t er = { close_tag };
        if (s < t) {
            el.open .l = s;
            er.close.r = t;
        } else {
            el.open .l = - s;
            er.close.r = - t;
        }
        el.open .i = i;
        er.close.i = i;
        que.push(el);
        que.push(er);
    }
    repeat (i,m) {
        int p; cin >> p;
        event_t e = { toggle_tag };
        e.toggle.p = p;
        que.push(e);
        e.toggle.p = - p;
        que.push(e);
    }
    // run
    ll ans = 0;
    int prv = 0;
    int on = 0;
    int off = 0;
    vector<int> ix(n, -1);
    vector<int> acc { 0 };
    while (not que.empty()) {
        event_t e = que.top(); que.pop();
        ans += on *(ll) (e.common.t - prv);
        prv = e.common.t;
        if (e.common.tag == open_tag) {
            on += 1;
            ix[e.open.i] = acc.size() - 1;
            acc.push_back(acc.back());
        } else if (e.common.tag == close_tag) {
            ((acc.back() - acc[ix[e.close.i]]) % 2 == 0 ? on : off) -= 1;
        } else if (e.common.tag == toggle_tag) {
            swap(on, off);
            acc.back() += 1;
        }
    }
    // output
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    cout << max(abs(v.back()-w), (n > 1 ? abs(v[n-2]-v.back()) : 0)) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
# 26 ** 9 < 1000000000000001 < 26 ** 10 なので最大でも(9+1)桁の文字
index = [None] * 11
n = N
for i in range(0, 11, 1):
  a = n % 26
  if a == 0:
    index[i] = 26
    n = (n // 26) - 1
  else:
    index[i] = a
    n = n // 26  
  if n == 0:
    break
  
word = ''
for i in index:
  s = ''
  if i:
    s = chr(ord('a') + i - 1)
    word += s
print(word[::-1])

Measured memory_bytes: 62036
#include<iostream>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 0) {
		cout << (A + B) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    auto s = InputVec(N);
    ll res = 0;
    sort(s.begin(),s.end());
    for (int i = 0; i < N; ++i) {
        res += s[i];
    }
    if(res % 10 == 0){
        for (int i = 0; i < N; ++i) {
            if((res-s[i])%10!=0){
                cout << res -s[i] << endl;
                return 0;
            }
        }
    }else{
        cout << res << endl;
        return 0;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
b = [0]
for i in ab:
    b.append(b[-1]+i[1])
i = 0
while b[i]<k:
    i += 1
print(ab[i-1][0])

Measured memory_bytes: 32476
#include <stdio.h>

int main(void){
  int i, j, n, m;
  int W[300], H[300];
  for(n=0 ; ; n++){
    scanf("%d %d",&H[n],&W[n]);
    if(H[n]==0 && W[n]==0){
      m=n;
      break;
    }
  }
  for(n=0 ; n<m ; n++){
    for(i=0 ; i<H[n] ; i++){
      for(j=0 ; j<W[n] ; j++){
	if(j==0 || j==W[n]-1 || i==0 ||i==H[n]-1){
	  printf("#");
	}else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
return 0;
}

Measured memory_bytes: 572
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define M_PI           3.14159265358979323846  /* pi */
#define sec second
#define fir first
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	ll minSum,maxSum;
	for(ll i=k;i<=n+1;i++)
	{
		minSum= (i*(i-1))/2;
		maxSum= ((n+1)*n)/2 - ((n+1-i)*(n-i))/2;
		ans+=maxSum-minSum + 1;
		ans%=1000000007;
	}
	cout<<ans<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast
  int T = 1;
  // cin >> T;
  while (T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3644
N, M, C = [int(x) for x in input().split()]
B_list = [int(x) for x in input().split()]
NUM = 0
for _ in range(N):
  A_list = [int(x) for x in input().split()]
  if sum([A*B for(A, B) in zip(A_list, B_list)]) + C > 0:
    NUM += 1
print(NUM)


Measured memory_bytes: 3060
//In The Name Of GOD
     
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll ;
    const ll mod = 998244353;
    const ll inf = 2000000000;
    const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
    const ll maxn = 100*1000+1;
    #define pb push_back
    #define pp pop_back
    #define X first
    #define Y second
    #define IO ios_base::sync_with_stdio(false);
     
    int main(){
      IO;
      string s;
      cin>>s;
      int ans1=s.size(),ans2=s.size();
      for(int  i=0 ;i<s.size();i++){
        if(s[i]=='1'){
          ans1=min(ans1,max(i,(int)s.size()-i-1));
        }
      }
      for(int  i=0 ;i<s.size();i++){
        if(s[i]=='0'){
          ans2=min(ans2,max(i,(int)s.size()-i-1));
        }
      }
      cout<<max(ans1,ans2) ;
    }

Measured memory_bytes: 512
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn d(a: &[f64], b: &[f64], p: u64) -> f64 {
    let p = p as f64;
    a.iter()
        .zip(b.iter())
        .map(|(i, j)| (i - j).abs().powf(p))
        .sum::<f64>()
        .powf(1.0 / p)
}

fn main() {
    let _: usize = read();
    let xx = read_vec::<f64>();
    let yy = read_vec::<f64>();
    println!("{}", d(&xx, &yy, 1));
    println!("{}", d(&xx, &yy, 2));
    println!("{}", d(&xx, &yy, 3));
    println!("{}", xx.iter().zip(yy.iter())
                     .map(|(x,y)| (x-y).abs() as u32).max().unwrap());
}



Measured memory_bytes: 5188
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(l,a[i])
s=0
l-=1
for i in range(n):
    s+=(l%a[i])
print(int(s))

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine();
        var count = 0;
        for(int i = 1; i < n.Length; i++)
        {
            if(n[i] != n[i - 1])
                count++;
        }
        WriteLine(count);
    }
}



Measured memory_bytes: 17456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
    
		ll s, w;
		cin >> s >> w;
		
		if (s > w)
			cout << "safe\n";
		else
			cout << "unsafe\n";
	//code
	return 0;
}


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

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

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if a >= 13 {
        b
    }
    else if a >= 6 {
        b / 2
    }
    else {
        0
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (auto &x : v)
    cin >> x;
  sort(v.begin(), v.end());
  cout << accumulate(v.begin(), v.begin() + k, 0) << "\n";
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map <string, int> mp;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(10);
}
string s;
int k;
signed main() {
	my_io();
	cin >> s >> k;
	set<string>st;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 1; j <= k; j++) {
			st.insert(s.substr(i, j));
		}
	}
	int count = 0;
	for (auto e : st) {
		count++;
		if (count == k) {
			cout << e << endl;
		}
	}
	return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  int s0 = S.size(), t0 = T.size();
  vector<string> s_box(0);
  for(int i = 0; i < s0 - t0 + 1; i++){
    bool nomatch = false;
    string ans = S.substr(0, i);
    for(int j = 0; j < t0; j++){
      //cout << i << ':' << j << endl;
      if(S.at(i + j) != '?' && S.at(i + j) != T.at(j)){
        nomatch = true;
        break;
      } 
      else ans += T.at(j);
    }
    if(nomatch) continue;
    else{
      ans += S.substr(i + t0);
      for(int j = 0; j < s0; j++){
        if(ans.at(j) == '?') ans.at(j) = 'a';
      }
      s_box.push_back(ans);
    }
  }
  
  if(s_box.size() == 0) cout << "UNRESTORABLE" << endl;
  else{
    sort(s_box.begin(), s_box.end());
    cout << s_box.at(0) << endl;
  
  }
}

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

int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  double x=-1;
  int max_all=0, max_su=0;
  for(int a=0; 100*A*a<=F; a++) {
    for(int b=0; 100*B*b<=F; b++) {
      int s = (A*a+B*b)*E;
      for(int c=0; C*c<=s; c++) {
        for(int d=0; D*d<=s; d++) {
          int su = C*c+D*d;
          int all = 100*A*a + 100*B*b + su;
          if(su > s) continue;
          if(all > F) continue;
          if(x < 100*su / (double)all) {
            x = 100*su / (double)all;
            max_all = all;
            max_su = su;
          }
        }
      }
    }
  }
  cout << max_all << " " << max_su <<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;
 
signed main(void) {
  int i,j;
  int n,t;
  int ans=1;
  cin>>n;
  rep(i,n){
    cin>>t;
    ans=ans/__gcd(ans,t)*t;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map { it.toLong() }
    val smaller = Math.min(A,B)
    val bigger = Math.max(A,B)
    for (i in smaller..bigger) {
        val smallEval = Math.abs(smaller - i)
        val biggerEval = Math.abs(bigger - i)
        if (smallEval == biggerEval) {
            println(i)
            return
        }
    }
    println("IMPOSSIBLE")
}


Measured memory_bytes: 37740
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    A, s, C = read_str_list()
    res = A[0] + s[0] + C[0]
    print(res)


main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
using llong = long long;

//===
struct UnionFind {
    int n;
    vector<int> parent;

    UnionFind() {}
    UnionFind(int nmemb) {
        init(nmemb);
    };

    void init(int nmemb) {
        parent.clear();
        parent.assign(nmemb, -1);
    };

    int root(int x) {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    };

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        if (parent[y] < parent[x]) swap(x, y);

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    };
    
    bool same(int x, int y) {
        return root(x) == root(y);
    };
    int size(int x) {
        return -(parent[root(x)]);
    };
};
//===

llong n, m;
using Edge = tuple<llong, llong, llong>;
vector<Edge> edges;

void solve() {
    edges.clear();
    UnionFind uf(n + 1);
    for (int i = 0; i < m; i++) {
        llong s, t, c;
        cin >> s >> t >> c;

        edges.emplace_back(c, s, t);
    }

    sort(edges.begin(), edges.end());
    llong cnt = 0;
    llong med;
    for (int i = 0; i < m; i++) {
        llong s, t, c;
        tie(c, s, t) = edges[i];

        if (uf.same(s, t)) continue;

        cnt++;
        uf.unite(s, t);

        if (cnt == n / 2) {
            med = c;
        }
    }

    cout << med << '\n';
}

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

    while (cin >> n >> m, n) {
        solve();
    }
    
    return 0;
}




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

const int MOD = 1000000007;

long long sum(long long N, long long n);
long long mod_subtract(long long val1, long long val2);

int main() {
	long long  N, K;
	long long output;

	cin >> N >> K;

	output = mod_subtract(sum(N, N + 1), sum(N, K - 1));

	cout << output << endl;
}



long long sum(long long N, long long n) {
	long long sum1, sum2, ans;

	sum1 = (N + 1) * n * (n + 1) / 2;
	sum2 = n * (n + 1) * (2 * n + 1) / 6;

	ans = (mod_subtract(sum1, sum2) + n) % MOD;

	return ans;
}

long long mod_subtract(long long val1, long long val2) {
	long long res = ((val1 % MOD) - (val2 % MOD)) % MOD;
	if (res < 0) res += MOD;
	return res;
}

Measured memory_bytes: 3684
while True:
    line = input()

    if line == "0 0":
        break

    stock, max_difficulty = map(int, line.split(" "))

    max_recommend_list = [0 for _ in range(max_difficulty)]

    for i in range(stock):
        difficulty, recommend = map(int, input().split(" "))
        max_recommend_list[difficulty - 1] = max(max_recommend_list[difficulty - 1], recommend)

    print(sum(max_recommend_list))



Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;

bool Check(ll k, ll A, ll B, vector<ll> &H){
        ll K =k;
        for(int i=0; i<H.size(); i++){
                K -= max(((H[i] -k*B+(A-B-1))/(A-B)), 0LL);
                if(K < 0){
                        return false;
                }
        }
        return true;
}


int main(){
        ll N ,A ,B;
        cin >> N >> A >> B;
        vector<ll> H(N);
        for(int i=0; i<N; i++){
                cin >> H[i];
        }
        ll l = 0;
        ll r = 1e10;
        ll point;
        while(r - l > 1){
                point = (r+l)/2;
                if(Check(point, A, B, H)) r = point;
                else l = point;
        }
        cout << r;

}

Measured memory_bytes: 1024
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n) read(k)
    readarr(a,n)
    ll curr = 0;
    ve(ll) hmm;
    hmm.push_back(0);
    f(i,0,n)
    {
        curr+=a[i];
        hmm.push_back(curr);
    }
    cout<<upper_bound(all(hmm),k) - hmm.begin();
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


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

signed main(){
  int H, W, D; cin >> H >> W>> D;
  vector<P> data(H * W + 1);
  for(int i = 0; i < H; i++){
	  for(int j = 0; j < W; j++){
			int x; scanf("%d", &x);
			data[x] = P(i, j);
		}
  }
	vector<int> sum(H * W + 1, 0);
	for(int i = H * W - D; i >= 0; i--){
		int a = data[i].first, b = data[i].second, c = data[i + D].first, d = data[i + D].second;
		sum[i] = sum[i + D] + abs(a - c) + abs(b - d);
	}
	int Q; cin >> Q;
	for(int i = 0; i < Q; i++){
		int l, r; scanf("%d%d", &l, &r);
		cout << sum[l] - sum[r] << '\n';
	}
}

Measured memory_bytes: 2176