akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, m; cin >> n >> m;
	vector<vector<int>> d(n, vector<int>(m));

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

	set<int> s;
	for (int i = 0; i < 10000; i++) {
		s.insert(i*i);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int val = 0;

			for (int k = 0; k < m; k++) {
				int diff = d[i][k] - d[j][k];
				val += diff * diff;
			}

			if (s.count(val))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF (INT32_MAX/2)
#define MOD (1000000000+7)
#define MAX 100
#define MAXK 100000

int N, K;
int a[MAX];

int memo[MAXK + 1];

int dfs( int k )
{
	if( memo[k] >= 0 ) {
		return memo[k];
	}
	for( int i = 0; i < N; i++ ) {
		if( k - a[i] < 0 ) {
			break;
		}
		int res = !dfs( k - a[i] );
		if( res ) {
			return memo[k] = 1;
		}
	}
	return memo[k] = 0;
}

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

	memset( memo, -1, sizeof(memo) );
	int ans = dfs( K );

	if( ans ) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
N = int(input())
A = list(map(int, input().split()))

# gcd(最大公約数)の定義(Euclidの互除法)
def gcd(a, b):
    if b == 0:
        return a
    else:
        return(gcd(b, a % b))

L = [0 for _ in range(N)]
R = [0 for _ in range(N)]
for i in range(N-1):
    L[i+1] = gcd(L[i], A[i])
    R[N-(i+2)] = gcd(R[N-(i+1)], A[N-(i+1)])

ans = 1
for i in range(N):
    ans = max(ans, gcd(L[i], R[i]))

print(ans)

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

int main(void){
    ll n,m,d;
    cin>>n>>m>>d;
    printf("%.10f\n",(m-1)*(n-d)*(d ? 2.0 : 1.0)/n/n);
    return 0;
}


Measured memory_bytes: 256
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
using namespace std;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, k;
    cin >> n >> k;
    //2次元vector
    //vector<vector<要素の型>> 変数名(縦の要素数, vector<要素の型>(横の要素数));
    vector<long long> H(n, 0);
    for (int i = 0; i < n; ++i)
		cin >> H[i];

    sort(H.begin(), H.end(), greater<int>());


    long long res = 0;
    for (int i = k; i < n; i++){
        res += H[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
*h, = map(int, input().split())
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
	if i < N - 2:
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[N - 1])


Measured memory_bytes: 55752
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = 998244353;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e5 + 9;

bool isprime(ll n) {
	if (n <= 1)
		return 0;
	for (ll i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
	return 1;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll power(ll x, int y)
{
	ll temp;
	if (y == 0)
		return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp * temp;
	else
		return x * temp*temp;
}
int n;
deque<ll> q;
ll dp[3000][3000];
ll calc(int i, int j,int k) {
	if (i > j) {
		return 0;
	}
	ll &ret = dp[i][j];
	if (ret != -1) return ret;
	if (k % 2 == 0) {
		ret = max(q[i]+calc(i + 1, j, k + 1),q[j]+ calc(i, j - 1, k + 1));
	}
	else {
		ret = OO;
		ret = min(-q[i]+calc(i + 1, j, k + 1),-q[j]+ calc(i, j - 1, k + 1));
	}
	return ret;
}
int main()
{
	let(dp, -1);
	scanf("%d", &n);
	q.resize(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &q[i]);
	}
	printf("%lld\n", calc(0, n - 1, 0));
	return 0;
}

Measured memory_bytes: 70784
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String[] S=sc.next().split("");
    	String[] target="CODEFESTIVAL2016".split("");
    	
    	
    	int cnt=0;
    	
    	for(int i=0;i<S.length;i++) {
    		
    		if(!S[i].equals(target[i])) {
    			cnt++;
    		}
    		
    	}
    	
    	System.out.println(cnt);

    }
}



Measured memory_bytes: 21204
from collections import defaultdict

n, x, y = map(int, input().split())
x -= 1
y -= 1

circle = y - x + 1
a = [0 for _ in range(circle)]
for i in range(1, circle // 2 + 1):
    a[i] = i
    a[-i] = i

dists = defaultdict(int)
for i in range(n - 1):
    if i >= y:
        for j in range(i + 1, n):
            dists[j - i] += 1
    elif x < i < y:
        for j in a[1:y - i + 1]:
            dists[j] += 1
        for j in range(1, n - y):
            dists[a[y - i] + j] += 1
    else:
        # i <= x
        for j in range(i + 1, x):
            dists[j - i] += 1
        for j in a:
            dists[x - i + j] += 1
        for j in range(1, n - y):
            dists[x - i + a[-1] + j] += 1

for i in range(1, n):
    print(dists[i])


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		String o = sc.nextLine();
		
		String e = sc.nextLine();
		
		String pw = "";
		
		for(int i=0; i<o.length(); i++){
			pw = pw + o.charAt(i);
			if( i<e.length()){
				pw = pw + e.charAt(i);
			}
		}
		
		System.out.println(pw);
	}
}

Measured memory_bytes: 21332
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long lng;
typedef long long ll;
typedef vector<int> vi;
typedef vector<lng> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<lng> > vvl;
typedef pair<int,int> pi;
typedef pair<lng,lng> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

ll n,k;
vl a;
vi pos[200020];
ll g[60][200020];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    a.resize(n);
    rep(i,n){
        cin >> a[i];
        pos[a[i]].pb(i);
    }
    //g[0][i]を埋める.つまり、i番目から1回操作を行なったら何歩進むか？
    rep(x,200020){
        if(pos[x].size() == 0)continue;//xが一回も登場しなかったら無視して良い
        //iが1周期の中における最後のx登場indexだった場合は次の周期の最初のxに行く
        for(int i = 0;i < pos[x].size();i++){
            int id = pos[x][i];
            int nextid = pos[x][(i+1)%pos[x].size()];
            if(i != pos[x].size()-1){
                g[0][id] = (ll)(nextid - id + 1);
            }else{
                g[0][id] = (ll)(nextid + n - id + 1);
            }
        }
    }

    for(int p = 1;p <= 59;p++){
        //g[i][p]を埋める
        for(ll i = 0;i < n;i++){
            ll nextid = (i + g[p-1][i]) % n;//2^(p-1)step後のmod N上
            g[p][i] = g[p-1][i] + g[p-1][nextid];
        }
    }
    ll now = 0;
    while(true){
        ll id = now % n;
        int l = -1,r = 60;
        while(l+1 != r){
            int m = (l + r)/2;
            if(now + g[m][id] > n*k - 1){
                r = m;
            }else{
                l = m;
            }
        }
        if(l == -1)break;
        else{
            now += g[l][id];
        }
    }
    now %= n;
    vector<ll> ans;
    while(now < n){
        if(now == pos[a[now]][pos[a[now]].size()-1]){
            ans.pb(a[now]);
            now++;
        }else{
            ll x = a[now];
            now++;
            while(a[now] != x)now++;
            now++;
        }
    }
    for(int i = 0;i < ans.size();i++){
        if(!i)cout << ans[i];
        else cout << ' ' << ans[i];
    }
    cout << '\n';
    return 0;

}


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

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

    int N, K;
    scanf("%d%d\n", &N, &K);
    int cnt = 0;
    char ch, prev;
    for (int i = 0; i < N; i++) {
        scanf("%c", &ch);
        if (i == 0) {
            prev = ch;
            continue;
        }
        if (prev == ch) {
            cnt++;
        }
        prev = ch;
    }
    cout << min(N - 1, cnt + 2 * K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, ans, a[205];
int main()
{
	cin >> n;
	for (int i = 1; i <= 2 * n; i ++) cin >> a[i];
	sort(a + 1, a + 1 + 2 * n);
	for (int i = 1; i <= 2 * n; i += 2)
		ans += a[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    n = int(input())
    restaurants = defaultdict(list)
    for i in range(n):
        s, p = input().split()
        p = int(p)
        restaurants[s].append((p, i))
    for key, restaurant in restaurants.items():
        restaurants[key] = sorted(restaurant, reverse=True)
    list_ress = [(key, val) for key, val in restaurants.items()]
    for key, val in sorted(list_ress):
        for p, i in val:
            print(i+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

double angleClock(double H, double M) {
    abs(H/12 + (M/12)/60 - M/60);
    
}

int main(){
    long double a,b,h,m;
    while(cin>>a>>b>>h>>m){
        long double ang = h/12 + (m/60)/12 - m/60;
        ang = (2*M_PI*ang);
        long double c2 = a*a + b*b - 2*a*b*cosl(ang);
        printf("%20.20Lf \n", sqrtl(c2));
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

string yn(bool f){
    return (f?"Yes":"No");
}

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << yn((abs(a-b)<=d&&abs(b-c)<=d)||(abs(a-c)<=d)) << endl;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  if ( s == "ani" ) {
    cout << "square1001" << endl;
  } else {
    cout << "e869120" << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 3108
def main():
  e=enumerate
  (n,t),*g=[list(map(int,t.split()))for t in open(0)]
  d=[0]
  g.sort()
  dp=[]
  d=[0]*t
  for a,b in g:
    p=d[:]
    for i in range(a,t):
      v=d[i-a]+b
      if v>p[i]:p[i]=v
    dp+=p,
    d=p
  a=m=0
  for(*_,v),(_,w)in zip(dp[-2::-1],g[::-1]):
    if w>m:m=w
    if v+m>a:a=v+m
  print(a)
main()

Measured memory_bytes: 357732
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
    }
    for i in 1..n + 1 {
        let mut count = 0usize;
        let t = 2 * i;
        let mut j = 2;
        while j * j < t {
            let mut k = 2;
            while k * k < t - j * j {
                let r = t - j * j - k * k;
                let rr = (r as f64).sqrt() as usize;
                if rr * rr == r {
                    let p = j + k + rr;
                    if p > 2 * j && p > 2 * k && p > 2 * rr {
                        count += 1;
                    }
                }
                k += 1;
            }
            j += 1;
        }
        println!("{}", count);
    }
}


Measured memory_bytes: 2076
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
    char s[10000];
	int n,i,a,b;
	while(scanf("%s",s)!=EOF){
	    n=strlen(s);
		a=0; b=0;
		for(i=0;i<n-2;i++){
		    if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I'){
			    a++;
			}
			if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I'){
			    b++;
			}
		}
		printf("%d\n%d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  int c=0;
  bool f=1;
  while(1){
    for(int i=0;i<n;i++){
      if(a.at(i)%2==0)
        a.at(i)/=2;
      else
        f=0;
    }
    if(f)
      c++;
    else
      break;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int c1, c5, c10,c50, c100, c500;
    cin >> c1>> c5>>c10>>c50>>c100>> c500;
	if (c1 + (5 * c5) + (10 * c10) + (50 * c50) + (100 * c100) + (500 * c500) >= 1000){
		cout << 1<<endl;
	}
	else if (c1 + (5 * c5) + (10 * c10) + (50 * c50) + (100 * c100) + (500 * c500) < 1000){
		cout << 0<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

#1回ずつ数えて答えを3で割る
N, M = lr()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(M):
    u, v = lr()
    graph[u].append(v)

S, T = lr()
que = deque([(S, 0)])
time_set = [set() for _ in range(N+1)] # 1-indexed
while que:
    q, time = que.popleft()
    if time > M * 3:
        break
    for next in graph[q]:
        if (time+1) % 3 in time_set[next]:
            continue
        if next == T and (time+1) % 3 == 0:
            print((time+1)//3); exit()
        que.append((next, time+1))
        time_set[next].add((time+1)%3)

print(-1); exit()
# 52

Measured memory_bytes: 76156
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;

#define MAX 25

int H,W,mem;
char field[MAX][MAX];
bool visited[MAX][MAX][16][4];
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

void Nextpos(int &y,int &x){
  if(x >= W){
    x = 0;
  }else if(y >= H){
    y = 0;
  }else if(x < 0){
    x = W-1;
  }else if(y < 0){
    y = H-1;
  }
}

bool solve(int y,int x,int dir){
  if(x >= 0 && field[y][x] == '@') return true;
  if(x >= 0 && visited[y][x][mem][dir]) return false;
  if(x >= 0) visited[y][x][mem][dir] = true;

  int nx = x + dx[dir], ny = y + dy[dir];
  Nextpos(ny,nx);
  
  if(isdigit(field[ny][nx])){
    mem = field[ny][nx] - '0';
  }else{
    switch(field[ny][nx]){
    case '>':
      dir = 0;
      break;
    case 'v':
      dir = 1;
      break;
    case '<':
      dir = 2;
      break;
    case '^':
      dir = 3;
      break;
    case '_':
      dir = (mem == 0 ? 0 : 2);
      break;
    case '|':
      dir = (mem == 0 ? 1 : 3);
      break;
    case '?':
      for(int i = 0 ; i < 4 ; i++){
        if(solve(ny,nx,i)) return true;
      }
      break;
    case '+':
      mem = (mem == 15 ? 0 : mem+1);
      break;
    case '-':
      mem = (mem == 0 ? 15 : mem-1);
      break;
    }
  }
  if(solve(ny,nx,dir)) return true;
  return false;
}

int main(){
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
    }
  }
  mem = 0;
  memset(visited,false,sizeof(visited));
  cout << (solve(0,-1,0) ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 2116
#include<cstdio>

int main()
{
	int i,n,a,c[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&c[i]);
	for(i=0;i<n;i++)
	{
		printf("Case %d:\n",i+1);
		for(a=0;a<10;a++)
		{
			printf("%d\n",c[i]=(c[i]*c[i])/100%10000);
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  int wa=0;
  
  rep(i,0,s.size()){
    char t=s.at(i);
    if(t=='0')wa+=0;
    if(t=='1')wa+=1;
    if(t=='2')wa+=2;
    if(t=='3')wa+=3;
    if(t=='4')wa+=4;
    if(t=='5')wa+=5;
    if(t=='6')wa+=6;
    if(t=='7')wa+=7;
    if(t=='8')wa+=8;
    if(t=='9')wa+=9;
  }
  
  if(s=="0"||s=="9"){
    cout<<"Yes";
    return 0;
  }
  if(wa%9==0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

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

#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


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

   int N = 3;
   set<int> s;
   while(N--){
      int i; cin >> i;
      s.insert(i);
   }

   if(s.size() == 2){
      cout << "Yes";
   }else{
      cout << "No";
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }



int main(){
  int a ,b ,c;
  cin >> a >> b >> c;
  cout <<(a-b == b - c?"YES":"NO") << endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  const int N = scan<int>();
  const long long X = scan<long long>();
  long long worst = 0;
  std::vector<long long> aoki(N), lb(N), ub(N), get(N);
  for (int i: range(0, N)) {
    std::cin >> aoki[i] >> lb[i] >> ub[i];
    get[i] = lb[i] * aoki[i] + ub[i] * (X - aoki[i]);
    worst += lb[i] * aoki[i];
  }
  std::vector<int> order(N);
  std::iota(order.begin(), order.end(), 0);
  std::sort(order.begin(), order.end(), [&](int i, int j) {
    if (get[i] == get[j]) {
      return i < j;
    }
    return get[i] > get[j];
  });
  std::vector<long long> sum(N + 1);
  for (int i: range(0, N)) {
    sum[i + 1] = sum[i] + get[order[i]];
  }
  const auto score = [&](int i, long long p) {
    if (p > aoki[i]) {
      return ub[i] * (p - aoki[i]) + lb[i] * aoki[i];
    }
    return lb[i] * p;
  };
  long long ok = X * N, ng = -1;
  while (ok - ng > 1) {
    long long md = (ok + ng) / 2;
    ([&] {
      long long full = md / X, remain = md % X;
      long long max = 0;
      for (int i: range(0, N)) {
        int t = order[i];
        if (i < full) {
          chmax(max, sum[full + 1] + score(t, remain) - get[t]);
        }
        else {
          chmax(max, sum[full] + score(t, remain));
        }
      }
      return max >= worst;
    }() ? ok : ng) = md;
  }
  std::cout << ok << '\n';
  return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
using namespace std;
#define ll long long
#define MX 1e9
int main(){
    int n;
    cin>>n;
     double t, a;
    cin>>t>>a;


    double ans = 2e9;
    int in=0;

    for(int i=1;i<=n;i++){
        double x;
        cin>>x;
        double res = t- x * 0.006;

        if(abs(res-a) < ans){
            ans = abs(res-a);
            in = i;
        }
    }
    cout<<in<<endl;


 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, K;
vector<int> v;

int dp[100005][2];

int solve(int x, int now){
  if(dp[x][now] != 0) return dp[x][now];
  int aite = 1 - now;

  bool flg = false;
  rep(i,v.size()){
    if(x >= v[i]){
      if(solve(x-v[i], aite) == 2) flg = true;
    }
  }
  if(flg) return dp[x][now] = 1;
  else return dp[x][now] = 2;
}

int main(){

  cin >> N >> K;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  if(solve(K, 0) == 1) cout << "First" << endl;
  else cout << "Second" << endl;
  
  return 0;
}


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

int main() {
 string S,T;
 cin >> S >> T;
  
 int count = 0;
 
 for(int i=0;i < S.size();i++){
   if(S.at(i) != T.at(i)){
     count++;
   }
 }
  cout << count <<endl;
}

Measured memory_bytes: 3920
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = input[0][0];

  return N.includes("9") ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29600
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll dp[500100];
void solve(){
    ll n,m;
    cin >> n >> m;
    dp[0]=1;
    dp[1]=m-n;
    repi(i,2,n+1){
        dp[i]=(m-n+i-1)*dp[i-1]+(i-1)*dp[i-2];
        dp[i]%=Mod;
    }
    ll ans=dp[n];
    repi(i,m-n+1,m+1){
        ans *= i;
        ans %= Mod;
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

using namespace std;

int D[10];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int N, K, x;
	cin >> N >> K;
	for (int i = 0; i < K; ++i) {
		cin >> x;
		D[x] = 1;
	}
	bool possible;
	for (int i = N; ; ++i) {
		possible = true;
		for (char c : to_string(i)) {
			if (D[c - '0'] == 1) {
				possible = false;
				break;
			}
		}
		if (possible) {
			cout << i << '\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#define M 100000000000000
#define ll long long
#define P pair<ll,ll>
#define f first
#define s second
using namespace std;
ll m, n, u, v, d, c;
struct edge {
    ll v, d, c;
    edge(ll vv = 0, ll dd = M, ll cc = M): v(vv), d(dd), c(cc) {}
};
#define PP pair<P, ll>
vector<edge> node[10005];
bool use[10005];
P dist[10005];
int main() {
    while ((~scanf("%lld %lld", &n, &m)) && n) {
        for (int i = 0; i <= n; ++i) node[i].clear();
        for (int i = 0; i < m; ++i) {
            scanf("%lld %lld %lld %lld", &u, &v, &d, &c);
            node[u].push_back(edge(v, d, c));
            node[v].push_back(edge(u, d, c));
        }
        priority_queue<PP, vector<PP>, greater<PP > > pq;
        pq.push(PP(P(0, 0), 1));
        for (int i = 2; i <= n; ++i) dist[i].f = dist[i].s = M;
        dist[1].f = dist[1].s = 0;
        memset(use, 0, sizeof use);
        long long ans = 0;
        while (!pq.empty()) {
            ll u = pq.top().s, dd = pq.top().f.f, cc = pq.top().f.s;
            pq.pop();
            use[u] = true;
            if (dist[u].f < dd || (dist[u].f == dd && dist[u].s < cc)) continue;
            //printf("%d---%d---%d\n", u, dist[u].f, dist[u].s);
            for (int i = 0; i < node[u].size(); ++i) {
                ll v = node[u][i].v, d = node[u][i].d, c = node[u][i].c;
                if (!use[v] && (dist[v].f > d + dist[u].f
                                || dist[v].f == d + dist[u].f && dist[v].s > c)) {
                    dist[v].s = c;
                    dist[v].f = d + dist[u].f;
                    pq.push(PP(dist[v], v));
                }
            }
        }
        for (int i = 1; i <= n; ++i) ans += dist[i].s;
        printf("%lld\n", ans);
    }
    return 0;
}



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

int main() {
  int i,n,j,ans=0;
  cin>>n;
  vector<string> s(n);
  for(i=0;i<n;i++)
    cin>>s[i];
  for(i=1;i<n;i++)
    if(s[i-1].at(s[i-1].size()-1) != s[i].at(0))
      ans++;
  for(i=0;i<n;i++)
    for(j=i+1;j<n;j++)
      if(s[i]==s[j])
        ans++;
  
  if(ans!=0)
    cout<<"No";
  else cout<<"Yes";
}


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

const int MAXN = 5010;
typedef std::string str;
typedef long long LL;
str get(str buf, int K) {
	// std::cout << "QRY " << buf << ' ' << K << std::endl;
	int L = buf.size(), at = L - 1;
	while (~at && buf[at] == buf[L - 1]) --at;
	int cnt = std::min((LL) (L - at - 1) << K, (LL) L);
	return str(cnt, buf[L - 1]) + str(buf.rbegin() + L - at - 1, buf.rbegin() + L - at + L - cnt - 1);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	str t, ans; int N, K;
	std::cin >> N >> K >> t; ans = t;
	if (K > 20) ans = std::string(N, *std::min_element(t.begin(), t.end()));
	t = t + str(t.rbegin(), t.rend());
	// std::cout << t << std::endl;
	for (int i = 0; i <= N; ++i) {
		str res = get(t.substr(i, N), K - 1);
		// std::cout << res << std::endl;
		if (res < ans) ans = res;
	}
	std::cout << ans << std::endl;
	return 0;
}


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

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
int main(void)
{
	int n, ans=0;

	cin>>n;

	vector<int> p(n);
	vector<bool> flag(n, false);

	rep(i, n){
		cin>>p[i];
		if(i+1==p[i]) flag[i]=true;
	}

	int i=0, count=0;
	while(i<n){
		if(flag[i]){
			count++;
		}else{
			ans+=count/2;
			if(count%2) ans++;
			count=0;
		}
		i++;
	}
	ans+=count/2;
	if(count%2) ans++;

	cout<<ans<<endl;
}

Measured memory_bytes: 640
import Control.Monad
import Data.List

solve = count . scanl' f 0
  where
    f n [a, b] = if a < n then n else b
    count = length . nub . tail

readN = map read . words <$> getLine

main = do
  [n, m] <- readN
  rs <- replicateM m readN
  print $ solve . sortOn last $ rs


Measured memory_bytes: 94588
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[100010];
int main(){
  ll n;
  while(cin>>n){
    for(ll i=0; i<n; ++i){
      cin>>a[i];
    }
    reverse(a, a+n);
    ll mx=3, mn=2, tmp1, tmp2, tmp3, tmp4;
    tmp3=2;
    tmp4=3;
    bool l=(a[0]==2);
    for(ll i=1; i<n; ++i){
      tmp1=(tmp3+a[i]-1)/a[i]*a[i];
      tmp2=(tmp4/a[i])*a[i];
      if(tmp1>tmp4||tmp2<tmp3){
        l=0;
        break;
      }
      tmp3=tmp1;
      tmp4=tmp2+a[i]-1;
    }
    mx=tmp4;
    mn=tmp3;
    if(!l){
      cout<<-1<<endl;
    }
    else{
      cout<<mn<<" "<<mx<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

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

    vector<ll> s(n + 1, 0);
    map<ll, ll> nums;
    rep(i, n) s[i + 1] = s[i] + a[i];
    rep(i, n + 1) nums[s[i]]++;

    ll res = 0;
    for (auto it : nums)
    {
        ll num = it.second;
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}

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

bool ok[50000];

int main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    int q;
    cin>>q;
    
    for(int bit=0;bit<(1<<n);bit++){
        int sum=0;
        rep(i,n){
            if(bit & (1<<i)) sum+=a[i];
        }
        ok[sum]=true;
    }

    rep(i,q){
        int m;
        cin>>m;
        if(ok[m]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}



Measured memory_bytes: 3072
def countCombinations(n, x, size=3):
    dp = [[0 for j in range(x + 1)] for i in range(size + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        for row in range(size - 1, -1, -1):
            for col in range(x + 1 - i):
                dp[1+row][i+col] += dp[row][col]
    return dp[-1][-1]

while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    print(countCombinations(m, n))


Measured memory_bytes: 5608
#include "iostream"
using namespace std;

template<class T> bool contain(const string& s, const T& v) {
  return s.find(v) != string::npos;
}

int main(int argc, char *argv[])
{
  string s1, s2;
  cin >> s1 >> s2;
  s1 = s1 + s1;
  if(contain(s1, s2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[100005];

int main(){
	cin >> s + 1;
	int n = strlen(s + 1);
	for(int i = 1;i <= n;i += 2){
		cout << s[i];
	}
}

Measured memory_bytes: 384
n = int(input())
matrix = []
for _ in range(2):
    matrix.append([int(x) for x in input().split()])

candies = []
for a in range(n):
    i , j = 0, 0
    candy = matrix[i][j]
    for b in range(n):
        if a == b:
            i+=1
        else:
            j+=1
        candy += matrix[i][j]
    candies.append(candy)

print(max(candies))

Measured memory_bytes: 3064
#include <stdio.h>
int c, p, l, lp;
long long r;
int main() {
  for(; (c = getchar_unlocked()) > ' '; r += ++l) if(c != p) {
    if(c == '<')
      r -= l < lp ? l : lp;
    p = c; lp = l; l = 0;
  }
  if(p == '>')
    r -= l < lp ? l : lp;
  printf("%lld\n", r);
  return 0;
}


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

int p[78500],flg[1000004],size;

bool isPrime(int x){
	for(int i=0;i<size && p[i]<=sqrt(x);i++){
		if(x % p[i] == 0) return false;
	}
	return true;
}

void mkPrime(void){
	p[0] = 2;
	flg[2] = size = 1;

	for(int i=3;i<=1000000;i+=2){
		if(isPrime(i)){
			p[size++] = i;
			flg[i] = 1;
		}
	}
}

int main(void){
	int x;

	mkPrime();

	while(cin>>x && x){
		int ans = 0, to = x / 2;
		for(int i=0;p[i]<=to;i++){
			if(flg[x-p[i]]) ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

int main() {
	int x; scanf("%d", &x);
	int st = 0, ed = x;
	while(ed - st > 1) {
		int mid = st + ed >> 1;
		if((long long)mid * (mid + 1) < x * 2) st = mid;
		else ed = mid;
	}
	printf("%d\n", st + 1);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

kion=[]
for i in range(len(h)):
    kion.append(t-h[i]*0.006)
#print(kion)
j=0
x=10000000000000000000000
for i in range(len(kion)):
    if abs(a-kion[i])<x:
        j=i+1
        x=abs(a-kion[i])
print(j)

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

int main() {
  string s,t;
  cin >> s >> t;
  
  int x;
  x = s.size();
  
  int y=0;
  
  for(int i=0;i<x;i++){
    if(s[i] != t[i])y++;
  }
  
  if(y == 0)cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

signed main() {
  int a, b;
  cin >> a >> b;
  cout << a - b + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
#define INF (1 << 30)
#define INFL (1ll << 60ll);
#define mod 1000000007

int a, b;

int ans;

signed main()
{
    cin >> a >> b;
    if(a == b){
        printf("%lld\n", a);
        return 0;
    }
    int m = max(a, b);
    if(a % 2 == 0 && b % 2 == 0){
        ans += ((b - a) / 2) % 2;
    }
    else if(a % 2 == 0){
        ans += ((b - a) / 2 + 1) % 2;
    }
    else if(b % 2 == 0){
        ans += ((b - a + 1) / 2) % 2;
    }
    else {
        ans += ((b - 1 - a + 1) / 2 + 1) % 2;
    }
    int i = 1ll;
    while((1ll << i) <= m){
        int l, r;
        if(a % 2ll == 0ll){
            l = 2ll;
        }
        else {
            l = 1ll;
        }
        if(b % 2ll == 0ll){
            r = 1ll;
        }
        else {
            r = 2ll;
        }
        //printf("i:%lld i&a:%lld i&b%lld ", i, (int)((a & (1ll << i)) > 0ll), (int)((b & (1ll << i)) > 0ll));
        int res = l * (int)((a & (1ll << i)) > 0ll) + r * (int)((b & (1ll << i)) > 0ll);
        //printf("l:%lld r:%lld res:%lld ans:%lld\n", l, r, res, ans);
        ans += (res % 2ll) * (1ll << i);

        i++;
    }

    cout << ans << endl;


    return 0;
}


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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.length() <= k) {
    cout << s << endl;
  } else {
    rep(i, k) cout << s[i];
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 ) + 7;
 
bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    std::vector< std::string > aa( 2 );
    int64_t a,b,c,d,e;

    std::cin>> aa[0];
    std::cin>> aa[1];
    
    std::cin>> a;
    std::cin>> b;

    std::string bb;
    std::cin>> bb;

    if( aa[0] == bb )
    {
        a -= 1;
    }
    else
    {
        b -= 1;
    }

    std::cout<< a << " " << b;
}



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

using namespace std;

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

    string str;
    getline(cin, str);
    for(string::iterator it = str.begin(); it != str.end(); ++it) {
        if(*it == ' ' || *it == '.' || *it == ',') *it = ' ';
    }
    istringstream is(str);
    string chunk;
    bool first = true;
    while(is >> chunk) {
        if(chunk.size() >= 3 && chunk.size() <= 6) {
            if(!first) cout << ' ';
            cout << chunk;
            first = false;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<algorithm>
#define MAXN 16
#define MAXM 1<<15
#define MOD 1000000007
using namespace std;
int u,v,n,bit[MAXM],cnt[MAXN][MAXM],g[MAXN][MAXM],m,bz[MAXN][MAXM],f[MAXM],ok[MAXM];
int main()
{
	scanf("%d%d",&n,&m);
	int S=1<<n;
	bit[0]=1;
	for(int i=1;i<=n;i++)
		bit[i]=bit[i-1]*2;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&u,&v);
		bz[u][1<<v-1]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<S;j++)
		{
			int k=j&(-j);
			cnt[i][j]=cnt[i][j^k]+bz[i][k];
			g[i][j]=bit[cnt[i][j]]-1;
		}
	}
	for(int i=0;i<S;i++)
		ok[i]=(((1&i)>0)==((2&i)>0));
	f[0]=1;
	for(int i=1;i<S;i++)
		if(ok[i])
		{
			f[i]=1;
			for(int j=(i-1)&i;j;j=(j-1)&i)
				if(ok[j])
				{
					int k=i^j,s=f[k];
					for(int x=0;x<n;x++)
						if(((1<<x)&k)>0) s=1ll*s*g[x+1][j]%MOD;
						else if(((1<<x)&j)>0) s=1ll*s*bit[cnt[x+1][k]]%MOD;
						f[i]=(f[i]+s)%MOD;
				}
		}
	int ans=1;
	for(int i=0;i<m;i++)
		ans=ans*2%MOD;
	ans=(ans-f[S-1]+MOD)%MOD;
	printf("%d",ans);
}

Measured memory_bytes: 4992
// AOJ 1619 Making Lunch Boxes
// 2018.2.12 bal4u

#include <stdio.h>
#include <string.h>

char b[503][503];
char d[503];
short dp[2][1 << 21];
int a[1 << 24];

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int bitcount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main()
{
	int n, m, i, j, k, f, cnt, lim, ans;
	int k1, k2;
	char *p;

	while (n = in()) {
		m = in();
		for (i = 0; i < n; i++) {
			fgets(p=b[i], 503, stdin);
			for (j = 0; j < m; j++) *p &= 1, p++;
		}

		ans = 0;
		if (m > 30) {
			lim = 1 << n;
			for (i = 0; i < lim; i++) {
				cnt = 0;
				memset(d, 0, m);
				for (j = 0; j < n; j++) if ((i >> j) & 1) {
					cnt++;
					p = b[j]; for (k = 0; k < m; k++) d[k] ^= *p++;
				}
				f = 1; for (k = 0; k < m; k++) if (d[k]) { f = 0; break; }
				if (f && ans < cnt) ans = cnt;
			}
		} else if (n <= 24) {
			lim = 1 << n;
			a[0] = 0;
			for (j = 0; j < n; j++) {
				f = 0;
				p = b[j], k = m; while (k--) f = (f << 1) | *p++;
				a[1 << j] = f;
			}
			for (j = 1; j < lim; j++) {
				f = j & -j;
				if (j > f) a[j] = a[f] ^ a[j-f];
			}
			for (j = 0; j < lim; j++) if (!a[j]) {
				f = bitcount(j);
				if (ans < f) ans = f;
			}
		} else {
			lim = 1 << m;
			memset(dp, -1, lim << 2);
			dp[0][0] = 0;
			for (k1 = 0, k2 = 1, j = 0; j < n; j++, k1 = k2, k2 = !k2) {
				f = 0;
				p = b[j], k = m; while (k--) f = (f << 1) | *p++;
				memcpy(dp[k2], dp[k1], lim << 2);
				for (k = 0; k < lim; k++) if (dp[k1][k] >= 0) {
					int x = k ^ f;
					if (dp[k2][x] < dp[k1][k] + 1) dp[k2][x] = dp[k1][k] + 1;
				}
			}
			ans = dp[k1][0];
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 43088
#include <iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

int main() {
	string str;
	cin >> str;

	str = str.replace(5, 1, " ");
	str = str.replace(13, 1, " ");

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  char a[4]; cin >> a;
  if (a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3]){
    cout << "No" << endl;
    return 0;
  }else if((a[0]==a[1]&&a[2]==a[3])||
     (a[0]==a[2]&&a[1]==a[3])||
     (a[0]==a[3]&&a[2]==a[1])||
     (a[1]==a[2]&&a[0]==a[3])||
     (a[1]==a[3]&&a[2]==a[0])||
     (a[2]==a[3]&&a[0]==a[1])){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256