akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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 n = read::<usize>();
    let mut aseq = vec![0; n];
    for i in 0..n {
        aseq[i] = read::<usize>();
    }
    let mut prev = 1 << 30;
    let mut ans = 0;
    for i in 0..n {
        if aseq[i] == prev {
            ans += 1;
            prev = 1 << 30;
        } else {
            prev = aseq[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	lli s,t,d;
	cin >> s >> t >> d;
	vector<lli> w(d);
	for(int i=0; i<d; i++){
		cin >> w[i];
	}

	lli sum = 0;
	lli minv=1e12;
	for(int i=0; i<d; i++){
		sum += w[i];
		if(sum < minv){
			minv = sum;
		}
	}
	if(sum >= 0 and s+minv > t){
		cout << -1 << endl;
		return 0;
	}

	lli rem = s-t;
	lli ans = max(rem +minv, 0LL) /(-sum);
	rem += ans*sum;
	ans *= d;
	for(int i=0; i<2*d; i++){
		ans++;
		rem += w[i%d];
		if(rem <= 0) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int A, B, K;

int main(void) {

	cin >> A >> B >> K;

	int count = 0;

	for (int i = 100; i >= 1; i--) {
		if (((A%i) == 0) && ((B%i) == 0)) {  count++; if (count == K) { cout << i << endl; break; } }
	}
	


	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto x = readLong();
    long ans = (x/11) * 2;
    if(x % 11 > 0) {
        if(x % 11 > 6) {
            ans += 2;
        } else {
            ans += 1;
        }
    }
    writeln(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long int
 
#define mod  1000000007
 

 
int main()
{
	FAST;
	int n;
	cin >> n;
	ll ans = 0;
	while(n ){
		int x = n;
		int f = 0;
		while(x){
			x /= 10;
			f ++;
		}
		if(f % 2){
			ans ++;
		}
		n --;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
  int i,j,h,v;
  int a[5];
  int b[5];

  while(scanf("%d %d %d %d",&a[1],&a[2],&a[3],&a[4])!=EOF){
    scanf("%d %d %d %d",&b[1],&b[2],&b[3],&b[4]);
    h=0;v=0;
    for(i=1;i<=4;i++){
      for(j=1;j<=4;j++){
	if(a[i]==b[j]){
	  if(i==j)h++;
	  else v++;
	}
      }
    }
    printf("%d %d\n",h,v);
  }
  return 0;
}

Measured memory_bytes: 596
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> as(n); cin >> as;
    vector<int> bs(m); cin >> bs;
    unordered_map<int, int> ras, rbs;
    for(int i = 0; i < n; i++){ ras[as[i]] = i; }
    for(int i = 0; i < m; i++){ rbs[bs[i]] = i; }
    printde(as);
    printde(bs);
    printde(ras);
    printde(rbs);
    int hs = 0, vs = 0;
    ll ans = 1;
    // ll cnt = 0;
    ll cnt2 = 0;
    for(int i = n * m; i >= 1; i--){
        if(ras.count(i) && rbs.count(i)){
            hs++;
            vs++;
            // cnt += m - vs;
            // cnt += n - hs;
            cnt2 += vs - 1;
            cnt2 += hs - 1;
        }else if(ras.count(i)){
            hs++;
            // cnt += m - vs;
            cnt2 += vs - 1;
            ans *= vs;
        }else if(rbs.count(i)){
            vs++;
            // cnt += n - hs;
            cnt2 += hs - 1;
            ans *= hs;
        }else{
            // ans *= cnt;
            // cnt--;
            ans *= cnt2;
            if(cnt2 == 0){
                cout << 0 << '\n';
                return 0;
            }
            cnt2--;
            // ans *= vs;
            // ans %= M;
            // ans *= hs;
        }
        // cnt %= M;
        cnt2 %= M;
        ans %= M;
        printde(i, hs, vs, cnt2, ans);
    }
    cout << ans << '\n';
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
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; }

int main()
{
	ll n, k;
	vector<P> l;
	ll a, b;
	ll count = 0;

	cin >> n >> k;

	rep(i, n)
	{
		cin >> a >> b;
		l.push_back(P(a, b));
	}

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

	rep(i, n)
	{
		P tmp;
		tmp = l[i];
		count += tmp.second;
		if (count >= k)
		{
			cout << tmp.first << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    set<int> s;
    rep1(i,10) rep1(j,10) s.insert(i*j);
    auto it = s.find(n);
    if (it == s.end())
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3616
INF = 10**3


def reconstruction(o_ary, p_ary, i_ary, l, r):
    if l >= r:
        return

    ind = INF
    for i in i_ary[l:r]:
        tmp_ind = p_ary.index(i)
        if ind > tmp_ind:
            ind = tmp_ind
    c = p_ary[ind]
    m = i_ary.index(c)

    reconstruction(o_ary, p_ary, i_ary, l, m)
    reconstruction(o_ary, p_ary, i_ary, m + 1, r)
    o_ary.append(c)


n = int(input())
p_ary = [int(_) for _ in input().split()]
i_ary = [int(_) for _ in input().split()]
o_ary = []
reconstruction(o_ary, p_ary, i_ary, 0, n)
print(*o_ary)



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
    cout << "No" << endl;
    return 0;
  }
  if(S.substr(0,N/2)==S.substr(N/2,N/2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3616
import java.util.Scanner;

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

		int N, M, flag;
		int con = 0;

		String[] U = new String[256];
		String[] T = new String[256];

		N = scan.nextInt();
		for (int i = 0; i < N; i++) {
			U[i] = scan.next();
		}

		M = scan.nextInt();
		for (int i = 0; i < M; i++) {
			T[i] = scan.next();
		}

		for (int i = 0; i < M; i++) {
			flag = 0;
			for (int j = 0; j < N; j++) {
				if (U[j].equals(T[i])) {
					con++;
					if ((con % 2) == 1)
						System.out.println("Opened by " + T[i]);
					if ((con % 2) == 0)
						System.out.println("Closed by " + T[i]);
					flag = 1;
				}
			}
			if (flag == 0)
				System.out.println("Unknown " + T[i]);
		}

	}
}

Measured memory_bytes: 21120
s = gets.chomp
while !(s.empty?)
  if s[0..4] == "erase"
    if s[5] == "r"
      s.slice!(0,6)
    else
      s.slice!(0,5)
    end
  elsif s[0..4] == "dream"
    if s[5..6] == "er" && s[7] != "a"
      s.slice!(0,7)
    else
      s.slice!(0,5)
    end
  else
    puts "NO"
    exit
  end
end
puts "YES"

Measured memory_bytes: 67708
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <set>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;

    cin >> n;
    string s;
    set<string> st;
    REP(i,n){
        cin >> s;
        st.insert(s);

    }
    cin >> n;
    bool is_open = false;
    REP(i,n){
        cin >> s;
        auto it = st.find(s);
        if(it!=st.end()){
            if(!is_open){
                cout << "Opened by " << s << endl;
            }else{
                cout << "Closed by " << s << endl;
            }
            is_open = !is_open;
        }else{
            cout << "Unknown " << s << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define M1 1000000007LL
typedef pair<int,int> ii;
typedef vector<int> vi;
#define MAXH 101
#define MAXW 10
#define MAXK 10
#define MAXM 512
ll dp[MAXH][MAXK];
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int h,w,k;
	cin >> h >> w >> k;
	int mask = (1 << (w-1));
	for (int i=0; i<MAXH; i++) {
		for (int j=0; j<MAXK; j++) {
			dp[i][j] = 0;
		}
	}
	dp[0][1] = 1;
	for (int i=1; i<=h; i++) {
		for (int j=0; j<mask; j++) {
			bool valid = true;
			for (int r=1; r<w-1; r++) {
				if (((j >> r) & 1) && ((j >> (r-1)) & 1)) {
					valid = false;
				}
			}
			if (!valid) {
				continue;
			}
			for (int r=1; r<w; r++) {
				if ((j >> (r-1)) & 1) {
					dp[i][r+1] = (dp[i][r+1] + dp[i-1][r]) % M1;
					dp[i][r] = (dp[i][r] + dp[i-1][r+1]) % M1;
				}
			}
			for (int r=1; r<w-1; r++) {
				if (((j >> r) & 1) == ((j >> (r-1) & 1))) {
					dp[i][r+1] = (dp[i][r+1] + dp[i-1][r+1]) % M1;
				}
			}
			if ((j&1) == 0) {
				dp[i][1] = (dp[i][1] + dp[i-1][1]) % M1;
			}
			if (w > 1) {
				if (((j >> (w-2)) & 1) == 0){
					dp[i][w] = (dp[i][w] + dp[i-1][w]) % M1;
				}
			}
 		}
	}
	ll res = dp[h][k];
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
typedef long long ll;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n, k;
int a[maxx];
int pos;

int main() {
	scanf("%d %d", &n, &k);
	int num = 0;
	while(n) {
		a[++num] = n % k;
		n /= k;
	}
	for(int i = num; i >= 1; i--) {
		if(a[i]) {
			pos = i;
			break;
		}
	}
	cout << pos << endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef _MSC_VER
#include <bits/stdc++.h>
#endif // ! _MSC_VER

using namespace std;

typedef long long ll;

int dn = 0;
vector<pair<int,int>> h;
vector<int> p;
vector<int> x;

void next(int now)
{
	for (int i = 0; i < h.size(); ++i) {
		int nx = -1;
		if (h[i].first == now) {
			nx = h[i].second;
		} else if (h[i].second == now) {
			nx = h[i].first;
		} else {
			continue;
		}

		if (x[nx] <= 0) {
			x[nx] = p[++dn];
			cerr << nx << "," << dn << "," << x[dn] << "\n";
			next(nx);
		}
	}
}


int main(int, char**)
{
	int n;
	cin >> n;
	h.resize(n-1);
	p.resize(n);
	x.resize(n);

/*	for (int i = 0; i < n; i++) {
		c[i].first = 0;
		c[i].second = i;
	}
*/	for (int i = 0; i < (n - 1); i++) {
		cin >> h[i].first >> h[i].second;
		(h[i].first)--;
		(h[i].second)--;
	}
	// sort(&(c[0]), &(c[n]));

	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p.rbegin(), p.rend());

	dn = 0;
	x[0] = p[0];
	next(0);

	ll ans = 0;
	for (int i = 1; i < n; i++)
		ans += p[i];

	cout << ans << "\n";
	for (int i = 0; i < n - 1; i++)
		cout << x[i] << " ";
	cout << x[n-1] << endl;

	return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 5010;

int N,M;
int ed;
int st;

char G[55][55];
int vis[55][55];

bool get_input(){
    scanf("%d %d",&N,&M);
    if(!N && !M) return false;
    getchar();
    _for(i,0,N){
        fgets(G[i],55,stdin);
    }
    st = 0;
    ed = N*M*2+1;

    return true;
}

bool valid(int nx,int ny){
    if(nx < 0 || nx >= N || ny < 0 || ny >= M) return false;
    if(G[nx][ny] == '#') return false;
    return true;
}

bool dfs(int x,int y,int dir,int goods){

    if(G[x][y] == '#') return false;

    if(x == 0 && y == 0 && goods == 3) return true;
    if(x == 0 && y == M-1 && goods == 0) goods++;
    if(x == N-1 && y == M-1 && goods == 1) goods++;
    if(x == N-1 && y == 0 && goods == 2) goods++;

    if(vis[x][y]) return false;
    vis[x][y] = 1;

    _for(i,-1,2){
        int nexd = (i + dir + 4)%4;
        int nx =  dx[nexd] + x;
        int ny =  dy[nexd] + y;
        if(valid(nx,ny)){
            if(dfs(nx,ny,nexd,goods)) return true;
        }
    }
    return false;
}

int main()
{
    while(get_input()){
        memset(vis,0,sizeof(vis));

        if(dfs(0,0,1,0)) printf("YES\n");
        else printf("NO\n");

    }
    return 0;
}



Measured memory_bytes: 3140
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()

  if n%2==0:
    n-=1
  return n//2

# main()
print(main())


Measured memory_bytes: 7848
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  string s;
  int64_t k;
  cin >> s >> k;

  rep(i,min((int64_t)s.size(), k)) {
    if (s[i] > '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main()
{	
    int n, x;
	cin >> n >> x;
    vector<int> l,d;
    l.resize(n);
    d.resize(n+1);
    for(int i=0; i<n; i++) cin >> l[i];

    d[0] = 0;
    for(int i=1; i<n+1; i++){
        d[i] = d[i-1] + l[i-1];
    }

    int count(0);
    for(int i=0; i<n+1; i++){
        if(d[i]<=x) count++;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	BufferedReader input;
	
	String solve(String[] str){
		StringBuilder[] number=new StringBuilder[2];
		for(int i=0;i<2;++i){
			number[i]=new StringBuilder(str[i]);
			number[i].reverse();
		}
		StringBuilder solution=new StringBuilder(80);
		int carry=0;
		for(int i=0;i<Math.max(number[0].length(),number[1].length());++i){
			int a[]=new int[2];
			for(int j=0;j<2;++j)a[j]=(int)(i<number[j].length()?number[j].charAt(i)-'0':0);
			int x=(a[0]+a[1]+carry)%10;
			carry=(a[0]+a[1]+carry)/10;
			solution.append(x);
		}
		if(carry>0){
			solution.append(carry);
		}
		solution.reverse();
		return solution.length()<=80?solution.toString():"overflow";
	}
	
	void io(){
		input=new BufferedReader(new InputStreamReader(System.in));
		String[] str=new String[2];
		int n=0;
		try {
			 n=Integer.parseInt(input.readLine());
		} catch (Exception e) {}
		for(int i=0;i<n;++i){
			for(int j=0;j<2;++j){
				try{
				str[j]=input.readLine();
				}catch(Exception e){}
			}
			System.out.println(solve(str));
		}		
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 16912
txt="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
n=int(input())
line=list(map(int,txt.split(", ")))
print(line[n-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;
int main(){
    int n;
    cin >> n;
    vector<int> height(n);
    rep(i,n){
        cin >> height[i];
    }
    long long ans = 0;
    map<int,int> mp;
    rep(i,n){
        int sa = i - height[i];
        int wa = i + height[i];
        ans += mp[sa];
        mp[wa]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 20992
#include <cstdio>
#include <algorithm>

using namespace std;

const long long inf=1e15;
struct arbint
{
    long long s1=inf,s2=inf;
}arb[800010];
long long sol1,sol2,rez;

void arbint_update(int nod,int st,int dr,int poz,long long val)
{
    if(st==dr)
    {
        arb[nod].s1=val-poz;
        arb[nod].s2=val+poz;
    }
    else
    {
        int mid=(st+dr)/2;
        if(poz<=mid) arbint_update(nod*2,st,mid,poz,val);
        else arbint_update(nod*2+1,mid+1,dr,poz,val);
        arb[nod].s1=min(arb[nod*2].s1,arb[nod*2+1].s1);
        arb[nod].s2=min(arb[nod*2].s2,arb[nod*2+1].s2);
    }
}

void arbint_query(int nod,int st,int dr,int left,int right)
{
    if(left<=st && dr<=right)
    {
        sol1=min(sol1,arb[nod].s1);
        sol2=min(sol2,arb[nod].s2);
    }
    else
    {
        int mid=(st+dr)/2;
        if(left<=mid) arbint_query(nod*2,st,mid,left,right);
        if(mid<right) arbint_query(nod*2+1,mid+1,dr,left,right);
    }
}

void arbint_query1(int nod,int st,int dr)
{
    if(st==dr) rez=min(rez,arb[nod].s1+st);
    else
    {
        int mid=(st+dr)/2;
        arbint_query1(nod*2,st,mid);
        arbint_query1(nod*2+1,mid+1,dr);
    }
}

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,q,a,b,x;
    scanf("%d%d%d%d",&n,&q,&a,&b);
    long long aduna=0;
    arbint_update(1,1,n,a,0);
    int last=b;
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&x);
        sol1=sol2=inf;
        arbint_query(1,1,n,1,x);
        long long s=sol1+aduna+x;
        sol1=sol2=inf;
        arbint_query(1,1,n,x,n);
        s=min(s,sol2+aduna-x);
        aduna+=abs(x-last);
        arbint_update(1,1,n,last,s-aduna);
        last=x;
    }
    rez=inf;
    arbint_query1(1,1,n);
    rez+=aduna;
    printf("%lld",rez);
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int len = s.length();
	if(len%2 != 0){
		cout<<"No";
	}
	else{
		int by2 = len/2;
		int j = by2;
		bool flag = true;
		for(int i=0;i<by2;i++){
		//	cout<<"comparing "<<s[i]<<"\t"<<s[j]<<endl;
			if(s[i] != s[j]){
				
				flag = false;
				break;
			}
			else{
		//		cout<<"heere\n";
				flag = true;
			}
			j++;
		}
		if(flag == true)
				  cout<<"Yes";
		else{
			cout<<"No";
		}		  
	}
}

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

using namespace std;

const int maxn=200000+5;
const int maxa=2000+5;
const int MOD=1e9+7;

#define inv(x) pow_mod(x,MOD-2)

int pow_mod(int x,int y) {
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1) ret=1ll*ret*x%MOD;
	return ret;
}

int fac[maxa<<2],inv_fac[maxa<<2];

void init(int n) {
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%MOD;
	
	inv_fac[n]=inv(fac[n]);
	for(int i=n;i>=1;i--) inv_fac[i-1]=1ll*inv_fac[i]*i%MOD;
}

int C(int n,int m) {
	return 1ll*fac[n]*inv_fac[m]%MOD*inv_fac[n-m]%MOD;
}

#define f(i,j) f[i+mxa][j+mxb]

int f[maxa<<1][maxa<<1];
int A[maxn],B[maxn],N,mxa,mxb;

int solve() {
	for(int i=1;i<=N;i++) ++f(-A[i],-B[i]);
	
	for(int i=-mxa;i<=mxa;i++)
		for(int j=-mxb;j<=mxb;j++) {
			if(i>-mxa) f(i,j)=(f(i,j)+f(i-1,j))%MOD;
			if(j>-mxb) f(i,j)=(f(i,j)+f(i,j-1))%MOD;
		}
	
	int ans=0;
	for(int i=1;i<=N;i++)
		ans=(ans+f(A[i],B[i]))%MOD;
	
	init(mxa+mxb<<1);
	for(int i=1;i<=N;i++)
		ans=(ans-C(A[i]+B[i]<<1,A[i]<<1)+MOD)%MOD;
	
	return 1ll*ans*inv(2)%MOD;
}

int main() {
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		scanf("%d%d",&A[i],&B[i]);
		mxa=max(mxa,A[i]);
		mxb=max(mxb,B[i]);
	}
	
	printf("%d\n",solve());
	return 0;
}

Measured memory_bytes: 64512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, mn_co = 0;
	cin >> n;
	ll sum = 0, mn = 1001001001;
	rep(i, n){
		ll in;
		cin >> in;
		sum += fabs(in);
		mn = min(mn, (ll)fabs(in));
		if(in < 0) mn_co++;
	}
	if(mn_co % 2 == 0){
		cout << sum << endl;
	}else{
		cout << sum - mn * 2 << endl;
	}
	return 0;
}

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

typedef  long long ll;

using namespace std;

int n, l;

int main(){
    cin >> n >> l;
    vector<string> s(n);
    string ans;

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

    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++){
        ans += s[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int e = sc.nextInt();
		int[] x = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			int check = x[i] * ((t+e)/ x[i]);
			if(check <= t+e && check >= t-e) {
				System.out.println((i+1));
				return;
			}
		}
		System.out.println(-1);
		
	}
}

Measured memory_bytes: 18292
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
  int N;

  cin >> N;

  int c = N % 10;
  if(c == 3) cout << "bon";
  else if(c == 0 || c == 1 || c == 6 || c == 8) cout << "pon";
  else cout << "hon";

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int N; cin >> N;
    ll A[100000];
    for(int i=0;i<N;i++) cin >> A[i];
    ll out=A[0];
    for(int i=0;i<N;i++){
        ll b=A[i];
        if(out<b){
            ll tmp=out;
            out=b; b=tmp;
        }
        ll r;
        ll a=out;
        while(true){
            r=a%b;
            if(r==0){
                r=b;
                break;
            }
            a=b;
            b=r;
        }
        out=b;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  for(int i=n;i>=1;--i){
    int sum=0;
    for(int j=i+i;j<=n;j+=i){
      sum^=b[j];//xor
    }
    b[i] = sum^a[i];//xor
  }
  vector<int> ans;
  for(int i=1;i<=n;i++){
    if(b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i,ans.size()){
    printf("%d%c", ans[i],i+1 == ans.size()?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e17+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[200001]={0};
//ll b[200001]={0};
//bool c[100000001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<ll> adj[100001];
//vpii edges;
//bool visited[100001]={0};
//bool color[100001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr)+1;
        }
    }
}*/

/*void dfs(ll x,ll y,ll px,ll py,char color){
    if(x<0 || y<0 || x>=n || y>=m)return;
    if(grid[x][y]!=color)return;

    if(visited[x][y]){
        f=true;
        return;
    }
    visited[x][y]=true;

    if(px!=(x+1) || py!=y)
        dfs(x+1,y,x,y,color);
    if(px!=(x-1) || py!=y)
        dfs(x-1,y,x,y,color);
    if(px!=(x) || py!=y+1)
        dfs(x,y+1,x,y,color);
    if(px!=(x) || py!=y-1)
        dfs(x,y-1,x,y,color);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s,bool colr){
    if(visited[s])return;
    visited[s]=true;
    color[s]=colr;
    for(auto u:adj[s]){
        dfs(u,!colr);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

void solve(){
    ll n,k;
    cin>>n>>k;

    input(a,n);
    sort(a,a+n);
    ll ans=0;
    for(ll i=0;i<k;i++){
        ans+=a[i];
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(10000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, 0, n){
        cin >> t[i];
    }
    int ans = 1;
    sort(all(t));
    int now = t[0], cnt = 1;
    rep(i, 1, n){
        if(now + k >= t[i] && cnt + 1 <= c){
            cnt++;
        }else{
            ans++;
            now = t[i];
            cnt = 1;
        }
    }
    cout << ans << endl;
}

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

int ans[100000];

int main(){
	int n;
	string s;
	cin>>n>>s;

	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			ans[0] = i;
			ans[1] = j;
			bool f = 0;

			for(int it=1;it<n-1;it++){
				if((ans[it] && s[it]=='o') || (!ans[it] && s[it]=='x')){
					ans[it+1] = ans[it-1];
				} else {
					ans[it+1] = !ans[it-1];
				}
			}

			if((ans[n-1] && s[n-1] == 'o') || (!ans[n-1] && s[n-1] == 'x')){
				if(ans[0] != ans[n-2]) f = 1;
			}
			else if(ans[0] == ans[n-2]) f = 1;

			for(int it=0;it<n;it++){
				if(ans[it] && s[it]=='o') if(ans[(it-1+n)%n] != ans[(it+1)%n]) f = 1;
				if(!ans[it] && s[it]=='x') if(ans[(it-1+n)%n] != ans[(it+1)%n]) f = 1;
				if(ans[it] && s[it] =='x') if(ans[(it-1+n)%n] == ans[(it+1)%n]) f = 1;
				if(!ans[it] && s[it] =='o') if(ans[(it-1+n)%n] == ans[(it+1)%n]) f = 1;
			}

			if(!f){
				for(int it=0;it<n;it++){
					cout<<(ans[it] ? 'S' : 'W');
				}
				return 0;
			}
		}
	}
	cout<<"-1";
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int k,x;
  cin >> k >> x;
  if(500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (h, w, k): (usize, usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        let c = ws.next().unwrap().parse().unwrap();
        (a, b, c)
    };

    let mut v: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let v_i: Vec<char> = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right().to_owned();
            s.chars().collect()
        };
        v.push(v_i)
    }

    // println!("{:?}", v);

    // let mut ans = vec![vec![0; w]; h];

    // for i in 0..h {
    //     for j in 0..w {
    //         ans[i][j] = count;
    //     }
    //     if v[i].iter().any(|&c| c == '#') {
    //         count += 1;
    //     }
    // }
    let mut tmpv = vec![];
    let mut is_first = true;
    for i in 0..h {
        if v[i].iter().any(|&c| c == '#') {
            if is_first {
                is_first = false;
                continue;
            }
            tmpv.push(i);
        }
    }
    tmpv.push(h);
    // debugln!("{:?}", tmpv);

    let mut h_sections = vec![(0, tmpv[0])];
    for i in 1..tmpv.len() {
        h_sections.push((tmpv[i - 1], tmpv[i]));
    }
    // debugln!("{:?}", h_sections);

    let mut sections = vec![];
    for sec in h_sections {
        sections.push((sec, solve_part(sec, &v)));
    }
    // debugln!("{:?}", sections);

    let mut ans = vec![vec![0; w]; h];
    let mut count = 1;
    for (h_sec, w_secs) in sections {
        let (h1, h2) = h_sec;
        for ws in &w_secs {
            let (w1, w2) = *ws;
            for i in h1..h2 {
                for j in w1..w2 {
                    ans[i][j] = count;
                }
            }
            count += 1;
        }
    }

    // print answer
    for i in 0..h {
        println!("{}", ans[i].iter().map(|&c| c.to_string()).collect::<Vec<String>>().join(" "));
    }
}

fn solve_part((a, b): (usize, usize), v: &Vec<Vec<char>>) -> Vec<(usize, usize)> {
    let h = v.len();
    let w = v[0].len();

    let mut tmpv = vec![];
    let mut is_first = true;
    'outer: for i in 0..w {
        for j in a..b {
            if v[j][i] == '#' {
                if is_first {
                    is_first = false;
                    continue 'outer;
                }
                tmpv.push(i);
            }
        }
    }
    tmpv.push(w);

    let mut w_sections = vec![(0, tmpv[0])];
    for i in 1..tmpv.len() {
        w_sections.push((tmpv[i - 1], tmpv[i]));
    }
    // debugln!("{:?}", w_sections);

    w_sections
}


Measured memory_bytes: 8444
N=int(input())
class Lucky:
    def __init__(self,N):
        self.N=N
        self.N_1=int(N/100)
        self.N_2=int((N - 100*self.N_1)/10)
        self.N_3=int((N-100*self.N_1-10*self.N_2))
        
    def Lucky_7(self):
        if self.N_1==7 or self.N_2==7 or self.N_3==7:
            return print("Yes")
        else:
            return print('No')

Lucky(N).Lucky_7()

Measured memory_bytes: 9148
s = input()
mod = 10**9+7

dp = [[0 for j in range(13)] for i in range(len(s)+1)]
dp[0][0] = 1
for i in range(len(s)):
  c = -1 if s[i] == '?' else int(s[i])
  for j in range(10):
    if (c != -1 and c != j):
      continue
    for k in range(13):
      dp[i+1][(k * 10 + j) % 13] += dp[i][k]
      dp[i+1][(k * 10 + j) % 13] %= mod
		
  for j in range(13):
    dp[i+1][j] %= mod    
  
print(int(dp[len(s)][5]))


Measured memory_bytes: 66908
S = input()
T = input()

cum_s = [(0, 0)]
cum_t = [(0, 0)]

for i in range(len(S)):
    p, q = cum_s[-1]
    if S[i] == 'A':
        cum_s.append((p + 1, q))
    else:
        cum_s.append((p, q + 1))

for i in range(len(T)):
    p, q = cum_t[-1]
    if T[i] == 'A':
        cum_t.append((p + 1, q))
    else:
        cum_t.append((p, q + 1))

Q = int(input())

for _ in range(Q):
    a, b, c, d = map(int, input().split())
    sp = cum_s[b][0] - cum_s[a - 1][0]
    sq = cum_s[b][1] - cum_s[a - 1][1]
    tp = cum_t[d][0] - cum_t[c - 1][0]
    tq = cum_t[d][1] - cum_t[c - 1][1]
    sp += sq * 2
    tp += tq * 2
    if sp % 3 == tp % 3:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 29948
#include<iostream>

using namespace std ;

int main()
{
	int a , b , c ;
	cin >> a >> b >> c ;
	if(a == b && b == c)
	cout << "No" << endl ;
	else if(a != b && b != c && a != c)
	cout << "No" << endl ;
	else
	cout << "Yes" << endl ; 
	
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  long long int sum=0;
  for(long long int i=1;i<=N;i++){
    if(i%3==0){
      continue;
    }
    else if(i%5==0){
      continue;
    }
    else{
      sum+=i;
    }
  }
  cout << sum;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
int main()
{
	char charnum,flick;
	int num,f;
	const char boin[5]={'a','i','u','e','o'};
	while(std::cin>>charnum){
		num=charnum-'0';
		std::cin>>flick;
		switch(flick){
case 'T':f=0;break;
case 'L':f=1;break;
case 'U':f=2;break;
case 'R':f=3;break;
case 'D':f=4;break;
		}
		if(num==0){
			const char wa[5][3]={"wa","","nn","","wo"};
			std::cout<<wa[f];
		}
		else if(num==1){
			std::cout<<boin[f];
		}else{
			const char ciin[10]={0,0,'k','s','t','n','h','m','y','r'};
			std::cout<<ciin[num]<<boin[f];
		}
	}
	std::cout<<std::endl;
	return 0;
}

Measured memory_bytes: 1140
s = input()
t = input()

# DPテーブルを初期化
dp = [[0 for j in range(len(t)+1)] for i in range(len(s)+1)]


# ループを回す
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

# 答えを復元
ans = ''
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1]+ans
        i -= 1
        j -= 1
print(ans)


Measured memory_bytes: 121436
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
diff = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
diff_i = [abs(A[i + 2] - A[i]) for i in range(N)]
a = sum(diff)
for i in range(N):
  print(a + diff_i[i] -  (diff[i] + diff[i + 1]))

Measured memory_bytes: 16300
#include<stdio.h>
#include<math.h>

int main(){
    double a,b,c;
  double S,L2, L, h;
 
  scanf("%lf %lf %lf",&a,&b,&c);
 
  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;
 
  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 
 
    return 0;
}


Measured memory_bytes: 2036
import bisect
while True:
    N,Q = map(int,input().split())
    if N == 0: break
    src = []
    for i in range(N):
        n,l,y = input().split()
        src.append((int(y), int(l), n))
    src.sort()
    for i in range(Q):
        q = int(input())
        a = bisect.bisect(src,(q,-1,-1))
        if a < N:
            y,l,n = src[a]
            if y-l < q <= y:
                print(n + ' ' + str(q-y+l))
                continue
        if a+1 < N:
            y,l,n = src[a+1]
            if y-l < q <= y:
                print(n + ' ' + str(q-y+l))
                continue
        print('Unknown')

Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

#include <bits/stdc++.h>
using namespace std;

template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 998244353;
using mint = Fp<MOD>;

vector<mint> dp(210000, 0);

int main()
{
    int n, k;
    cin >> n >> k;
    vector<P> rng(k);

    for (int i = 0; i < k; i++)
    {
        int l, r;
        cin >> l >> r;
        r++;
        rng[i] = make_pair(l, r);
    }

    vector<mint> dp(n);
    dp[0] = 1;
    dp[1] = -1;

    for (int i = 0; i < n; i++)
    {
        if (i > 0)
            dp[i] += dp[i - 1];
        for (int j = 0; j < k; j++)
        {
            int l, r;
            tie(l, r) = rng[j];
            if (i + l < n)
                dp[i + l] += dp[i];
            if (i + r < n)
                dp[i + r] -= dp[i];
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
int N, X, Y, G[2005][2005], cnt[2005];
int main()
{
    cin>>N>>X>>Y;
    for(int i = 1; i<=N; ++i)
    {
        for(int j = i+1; j<=N; ++j)
        {
            if(i<=X)
            {
                if(j<=X)
                    G[i][j] = j-i;
                else if(X<j && j<Y)
                    G[i][j] = min(j-i, X-i+1+Y-j);
                else 
                    G[i][j] = X-i+1+j-Y;
            }
            else if(X<i && i<Y)
            {
                G[i][j] = min(j-i, i-X+1+abs(Y-j));
            }
            else
            {
                G[i][j] = j-i;
            }
            
        }
    }
    for(int i = 1; i<=N; ++i)
    {
        for(int j = i+1; j<=N; ++j)
        {
            //cout<<G[i][j]<<" ";
            cnt[G[i][j]]++;
        }
        //cout<<"\n";            
    }
    for(int i = 1; i<N; ++i) 
        cout<<cnt[i]<<"\n";
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,a[200005],b,c,e,f,g,cnt;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n+1;i++){
		ll x=a[i-1],y=a[i];
		if(x==y)continue;
		if(x<y){
			e=y-x+b;
			f=min(b,y-x+c);
			g=min(c,y-x);
			while(e>y){
				cnt++;
				e=f;
				f=g;
				g=0;
			}
			b=e;
			c=f;
		}else{
			e=b;
			f=min(c,max(y-x+b,0LL));
			g=0;
			while(e>y){
				cnt++;
				e=f;
				f=g;
				g=0;
			}
			b=e;
			c=f;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1792