akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;

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

bool flg[150][150];
int fld[150][150];
int w,h;
int xg,yg;
bool ans;

void check(int c,int x,int y){
    if(fld[y][x]!=c){
        return;
    }

    if(x == xg && y == yg){
        ans = true;
        return;
    }

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

    int dx[] = {0,0,1,-1};
    int dy[] = {1,-1,0,0};
    rep(i,4){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(nx<=0 || nx>w || ny<=0 || ny>h){
            continue;
        }
        check(c,nx,ny);
    }
}

int main(){
    while(cin >> w >> h,w+h){
        rep(i,150){rep(k,150){flg[i][k]=false;}}
        ans = false;
        int xs,ys;
        cin >> xs >> ys;
        cin >> xg >> yg;

        int n;
        cin >> n;
        rep(i,n){
            int c,d,x,y;
            cin >> c >> d >> x >> y;
            int width,height;
            if(d == 0){
                width = 4;
                height = 2;
            }else{
                width = 2;
                height = 4;
            }

            reep(ny,y,y+height){
                reep(nx,x,x+width){
                    fld[ny][nx] = c;
                }
            }
        }

        reep(i,1,6){
            check(i,xs,ys);
        }
        if(ans){
            puts("OK");
        }else{
            puts("NG");
        }
    }
}

Measured memory_bytes: 1164
#include<cstdio>
#include<cstring>
using namespace std;
char s[500005];
int n,m;
int ne[500005][27],Ne[500005][20];
inline int read(){
    int ret=0;char c=getchar();
    while((c>'9')||(c<'0'))c=getchar();
    while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();
    return ret;
}
void pre(){
	for(int i=1;i<=n+2;i++){
		for(int j=0;j<=26;j++)ne[i][j]=n+2;
		for(int j=0;j<=19;j++)Ne[i][j]=n+2;
	}
	for(int i=n;i;i--){
		ne[i][s[i]]=i+1;
		for(int j=s[i]+1;j<=26;j++)ne[i][j]=ne[ne[i][j-1]][j-1];
		Ne[i][0]=ne[i][26];
		for(int j=1;j<20;j++)Ne[i][j]=Ne[Ne[i][j-1]][j-1];
		for(int j=0;j<26;j++)if(ne[i][j]==n+2)ne[i][j]=ne[Ne[i][0]][j];
	}
}
inline bool check(int l,int r){
	for(int i=19;i>=0;i--){
		if(Ne[l][i]==r+1)return true;
		if(Ne[l][i]<=r)l=Ne[l][i];
	}
	return false;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)s[i]-='a';
	pre();
	m=read();
	while(m--){
		int l=read(),r=read();
		if(check(l,r))puts("Yes");
		else puts("No");
	}
}

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

int main()
{
	int N;
	cin >> N;
	priority_queue<long long> que;
	for( int i = 0; i < N * 3; i++ ) {
		long long a;
		cin >> a;
		que.push( a );
	}

	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		que.pop();
		long long a = que.top();
		que.pop();
		ans += a;
	}

	cout << ans << endl;
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

class UnionFind {
private:
  vector<ll> parent;
  vector<ll> rank;

public:
  vector<ll> sz;
  UnionFind(ll size) : parent(size), rank(size, 0), sz(size, 1) {
    for (ll i = 0; i < size; i++) {
      parent[i] = i;
    }
  }

  ll find(ll x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
      sz[y] += sz[x];
    } else {
      parent[y] = x;
      sz[x] += sz[y];
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
};

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

  ll n, m, k;
  cin >> n >> m >> k;
  vl a(m), b(m), c(k), d(k);
  vector<vl> block(n), tomo(n);

  UnionFind uf(n);

  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    tomo[a[i]].push_back(b[i]);
    tomo[b[i]].push_back(a[i]);
    uf.unite(a[i], b[i]);
  }

  vl ans(n);
  rep(i, n) {
    ans[i] = uf.sz[uf.find(i)]-1;
  }

  rep(i, m) {
    if (uf.same(a[i], b[i])) {
      ans[a[i]]--;
      ans[b[i]]--;
    }
  }
  
  rep(i, k) {
    ll c, d;
    cin >> c >> d;
    c--;
    d--;
    if (uf.same(c, d)) {
      ans[c]--;
      ans[d]--;
    }
  }

  rep(i, n) {
    cout << ans[i];
    if (i == n-1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 15732
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll cnt =1;
    ll ans = 0;
    sort(a.begin(),a.end(),greater<int>());
    ans+=a[0];
    int i = 1;
    while(cnt<n-1){
        ans+=a[i];
        cnt++;
        if(cnt==n-1) break;
        ans+=a[i];
        cnt++;
        i++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;

ll pw(ll b, ll e) {
  ll ans = 1;
  for (; e; e /= 2, b = (b*b)%MOD) {
    if (e%2) ans = (ans*b)%MOD;
  }
  return ans;
}

ll inv(ll x) { return pw(x, MOD-2); }

ll choose(int n, int k) {
  ll ans = 1;
  for (int i = 1; i <= k; i++) {
    ans *= (n-i+1);
    ans %= MOD;
    ans *= inv(i);
    ans %= MOD;
  }
  return ans;
}

int n, a, b;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b;
  // 2^n - n choose a - n choose b
  ll ans = pw(2, n);
  ans += MOD-choose(n, a);
  ans += MOD-choose(n, b);
  ans += MOD-1;
  cout << ans % MOD << nl;
}


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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-12

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())

// bitmask operations
#define SETBIT(S, j) S |= (1 << j)
#define CLEARBIT(S, j) S &= ~(1 << j)
#define ISSET(S, j) S & (1 << j)
#define FLIPBIT(S, j) S ^= (1 << j)
#define LSBIT(S) (S & (-S))

// debug
#define DEBUGSTR(S) cout << "(" << S << ")\n";

int main() {
  //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int N, A;
  scanf(" %d %d", &N, &A); // N = pagamento / A = 1-yen

  int resto = N%500;

  if(resto > A) {
    printf("No\n");
  }
  else {
    printf("Yes\n");
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0 ; i < n ; i++) d[i] = sc.nextInt();
		int m = sc.nextInt();
		int[] t = new int[m];
		for(int i = 0 ; i < m ; i++) {
			t[i] = sc.nextInt();
		}
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(!map.containsKey(d[i])) {
				map.put(d[i], 1);
			} else {
				map.put(d[i], map.get(d[i]) + 1);
			}
		}
		for(int i = 0 ; i < m ; i++) {
			if(!map.containsKey(t[i]) || map.get(t[i]) == 0) {
				System.out.println("NO");
				return;
			} else {
				map.put(t[i], map.get(t[i]) - 1);
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 137284
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (100000)

int N, A[MAX_N], S[MAX_N];

ll calc(ll sum, ll ans) {
  for (int i = 1; i < N; i++) {
    ll s = sum;
    sum += A[i];
    if (s * sum < 0) continue;
    ans += abs(sum) + 1;
    sum = (s < 0)? 1: -1;
  }
  return ans;
}

void solve() {
  ll ans;
  if (A[0] == 0) {
    ans = min(calc(1, 1), calc(-1, 1));
  } else if (A[0] > 0) {
    ans = min(calc(A[0], 0), calc(-1, abs(A[0]) + 1));
  } else {
    ans = min(calc(A[0], 0), calc(1,  abs(A[0]) + 1));
  }
  printf("%lld\n", ans);
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main()
{
    int n;
    long long int sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&i%5!=0&i%15!=0)
        sum+=i;
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1732
using System;
using System.Linq;

class Program
{
    static int n;
    static int q;
    static RMQ rmq;

    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        n = input[0];
        q = input[1];
        rmq = new RMQ(n, (int)(Math.Pow(2, 31) - 1));

        for (int i = 0; i < q; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (input[0] == 0) // update
            {
                int x = input[1];
                int y = input[2];
                rmq.Update(x, y);
                continue;
            }
            // find
            Console.WriteLine(rmq.Query(input[1], input[2] + 1));
        }
    }
}

struct RMQ
{
    private int n;
    private int[] dat;
    public int Length { get; private set; }

    /* nを要素数として、すべてint.MaxValueで初期化 */
    public RMQ(int n)
    {
        Length = n;
        this.n = 1;
        while (this.n < n) this.n *= 2;
        dat = new int[2 * this.n];
        for (int i = 0; i < 2 * this.n - 1; i++)
            dat[i] = int.MaxValue;
    }

    /* nを要素数として、すべてNで初期化 */
    public RMQ(int n, int N)
    {
        Length = n;
        this.n = 1;
        while (this.n < n) this.n *= 2;
        dat = new int[2 * this.n];
        for (int i = 0; i < 2 * this.n - 1; i++)
            dat[i] = N;
    }

    /* k番目(0-indexed)をaに変更 */
    public void Update(int k, int a)
    {
        k += n - 1;
        dat[k] = a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            dat[k] = Math.Min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    private int Query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l) return int.MaxValue;
        if (a <= l && r <= b) return dat[k];
        int v1 = Query_(a, b, k * 2 + 1, l, (l + r) / 2);
        int v2 = Query_(a, b, k * 2 + 2, (l + r) / 2, r);
        return Math.Min(v1, v2);
    }

    /* [a,b)の最小値を求める */
    public int Query(int a, int b)
    {
        return Query_(a, b, 0, 0, n);
    }
}


Measured memory_bytes: 23620
data = []
try:
    while True:
        data.append(raw_input())

except EOFError:
    pass

for i in data:
    a, b, c, d, e, f = map(float, (i.split()))
    if (abs(a) <= 1000
        and abs(b) <= 1000
        and abs(c) <= 1000
        and abs(d) <= 1000
        and abs(e) <= 1000
        and abs(f) <= 1000):
        y = (a*f - c*d) / (a*e - b*d)
        x = (c - b*y) / a
        print "{:.3f} {:.3f}".format(x, y)

Measured memory_bytes: 4264
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s,t;
  cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main(void) {
    long n, k;
    cin >> n >> k;
    vector<long> x(n);
    for(auto &y: x) cin >> y;

    long posi = lower_bound(x.begin(), x.end(), 0) - x.begin();

    long l = max(0l, posi - k);
    long r = l + k - 1;
    // [l, r]
    long res = 1e10;
    while(l <= posi && r < n) {
        if(x[r] <= 0) {
            res = min(res, -x[l]);
            goto next;
        }

        if(x[l] >= 0) {
            res = min(res, x[r]);
            goto next;
        }

        if(-x[l] < x[r]) {
            res = min(res, -2*x[l]+x[r]);
        } else {
            res = min(res, 2*x[r] - x[l]);
        }

next:
        l++, r++;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
/*************************************************************
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0077
*************************************************************/
#include <stdio.h>
#include <string.h>
#define LENGTH 1000

int ctoi(char input)
{
  int i;
  i = input - '0';
  return i;
}

int main()
{
  char st[LENGTH] = {};
  char output_st[LENGTH] = {};
  int i = 0, j = 0, k = 0;

  for( k = 0 ; k < 50 ; k++ )
  {
    if( (scanf("%s", st)) != EOF )
    {
      i = 0;
      while( st[i] != '\0' )
      {
        if( st[i] == '@' )
        {
          i++;
          j = ctoi(st[i]);
          i++;
          for( ; j > 0 ; j-- )
            sprintf(output_st, "%s%c", output_st, st[i]);
        }

        else
          sprintf(output_st, "%s%c", output_st, st[i]);
        i++;
      }
      printf("%s\n", output_st);
      memset(output_st, '\0', LENGTH);
    }
    else
      return 0;
  }
}



Measured memory_bytes: 2020
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
ll a[100010];
ll dp[100010];
int main()
{
    ll minst = -mod;
    int n;
    cin>>n;
    int ans1=0;
    ll sum = 0;
    ll ans = 0x3f3f3f3f;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<0)
        {
            ans1++;
        } 
        sum+=abs(a[i]);
        ans=min(ans,abs(a[i]));
    }
    if(ans1%2)
    {
        sum-=2*ans;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.time.Year;
import java.util.Random;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int a = sc.nextInt();
        if(a<30){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 35616
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(n:usize, s:String);
    let s = s.chars().collect::<Vec<char>>();
    let mut ans = 1;
    let mut c = s[0];
    for i in 1..n {
        if c != s[i] {
            ans += 1;
            c = s[i];
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int main() {
  int x,y;
  cin>>x>>y;
  if(4*x-y>=0 and y-2*x>=0 and (y-2*x)%2==0 and (4*x-y)%2==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modwdop = 998244353ll;
 
ll pp = 13337ll;
ll modw = 1e9 + 7;
 
using namespace std;

ll dp[N];
ll n, k;

ll binpow(ll a, ll n)
{
	if(n == 0)	return 1ll;
	if(n % 2 == 1)	return (binpow(a, n - 1) * a) % modw;
	else
	{
		ll b = binpow(a, n / 2);
		return (b * b) % modw;
	}
}

ll rec(ll x)
{
    if(dp[x])	return dp[x];
    dp[x] = binpow(k / x, n);
    for(int i = x * 2; i <= k;i += x)
    {
    	dp[x] -= rec(i);
		while(dp[x] < 0ll)	dp[x] += modw;
		dp[x] %= modw; 
	}
    return dp[x];
}

int main()
{
	barnarnar
	cin >> n >> k;
	ll ans = 0;
	forr1(i, k)
	{
		ans += (i * rec(i)) % modw;
		ans %= modw;
	}
	cout << ans;
}

Measured memory_bytes: 4440
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<long> x(N), a(N);
	for (long& i : x) cin >> i;
	for (int i = 1; i < N; ++i) {
		a[i] = x[i] - x[i - 1];
		a[i] += a[i - 1];
	}
	long ans = LONG_MAX;
	for (int i = 0; i <= N - K; ++i) ans = min(a[K + i - 1] + min(abs(x[K + i - 1]), abs(x[i])) - a[i], ans);
	cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, M; cin >> N >> M;
 
	vector<vector<int>> vec(M);
 
	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}
 
	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];
 
	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	vector<int> t(N+1);
	vector<int> x(N+1);
	vector<int> y(N+1);
	t[0] = x[0] = y[0] = 0;
	FOR(i,1,N+1) cin >> t[i] >> x[i] >> y[i];


	FOR(i,1,N+1){
		int dt = t[i] - t[i-1];
		int dx = abs(x[i] - x[i-1]);
		int dy = abs(y[i] - y[i-1]);

		if(dx+dy <= dt and (dx+dy)%2 == dt %2) continue;
		else{ 
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;




	return 0;

}


Measured memory_bytes: 1408
#!/usr/bin/env python3
#ABC82 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
x,y = LI()
lst = []
tmp = 0
for i in range(n):
    if s[i] == 'T':
        lst.append(tmp)
        tmp = 0
    else:
        tmp += 1
if s[-1] != 'T':
    lst.append(tmp)
m = len(lst)
dpx = defaultdict(int)
dpy = defaultdict(int)
dpx[0] = True
dpy[0] = True
for i in range(m):
    if i % 2:
        tmp = defaultdict(int)
        for k in dpy.keys():
            tmp[k + lst[i]] = True
            tmp[k - lst[i]] = True
        dpy = tmp
    else:
        tmp = defaultdict(int)
        if i == 0:
            for k in dpx.keys():
                tmp[k + lst[i]] = True
        else:
            for k in dpx.keys():
                tmp[k + lst[i]] = True
                tmp[k - lst[i]] = True
        dpx = tmp
if dpx[x] and dpy[y]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 75996
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n), v(1e6, 0);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    v[a[i]]++;
    sum += a[i];
  }

  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int b, c; cin >> b >> c;
    if(v[b] == 0){
      cout << sum << endl;
    }else{
      sum += v[b] * (c - b);
      v[c] += v[b];
      v[b] = 0;
      cout << sum << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 11896
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

h1, m1, h2, m2, k = Is()
start = h1*60+m1
end = h2*60+m2
time = end - k - start
if time < 0:
    time += 24*60

print(time)


Measured memory_bytes: 77112
N = int(input())
musics = []
dict_musics = {}
for i in range(N):
  a, b = map(str,input().split())
  musics.append([a,int(b)])
  dict_musics[a] = int(b)
X = input() 

times = []
for i in range(N): times.append(musics[i][1])
print(sum(times[times.index(dict_musics[X])+1:]))

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    int k = get<int>();
    vector<int> neg;
    vector<int> pos;

    for (int i=0; i < n; i++) {
        int x = get<int>();
        if (x < 0)
            neg.push_back(x);
        else if (x > 0)
            pos.push_back(x);
        else if (x == 0)
            k--;
    }
    reverse(neg.begin(),neg.end());

    if (k == 0) {
        cout << 0 << endl;
    } else {
        long ans = LONG_MAX;
        for (int i = 0; i <= min(k,(int)neg.size()); i++) {
            int j = k - i;
            if (j > pos.size())
                continue;
            long n, p;
            if (i == 0)
                n = 0;
            else
                n = abs((long)neg[i-1]);
            if (j == 0)
                p = 0;
            else
                p = pos[j-1];

            //cerr << "(i,j)=" << i << " " << j<< endl;
            ans = min(ans, n*2 + p);
            ans = min(ans, n + p*2);
        }

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int A;
  int answer = 0;
  vector<int> a(n+1);
  for(int i = 0;i < n;i++){
    cin >> A;
    a[A]++;
  }
  sort(a.begin(),a.end());
  for(int i = 0;i < n-k+1;i++){
    answer += a[i];
  }
  cout << answer << endl;
}

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

int W, D;
int hw[21], hd[21];

int main(){
	int h;
	while(cin >> W >> D, W){
		for(int i = 0; i < 21; i++){
			hw[i] = 0;
			hd[i] = 0;
		}

		for(int i = 0; i < W; i++){
			cin >> h;
			hw[h]++;
		}

		for(int i = 0; i < D; i++){
			cin >> h;
			hd[h]++;
		}

		int ans = 0;
		for(int i = 0; i <= 20; i++){
			ans += max(hd[i], hw[i]) * i;
		}
		cout << ans << endl;
	}
}

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

int main()
{
	int x, y;
	cin >> x >> y;

	vector<int> g1{ 1,3,5,7,8,10,12 };
	vector<int> g2{ 4,6,9,11 };
	vector<int> g3{ 2 };

	if (find(g1.begin(), g1.end(), x) != g1.end() && find(g1.begin(), g1.end(), y) != g1.end()
		|| find(g2.begin(), g2.end(), x) != g2.end() && find(g2.begin(), g2.end(), y) != g2.end()
		|| find(g3.begin(), g3.end(), x) != g3.end() && find(g3.begin(), g3.end(), y) != g3.end())
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 1000000100000000000
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define st size_t
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=1000005;
const int NN=1000001;
const ll md=998244353;



int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll k,n;
    cin >> k >> n;
    ll a[N]={0};
    ll ans=oo;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        a[i+n]=a[i];
    }
    for (int i=1;i<=n;i++){
        ll a1=a[n+i-1]-a[i];
        if (a1<0)a1+=k;

        ans=min(ans,a1);
    }

    cout << ans << E;
    r0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll x;
    cin >> x;

    exrep(i, 2, 9) {
        if(200*i <= x && x < 200*(i+1)) {
            out(10 - i);
        }
    }
    
    re0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        boolean flag = true;

        for(int i=0; i<a; i++){
            if(s.charAt(i)=='-') flag =false;
        }
        if(s.charAt(a)!= '-') flag = false;

        for(int i=a+1; i<s.length(); i++){
            if(s.charAt(i)=='-') flag = false;
        }
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctype.h>
#include <stack>
#include <bitset>
#include <iterator>
using namespace std;
#define ull unsigned long long
#define ll long long
const int maxn=1005;
int cnt,n,m,c;
int b[25];
int main(void){
	scanf("%d%d%d",&n,&m,&c);
	for(int i=0;i<m;++i) scanf("%d",&b[i]);
	for(int i=0;i<n;++i){
		int sum=c,x;
		for(int j=0;j<m;++j){
			scanf("%d",&x);
			sum+=x*b[j];
		}
		if(sum>0) ++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

int main() {
    ios
    int N,W;
    cin >> N >> W;
    vector<int> w(110,0);
    vector<int> v(110,0);
    vector< vector< ll > > dp(110, vector< ll >(110000, 0));
    rep(i,0,N)
    cin >> w[i] >> v[i];
    int k=0;
    rep(i,0,N)
    dp[i][k]=0;
    rep(i,0,N)
        rep(j,1,W+1)
    {
        if(i==0)
        {
            if(j<w[i])
                dp[i][j]=0;
            else dp[i][j]=v[i];
            continue;
        }
        if(j<w[i])
            dp[i][j]=dp[i-1][j];
        else
        {
            dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
    }
    cout << dp[N-1][W];
    return 0;
}


Measured memory_bytes: 95744
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (a, b, c, x, y) = {
        let vec: Vec<i64> = read_vec();
        (vec[0], vec[1], vec[2], vec[3], vec[4])
    };
    let mut amount = (a * x) + (b * y);
    let mut min = amount;
    let mut a_count = x;
    let mut b_count = y;
    for _ in 0..(x + y) {
        amount += 2 * c;
        if a_count > 0 {
            amount -= a;
            a_count -= 1;
        }
        if b_count > 0 {
            amount -= b;
            b_count -= 1;
        }
        min = std::cmp::min(min, amount);
    }
    println!("{}", min);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).err();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

int main(){
  int a,b;
  cin >> a >>b;
  
  if((b-a)%2)
    cout << "IMPOSSIBLE" << endl;
  else{
    cout << a + (b-a)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	
	ll ans;

	bool b;
	if (s[0] == t[0]) {
		b = true;ans = 3;
	}
	else {
		b = false;
		ans = 6;
	}

	rep(i, n-1) {
		if (s[i] == t[i] && s[i + 1] == t[i + 1]) { ans *= 2; ans %= MOD; }
		if (s[i] == t[i] && s[i + 1] != t[i + 1]) { ans *= 2; ans %= MOD; b = false; }
		if (s[i] != t[i] && s[i + 1] == t[i + 1]) { b = true; }
		if (s[i] != t[i] && s[i + 1] != t[i + 1]) {
			if (b) { ans *= 3; ans %= MOD; b = false; }
			else b = true;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define STA 1000000
using namespace std;

int leap[1000000] = {0};

int main(){
    long long days1,days2;
    int y1,m1,d1,y2,m2,d2;
    for(int i=0;i<=STA;i++){
        if(i % 400 == 0 ||(i % 4 == 0 && i % 100 != 0)) leap[i] = 1;
    }
    while(1){
        days1 = 0;
        days2 = 0;
        cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
        if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;
        for(int i=0;i<y1;i++){
            if(leap[i] == 1) days1 += 366;
            else days1 += 365;
        }
        for(int i=0;i<y2;i++){
            if(leap[i] == 1) days2 += 366;
            else days2 += 365;
        }
        for(int i=1;i<m1;i++){
            switch(i){
                case 4:
                case 6:
                case 9:
                case 11:
                    days1 += 30;
                    break;
                case 2:
                    if(leap[y1] == 1) days1 += 29;
                    else days1 += 28;
                    break;
                default:
                    days1 += 31;
                    break;
            }
        }
        for(int i=1;i<m2;i++){
            switch(i){
                case 4:
                case 6:
                case 9:
                case 11:
                    days2 += 30;
                    break;
                case 2:
                    if(leap[y2] == 1) days2 += 29;
                    else days2 += 28;
                    break;
                default:
                    days2 += 31;
                    break;
            }
        }
        days1 += d1;
        days2 += d2;
        cout << days2 - days1 << endl;
    }
}

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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	ll koft, goh, sik, an, n, minn1, minn2;
	cin >> koft >> goh >> sik >> an >> n;
	minn1 = min(4 * koft, min(2 * goh, sik));
	minn2 = min(minn1 * 2, an);
	cout << (n / 2) * minn2 + (n % 2) * minn1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	vector<int> a(5);
	rep(i, 5)cin >> a[i];
	rep(i, 5) {
		if (a[i] == 0) {
			cout << i + 1;
			break;
		}
	}
	return 0;
}













Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 3005
#define mod 1000000007
using namespace std;
int n,m,ri[maxn],cnt[maxn],dp[maxn][maxn];
char s[maxn];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n+1;i++) ri[i]=i;
	for(int i=1;i<=n;i++) cnt[i]=cnt[i-1]+s[i]-'0';
	cnt[n+1]=cnt[n];
	while(m--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		ri[l]=max(ri[l],r);
	}
	for(int i=1;i<=n;i++) ri[i]=max(ri[i],ri[i-1]);
	dp[1][cnt[ri[1]]]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(dp[i][j])
			{
				int l=ri[i]+1,r=ri[i+1];
				if(j) dp[i+1][j+cnt[r]-cnt[l-1]-1]=(dp[i+1][j+cnt[r]-cnt[l-1]-1]+dp[i][j])%mod;
				if(ri[i]-i+1-j) dp[i+1][j+cnt[r]-cnt[l-1]]=(dp[i+1][j+cnt[r]-cnt[l-1]]+dp[i][j])%mod;
			}
	printf("%d\n",(dp[n+1][0]+mod)%mod);
}

Measured memory_bytes: 33792
#include<iostream>
using namespace std;
int main(){
  string s; cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) =='x') ans++;
  }
  if(ans >= 8)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

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

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
X, Y, A, B, C = map(int, input().split())
qa = sorted(list(map(int, input().split())), reverse=True)
qb = sorted(list(map(int, input().split())), reverse=True)
qc = sorted(list(map(int, input().split())), reverse=True)
chk = []
chk.extend(qa[:X]+qb[:Y]+qc)
chk.sort(reverse=True)
print(sum(chk[:X+Y]))

Measured memory_bytes: 22720
#include<cstdio>
#include<algorithm>
using namespace std;
int yaku[10000];
int array_addr = 0;
void Yakunum(int c){
  int   i = 1;
  while(i != c+1){
    if(c % i == 0){
      yaku[array_addr] = i;
      array_addr++;
    }
    i++;
  }
}

int main(){
  int a,b,c,yaku_cout=0;
  scanf("%d %d %d",&a,&b,&c);
  Yakunum(c);
  for(int i=a;i<=b;i++){
    for(int j=0;j<array_addr;j++){
      if(i == yaku[j]){
        yaku_cout++;
      }
    }
  }
  printf("%d\n",yaku_cout);
  return 0;
}

Measured memory_bytes: 2732
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
  int k;
  char s[100];

  scanf("%d",&k);
  scanf("%s",s);

  if(k<strlen(s))
  {
    for(int i=0;i<k;i++)
    {
      printf("%c",s[i]);
    }
    printf("...\n");
  }
  else
  {
    printf("%s\n",s);
  }

  return 0;
}

Measured memory_bytes: 1648
#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[i];
  vector<int> b(n);
  for(int i=n-1;i>=0;i--){
    if(i%2==(n-1)%2){
      b[(n-1-i)/2]=a[i];
    }
    else{
      b[n-1-(n-1-i)/2]=a[i];
    }
  }
  for(int i=0;i<n;i++){
    cout<<b[i];
    if(i!=n-1) cout<<" ";
    else cout<<endl;
  }
  
  
  
  return 0;
}


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

#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M;
    cin >> N >> M;
    VL dp(N+10, 0);
    VB a(N+10, false);
    rep(i, 0, M){
        ll aa; cin >> aa;
        a[aa] = true;
    }
    constexpr ll mod = 1e9+7;
    dp[0] = 1;
    rep(i, 0, N){
        if(!a[i+1]){dp[i+1] += dp[i]; dp[i+1] %= mod;} 
        if(!a[i+2]){dp[i+2] += dp[i]; dp[i+2] %= mod;} 
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  s <- getLine
  putStrLn $ solve s

solve s = f s []

f []         acc = reverse acc
f ('B' : as) []  = f as []
f (a   : as) []  = f as [a]
f (a : as) (ac : accs) | a == '0'  = f as ('0' : ac : accs)
                       | a == '1'  = f as ('1' : ac : accs)
                       | otherwise = f as accs


Measured memory_bytes: 380
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = [None]*n
for i in range(n):
    s[i] = input()
    
ans = n * sum(all(all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)) for j in range(n)) for i in range(n))
print(ans)

Measured memory_bytes: 74128
#include<stdio.h>
#include<string.h>
int main()
{
    char w[3][7],s[7],i=0;
    strcpy(w[0],"Sunny");
    strcpy(w[1],"Cloudy");
    strcpy(w[2],"Rainy");
    gets(s);
    for (i=0;i<3;i++)
    {
        if (strcmp(w[i],s)==0&&i<2)
            {
                puts(w[i+1]);
                break;
            }
        else if (strcmp(w[i],s)==0&&i==2)
            {
                puts(w[0]);
                break;
            }
    }
    return 0;
}


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


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

   sort(all(A),greater<ll>());
   ll res = 0;
   priority_queue<pll, vector<pll>> que;
   que.push({A[1], A[0]}); res += A[0];
   for(int i=2; i<n; i++){
       auto p = que.top(); if(i!=2)que.pop();
       ll big = p.second, small = p.first;
      // cout << "big:" << big << " small:" << small;
       res += small;
       ll a1 = min(big, A[i]), a2 = max(big, A[i]);
       //cout << " ai:" << a1 << " a2:" << a2 << " ";
       que.push({a1, a2});
       a1 = min(small, A[i]); a2 = max(small, A[i]);
              //cout << " ai:" << a1 << " a2:" << a2 << ln;
       que.push({a1, a2});
   }
   cout << res << ln;
}


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

int main() {
  int H = 0, W = 0; 
  cin >> H >> W; 
  
  for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;

  string a;
  for(int i = 0; i < H; i++){
    cin >> a;
    cout << "#" << a << "#" << endl;
  }

    for(int i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll t[202];
double v[202];
double maxV[200001];
int main() {
	ll n, T = 0; cin >> n;
	repe(i, 1, n) cin >> t[i];
	repe(i, 1, n) cin >> v[i];

	repe(i, 1, n) {
		T += t[i];
	}

	rep(i, 0, 200001)maxV[i] = INF;

	ll nowT = 1;
	maxV[0] = 0;
	maxV[T * 2] = 0;

	repe(i, 1, n) {
		maxV[nowT - 1] = min(maxV[nowT - 1], v[i]);
		rep(ti, 0, t[i]) {
			ll t1 = nowT + ti * 2;
			ll t2 = nowT + ti * 2 + 1;
			maxV[t1] = min(maxV[t1], v[i]);
			maxV[t2] = min(maxV[t2], v[i]);
		}
		nowT += t[i] * 2;
		//maxV[nowT] = min(maxV[nowT], v[i]);
	}

	rep(ti, 0, 2 * T) {
		maxV[ti + 1] = min(maxV[ti + 1], maxV[ti] + 0.5);
	}
	rep_r(ti, 0, 2 * T) {
		maxV[ti] = min(maxV[ti], maxV[ti + 1] + 0.5);
	}
	double ans = 0;

	rep(i, 0, 2 * T) {
		ans += (maxV[i] + maxV[i + 1])*0.5 / 2;
	}

	printf("%.10f\n", ans);
	return 0;
}

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

namespace Util {
#ifdef LOCAL
#define dbg(a) cerr << __LINE__ << '"' << #a << "\": " << a << '\n'
#else
#define dbg(a) 0
#endif

#define all(v) (v).begin(), (v).end()
#define long int64_t
}
using namespace Util;

double Dist(array<double, 2> f) {
    return sqrt(f[0] * f[0] + f[1] * f[1]);
}

signed main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    long n, D; cin >> n >> D;
    vector<array<double, 2>> point(n);
    for (auto &i : point) cin >> i[0] >> i[1];
    long cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (Dist(point[i]) <= D) {
            ++cnt;
        }
    }
    cout << cnt;
    return 0;
}


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





int main() {
  int g;
cin>>g;
  int s=0;
  vector<int>zi(g-1);
  for(int i=0;i<g-1;i++)
  {
  int a;
    cin>>a;
    zi.at(i)=a;
  }
  
if(g>=3)
{
  s=zi.at(0)+zi.at(g-2); 
  for(int i=0;i<g-2;i++)
  {
  s=s+min(zi.at(i),zi.at(i+1));
  }
 cout<<s<<endl;
}
  else if(g==2) cout<<2*zi.at(0);
    }

Measured memory_bytes: 256