akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int is_bomb(int h, int w, char cells[h][w], int pos_x, int pos_y)
{
#ifdef DBG
  printf("%d %d %d %d %c \t", h, w, pos_x, pos_y, cells[pos_y][pos_x]);
#endif
  
  if (pos_x < 0 || pos_y < 0 || pos_x >= w || pos_y >= h) {
#ifdef DBG
    printf("out of bounds %d:%d %d:%d\n", w, pos_x, h, pos_y);
#endif
    return 0;
  }

  if (cells[pos_y][pos_x]=='#') {
#ifdef DBG
    printf("bomb found %c\n", cells[pos_y][pos_x]);
#endif
    return 1;
  } else {
#ifdef DBG
    printf("bomb NOT found %c\n", cells[pos_y][pos_x]);
#endif
    return 0;
  }
}

int search_bomb(int h, int w, char cells[h][w], int pos_x, int pos_y)
{
  int bomb_num = 0;

#ifdef DBG
  printf("search_bomb(): %d %d\n", pos_x, pos_y);
#endif // DBG

  if (is_bomb(h, w, cells, pos_x-1, pos_y)) {
    bomb_num++;
  } 
  if (is_bomb(h, w, cells, pos_x+1, pos_y)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x, pos_y-1)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x, pos_y+1)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x-1, pos_y+1)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x+1, pos_y+1)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x-1, pos_y-1)) {
    bomb_num++;
  }
  if (is_bomb(h, w, cells, pos_x+1, pos_y-1)) {
    bomb_num++;
  }

  return bomb_num;
}

int main()
{
  int h, w;
  scanf("%d%d", &h, &w);

  char cells[h][w];

  for (int i=0; i<h; i++) {
    scanf("%s", cells[i]);
  }

#ifdef DBG
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      printf("%c", cells[i][j]);
    }
      printf("%c", '\n');
  }
#endif

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (cells[i][j]=='#') {
	continue;
      } else {
#ifdef DBG
	int tmp = (char)search_bomb(h, w, cells, j, i);
	cells[i][j] = tmp;
	printf("(%d, %d) %c %d\n", i, j, cells[i][j], tmp);
#else
	cells[i][j] = (char)search_bomb(h, w, cells, j, i);
#endif
      }
    }
  }

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (cells[i][j]==35)
	printf("%c", cells[i][j]);
      else
	printf("%d", cells[i][j]);
    }
    printf("%c", '\n');
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int[] ans = new int[s.length];
		int r = 0;
		int l = 0;
		boolean rflg = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'R') {
				r++;
				rflg = true;
			} else {
				l++;
				rflg = false;
			}

			if (!rflg && (i == s.length - 1 || s[i + 1] == 'R')) {
				if (r % 2 == 0) {
					ans[i - l] = r / 2;
					ans[i - l + 1] = r / 2;
				} else {
					ans[i - l] = r / 2 + 1;
					ans[i - l + 1] = r / 2;
				}
				if (l % 2 == 0) {
					ans[i - l] += l / 2;
					ans[i - l + 1] += l / 2;
				} else {
					ans[i - l] += l / 2;
					ans[i - l + 1] += l / 2 + 1;
				}
				r = 0;
				l = 0;
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ans.length; i++) {
			sb.append(ans[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


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


int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  rep(i, N) cin >> T[i];
  int M;
  cin >> M;
  vector<int> P(M), X(M);
  rep(i, M) {
    cin >> P[i];
    cin >> X[i];
  }
  
  int sum = 0;
  rep(i, N) sum += T[i];
  
  rep(i, M) {
    int ans = sum;
    ans -= T[P[i]-1];
    ans += X[i];
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string foo(int A, int B) {
  if (A > 8 || B > 8) {
    return ":(";
  }
  else {
    return "Yay!";
  }
}
  
  
int main() {
  int A, B;
  cin>>A;
  cin>>B;
  cout<<foo(A, B)<<endl;
  return 0;
    
}


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

int main(){
  string S;
  int co=0, ce=0;
  int so=0, se=0;
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(i%2==0){
      se++;
      if(S[i]=='0') ce++;
    }
    else{
      so++;
      if(S[i]=='0') co++;
    }
  }
  if(ce>co) cout << se-ce+co << endl;
  else cout << so-co+ce << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  char c;
  cin >> c;
  map<char, char> mp;
  mp['A'] = 'T';
  mp['T'] = 'A';
  mp['G'] = 'C';
  mp['C'] = 'G';
  
  cout << mp[c] << endl;
}

Measured memory_bytes: 256
use petgraph::algo::dijkstra;
use petgraph::Graph;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        m: usize,
        uv: [(Usize1, Usize1); m],
        s: Usize1,
        t: Usize1,
    }
    let mut nodes = HashMap::new();
    let mut graph = Graph::new();
    for i in 0..n {
        for j in 0..3 {
            nodes.insert((i, j), graph.add_node((i, j)));
        }
    }
    for &(ui, vi) in &uv {
        for j in 0..3 {
            graph.add_edge(nodes[&(ui, j)], nodes[&(vi, (j + 1) % 3)], ());
        }
    }
    let distance = dijkstra(&graph, nodes[&(s, 0)], None, |_| 1);
    if let Some(d) = distance.get(&nodes[&(t, 0)]) {
        println!("{}", d / 3);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 38592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;

public class Main {
	static int n, m;
	static Hen[] arr;
	static List<List<Hen>> list;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		m = Integer.parseInt(sa[1]);
		arr = new Hen[m];
		list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			Hen h = new Hen();
			h.i = i;
			h.a = Integer.parseInt(sa[0]) - 1;
			h.b = Integer.parseInt(sa[1]) - 1;
			h.c = Integer.parseInt(sa[2]);
			arr[i] = h;
			list.get(h.a).add(h);
			list.get(h.b).add(h);
		}
		br.close();

		for (int i = 0; i < n; i++) {
			dijkstra(i);
		}
		int ans = 0;
		for (Hen h : arr) {
			if (!h.used) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	static void dijkstra(int s) {
		List<List<Hen>> pre = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			pre.add(new ArrayList<>());
		}
		long[] d = new long[list.size()];
		Arrays.fill(d, Long.MAX_VALUE);
		d[s] = 0;
		PriorityQueue<Node> que = new PriorityQueue<Node>();
		Node first = new Node(s, 0);
		que.add(first);

		while (!que.isEmpty()) {
			Node cur = que.poll();
			for (Hen hen : list.get(cur.v)) {
				long alt = d[cur.v] + hen.c;
				int next = hen.a;
				if (next == cur.v) {
					next = hen.b;
				}
				if (alt < d[next]) {
					pre.get(next).clear();
				}
				if (alt <= d[next]) {
					d[next] = alt;
					que.add(new Node(next, alt));
					pre.get(next).add(hen);
				}
			}
		}
		for (List<Hen> pre2 : pre) {
			for (Hen h : pre2) {
				h.used = true;
			}
		}
	}

	static class Hen {
		int i, a, b, c;
		boolean used;
	}

	static class Node implements Comparable<Node> {
		int v;
		long d;

		public Node(int v, long d) {
			this.v = v;
			this.d = d;
		}

		public int compareTo(Node o) {
			return Long.compare(d, o.d);
		}
	}
}


Measured memory_bytes: 28568
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
using namespace std;

struct Node {
    int num;
    int val;
    vector<Node*> children;
};

int main () {
    int n,q,a,b,p,x;
    cin >> n >> q;
    unordered_map<int, vector<int>> node_map;
    unordered_map<int, int> node_vals;
    for (int i = 1; i <= n; ++i) {
        node_map[i] = {};
        node_vals[i] = 0;
    }
    for (int i = 1; i < n; ++i) {
        cin >> a >> b;
        node_map[a].push_back(b);
    }
    for (int i = 0; i < q; ++i) {
        cin >> p >> x;
        node_vals[p] += x;
    }
    for (int i = 1; i <= n; ++i) {
        cout << node_vals[i] << " ";
        for (int j : node_map[i]) {
            node_vals[j] += node_vals[i];
        }
    }
}

Measured memory_bytes: 28304
#include <iostream>
#include <algorithm> 

using namespace std; 
int main()
{
  ios::sync_with_stdio(false); 
  cin.tie(0); 
  int n; 
  cin>>n; 
  int a[n]; 
  for (int i=0; i<n; i++) cin>>a[i]; 
  int dp[n]; dp[0]=0; 
  for (int i=1; i<n; i++){
    dp[i]=dp[i-1]+abs(a[i]-a[i-1]); 
    if (i>1){
      dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
  }
  cout<<dp[n-1]<<"\n"; 
  return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin >> N;
    int x[N], y[N];
    rep(i, 0, N) cin >> x[i];
    memcpy(y, x, sizeof(int) * N);
    sort(&y[0], &y[N]);
    rep(i, 0, N)
    {
        if (x[i] >= y[N / 2])
            cout << y[N / 2 - 1] << endl;
        else
        {
            cout << y[N / 2] << endl;
        }
    }
}
int main()
{
    func();
}

Measured memory_bytes: 5040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		int ans = 1;
		for (int i = 2; i * i <= x; i++) {
			int b = i;
			while (b <= x) {
				b *= i;
			}
			b /= i;
			ans = Math.max(ans, b);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n, k;
vector<int> e[2000];
int dist[2000][2000];
bool saw[2000][2000];

void dfs(int ro, int v, int d, int par){
	rep(i,e[v].size()){
		if(e[v][i] == par) continue;
		dist[ro][e[v][i]] = d+1;
		dfs(ro,e[v][i],d+1,v);
	}
}

int main(){
	cin >> n >> k;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	rep(i,n) dfs(i,i,0,-1);
	int ans = 0;
	bool ok = false;
	rep(i,n) for(int j = i+1; j < n; j++){
		if(dist[i][j] != k || saw[i][j] == true) continue;
		ok = true;
		int cnt = 0;
		rep(l,n){
			if(dist[l][i] <= k && dist[l][j] <= k){
				cnt++;
				saw[l][i] = true; saw[l][j] = true;
				saw[i][l] = true; saw[j][l] = true;
			}
		}
		ans = max(ans,cnt);
	}
	if(!ok) cout << 0 << endl;
	else cout << n-ans << endl;
}






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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
const double INF = 1e18;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

struct edge {
    int to;
    double cost;
    edge(int to, double cost): to(to), cost(cost){}
};

using P = pair<double, int>;

const int MAX_V = 1010;
int V;

vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

double calc_dist(double x1, double y1, double x2, double y2){

  double x = x1 - x2;
  double y = y1 - y2;
  return sqrt(x*x + y*y);
}

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

  double xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;

  int n;
  cin >> n;

  V = n + 2;
  vector<double> x(n+2), y(n+2), r(n+2);

  x[0] = xs;
  y[0] = ys;
  x[1] = xt;
  y[1] = yt;
  r[0] = 0.0;
  r[1] = 0.0;

  rep(i, n){
    cin >> x[i+2] >> y[i+2] >> r[i+2]; 
  }

  rep(i, V){
    rep(j, V){
      if(i == j) continue;

      double dist = calc_dist(x[i], y[i], x[j], y[j]);
      
      double c = max(0.0, dist - r[i] - r[j]);

      G[i].emplace_back(j, c);
    }
  }

  dijkstra(0);

  cout << setprecision(16) << d[1] << endl;


  return 0;
}


Measured memory_bytes: 22256
n,k = map(int,input().split())
mx = (n - 1) * (n - 2) // 2
if mx < k:
    print(-1)
    exit()

l,r = 1,2

res = []
for i in range(1, n):
    res.append([i, n])

while mx > k:
    mx -= 1
    res.append([l, r])
    if r == n - 1:
        l += 1
        r = l + 1
    else:
        r += 1

print(len(res))
for i in res:
    print(*i)

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

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> B.at(i);
  
  vector<int> C(N);
  int tarin = 0;
  int amari = 0;
  int chisai = 0;
  for( int i = 0; i < N; i++ ){
    C.at(i) = A.at(i) - B.at(i);
    if( A.at(i) > B.at(i) ) amari += A.at(i) - B.at(i);
    else if( A.at(i) < B.at(i) ){
      tarin += B.at(i) - A.at(i);
      chisai++;
    }
  }
  
  int count = 0;
  if( tarin > amari ){
    cout << -1 << endl;
    return 0;
  }else{
    sort( C.begin(), C.end() );
    for( int i = N-1; i > 0; i-- ){
      if( tarin > 0 ){
        tarin -= C.at(i);
        count++;
      }
      if( tarin <= 0 ) break;
    }
  }
  
  cout << count+chisai << endl;
  
}



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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
}

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

int N;
vector<int> A(200001);

void solve(){
    map<int, int> mp;
    for(int i = 1; i <= N; ++i){
        mp[A[i]]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        if(itr->second >= 2) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}
int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

long double a, b, x;
long double const pi = acos(-1);

void input() {
    cin >> a >> b >> x;
}

void solve() {
    long double S = a*a*b/2;
    
    if (x<=S) {
        long double ok = atan2(b, a); long double ng = acos(0.0);
        auto check = [&](long double mid) -> bool {
            long double vol = a*b*b/2/tan(mid);
            return x < vol;
        };
        rep(_, 50) {
            long double mid = (ok+ng)/2;
            (check(mid)? ok:ng) = mid;
        }
        cout << fixed << setprecision(15) <<  ok*180/pi << endl;
    } else {
        long double ok = 0.0; long double ng = atan2(b, a);
        auto check = [&](long double mid) -> bool {
            long double vol = a*a*b - a*a*a*tan(mid)/2;
            return x < vol;
        };
        rep(_, 50) {
            long double mid = (ok+ng)/2;
            (check(mid)? ok:ng) = mid;
        }
        cout << fixed << setprecision(15) << ok*180/pi << endl;
    }
}

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

    input();
    solve();
    
    return 0;
}

Measured memory_bytes: 512
N = int(input())
restaurant = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    restaurant.append([i + 1, s, p])

restaurant.sort(key=lambda x: x[2], reverse=True)
restaurant.sort(key=lambda x: x[1])

for i in range(N):
    print(restaurant[i][0])

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = [int(input()) for i in range(n)]
dp = [-inf] * (10**5+10);dp[-1] = inf
for ai in A:
  dp[bisect.bisect_left(dp,ai)-1] = ai
for di in dp:
  if di != -inf:ans += 1
print(ans - 1)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int ans = 0;
    rep(i, n)
    {
        ans += 2 * min(k - x[i], x[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool flag(bool *f, int n);
int main() {
	int n, a, b, c, x, y[100];
	while (cin >> n >> a >> b >> c >> x&&n) {
		int cnt = 0, i = 0;
		bool f[100] = {};
		//bool u = false;
		for (int i = 0; i < n; i++)cin >> y[i];
		while (true) {
			if (cnt > 10000) { cnt = -1; break; }
			if (y[i] == x) {
				f[i++] = true;
				//u = true;
			}
			if (flag(f, n))break;
			cnt++;
			x = (a*x + b) % c;
			//cout << cnt << " " << x;
			//if (u) { cout << '!'; u = false; }
			//cout << endl;
		}
		cout << cnt << endl;
	}
	return 0;
}

bool flag(bool *f, int n) {
	for (int i = 0; i < n; i++) {
		if (!f[i])return false;
	}
	return true;
}

Measured memory_bytes: 1160
# F - LCS
def get_lcs(str_1: str, str_2: str):
    dp = [[0] * (len(str_2) + 1) for _ in range(len(str_1) + 1)]
    for i, s in enumerate(str_1):
        for j, t in enumerate(str_2):
            if s == t:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    i, j = len(str_1), len(str_2)
    reversed_lcs = ""
    while i and j:
        if str_1[i - 1] == str_2[j - 1]:
            i -= 1
            j -= 1
            reversed_lcs += str_1[i]
            continue
        if dp[i - 1][j] > dp[i][j - 1]:
            i -= 1
        else:
            j -= 1
    return reversed_lcs[::-1]


def main():
    S, T = open(0).read().split()
    print(get_lcs(S, T))


if __name__ == "__main__":
    main()


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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    bool ok = true;
    if (s[0] != 'A') ok = false;
    if (count(s.begin() + 2, s.end() - 1, 'C') != 1) ok = false;
    rep(i, n) {
        if (s[i] != 'A' && s[i] != 'C') {
            if (!islower(s[i])) ok = false;
        }
    }

    if (ok)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(){
    int N; cin >> N;
    int T[N]; rep(i,N) cin >> T[i];
    int M; cin >> M;
    int P[M], X[M]; rep(i,M) cin >> P[i] >> X[i];

    int cnt = 0;
    rep(i,N) cnt += T[i];
    rep(i,M) cout << cnt - T[P[i]-1] + X[i] << endl;
}

Measured memory_bytes: 764
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s1: String = read();
    let s2: String = read();
    let s3: String = read();
    println!(
        "{}{}{}",
        s1[0..1].to_uppercase(),
        s2[0..1].to_uppercase(),
        s3[0..1].to_uppercase()
    );
}

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


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

using namespace std;

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

    vector <int> L(2 * N);

    for (int i = 0; i < 2 * N; i++){
        cin >> L[i];
    }
    
    sort(L.begin(), L.end());

    int ans = 0;
    for(int i = 0; i < 2 * N; i += 2){
        ans += L[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
s = [int(v) for v in input().split()]
q = int(input())
t = [int(v) for v in input().split()]

cnt = 0
left = 0
right = n
for i in t:
    left = 0
    right = n
    while left < right:
        mid = math.floor((left + right) / 2)
        if s[mid] == i:
            cnt += 1
            left = right +1
        elif s[mid] > i:
            right = mid
        else:
            left = mid + 1
print(cnt)

Measured memory_bytes: 19036
#include<stdio.h>

#define N 2000
int n, A[N];
int solve(int i, int m);

int main(void){
	
	int q,M[N];
	
	scanf("%d",&n);
		for(int i=0;i<n;i++){	scanf("%d",&A[i]);}
	scanf("%d",&q);
		for(int i=0;i<q;i++){	scanf("%d",&M[i]);}
	

	
	for(int i = 0; i < q; i++ ){
		if( solve( 0 , M[i]) == 1 ){
			printf( "yes\n" );
		}else{
			printf( "no\n" );
		}
	}
	
	return 0;
}

int solve(int i, int m){

	int res;
	
	if( m == 0 ){
		return 1;
	}else if( i >= n ){
		return 0;
	}
	
	res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}


Measured memory_bytes: 2616
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,n,m,tmp,sum=0,now_day;
  cin >> n >> m;
  priority_queue<ll> que;
  vector<ll> list[200000];
  now_day = 0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    list[a].push_back(b);
  }
  for(int i=m-1;i>=0;i--){
    tmp = m-i;
    for(int j=0;j<list[tmp].size();j++){
      que.push(list[tmp][j]);
    }
    if(!que.empty()){
      sum+=que.top();
      que.pop();
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define RG register
#define IL inline
#define int long long
#define DB double
using namespace std;

IL int gi() {
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}

const int N=2e5+10;

int n,m,ans,tot,cnt,k[N],s[N],fa[N],flag[N],head[N],size[N];

struct Edge{int next,to;}e[N<<1];
IL void make(int a,int b) {
	e[++tot]=(Edge){head[a],b},head[a]=tot;
	e[++tot]=(Edge){head[b],a},head[b]=tot;
}

int getfa(int x) {return x==fa[x]?x:fa[x]=getfa(fa[x]);}

void dfs(int x,int fx,int fl) {
	RG int i,y;
	fa[x]=fx,size[x]=flag[x]=fl;
	for (i=head[x];i;i=e[i].next)
		if ((y=e[i].to)!=fx) dfs(y,x,-fl),size[x]+=size[y];
}

signed main ()
{
	RG int i,x,y,fx,fy,Fr,To,now;
	n=gi(),m=gi();
	for (i=1;i<=n;++i) fa[i]=i;
	for (i=1;i<=m;++i) {
		x=gi(),y=gi(),fx=getfa(x),fy=getfa(y);
		if (fx==fy) Fr=x,To=y;
		else fa[fx]=fy,make(x,y);
	}
	dfs(1,0,1);
	if (m==n-1) {
		if (size[1]) return puts("-1"),0;
	}
	else if (flag[Fr]==flag[To]) {
		if (size[1]&1) return puts("-1"),0;
		now=size[1]/2,ans+=abs(now);
		for (i=Fr;i;i=fa[i]) size[i]-=now;
		for (i=To;i;i=fa[i]) size[i]-=now;		
	}
	else {
		if (size[1]) return puts("-1"),0;
		cnt=1;
		if(size[1]) return puts("-1"),0;
		for(i=Fr;i;i=fa[i]) ++k[i];
		for(i=To;i;i=fa[i]) --k[i];
		for(i=1;i<=n;i++) {
			if(k[i]==1) s[++cnt]=-size[i];
			if(k[i]==-1) s[++cnt]=size[i];
		}
		sort(s+1,s+1+cnt);
		now=s[(cnt+1)/2];ans+=abs(now);
		for(i=1;i<=n;i++) size[i]+=k[i]*now;
	}
	for (i=1;i<=n;++i) ans+=abs(size[i]);
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 17408
using System;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nkq = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] ansCnt = new int[nkq[0]];
            ansCnt = ansCnt.Select(e => e = 0).ToArray();
            for (int i = 0; i < nkq[2]; i++)
            {
                int idx = int.Parse(Console.ReadLine());
                ansCnt[idx-1]++;
            }


            foreach (var item in ansCnt)
            {
                Console.WriteLine(nkq[1] - (nkq[2]-item) > 0 ? "Yes" : "No");
            }
        }
    }
}

Measured memory_bytes: 17372
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	N := io.NextInt()

	V := make([]int, N)
	for i := range V {
		V[i] = io.NextInt()
	}

	max := 0
	for i := range V {
		C := io.NextInt()
		if V[i] > C {
			max += V[i] - C
		}
	}

	io.PrintLn(max)

}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string S; cin >> S;
	long long ans = 0;
	for (long long i = 0; i < S.size(); i++) {
		if (S.at(i) == 'D' || S.at(i) == '?') S.at(i) = 'D';
	}
	cout << S << endl;
}

Measured memory_bytes: 3752
import java.util.*

fun main(args:Array<String>){
    val s = readLine()!!
    var ans = ArrayDeque<Char>()
    for(i in 0 until s.length){
        if(s[i] == '0') ans.addLast('0')
        else if(s[i] == '1') ans.addLast('1')
        else{
            if(ans.isNotEmpty()) ans.removeLast()
        }
    }
    ans.forEach(){
        print(it)
    }
    println()
}


Measured memory_bytes: 33640
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int k; cin >> k;
    ll ans = 0;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(l,1,k+1){
                ans += gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
n, k = map(int, input().split())
hs = list(map(int, input().split()))

dp = [float('inf')] * n

dp[0] = 0

for i in range(1, n):
    min_bound = max(i - k, 0)
    for j in range(min_bound, i):
        dp[i] = min(dp[i], dp[j] + abs(hs[j] - hs[i]))

print(dp[-1])

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

int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if((a+b)%2==0){
    ans = (a+b)/2;
  }else{
    ans = (a+b)/2 + 1;
  }
  cout << ans << endl;

}


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

using namespace std;

int main(){
    int count = 0;
    string s,ans = "AC";
    cin >> s;

    if(s[0] != 'A' || 'A'<= s[s.size()-1] && s[s.size()-1] <= 'Z')ans = "WA";

    if('A' <= s[1] && s[1] <= 'Z')ans = "WA";
   
    for(int i = 2;i < s.size()-1;i++){
        if(s[i] == 'C')count++;
        else if('A' <= s[i] && s[i] <= 'Z')
            ans = "WA";
    }

    if(count > 1 || count == 0)ans = "WA";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int x=0,count=0;
	
	while(scanf("%d",&a)&&a!=0){
		for(;a!=1;count++){
			switch(a%2){
				case 0:
					a/=2;
					break;
				case 1:
					a=a*3+1;
					break;
			}
		}
		printf("%d\n",count);
                count=0;
	}
	return 0 ;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll dp[2005],hell=pow(10,9)+7;
void solve(){
	ll s;
	cin>>s;
	dp[0]=1;
	for(ll i=3;i<=s;i++)
		for(ll j=3;j<=i;j++)
			dp[i]=(dp[i]+dp[i-j])%hell;
	cout<<dp[s];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mo 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll n;cin >> n;
    ll ans[n+1]={0};
    for(ll i=1;i<=100;i++)
    {
        for(ll j=1;j<=100;j++)
        {
            for(ll k=1;k<=100;k++)
            {
                ll r1 = i*i + j*j + k*k + i*k + i*j + j*k;
                if(r1<=n) ans[r1]++;
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3668
def f():
    import sys
    input=sys.stdin.buffer.readline
    sys.setrecursionlimit(10**9)
    h,w,k=map(int,input().split())
    dp=[0]*w
    dp[k-1]=1
    ne=[0]*w
    mod=10**9+7
    table=[1,1,2,3,5,8,13,21,34]
    for c in range(h):
        for i in range(w):
            ne[i]=dp[i]*table[i]*table[w-i-1]
            if i>0:
                ne[i]+=dp[i-1]*table[i-1]*table[w-i-1]
            if i<w-1:
                ne[i]+=dp[i+1]*table[i]*table[w-i-2]
            ne[i]%=mod
        dp,ne=ne,dp
    print(dp[0])


if __name__ == "__main__":
    f()

Measured memory_bytes: 3064
s=input()
q=int(input())

for i in range(q):
  command=list(input().split(' '))

  if command[0]=='reverse':
    a=int(command[1])
    b=int(command[2])
    s_list=list(reversed(s[a:b+1]))
    s=s[:a]+''.join(s_list)+s[b+1:]

  if command[0]=='replace':
    a=int(command[1])
    b=int(command[2])
    p=command[3]
    s=s[:a]+p+s[b+1:]

  if command[0]=='print':
    a=int(command[1])
    b=int(command[2])
    print(s[a:b+1])


Measured memory_bytes: 5612
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		String Positive = "Positive";
		String Negative = "Negative";
		String Zero = "Zero";

		if (a <= 0 && b >= 0) {
			System.out.println(Zero);
		} else if (a > 0) {
			System.out.println(Positive);
		} else {
			if (a == b) {
				System.out.println(Negative);
			} else if (Math.abs(b - a) % 2 == 0) {
				System.out.println(Negative);
			} else {
				System.out.println(Positive);
			}
		}
	}
}


Measured memory_bytes: 10068
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){ 
    string s; int K; cin >> s >> K;
    int len = s.size();
    int dp[110][2][5];
    rep(i, 110){rep(j, 2){rep(k, 5){dp[i][j][k] = 0;}}};

    dp[0][0][0] = 1;

    rep(i, len){
        int n = s[i] - '0';
        rep(smaller, 2){
            rep(k, 4){    
                for(int x = 0; x <= (smaller ? 9 : n); x++){
                    dp[i+1][smaller || x < n][x != 0 ? k+1 : k] += dp[i][smaller][k];
                }
            }
        }
    }
    cout << dp[len][0][K] + dp[len][1][K] << ln;
}

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

int main(){
    char ch;
    char chLower;
    int n;
    int counter[26];

    for(int i = 0; i < 26; i++){
        counter[i] = 0;
    }

    while(cin >> ch){
        if(isalpha(ch)){
            // cout << ch << endl;
            chLower = tolower(ch);
            n = chLower - 'a';
            // cout << n << endl;
            counter[n]++;
        }
    }

    for(int i = 0; i < 26; i++){
        printf("%c : %d\n", 'a' + i, counter[i]);
        // cout << counter[i] << endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(toupper(a[0]));
    cout << char(toupper(b[0]));
    cout << char(toupper(c[0])) << endl;
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y<=0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int h,w,k;
int dp[110][10];
signed main(){
	cin>>h>>w>>k;k--;
	dp[h+1][0]=1;
	for(int i=h+1;i>=2;i--){
		for(int j=0;j<(1<<w-1);j++){
			bool valid=true;
			for(int _=0;_<w;_++){
				if(j&(1<<_))if(j&(1<<_+1))valid=false;
			}
			if(!valid)continue;
			for(int tmp=0;tmp<w;tmp++){
//				cerr<<j<<" "<<i<<" "<<tmp<<" "<<dp[i][tmp]<<endl;
				if(j&(1<<tmp))(dp[i-1][tmp+1]+=dp[i][tmp])%=mod;
				else if(tmp && (j&(1<<tmp-1)))(dp[i-1][tmp-1]+=dp[i][tmp])%=mod;
				else (dp[i-1][tmp]+=dp[i][tmp])%=mod;
			}
		}
	}
	cout<<dp[1][k]<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import heapq
 
N, M = list(map(int, input().split()))
jobs = []

#上限内で報酬を得られる単発を一度リストに入れる。
for line in sys.stdin:
    A, B = map(int, line.split())
    if A > M:
        continue
    jobs.append((A, B))

#逆順にsort
jobs.sort(reverse=True)

#heatpqでpriority quene，最大値を取り出すときは-qを加えて挿入し，-1をかけて取り出す
q = []
ans = 0
#後ろの日にちから回す
for i in range(1, M + 1):
    #日数が足りる単発をheatpqのリストに加えていく
    while jobs and jobs[-1][0] <= i:
        A, B = jobs.pop()
        heapq.heappush(q, -B)
 
    if q:
        #できる仕事がある場合，最大の給料のを取り出す
        ans += -heapq.heappop(q)
print(ans)

Measured memory_bytes: 17208
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

void solve(string C){
    cout << char(C.at(0) + 1) << "\n";
}

int main() {
    string C;
    cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBounding solver = new BBounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBounding {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int d = 0;
            int count = 1;
            for (int i = 0; i < n; i++) {
                int temp = in.nextInt();
                d += temp;
                if (d <= x) count++;
                else break;
            }
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
s = gets.chomp
c = [0]*s.length
i = 0
s.scan(/(R+)(L+)/).each do |r, l|
  u = r.length
  i += u
  c[i] += u/2
  c[i-1] += u/2 + u%2
  u = l.length

  c[i] += u/2 + u%2
  c[i-1] += u/2
  i += u
end
puts c*' '

Measured memory_bytes: 12924
#include <bits/stdc++.h>
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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n && s[i] == s[i + 1]) {
            v.push_back(2);
            i++;
        } else {
            v.push_back(1);
        }
    }
    n = sz(v);
    modint ans;
    if (v[0] == 1) {
        ans = modint(3);
    } else {
        ans = modint(6);
    }

    rep(i, n - 1) {
        if (v[i] == 1) {
            ans *= 2;
        } else {
            if (v[i + 1] == 1) {
                ans *= 1;
            } else {
                ans *= 3;
            }
        }
    }
    cout << ans.value() << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,int> pli;
typedef pair<long long, long long> pll;

const int maxN = 1003;

class Cake {
public:
  ll val[3];
  Cake(ll x, ll y, ll z) {
    val[0] = x;
    val[1] = y;
    val[2] = z;
  }
  ll score(int mode) {
    ll sum = 0;
    for(int i=0; i<3; i++) {
      if (mode & (1<<i)) {
        sum += val[i];
      } else {
        sum -= val[i];
      }
    }
    return sum;
  }
};


int main (int argc, char*argv[]) {
  int n, m;
  cin >> n >> m;
  vector<Cake> a;
  for(int i=0; i<n; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    Cake tmp (x, y, z);
    a.push_back(tmp);
  }
  ll best = LLONG_MIN;
  for(int mode = 0; mode < 8; mode ++) {
    vector<ll> scores;
    for(auto cake : a) {
      scores.push_back(cake.score(mode));
    }

    ll sum = 0;
    sort(scores.begin(), scores.end(), greater<long long>());
    for(int i=0; i<m; i++) {
      sum += scores[i];
    }
    best = max(sum, best);
  }
  cout << best << endl;
  return 0;
}


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

int main() {
  int N, A;
  cin >> N ;
  int g_counter=0;
  int w_counter=0;
  int p_counter=0;
  int y_counter=0;
  int kind=0;
  for(int i =0; i<N;i++){
    string color;
    cin >> color;
    if(color == "G" && g_counter == 0) g_counter++;
    if(color == "W" && w_counter == 0) w_counter++;
    if(color == "P" && p_counter == 0) p_counter++;
    if(color == "Y" && y_counter == 0) y_counter++;
  }
  kind += g_counter +  w_counter + p_counter + y_counter;
  if(kind==3) cout << "Three" << endl;
  if(kind == 4) cout << "Four" << endl;
  
    
      
    

  // ここにプログラムを追記
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S.begin(),S.end());
    bool flag;
    int count = 1;
    string s = S[0];
    for(int i = 1; i < N; i++)
    {
       if(s != S[i]) count++, s = S[i];
    }
    cout << count << endl;
}

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)

ll n, c, g, a, we, le, ac, L[7], p[7], k;

signed main()
{
    cin >> n >> c, c *= n, k = (1 << (n - 1));
    forn(i, n) cin >> L[i], L[i] *= n;
    sort(L, L + n);
    iota(p, p + n - 1, 0);
    do {
        vector<vector<ll> > dp(c + 1, vector<ll>(k));
        dp[L[n - 1]][0] = 1;
        forn(i, c) if (i % n)
        {
            we = p[i % n - 1];
            forn(mask, k) if (!((1 << we) & mask))
                for (ac = i; ac <= c; ac++)
                    dp[max(ac, min(c, L[we] + i))][mask + (1 << we)] += dp[ac][mask];
        }
        g += dp[c][k - 1], a++;
    } while (next_permutation(p, p + n - 1));
    printf("%.15f", g / pow(c / n, n - 1) / a);
}


Measured memory_bytes: 384