akhauriyash/Code-Regression huggingface dataset:
import sys
import queue

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def ddd(al, c):
	rcq = queue.PriorityQueue()
	for _ in range(c):
		rcq.put(0)
	for st, ed in al:
		earliest = rcq.get()
		#pa((earliest,st))
		if earliest >= st-0.5:
			return False
		rcq.put(ed)
	return True

def main():
	#a = int(input())
	n, c = tin()
	#s = input()
	dd=[[] for _ in range(c)]
	for _ in range(n):
		s, t, cv = tin()
		dd[cv-1].append((s,t))
	#for cl in dd:
	#	pa(cl)
	
	aal=[]
	for cl in dd:
		if len(cl)==0:
			continue
		cl.sort()
		sa, ta = cl[0]
		for s, t in cl[1:]:
			if ta == s:
				ta = t
			else:
				aal.append((sa, ta))
				sa,ta = s, t
		else:
			aal.append((sa, ta))
			
	#aal = [list(tin()) for _ in range(n)]
	aal.sort()
	#pa(aal)
	for i in range(1, c+1):
		is_ok = ddd(aal, i)
		#pa(i)
		if is_ok:
			return i
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

  if((a*b)%2==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		int num = r*100 + g*10 + b;
		if(num%4 == 0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int x[] = {0,1,0,-1};
int y[] = {1,0,-1,0};
int main() {
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  auto ok = [&](int i,int j){
    return 0<=i&&i<h&&0<=j&&j<w&&s[i][j]=='#';
  };
  bool ans = true;
  rep(i,h)rep(j,w){
    if(s[i][j]=='.')continue;
    ans &= [&]{
      bool res = false;
      rep(d,4) res |= ok(i+x[d],j+y[d]);
      return res;
    }();
  }
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    vector<bool> cb(n,false), ca(n,false);
    rep(i,n){
        string s;
        cin >> s;
        rep(j, s.size()-1){
            if(s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s[0] == 'B') cb[i] = true;
        if(s[s.size()-1] == 'A') ca[i] = true;
    }
    bool f = true;
    int cc = 0, cv = 0;
    rep(i,n){
        if(ca[i] != cb[i]) f = false;
        if(ca[i]) cc++;
        if(cb[i]) cv++;
    }
    if(f && min(cc,cv) != 0) ans += (min(cc, cv)-1);
    else ans += min(cc,cv);

    cout << ans << endl;
}


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

using namespace std;

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

	double ans = 0.0;
	int done = N + 1, temp = 1;
	while (done > 1){
		if((K + temp - 1) / temp <= N){
			ans += (double)(done - (K + temp - 1) / temp) / (double)temp;
			done = (K + temp - 1) / temp;
		}
		temp *= 2;
	}
	ans /= N;

	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
//careful not to convert INF to int type.
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n+1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    string s; cin >> s;
    string t; cin >> t;
    int n = t.size();
    int m = s.size();
    //cout << s.size();
    auto dp = new int[3030][3030];
    rep(i,0,3030){
        rep(j,0,3030){
            dp[i][j] = 0;
        }
    }
    rep(i,0,m){
      rep(j,0,n){
          if (s[i] == t[j]){
              dp[i+1][j+1] = dp[i][j]+1;
          }
          else
          {
              dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
          }
      }
    }
    string ans = "";
    int i = m; int j = n;
    //rep(i,0,m){
        //if(dp[i+1][n] != dp[i][n]){
            //ans = ans + s[i];
        //}
    //}
    while (i > 0 && j > 0)
    {
        if (dp[i][j] == dp[i-1][j]) {
            i--; 
        }

        else if (dp[i][j] == dp[i][j-1]) {
            j--; 
        }

        else {
            ans = s[i-1] + ans; 
            i--, j--; 
        }
    }
    cout << ans << endl;

    delete[] dp;
}

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

Measured memory_bytes: 36096
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x, y; cin>>x>>y;
	bool flag = true;
	for(int i=0; i<=x && flag; i++){
		int b = x-i;
		int op = (2*i) + (4*b);
		if(op == y){
			cout<<"Yes"<<endl;
			flag = false;
			break;
		}
	}
	if(flag)cout<<"No"<<endl;
}


Measured memory_bytes: 3648
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        k: usize,
        a:[usize;n]
    }

    let mut a = a;
    a.sort();
    a.reverse();

    let mut ans = 0;

    let mut min = 0;
    let mut max = 0;
    for i in 0..n {
        max = cmp::max(max, a[i]);
    }

    while max - min > 1 {
        let mid = (min + max) / 2;
        if check_Cutout(&a, mid) > k {
            min = mid;
        } else {
            max = mid;
        }
    }

    println!("{}", max);
}

// k回でcut_lengthに切り分けられるか
fn check_Cutout(a: &[usize], cut_length: usize) -> usize {
    let mut cut_count = 0;
    for i in 0..a.len() {
        if a[i] > cut_length {
            cut_count += (a[i] as f64 / cut_length as f64).ceil() as usize - 1;
        } else {
            break;
        }
    }

    //println!("{}: cut_count {}", cut_length, cut_count);

    cut_count
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 二分探索 vは単調増加 v[x] >= aとなる最小のxを返す
fn bin_search(v: &[usize], a: usize) -> usize {
    if v.is_empty() || a <= v[0] {
        return 0;
    }
    let mut min = 0;
    let mut max = v.len();
    while max - min > 1 {
        let mid = (min + max) / 2;
        if v[mid] < a {
            min = mid;
        } else {
            max = mid;
        }
    }
    max
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);


int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int a; sf(a);
	cout << (a / 2) * ((a + 1) / 2);
}

Measured memory_bytes: 256
n =  input()
f = n[:2]
a = n[2:]
#print(f,a)
month = ['01','02','03','04','05','06','07','08','09','10','11','12']
#print(type(f))
if   (f in month) & (a in month):
  print('AMBIGUOUS')
elif (f in month):
  print('MMYY')
elif (a in month):
#  a in month:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i)=0; i<(n); i++)
 
int main(){
  int n, s=0;
  cin >> n;
  vector<int> c(n+1,0);
  rep(i,n) cin >> c.at(i);
  sort(c.begin(), c.end(), greater<int>());
  rep(i,(n+1)/2) s = s + c.at(i*2) - c.at(i*2+1);
  cout << s;
}

Measured memory_bytes: 256
n,x,y=map(int,input().split())
a=[0]*n
z=y-x-1
for i in range(1,n):
	for j in range(i+1,n+1):
		p=min(j-i,abs(i-x)+1+abs(j-y))
		a[p]+=1
for k in a[1:]:
	print(k)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

const ll INF = 1ll<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin>>n>>k;
    vector<int>m,p;
    rep(i,n){
        int t;cin>>t;
        if(t>0)p.emplace_back(t);
        else if(t<0)m.emplace_back(-1*t);
        else k--;
    }
    if(k==0) {
        cout<<0<<endl;
        return 0;
    }
    sort(m.begin(), m.end());
    ll ans = INF;
    if(m.size()>=k) ans = min(ans, (ll)m[k-1]);
    if(p.size()>=k) ans = min(ans, (ll)p[k-1]);
    if(p.size()<m.size())
        for(int i=0;i<p.size();i++){
            if(k-i-2 >= m.size()) continue;
            ll t = p[i]*2+m[k-i-2];
            cerr<<i<<" "<<k-i-2<<" "<<t<<endl;
            ans = min(t,ans);
        }
    else
        for(int i=0;i<m.size();i++){
            if(k-i-2 >= p.size()) continue;
            ll t = m[i]*2+p[k-i-2];
            cerr<<i<<" "<<k-i-2<<" "<<t<<endl;
            ans = min(t,ans);
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 1020
N = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = a[0] + sum(b)
for i in range(1, N):
  temp = sum(a[:i + 1]) + sum(b[i:])
  ans = max(ans, temp)

print(ans)
  

Measured memory_bytes: 3064
import java.util.*;

public class Main {


    public static long lcm(long m, long n){
        return m*n/gcd(m,n);
    }

    public static long gcd(long c, long d){
        if (c<d){return gcd(d,c);}
        if(d==0){return c;}
        return gcd(d, c%d);
    }


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

//        long num[] = new long[b-a+1];
//        for (long i=0; i<b-a+1; i++){
//            num[i] = a+i;
//        }

        long count=0;

//        long total = b-a+1;


//        b = b-(b/c)-(b/d)+b/lcm(c,d);
//        a = a-1-((a-1)/c)-((a-1)/d)+(a-1)/lcm(c,d);

//        count = b-a;

        long c_count=0;
        long d_count=0;
        long cd_count=0;

        c_count = b/c-(a-1)/c;
        d_count = b/d-(a-1)/d;
        cd_count = b/lcm(c,d)-(a-1)/lcm(c,d);
//
//
//        c_count = b/c - (a-1)/c;
//        d_count = b/d - (a-1)/d;
//        cd_count = b/lcm(c,d)-(a-1)/lcm(c,d);
//
//        if (((c-(a%c))+b%c)>c){
//            c_count += (b-a+1)/c-1;
//        }else{
//            c_count += (b-a+1)/c;
//        }
//
//
//        if (((d-(a%d))+b%d)>d){
//            d_count += (b-a+1)/d-1;
//        }else{
//            d_count += (b-a+1)/d;
//        }
//
//
//
//
//        if (((lcm(c,d)-(a%lcm(c,d))+b%lcm(c,d))>lcm(c,d))){
//            cd_count += (b-a+1)/lcm(c,d)-1;
//        }else{
//            cd_count += (b-a+1)/lcm(c,d);
//        }

        count = (b-a+1)-c_count-d_count+cd_count;

        System.out.println(count);

    }
}



Measured memory_bytes: 21972
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
ans = [0]*n

for x in range(1,101):
    for y in range(x,101):
        for z in range(y,101):
            p = 3 if x==y else 6
            if y==z:
                p = 1 if p==3 else 3
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k <= n:
                ans[k-1] += p

for i in ans:
    print(i)

Measured memory_bytes: 74648
use std::io::*;
const MOD: u64 = 1_000_000_007;

mod fenwick_tree {
    use std::ops::*;
    pub struct FenwickTree<T> {
        size: usize,
        data: Vec<T>,
        identity: T,
    }
    impl<T: Copy + Clone + AddAssign + Sub<Output = T>> FenwickTree<T> {
        pub fn new(size: usize, id: T) -> FenwickTree<T> {
            FenwickTree {
                size: size,
                data: vec![id; size + 2],
                identity: id,
            }
        }
        pub fn query(&self, i: usize) -> T {
            let mut res = self.identity;
            let mut idx = i as isize - 1;
            while idx >= 0 {
                res += self.data[idx as usize];
                idx = (idx & (idx + 1)) - 1;
            }
            res
        }
        pub fn update(&mut self, i: usize, x: T) {
            let mut idx = i;
            while idx <= self.size {
                self.data[idx] += x;
                idx |= idx + 1;
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp: Vec<fenwick_tree::FenwickTree<u64>> = (0..n + 1)
        .map(|_| fenwick_tree::FenwickTree::new(k + 1, 0))
        .collect();
    dp[0].update(0, 1);
    for i in 1..n + 1 {
        for j in (0..k + 1).rev() {
            let mut tmp = (dp[i - 1].query(j + 1) % MOD
                - dp[i - 1].query(j - std::cmp::min(j, a[i - 1])) % MOD
                + MOD)
                % MOD;
            tmp %= MOD;
            dp[i].update(j, tmp);
        }
    }
    println!(
        "{}",
        (dp[n].query(k + 1) % MOD - dp[n].query(k) % MOD + MOD) % MOD
    );
}


Measured memory_bytes: 106876
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <random>

using namespace std; 

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

	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;

	return 0;
}

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


using namespace std;

int main()
{

    int a,b; cin>>a>>b;
    for(int i =1 ; i<=3 ; i++)
    {
        if(i!=a && i!=b)
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;


int main(){
  int n=37;
  int m=n*(n+1);
  cout<<m+1<<" "<<n+1<<endl;
  vector<int> x[m+1];
  rep(i,n)rep(j,n)rep(k,n)x[i*n+j].push_back((j+i*k)%n+n*k+1);
  rep(i,n)rep(j,n)x[i*n+j].push_back(n*n+i+1);
  rep(i,n+1)rep(j,n)x[n*n+i].push_back(i*n+j+1);
  rep(i,n+1)x[n*n+i].push_back(m+1);
  rep(i,m+1)sort(x[i].begin(),x[i].end());
  rep(i,m+1){
      rep(j,n+1)cout<<x[i][j]<<" ";
      cout<<endl;
  }
  return 0;
  }



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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(16);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> G(n);
    while(m--) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> dis(n, 1e9);
    dis[0] = 0;

    priority_queue<pair<ll,ll>> q;
    q.push({0,0});
    while(!q.empty()) {
        auto [d, i] = q.top(); q.pop();
        d = -d;

        for(auto &v: G[i]) {
            if(dis[v] <= d+1) continue;
            dis[v] = d+1;
            q.push({-(d+1), v});
        }
    }

    cout << "Yes" << endl;
    for(ll i=1; i<n; i++) {
        for(auto &v: G[i]) {
            if(dis[v] == dis[i]-1) {
                cout << v+1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 14176
<?php

fscanf(STDIN, "%d", $num);
$array = str_split(trim(fgets(STDIN)));

$moji = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$mojiArray = str_split($moji);

$newArray = array();
foreach ($array as $k => $v) {
  $mojiNum = array_search($v, $mojiArray) + $num;

  if ($mojiNum >= 26 ) $mojiNum -= 26;

  $newArray[] = $mojiArray[$mojiNum];
}

foreach ($newArray as $key => $value) {
  echo $value;
}


Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int ans=0;
  x-=2*z;
  for(int i=1;i<x;i++){
    if(x>=y*i+z*(i-1)){
      ans++;
    }
    else{
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

#
x_deposit = int(input())

#x_deposit = 1333333333

deposit = 100

interest = 1.01

past_deposit = []

while x_deposit > deposit:
    deposit = deposit * interest
    deposit = math.floor(deposit)
    past_deposit.append(deposit)

#print(past_deposit)



years = len(past_deposit)

print(years)


Measured memory_bytes: 9292
#include <stdio.h>

int main()
{
    int x;
    scanf("%d",&x);
    int a;
    scanf("%d",&a);
    int b;
    scanf("%d",&b);
    int C1,C2;
    C1=x-a;
    C2=x-b;
    if (C1>0)
        C1=C1;
    else
        C1=(-C1);
    if (C2>0)
        C2=C2;
    else
        C2=(-C2);
    if (C1>C2)
    printf("B");
    else
    printf("A");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for(int i=(k);i<=(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define LL long long
using namespace std;

int main(){
	LL N,M,cnt;
	cin>>N>>M;

	if(2*N<=M){
		cnt=N+(M-2*N)/4;
		cout<<cnt<<endl;
		return 0;
	}

	else {
		cnt=M/2;
		//cnt=cnt+int((N-cnt)/2);
		cout<<cnt<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2112
def ab_substrings(N: int, S: list)->int:
    res = 0
    endA = 0
    startB = 0
    both = 0

    for s in S:
        res += s.count('AB')
        if s.endswith('A'):
            if s.startswith('B'):
                both += 1
            else:
                endA += 1
        elif s.startswith('B'):
            startB += 1

    if both > 0:
        res += both - 1

        if endA > 0:
            res += 1
            endA -= 1

        if startB > 0:
            res += 1
            startB -= 1

    return res + min(endA, startB)


if __name__ == "__main__":
    N = int(input())
    S = [input() for _ in range(N)]

    ans = ab_substrings(N, S)
    print(ans)


Measured memory_bytes: 3700
#include "bits/stdc++.h"
using namespace std;

int N, INF = 1000000000;
static int Dis1[100010] = {}, DisN[100010] = {};
vector<int> V[100010];

void BFS1() {
	for (int i = 1; i < N; i++) {
		Dis1[i] = INF;
	}
	queue<int> Q;
	Q.push(0);
	while (Q.size()) {
		int x = Q.front();
		Q.pop();
		for (int i : V[x]) {
			if (Dis1[i] == INF) {
				Q.push(i);
				Dis1[i] = Dis1[x] + 1;
			}
		}
	}
}

void BFSN() {
	for (int i = 0; i < N - 1; i++) {
		DisN[i] = INF;
	}
	queue<int> Q;
	Q.push(N - 1);
	while (Q.size()) {
		int x = Q.front();
		Q.pop();
		for (int i : V[x]) {
			if (DisN[i] == INF) {
				Q.push(i);
				DisN[i] = DisN[x] + 1;
			}
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		V[a].emplace_back(b);
		V[b].emplace_back(a);
	}
	BFS1();
	BFSN();
	int F = 0, S = 0;
	for (int i = 0; i < N; i++) {
		if (Dis1[i] <= DisN[i]) F++;
		else S++;
	}
	if (F > S) cout << "Fennec";
	else cout << "Snuke";
}

Measured memory_bytes: 6656
"""
与えられた数列の奇数番目の数と偶数番目の数をそれぞれ確認し、
要素数の多いものにそれぞれ書き換える。
文字種が1種類にならないように注意する
"""
from collections import Counter

N = int(input())
V_LI = list(map(int, input().split()))
if len(set(V_LI)) == 1:
    # そもそも一種類しかなかったら
    print(N // 2)
    exit()
odd_li = [V_LI[i] for i in range(0, N, 2)]
even_li = [V_LI[i] for i in range(1, N, 2)]
odd_c = sorted(Counter(odd_li).items(), key=lambda x: -x[1])
even_c = sorted(Counter(even_li).items(), key=lambda x: -x[1])
if odd_c[0][0] == even_c[0][0]:
    cnt_1 = N
    cnt_2 = N
    # 偶数側を固定する
    if len(even_c) > 1:
        odd_cnt = len(odd_li) - odd_c[0][1]
        even_cnt = len(even_li) - even_c[1][1]
        cnt_1 = odd_cnt + even_cnt

    # 奇数側を固定する
    if len(odd_c) > 1:
        odd_cnt = len(odd_li) - odd_c[1][1]
        even_cnt = len(even_li) - even_c[0][1]
        cnt_2 = odd_cnt + even_cnt

    print(min(cnt_1, cnt_2))
else:
    odd_cnt = len(odd_li) - odd_c[0][1]
    even_cnt = len(even_li) - even_c[0][1]
    print(odd_cnt + even_cnt)


Measured memory_bytes: 112964
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define int long long
#define pb push_back
#define pencho ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 1005
#define mod 1000000007

int dp[N][N];
string matrix[N];


int solveDp(int x, int y) {
       if (x < 0 || y < 0)  return 0;
       if (dp[x][y] != -1)      return dp[x][y];

       if (matrix[x][y] == '#')    dp[x][y] = 0;
       else dp[x][y] =  (solveDp(x - 1, y) + solveDp(x, y - 1)) % mod;

       return dp[x][y];
}


void solve() {
       pencho
       int n, m;     cin >> n >> m;
       for (int i = 0; i < n; i++) cin >> matrix[i];
       memset(dp, -1, sizeof(dp));
       dp[0][0] = 1;
       cout << solveDp(n - 1, m - 1);

}


signed main()
{
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("o.txt", "w", stdout);
#endif

       solve();
}

Measured memory_bytes: 12720
N, M = list(map(int, input().split()))
sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
    
num = "a" * N

for i in range(M):
    s,c = sc[i][0], sc[i][1]
    if num[s-1] == "a":
        num = num[:s-1] + str(c) + num[s:]
    else:
        if num[s-1] == str(c):
            continue
        else:
            print(-1)
            break

        
else:
    if (len(num) != 1) and (num[0] == "0"):
        print(-1)
    else:
        num = num.replace("a", "0")
        if num == "0":
            num = num
        elif num[0] == "0":
            num = "1" + num[1:]
    
        print(num)
    


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
        char x[200100];
        scanf("%s", x);
        int s = 0,  ans = 0, i;
        for(i=0; x[i]!='\0'; i++){
                if(x[i]=='S') s++;
                else if(s){
                        ans++;
                        s--;
                }

        }
        printf("%d\n", i-2*ans);
        return 0;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int P, Q, R; cin >> P >> Q >> R;

    int ans = min(P+Q, min(Q+R,R+P));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNext() == true) {
			int d = Integer.parseInt(sc.next());

			int sum = 0;
			for (int i = d; i < 600; i = i + d) {
				sum = sum + (int)Math.pow(i, 2) * d;
			}
			System.out.println(sum);
		}
	}
}

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

using namespace std;

const int N = 100005;
vector<int> g[N];

void dfs(int v, int p, vector<int> & d) {
    for (int nxt : g[v]) {
        if (nxt == p) continue;
        d[nxt] = d[v]+1;
        dfs(nxt, v, d);
    }
}

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

    int n, t, a;
    cin >> n >> t >> a;
    a--;
    t--;
    for (int j = 0; j < n-1; j++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vector<int> dt(n);
    dt[t] = 0;
    dfs(t, -1, dt);

    vector<int> da(n);
    da[a] = 0;
    dfs(a, -1, da);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (dt[i] < da[i]) {
            ans = max(ans, da[i] - 1);
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 11648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q_size;
    cin >> n >> m >> q_size;
    vector<VI> train_cnt(n, VI(n, 0));
    REP(i, m) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        FOR(j, 0, l) train_cnt[j][r]++;
    }

    REP(i, q_size) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        int ans = 0;
        FOR(j, p, q) ans += train_cnt[p][j];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
N=int(input())
s=input()
ans='SS'
for i in range(1,N):
    if s[i]=='o' and ans[-1]=='S' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='o' and ans[-1]=='S' and ans[-2]=='W':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='W':
        ans+='S'
    if s[i]=='x' and ans[-1]=='S' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='x' and ans[-1]=='S' and ans[-2]=='W':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='W':
        ans+='W'

if ans[0]==ans[-1]:
    ans=ans[:N]
    if s[0]=='o' and ans[-1]==ans[1]:
        print(ans)
        exit()
    elif s[0]=='x' and ans[-1]!=ans[1]:
        print(ans)
        exit()
    

ans='SW'
for i in range(1,N):
    if s[i]=='o' and ans[-1]=='S' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='o' and ans[-1]=='S' and ans[-2]=='W':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='W':
        ans+='S'
    if s[i]=='x' and ans[-1]=='S' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='x' and ans[-1]=='S' and ans[-2]=='W':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='W':
        ans+='W'

if ans[0]==ans[-1]:
    ans=ans[:N]
    if s[0]=='o' and ans[-1]==ans[1]:
        print(ans)
        exit()
    elif s[0]=='x' and ans[-1]!=ans[1]:
        print(ans)
        exit()

ans='WS'
for i in range(1,N):
    if s[i]=='o' and ans[-1]=='S' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='o' and ans[-1]=='S' and ans[-2]=='W':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='W':
        ans+='S'
    if s[i]=='x' and ans[-1]=='S' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='x' and ans[-1]=='S' and ans[-2]=='W':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='W':
        ans+='W'

if ans[0]==ans[-1]:
    ans=ans[:N]
    if s[0]=='x' and ans[-1]==ans[1]:
        print(ans)
        exit()
    elif s[0]=='o' and ans[-1]!=ans[1]:
        print(ans)
        exit()

ans='WW'
for i in range(1,N):
    if s[i]=='o' and ans[-1]=='S' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='o' and ans[-1]=='S' and ans[-2]=='W':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='o' and ans[-1]=='W' and ans[-2]=='W':
        ans+='S'
    if s[i]=='x' and ans[-1]=='S' and ans[-2]=='S':
        ans+='W'
    elif s[i]=='x' and ans[-1]=='S' and ans[-2]=='W':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='S':
        ans+='S'
    elif s[i]=='x' and ans[-1]=='W' and ans[-2]=='W':
        ans+='W'

if ans[0]==ans[-1]:
    ans=ans[:N]
    if s[0]=='x' and ans[-1]==ans[1]:
        print(ans)
        exit()
    elif s[0]=='o' and ans[-1]!=ans[1]:
        print(ans)
        exit()

print(-1)


Measured memory_bytes: 3772
#include <stdio.h>

int main(void) {

	int n, x, i, j, k, sum = 0, cnt = 0;

	scanf("%d %d", &n, &x);
	while(1){

		for(i = 1; n-2 >= i; i++){
			for(j = i + 1; n-1 >= j; j++){
				for(k = j + 1; n >= k; k++){

						sum = sum + i + j + k;

					if(sum == x){
						cnt++;
					}
					sum = 0;
					}
			}
		}
		printf("%d\n", cnt);
		cnt = 0;
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0){
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter
#include <climits>
#include <sstream>

using namespace std;

typedef long ll;

int main()
{
    ll d, t, s;
    cin >> d >> t >> s;
    cout << ((d <= s * t) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3596
#include <string>
#include <iostream>
#include <vector>

using namespace std;
int main() {
  
	int K, N;
	cin >> K;
	cin >> N;
	
	int l;
	int *A = new int[N];
	int *A_org = A;
    for (int i = 0; i < N; ++i ) {
        std::cin >> l;
        *A = l;
        //cout << *A << endl;
        A++;
    }
    
    A = A_org;
  
  int answer = 0;
  
  int *A_diff = new int[N+1];
  A_diff[0] = A[0];
  int max_diff = A[0];
  for(int i = 1; i < N; ++i) {
      A_diff[i] = A[i] - A[i-1];
      if( max_diff < A_diff[i] ) {
          max_diff = A_diff[i];
      }
  }
 
    A_diff[N] = A[0] + K - A[N-1];
    //int A_1toN = A_diff[0] + A_diff[N-1];
    if( max_diff < A_diff[N] ) {
        max_diff = A_diff[N];
    }
  
  answer = K - max_diff;
  
 #if 0
  for(int i = 0; i < N+1; ++i) {
    cout << A_diff[i] << endl;
  }
 #endif
   delete [] A_org;
   delete [] A_diff;
  
  cout << answer << endl;
}

Measured memory_bytes: 1792
while 1:
    N = int(input())
    if N == 0:
        break
    P = [
        [1, 2, 3, 4],
        [2, -1, 4, -3],
        [3, -4, -1, 2],
        [4, 3, -2, -1],
    ]
    for i in range(N):
        *X, = map(int, input().split())
        X0 = X[:4]; X1 = X[4:]
        Y = [0]*4
        for i, x0 in enumerate(X0):
            for j, x1 in enumerate(X1):
                z = P[i][j]
                if z > 0:
                    Y[z-1] += x0*x1
                else:
                    Y[-z-1] -= x0*x1
        print(*Y)



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

const int MOD = 998244353;

void solve_test() {
	string s;
	cin >> s;
	int n = s.length();
	
	int cost = 0;
	for (int i = 0; i < n / 2; i++)
		if (s[i] != s[n - i - 1])
			cost++;
	cout << cost << '\n';
}

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

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
bool isSquare(Int a){
  bool flag = false;
  double z = double(sqrt(a));
  if(ceil(z)==floor(z)) flag = true;
  return flag;
}

int main(){
  string a,b;cin >> a >> b;
  string ans = a+b;
  int n = stoi(ans);
  if(isSquare(n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,ans;
    cin>>a>>b>>c;
    for(int i=1;i<=a;i++){
        cin>>d;
        if(d<b || d>=c) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n, d = map(int, input().split())
xs = [list(map(int, input().split())) for _ in range(n)]
sq_num = set([i**2 for i in range(128)])

cnt = 0
for x1, x2 in itertools.combinations(xs, 2):
    distance_sq = sum(map(lambda xx: (xx[0]-xx[1])**2, zip(x1, x2)))
    if distance_sq in sq_num:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
// ＡＢＣの過去問を解くだけだよ

// フォント x:小文字 X:大文字

#include <bits/stdc++.h>

using namespace std;

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

    x -= a;

    x -= b * (x / b);

    cout << x;

    return 0;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  st S;
  ci(S);
  int a = 999;
  rep(i, sz(S) - 2){
    st s = "";
    s += S.at(i);
    s += S.at(i + 1);
    s += S.at(i + 2);
    int t = abs(753 - stoi(s));
    a = min(a, t);
  }
  co(a);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    vector<int> value;
    rep(i,n) {
        if ((v[i]-c[i]) > 0) value.push_back(v[i]-c[i]);
    }
    int ans = 0;
    rep(i,value.size()) ans += value[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vl a(n), s(n), d(n);
  rep(i, n) cin >> a[i];
  s[0] = a[0] % k;
  REP(i, 1, n) s[i] = (s[i - 1] + a[i]) % k;
  unordered_map<ll, ll> m;
  ll ans = 0;
  // rep(i, n) cerr << s[i] << " ";
  // cerr << endl;
  rep(i, n) {
    d[i] = s[i] - (i + 1);
    if (d[i] < 0) {
      ll tmp = -d[i] / k + 1;
      d[i] = (d[i] + k * tmp) % k;
    }
    // cerr << d[i] << " ";
    if (i < k - 1 && d[i] == 0) {
      // cerr << "!" << i << endl;
      ans++;
    }
    if (m.find(d[i]) != m.end()) {
      // cerr << "!" << i << ":" << m[d[i]] << endl;
      ans += m[d[i]];
      m[d[i]]++;
    } else {
      m[d[i]] = 1;
    }
    if (i >= k - 1) {
      m[d[i - k + 1]]--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	ll n,m; cin>>n>>m;
	vvl vec(n,vl(0));
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		--a; --b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	//vl dist(n,-1);
	//dist[0]=0;
	set<ll> s;
	vl fro(n,-1);
	fro[0]=0;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll v=q.front(); q.pop();
		for(ll c:vec[v]){
			if(s.count(c)) continue;
			//dist[c]=dist[v]+1;
			s.insert(c);
			fro[c]=v;
			q.push(c);
		}
	}
	cout<<"Yes"<<endl;
	rep(i,0,n){
		if(i==0) continue;
		ll ans=fro[i];
		++ans;
		cout<<ans<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 17488
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		
		adList = new List[n];
		for (int i=0;i<n;i++) {
			adList[i] = new ArrayList<P>();
		}
		for (int i=0;i<n;i++) {
			int u=in.nextInt();int k = in.nextInt();
			for (int j=0;j<k;j++) {
				adList[i].add(new P(in.nextInt(), in.nextLong()));
			}
		}
		dist = new long[n];
		Arrays.fill(dist, Long.MAX_VALUE);
		
		dijkstra(0);
		
		for (int i=0;i<dist.length;i++) {
			System.out.println(i+" "+dist[i]);
		}
	}

	static List<P>[] adList;
	static long[] dist;
	static void dijkstra(int s) { // s is start
		dist[s] = 0L;
		PriorityQueue<P> q = new PriorityQueue<P>();
		q.add(new P(s, 0L));
		
		while (!q.isEmpty()) {
			P cur = q.poll();
			if (dist[cur.index] < cur.dist)
				continue;
			for (P next : adList[cur.index]) {
				if (dist[next.index] > dist[cur.index] + next.dist) {
					dist[next.index] = dist[cur.index] + next.dist;
					q.add(new P(next.index, dist[next.index]));
				}
			}
		}
		
	}
	static class P implements Comparable<P> {
		int index; long dist;
		public P(int index, long dist) {this.index = index; this.dist = dist;}
		public int compareTo(P p) {
			return this.dist < p.dist ? -1 : this.dist == p.dist ? 0 : 1;
		}
	}
	// in adList, P.dist is distance from adjacent point
	// in q, P.dist is shortest path distance from start point
}

Measured memory_bytes: 276220
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


int Monsters[100100];
int Yusha[100100];

signed main() {
  int N; cin >> N;
  for (int i = 0; i < N+1; i++) {
    cin >> Monsters[i];
  }
  reverse(Monsters, Monsters+N+1);

  for (int i = 0; i < N; i++) {
    cin >> Yusha[i];
  }
  reverse(Yusha, Yusha+N);

  int ans = 0;
  int prev = 0;
  for (int i = 0; i <= N; i++) {
    if (Monsters[i] - prev <= 0) {
      ans += Monsters[i];
      prev = Yusha[i];
      Monsters[i] = 0;
    } else {
      Monsters[i] -= prev;
      if (Monsters[i] - Yusha[i] <= 0) {
        ans += Monsters[i] + prev;
        prev = Yusha[i] - Monsters[i];
        Monsters[i] = 0;
      } else {
        ans += Yusha[i] + prev;
        prev = 0;
        Monsters[i] -= Yusha[i];
      }
    }
  }

  // for (int i = 0; i <= N; i++) {
  //   cout << Monsters[i] << endl;
  // }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e6+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    string s;
    cin>>s;
    int ans=0;
    for(auto x: s){
        ans=ans+(x-'0');
    }
    if(ans%9==0){
        cout<<"Yes";
    }
    else cout<<"No";
}

Measured memory_bytes: 3760
n = int(input())
s = input()
w_cnt = [0] * (n + 2)
e_cnt = [0] * (n + 2)
for i in range(1, n + 1):
    if s[i - 1] == 'W':
        w_cnt[i] = 1 + w_cnt[i - 1]
    else:
        w_cnt[i] = w_cnt[i - 1]

for i in range(1, n + 1):
    if s[-i] == 'E':
        e_cnt[n + 1 - i] = 1 + e_cnt[n + 2 - i]
    else:
        e_cnt[n + 1 - i] = e_cnt[n + 2 - i]
ans = n
for i in range(1, n + 1):
    tmp = w_cnt[i - 1] + e_cnt[i + 1]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 17644
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = 10001;
		long[] a = new long[m];
		a[1] = 2;
		for(int i = 2; i < m; i++) {
			a[i] = a[i - 1] + i;
		}
		while(sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(a[n]);
		}
		sc.close();
	}
}


Measured memory_bytes: 26156
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static long sum(int L, int R, int[] a ) {
		long sum =0;
		for(int i=L; i<=R;i++) {
			sum+= a[i];
		}
		return sum;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in= new Scanner(System.in);
		int n = in.nextInt();
		int arr [] = new int[n];
		for( int i= 0; i<n; i++ )
			arr[i]= in.nextInt();
		long dp[][] = new long [n][n];
		for(int i=0;i<n; i++) {
			Arrays.fill(dp[i], (long)1e18 + 5);
			
		}
		
		for( int L= n-1; L>=0;L--) {
			for( int R=L;R<n;R++) {
				if(L==R)
					dp[L][R] = 0;
				else {
					long sum =sum(L,R,arr);
					for( int i=L; i<=R-1;i++) {
						dp[L][R] = Math.min(dp[L][R], dp[L][i] + dp[i+1][R] + sum);
					}
				}
			}
		}
		System.out.println(dp[0][n-1]);
	}

}


Measured memory_bytes: 29656