akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7, arr[105], pre[105], sum[100005], dp[105][100005];
ll solve(ll n, ll k)
{
	dp[0][0] = 1;
	for (int i = 1; i <= k; ++i)
		dp[0][i] = 0;
	for (int i = 1; i <= n; ++i) {
		sum[0] = dp[i - 1][0];
		for (int j = 1; j <= k; ++j)
			sum[j] = (sum[j - 1] + dp[i - 1][j]) % mod;
		ll bound = min(k, pre[i]);
		for (int j = 0; j <= bound; ++j) {
			dp[i][j] = sum[j];
			if (j > arr[i])
				dp[i][j] = (dp[i][j] - sum[j - arr[i] - 1] + mod) % mod;
		}
	}
	return dp[n][k];
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		pre[i] = pre[i - 1] + arr[i];
	}
	cout << solve(n, k) << '\n';
	return 0;
}

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

int main() {
  int n, m;
  
  std::cin >> n >> m;
 
  std::vector<int> a(n);
  std::fill(a.begin(), a.end(), -1);
  
  for(int i=0; i<m; ++i) {
    int s, c;
    std::cin >> s >> c;
    if(a[s-1] == -1)
      a[s-1] = c;
    else if(a[s-1] != c){
      std::cout << "-1\n";
      return 0;
    }
  }

  if(a.size() ==1) {
    if(a[0] != -1)
      std::cout << a[0] << std::endl;
    else
      std::cout << 0 << std::endl;
    return 0;
  }
  
  if(a[0] == 0) {
    std::cout << "-1\n";
    return 0;
  }
  
  if(a[0] == -1) {
    a[0] = 1;
  }
  
  for(auto&& v : a) {
    if(v==-1)
      v = 0;
	std::cout << v;
  }
  std::cout << std::endl;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;


int main(){
 ll N,M; cin >> N >> M;

vector<vector<pair<ll,ll>>> to; to.resize(N);

 vector<ll> dist(N,INF);
  
  dist[0] = 0;
   
   for(ll i = 0; i < M; i++){ 
     ll a,b,c; cin >> a >> b >> c; a--; b--; c *= -1;
     to[a].push_back(make_pair(b,c));}
  
  bool flag = false;
  
   for(ll k = 0; k < 2 * N - 2; k++){
    for(ll i = 0; i < N; i++){
      // considering i- node
      if( dist[i] == INF){ continue;}
      for(auto ne: to[i]){
        ll p = ne.first;   ll q = ne.second; 
        if( dist[p] > dist[i] + q){ 
          dist[p] = dist[i] + q;
          if( p == N - 1 && k >= N - 1){ flag = true; break;}
        }
      }
    }
   }
  
  if( flag){ cout << "inf" << endl; }
  else{ cout << -dist[N-1] << endl; } 
  
  return 0;}
          


Measured memory_bytes: 384
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt+=1
   if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans+=1
print(ans)

Measured memory_bytes: 9192
def main():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    xy=[list(map(int,input().split())) for _ in [0]*m]
    class unionfind():
        #size:要素数,tree：unionfind木
        def __init__(self,size):#self,要素数
            self.size=size
            self.tree=[[i,1] for i in range(self.size)]#root,depth
        
        #rootを探す
        def root(self,index):
            if self.tree[index][0]==index:
                return index
            else:
                self.tree[index][0]=self.root(self.tree[index][0])
                return self.tree[index][0]
    
        #結合
        def unite(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1!=r2:
                d1,d2=self.tree[r1][1],self.tree[r2][1]
                if d1<=d2:
                    self.tree[r1][0]=r2
                    self.tree[r2][1]=max(d1+1,d2)
                else:
                    self.tree[r2][0]=r1
                    self.tree[r1][1]=max(d2+1,d1)
    
        #同じか判定
        def same(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            return r1==r2
    
        #連結成分の個数
        def component(self):
            return len({self.root(i) for i in range(self.size)})
    
    u=unionfind(n)
    for x,y in xy:
        u.unite(x,y)
    for i in range(n):
        u.tree[i][0]=u.root(i)
    ut=u.tree
    d=dict()
    for i in range(n):
        if ut[i][0] in d.keys():
            d[ut[i][0]].append(a[i])
        else:
            d[ut[i][0]]=[a[i]]
    list1=[]
    list2=[]
    for s in d.values():
        s2=sorted(s)
        list1.append(s2[0])
        list2+=s2[1:]
    if len(list1)==1:
        print(0)
    elif len(list1)>len(list2)+2:
        print("Impossible")
    else:
        list2.sort()
        print(sum(list1)+sum(list2[:len(list1)-2]))
main()

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

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int i=0;
		int sum=0;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null ) {
            	sum+=Integer.parseInt(line);
            	i++;
            	if(i==4){
            		break;
            	}
            }
            System.out.println(sum/60);
            System.out.println(sum%60);
		}
	}
}

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

using namespace std;

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

  //cout << max << endl;
  
  int c[max];
  for(int i=0; i<max; i++) c[i] = 0; 
  
  for(int i=0; i<n; i++){
    c[a[i]-1]++;    
  }

  //for(int i=0; i<max; i++) cout << i << " : " << c[i] << endl; 

  int count = 0;
  for(int i=0; i<max; i++){  
    while(c[i] > 1){
      //cout << i << " : " << a[i] << endl;
      count++;
      c[i]--;
    }
  }
  if(count%2 != 0) count++;
  cout << n - count << endl;
  
  return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL x(n), y(n);
	vector<PLL> xy(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		xy[i] = {x[i],y[i]};
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			int dx = x[i] - x[j];
			int dy = y[i] - y[j];
			int num = 1;
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					if (l == i or l == j or l == k) {
						continue;
					}
					if (x[k] - x[l] == dx and y[k] - y[l] == dy) {
						num++;
					}
				}
			}
			ans = max(ans, num);
		}
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000

int A[MAX];
int n = 0;

void maxHeapify(int i) {
  int left = 2*(i+1)-1;
  int right = 2*(i+1)+1-1;
  int largest;
  if (left < n && A[left] > A[i]) {
    largest = left;
  } else {
    largest = i;
  }
  if (right < n && A[right] > A[largest]) {
    largest = right;
  }
  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

void insert(int key) {
  n++;
  A[n-1] = key;
  int i = n-1;
  int parent = (i+1)/2-1;
  while (i > 0 && A[parent] < A[i]) {
    swap(A[i], A[parent]);
    i = (i+1)/2-1;
    parent = (i+1)/2-1;
  }
}

void heapExtractMax() {
  printf("%d\n", A[0]);
  A[0] = A[n-1];
  A[n-1] = NIL;
  n--;
  maxHeapify(0);
}

int main() {
  for ( int i = 0; i < MAX; i++ ) {
    A[i] = NIL;
  }

  char str[14];
  int key;
  for ( ;; ) {
    scanf("%s", str);
    if ( strcmp(str, "insert") == 0 ) {
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(str, "extract") == 0 ) {
      heapExtractMax();
    } else if ( strcmp(str, "end") == 0 ) {
      break;
    }
  }

  return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d%d",&a[i],&b[i]);

	vector<int> sum(n);
	rep(i,n) sum[i]=a[i]+b[i];

	sort(sum.rbegin(),sum.rend());

	lint ans=0;
	rep(i,n) ans+=a[i];
	for(int i=1;i<n;i+=2) ans-=sum[i];
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 4552
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int a,b,t;
  scanf("%d%d%d",&a,&b,&t);
  int ans = t/a*b;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        x: i64,
        n: usize,
        p: [i64;n]
    }

    let mut ans = -1;

    for i in -1..=101 {
        if p.contains(&i) {
            continue;
        }

        if (x - i).abs() < (x - ans).abs() {
            ans = i;
        }
    }

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


Measured memory_bytes: 2112
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


int main() {
    int N;
    cin >> N;
    vint A(N);
    vint B(N);
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    map<int, int> sorted_idx_map;
    rep(i, N) {
        sorted_idx_map[B[i]] = i;
    }
    int count = 0;
    int idx_odd_count = 0;
    int idx_even_count = 0;
    rep(i, N) {
        if (i % 2 != sorted_idx_map[A[i]] % 2) {
            count++;
            if (i % 2 == 0) idx_even_count++;
            else idx_odd_count++;
        }
    }
    cout << max(idx_odd_count, idx_even_count) << endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	long long a[n+1]={0};
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
		
	for(int i=k+1;i<=n;i++)
	{
		long long x,y;
		x= a[i]-a[i-k];
		y= a[i-1]-a[i-k-1];
	//	cout<<x<<" "<<y;
		if(x>y)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		
	}
    return 0;
}

Measured memory_bytes: 5232
#include<stdio.h>
#include<string.h>

int main(){
  int n;

  scanf("%d", &n);

  char w[n + 1][11];
  int i, j, k;
  int saigo = 0;
  int check = 0;

  for(i = 0; i < n; i++){
    scanf("%s", w[i]);
  }

  for(i = 0; i < n - 1; i++){
    for(j = 1; j < n; j++){
      if(i != j){
	int ret = strcmp(w[i], w[j]);
	if(ret == 0){
	  check = 1;
	  //	  printf("retNo\n");
	  break;
	}
      }
    }
    //  printf("1check = %d\n", check);
    for(k = 1; k <= 10; k++){
      if(w[i][k] == '\0'){
	saigo = k - 1;
	break;
      }
    }
    // printf("2check = %d\n", check);
    //printf("%s %d ", w[i], saigo);
    //printf("%c ", w[i][saigo]);
    //printf("%s %c\n", w[i + 1], w[i + 1][0]);

    if(w[i + 1][0] != w[i][saigo]){
      //      printf("check\n");
      saigo = 0;
      check = 1;
      break;
    }

    //printf("3check = %d\n", check);
  }

  // printf("4check = %d\n", check);

  if(check == 1){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int l = in();
  int r = in();
  int d = in();
  int ans = 0;
  rep(i,l,r+1){
    if(!(i % d))++ans;
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
    int N,ans=0,cnt=0;
    cin >> N;
    for(int i=9;i<=N;i+=2){
        cnt = 0;
        for(int j=1;j<=N;j+=2){
            if(i%j==0) ++cnt;
        }
        if(cnt==8) ++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
N = gets.to_i
hash = Hash.new

class Node
    attr_accessor :no
    attr_accessor :children
end

N.times do
    info = gets.chomp.split(" ").map(&:to_i)
    no = info.shift
    child_size = info.shift
    node = Node.new
    node.no = no
    node.children = info
    hash[no] = node
end

hash.values.each do |node|
    node.children = node.children.map {|i| hash[i] } 
end

memo = {}

P = gets.to_i
P.times do
    s,d,v=gets.chomp.split(" ").map(&:to_i)

    node = hash[s]
    if node != nil && memo[node.no] == nil
        memo[node.no] = {}
        memo[node.no][node.no] = 1
        nexts = [node]
        distance = 2
        while !nexts.empty?
            nexts = nexts.map {|e| e.children }.flatten.uniq

            nexts_pre = []
            nexts.each do |next_node|
                if memo[node.no][next_node.no] == nil
                    memo[node.no][next_node.no] = distance
                    nexts_pre.push(next_node)
                end
            end
            nexts = nexts_pre
            distance += 1
        end
    end

    distance = memo.dig(s, d)
    if distance == nil || distance > v
        puts "NA"
    else
        puts distance
    end
end


Measured memory_bytes: 7748
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
t0,x0,y0=0,0,0
for i in range(n):
    t,x,y=map(int,input().split())
    d=abs(x0-x)+abs(y0-y)
    if d%2!=(t-t0)%2 or (t-t0)<d:
        print("No")
        exit()
    t0,x0,y0=t,x,y
print("Yes")




Measured memory_bytes: 42600
import static java.lang.System.out;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    String str = in.next();
    String s ="";
    if(str.length()>=4) {
        s = str.substring(0,4);
    }
    if(s.equals("YAKI")) out.println("Yes");
    else out.println("No");

	}
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() { 
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



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

void solve();

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	for(int i = 0; i < t; i++){
		solve();
	}
	return 0;	
}

void solve(){
	string S;
	cin >> S;
	bool flag = true;
	int k = (S.length()-1)/2;
	for(int i = 0; i < 2*k+1; i++){
		if(S[i] != S[2*k-i]){ 
			flag = false;
			break;
		}
		if(i < k){
			if(S[i] != S[k-1-i]){
				flag = false;
				break;
			}
		}
		if(i > k){
			if(S[i] != S[3*k+1-i]){
				flag = false;
				break;
			}
		} 
	}
	if(flag){
		cout << "Yes";
	}else cout << "No";
	
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

/**

時刻tにおける砂の量
       ______
      /
     /
____/

     初期値a

上へ移動、上がつぶれる

下へ移動、下がつぶれる

(l, r, y)
z = y+(r-l)
**/

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

    int X, K;
    cin >> X >> K;

    vector<pii> ev;
    rep(i, K) {
        int r;
        cin >> r;
        ev.emplace_back(r, -1);
    }

    int Q;
    cin >> Q;

    vi A(Q);
    
    rep(i, Q) {
        int t;
        cin >> t >> A[i];
        ev.emplace_back(t, i);
    }

    sort(all(ev));
    int s = -1, pre = 0, y = 0, l = 0, r = X;

    vi ans(Q);
    each(e, ev) {
        int t, k;
        tie(t, k) = e;
        int dt = t - pre;

        if (s == -1) {
            if (y < dt) {
                l = min(l + dt - y, r);
            }
            y = max(0, y - dt);
        } else {
            int z = (r - l) + y;
            if (X - z < dt) {
                r = max(l, r - dt + X - z);
            }
            y = min(X, y + dt);
        }

        if (k == -1) {
            s *= -1;
        } else {
            int a = A[k];
            if (a <= l)ans[k] = y;
            else if (a >= r)ans[k] = y + r - l;
            else ans[k] = y + a - l;
        }

        pre = t;
    }

    each(a, ans)cout << a << endl;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    int a = 0, b = 0;
    vector<int> N(0);
    rep(i, n) { N.push_back(i + 1); }
    vector<int> p(n, 0), q(n, 0);
    rep(i, n) { cin >> p[i]; }
    rep(i, n) { cin >> q[i]; }

    int i = 1;
    dump(p);
    do {
        dump(N);
        bool isSame = true;
        for (int i = 0; i < n; i++) {
            if (N[i] == p[i]) {
                continue;
            } else {
                isSame = false;
                break;
            }
        }
        if (isSame) { a = i; }
        i++;
    } while (next_permutation(all(N)));
    i = 1;
    do {
        bool isSame = true;
        for (int i = 0; i < n; i++) {
            if (N[i] == q[i]) {
                continue;
            } else {
                isSame = false;
                break;
            }
        }
        if (isSame) { b = i; }
        i++;
    } while (next_permutation(all(N)));
    dd(a, b);
    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (forM_)
import Data.List (sort, unfoldr)

main :: IO ()
main = do
  _ <- getLine
  xs <- sort . map read . words <$> getLine
  forM_ (solve xs) print
  
solve :: [Int] -> [Int]
solve = factors . foldr1 gcd

factors :: Int -> [Int]
factors n = [ n `div` k | k <- [n, n-1 .. 1], n `mod` k == 0 ]


Measured memory_bytes: 4084
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();

		int A[] = new int[N];

		for(int n=0;n<N;n++){
			A[n] = sc.nextInt();
		}

		int ans = X;

		for(int n=0;n<N;n++){
			ans += (D-1)/A[n]+1;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 21588
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], K = l[2];
            if (K > B) K = B - A;

            if (A == B)
            {
                Console.WriteLine(A);
                return;
            }

            var set = new HashSet<int>();

            for (var i = A; i <= B && i < A + K; i++)
                set.Add(i);
            for (var i = B - K + 1; i <= B && i >= A; i++)
                set.Add(i);

            foreach (var s in set)
//                foreach (var s in set.OrderBy(z => z))
                Console.WriteLine(s);
        }
    }
}


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

int main(){
  int M1,M2,D1,D2;
  cin>>M1>>D1;
  cin>>M2>>D2;

  if(M1!=M2){
    cout<<"1"<<endl;
  }
  else{
    cout<<"0"<<endl;
  }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p_a(n);
    iota(p_a.begin(), p_a.end(), 1);
    vector<int> q_b(n);
    iota(q_b.begin(), q_b.end(), 1);
    vector<int> p;
    vector<int> q;
    
    for( int i = 0; i < n; i++ )
    {
        int a = 0;
        cin >> a;
        p.push_back(a);
    }

    for( int i = 0; i < n; i++ )
    {
        int a = 0;
        cin >> a;
        q.push_back(a);
    }
    
    bool p_check = false;
    bool q_check = false;
    int count_p = 1;
    int count_q = 1;
    do{
        int p_c = 0;
        int q_c = 0;
        for( int i = 0; i < n; i++ )
        {
            if( p_a.at(i) == p.at(i) )
            {
                p_c += 1;
            }
            if( p_a.at(i) == q.at(i) )
            {
                q_c += 1;
            }
        }
        if( p_c == n && p_check == false )
        {
            p_check = true;
        }
        else if( p_check == false )
        {
            count_p += 1;
        }

        if( q_c == n && q_check == false )
        {
            q_check = true;
        }
        else if( q_check == false )
        {
            count_q += 1;
        }

    }while(next_permutation(p_a.begin(),p_a.end()));
    
    cout << abs(count_p-count_q) << endl;
    return 0;
}



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

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0] * H
    ws = [0] * W
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()
    print(ans-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 90312
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
N=l()[0]
s=set()
for i in range(N):
    a=l()[0]
    if(a in s):
        s.discard(a)
    else:
        s.add(a)
print(len(s))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, k, s, u, v, x, y, t, a, b, ans;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>k>>s;
	for (int i=1; i<=k; i++) cout<<s<<' ';
	if (s==1000000000){
		for (int i=k+1; i<=n; i++) cout<<"1 ";
		cout<<'\n';
		return 0;
	}
	for (int i=k+1; i<=n; i++) cout<<"1000000000 ";
	
	
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std ;
int main(){
	vector<int> a = {1,4,7,9} ;
  	vector<int> b(4) ;
    for(int& i : b)
      scanf("%d", &i) ;
  	sort(b.begin() , b.end()) ;
  	if(a == b)
      puts("YES") ;
  	else
      puts("NO") ;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var x, k, d int64
	fmt.Scan(&x, &k, &d)
	if x < 0 {
		x = -x
	}
	n := x / d

	t1 := x % d
	t2 := t1 -d

	var ans int64

	if k <= n {
		ans = x - k * d
	} else {
		if (k-n) % 2 == 0 {
			ans = t1
		} else {
			ans = -t2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
# AtCoder Beginner Contest 134 E - Sequence Decomposing

import sys
import bisect

N = int(input())
now = int(sys.stdin.readline().strip())
ans = [now]

for n in range(N - 1):
    now = int(sys.stdin.readline().strip())

    if now > ans[0]:
        ans[0] = now
    elif ans[-1] >= now:
        ans.append(now)
    else:
        # 2部探査で行進位置を探る
        left = 0  # 挿入不可能
        right = len(ans) - 1  # 挿入可能

        while right - left > 1:
            mid = (right + left) // 2
            if now > ans[mid]:
                right = mid
            else:
                left = mid

        ans[right] = now

print(len(ans))

    # if ans:  # 最初の入力以外であり、すでに追加対象のリストが存在する
    #     if ans[0][-1] < now:
    #         ans[0].append(now)
    #     elif ans[-1][-1] >= now:
    #         appending = [now]
    #         ans.append(appending)
    #     else:
    #         # 二分探索で追加するリストの位置を特定する
    #         left = 0   # 追加できない  ans[left][-1] > now
    #         right = len(ans) - 1  # ans[right][-1] < now
    #
    #         while right - left > 1:
    #             mid = (right - left) // 2
    #             if ans[mid][-1] < now:
    #                 right = mid
    #             else:
    #                 left = mid
    #         ans[right].append(now)
    # else:
    #     appending = [now]
    #     ans.append(appending)

    # for a in ans:
    #     if a[-1] < now:
    #         a.append(now)
    #         break
    # else:
    #     appending = [now]
    #     ans.append(appending)

# print(len(ans))


Measured memory_bytes: 77492
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	  static int MOD=1000000007;
	  static long p[][]=new long[405][405];
	  static long sum[][]=new long[405][405];
	  static long dp[][]=new long[35][100005];
	  static long a[]=new long[100005];
	  static long b[]=new long[405];
      public static void main(String[] args) {
    	  Scanner in=new Scanner( new BufferedReader(new InputStreamReader(System.in)))	;
          int n=in.nextInt();
         
         for(int i=0;i<=30;i++)
        	 dp[i]=new long[100005];
          for(int i=1;i<=n;i++)
          {
        	  a[i]=in.nextLong();
          }
          int L=in.nextInt();
          for(int i=1;i<=n;i++)
          {
        	  int pos=find(1,n,a[i]+L);
        	  //System.out.println("pos:"+pos);
        	  dp[0][i]=pos;
          }
          for(int i=1;i<=30;i++)
          {
        	  for(int j=1;j<=n;j++)
        	  {
        		  dp[i][j]=dp[i-1][(int) dp[i-1][j]];
        	  }
          }
          int q=in.nextInt();
          while(q-->0)
          {
        	  int l=in.nextInt();
        	  int r=in.nextInt();
        	  if(l>r) {int t=l;l=r;r=t;}
        	  long ans=0;
        	  for(int i=30;i>=0;i--)
        	  {
        		  if(dp[i][l]<r)
        		  {
        			  ans+=(1<<i);
        			  l=(int) dp[i][l];
        		  }
        	  }
        	  System.out.println(ans+1);
          }
    	  return;
      }
	private static int find(int l, int r, long v) {
		// TODO 自动生成的方法存根
		while(l<r)
		{
			int mid=(l+r+1)>>1;
		    if(a[mid]<=v)
		    	l=mid;
		    else
		    	r=mid-1;
		}
		return l;
	}
}


Measured memory_bytes: 189728
from collections import defaultdict
s = input()
s_set = set(s)

count_min = 100
count = 0
for i in s_set:
    s_copy = s
    while True:
        t = ""
        if s_copy == i*len(s_copy):
            break
        for j in range(len(s_copy)-1):
            if s_copy[j] == i or s_copy[j+1] == i:
                t += i
            else:
                t += "?"
        s_copy = t
        count += 1
    count_min = min(count_min,count)
    count = 0
print(count_min)

Measured memory_bytes: 3316
d,g = map(int, input().split())
pd = [[int(i) for i in input().split()] for _ in range(d)]

ans = float("INF")
for mask in range(1 << d):
  tmp = 0
  tmp1 = 0
  for j in range(d):
    if 1 << j & mask:
      tmp += pd[j][1]
      tmp += pd[j][0] * 100 * (j + 1)
      tmp1 += pd[j][0]
  if tmp >= g:
    ans = min(ans, tmp1)
    continue
  for j in range(d-1,-1,-1):
    if not(1 << j & mask):
      if tmp + pd[j][0] * 100 * (j + 1) >= g:
        tmp1 += (g - tmp - 1) // (100 * (j + 1)) + 1
        tmp = g
        break
      tmp1 += pd[j][0]
      tmp += pd[j][0] * 100 * (j + 1)
  if tmp >= g:
    ans = min(ans, tmp1)
print(ans)


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

int main(){
	long n,k,d;
	cin >> n >> k;
	long z[101];
	rep(i,101)z[i]=0;
	for(int i=0;i<k;i++){
		cin >> d;
		for(int i=0;i<d;i++){
			long a;
			cin >> a;
			z[a]=1;
		}
	}
	long ans=0;
	for(int i=1;i<=n;i++){
		if(z[i]==0)ans++;
	}
	cout << ans;
	return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int R,G,B,N;
	cin >> R >> G >> B >> N;
	
	int ans=0;
	for(int i=0;i<=N;i++){
		if(i*R>N)	break;
		for(int j=0;j<=N;j++){
			if(i*R+j*G>N)	break;
			if(i*R+j*G==N)	ans++;
			else if((N-i*R-j*G)%B==0)	ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }
        static void Main() {
            var Key = getKeys();
            Console.WriteLine(Math.Max(Key[0] - Key[1], 0));
        }
    }
}


Measured memory_bytes: 11092
E_DICT = {}


def search_pass(v_idx, v_set, cnt):
    v_set2 = v_set.copy()
    v_set2.remove(v_idx)

    if len(v_set2) == 0:
        return cnt + 1

    e_tup = E_DICT[v_idx]

    for i in range(len(e_tup)):
        if e_tup[i] in v_set2:
            cnt = search_pass(e_tup[i], v_set2, cnt)

    return cnt


def main():
    n, m = map(int, input().split())
    v = {i+1 for i in range(n)}

    for i in range(m):
        a, b = map(int, input().split())

        if a in E_DICT:
            E_DICT[a].append(b)
        else:
            E_DICT[a] = [b]

        if b in E_DICT:
            E_DICT[b].append(a)
        else:
            E_DICT[b] = [a]

    if m == 0:
        comb = 0
    else:
        comb = search_pass(1, v, 0)

    print(comb)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int w, s[31], n, a, b;
    cin >> w >> n;
    for(int i=1; i<=w; i++){
        s[i]=i;
    }
    while(n--){
        scanf("%d,%d", &a, &b);
        swap(s[a], s[b]);
    }
    for(int i=1; i<=w; i++){
        cout << s[i] << "\n";
    }
}



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

int main(){
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(j,D) rep(i,26) cin >> s[j][i];

    vector<int> t(D);
    rep(j,D) cin >> t[j];
    vector<vector<int>> last(D, vector<int>(26,-1));
    Int manzoku = 0;
    rep(j,D) {
        manzoku += s[j][t[j]-1];
        for (int k = j; k < D; k++) last[k][t[j]-1] = j;
        rep(i,26) {
            manzoku -= c[i] * (j - last[j][i]);
        }
        cout << manzoku << endl;
    }

    //rep(j,D) cout << t[j] << endl;
}

Measured memory_bytes: 3632
s = int(input())

def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

a = [s]
i = 2
while True:
    x = f(a[i-2])
    if x in a:
        print(i)
        break
    a.append(x)
    i += 1

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


// 1
// A
// B
// N

ll solve(){
  ll N,A,B; cin>>N>>A>>B;
  ll ans = pow(10,19);
  if( (B-A)%2==0 ){
    ans = (B-A)/2;
  } else{
    ans = min(A-1 , N-B) + 1 + (B-A-1)/2;
  }
  return ans;
}

int main(){
  cout << solve()<<"\n";
}

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

using namespace std;

int x[55];

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

    int counting = 0;

    for (int i = 0; i < n-2; i++)
    {
        if (S[i] == 'A' && S[i+1] == 'B' & S[i+2] == 'C')
            counting++;
    }
    cout << counting << endl;
    return 0;
}


Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]

    return i+1


if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    n = int(input())
    A = list(map(int, input().split()))

    q = partition(A, 0, n-1)
    A[q] = '[{}]'.format(A[q])

    print(' '.join(map(str, A)))



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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int a,b;
   cin>>a>>b;
   
   int now=1;
   int ans=0;
   do{
      if(now>=b) {
         cout<<ans; 
         break;
      }
      now=(now-1)+a;
      ans++;
    
   }while(1);
   return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll n,k;
	cin >> n >> k;
	n %= k;
	cout << min(n,k-n) << endl;
	return 0;
}


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

int main(){
    int X;
    int joy = 0;
    cin >> X;

    while(X >= 500){
        joy += 1000;
        X -= 500;
    }
    while(X >= 5){
        joy += 5;
        X -= 5;
    }
    cout << joy << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair <int,pair <int,int> > P;
#define dis first
#define node second.first
#define mo second.second
#define INF 1000000000;
int N,M,L;
pair <int,int> mp[101][101];
 
P mk(int a,int b, int c){
  P res;
  res.dis = a, res.node = b; res.mo = c;
  return res;
}
 
int dijkstra(){
  priority_queue < P, vector<P>, greater<P> > Q;
  int D[101][101],visited[101][101]={};
  for(int i=0;i<=L;i++)
    for(int j=0;j<=N;j++) D[i][j] = INF;
  Q.push(mk(0,1,0)),  D[0][1] = 0;
 
  while(!Q.empty()) {
    P t = Q.top(); Q.pop();
    if(visited[t.mo][t.node] != 0) continue;
    visited[t.mo][t.node] = 1;
    if(t.node == N) return t.dis;
 
    for(int i=1;i<=N;i++){
      if(mp[t.node][i].first == -1) continue;
      int nmo = t.mo+mp[t.node][i].first;
      int ndis = t.dis + mp[t.node][i].second;
      if(nmo <=L && D[nmo][i] > t.dis )Q.push(mk(t.dis,i,nmo));
      if(D[t.mo][i] > ndis ) Q.push(mk(ndis,i,t.mo));
    }
  }
  return -1;   
}
 
int main() {
 
  while(1) {
  cin >> N >> M >> L;
  if(N==0 && M==0 && L==0) break;
  for(int i=0;i<=N;i++)
    for(int j=0;j<=N;j++) mp[i][j].first= -1;
 
  for(int i=0;i<M;i++){
    int x,y,z,w;
    cin >> x >> y >> z >> w;
    mp[x][y].first = z,mp[x][y].second = w;
    mp[y][x].first = z,mp[y][x].second = w;
  }
  cout << dijkstra() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1844