akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[55][55];
	int i, j;
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	int count[30], ans[30], m;
	for (i = 0; i < 30; i++)
		ans[i] = 100;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 30; j++)
			count[j] = 0;
		m = strlen(s[i]);
		for (j = 0; j < m; j++)
			count[s[i][j] - 'a']++;
		for (j = 0; j < 30; j++)
			if (ans[j] > count[j])
				ans[j] = count[j];
	}
	for (i = 0; i < 30; i++)
		for (j = 0; j < ans[i]; j++)
			printf("%c", 'a' + i);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	vector<ll> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	ll ans = 0;
	for(ll i = 0, s = 0; i < n; i++) {
		ans = (ans + s * arr[i]) % MOD;
		s += arr[i];
		s %= MOD;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 

bool cmp(pair<pair<int, int>, pair<int, int>> p1, pair<pair<int, int>, pair<int, int>> p2){
	return p1.ss.ss > p2.ss.ss;
}

int solve(){
	ll a, b, n;
	cin>> a>> b>> n;
	if(n < b){
		cout<< (a * n) / b;
		return 0;
	}
	n = b - 1;
	cout<< (a * n) / b;
	return 0;
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}
//upper_bound returns an iterator pointing to the 
//first element in the range [first,last) which has a value greater than ‘val’
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

Measured memory_bytes: 3656
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      t1: usize,
      t2: usize,
      a1: usize,
      a2: usize,
      b1: usize,
      b2: usize,
    }
    if t1*a1 + t2*a2 == t1*b1 + t2*b2 {
        return puts!("{}\n", "infinity");
    }

    let ta1 = t1*a1;
    let tb1 = t1*b1;
    let ta = ta1 + t2*a2;
    let tb = tb1 + t2*b2;

    if a1 > b1 {
        if ta > tb {
            return puts!("{}\n", 0);
        }


        let cnt = t1 * (a1-b1) / (tb-ta);
        if t1 * (a1-b1) % (tb-ta) == 0 {
            puts!("{}\n", cnt*2);
        } else {
            puts!("{}\n", cnt*2+1);
        }
    } else {
        if tb > ta {
            return puts!("{}\n", 0);
        }

        let cnt = t1 * (b1-a1) / (ta-tb);
        if t1 * (b1-a1) % (ta-tb) == 0 {
            puts!("{}\n", cnt*2);
        } else {
            puts!("{}\n", cnt*2+1);
        }
    }
}


Measured memory_bytes: 4352
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

class Main{
    public static void main(String[] args) throws IOException {
        int[] inputs = receiveIntArray(Delimiter.SPACE);
        int num = inputs[0];
        int goal = inputs[1];
        
        println(num * 500 >= goal ? "Yes" : "No");
        flush();
    }



    // 入出力関連
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    enum Delimiter {
        NONE(""),
        SPACE(" "),
        DOT("\\."),
        COMMA(",");

        private String regex;
        private Delimiter(String regex) {
            this.regex = regex;
        }
        public String getRegex() { return regex; }
    }

    static String receive() throws IOException { return br.readLine(); }
    static int receiveInt() throws IOException { return Integer.parseInt(br.readLine()); }
    static char receiveChar() throws IOException { return  br.readLine().charAt(0); }
    static char[] receiveCharArray() throws IOException { return  br.readLine().toCharArray(); }
    static int[] receiveIntArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).mapToInt(Integer::parseInt).toArray();
    }
    static String[] receiveStringArray(Delimiter delimiter) throws IOException {
        return Stream.of(br.readLine().split(delimiter.getRegex())).toArray(String[]::new);
    }

    static void print(Object obj) { pw.print(obj); }
    static void println(Object obj) { pw.println(obj); }
    static void flush() { pw.flush(); }
}

Measured memory_bytes: 26580
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
string s, t;

int main () {
  cin >> N;
  cin >> s >> t;

  string ans = "";

  Rep(i, N) {
    ans += s[i];
    ans += t[i];
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc075/tasks/abc075_d
# 座標圧縮して二次元累積和に打ち込めば良さそう

# はじめての座圧...?

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


class cumsum2d:  # 二次元累積和クラス pypyでも使えるよ
    def __init__(self, ls: list):
        '''
        2次元のリストを受け取る
        '''
        from itertools import product
        H = len(ls)
        W = len(ls[0])
        self.ls_accum = [[0] * (W + 1)]
        for l in ls:
            self.ls_accum.append([0] + l)

        # 縦に累積
        for i, j in product(range(1, H + 1), range(1, W + 1)):
            self.ls_accum[i][j] += self.ls_accum[i - 1][j]
        # 横に累積
        for i, j in product(range(1, H + 1), range(1, W + 1)):
            self.ls_accum[i][j] += self.ls_accum[i][j - 1]

    def total(self, i1, j1, i2, j2):
        '''
        点(i1,j1),(i1,j2),(i2,j1),(i2,j2)の4点が成す四角の中の合計を取り出す
        ただし i1<=i2, j1<=j2
        ただし、i軸に関しては[i1,i2),j軸に関しては[j1,j2)の半開区間である
        '''
        return self.ls_accum[i2][j2] - self.ls_accum[i1][j2] \
            - self.ls_accum[i2][j1] + self.ls_accum[i1][j1]


class ZaAtu:
    def __init__(self, ls):
        # 座標圧縮クラス(仮) #どうしたら使いやすくなるのか知らんけど
        self.i_to_orig = sorted(set(ls))
        self.orig_to_i = {}
        for i, zahyou in enumerate(self.i_to_orig):
            self.orig_to_i[zahyou] = i
        self.len = len(self.i_to_orig)

    def __len__(self):
        return len(self.i_to_orig)


from itertools import product

N, K = read_ints()
X_ori, Y_ori = read_col(N, 2)
X = ZaAtu(X_ori)
Y = ZaAtu(Y_ori)
table = [[0] * Y.len for _ in range(X.len)]  # 二次元累積和を作る
for x, y in zip(X_ori, Y_ori):
    i = X.orig_to_i[x]
    j = Y.orig_to_i[y]
    table[i][j] += 1

table = cumsum2d(table)
# 怒りの全探索
ans = (2 * 10**9)**2 + 114514
for i, j in product(range(X.len), range(Y.len)):  # 始点
    for ii, jj in product(range(i, X.len + 1), range(j, Y.len + 1)):  # 終点
        if table.total(i, j, ii, jj) >= K:
            S = (X.i_to_orig[ii - 1] - X.i_to_orig[i]) * \
                (Y.i_to_orig[jj - 1] - Y.i_to_orig[j])
            ans = min(ans, S)
print(ans)


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

using namespace std;

typedef long long ll;

ll N, M;

ll y(ll x) {
    if (0 <= x && x <= M/2) {
        return min(N+x, M/2 - x);
    } else {
        return 0;
    }
}

int main() {
    scanf("%lld %lld", &N, &M);
    ll x = M/4 - N/2;
    ll ans = max(y(0), y(M/2));
    ans = max(ans, y(x-1));
    ans = max(ans, y(x));
    ans = max(ans, y(x+1));
    printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, int> pp;

int main()
{
    int n, p, d1, d2;
    while(cin >> n && n)
    {
        vector<pp> ps;
        REP(n){cin >> p >>  d1 >> d2; ps.push_back(pp(d1+d2, p));}

        sort(all(ps), greater<pp>() );

        cout << ps[0].second << " " << ps[0].first << endl;
        
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int a[] = new int[4];
        for (int i = 3; i >= 0; i--) {
            a[i] = n % (int) Math.pow(10, 4 - i);
            a[i] = a[i] / (int) Math.pow(10, 3 - i);
            //out.println(a[i]);
        }
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    int now = a[0];
                    now += (i == 0 ? a[1] : -a[1]);
                    now += (j == 0 ? a[2] : -a[2]);
                    now += (k == 0 ? a[3] : -a[3]);
                    if (now == 7) {
                        out.print(a[0]);
                        if (i == 0) out.print('+');
                        else out.print('-');
                        out.print(a[1]);
                        if (j == 0) out.print('+');
                        else out.print('-');
                        out.print(a[2]);
                        if (k == 0) out.print('+');
                        else out.print('-');
                        out.println(a[3] + "=7");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

const double pi = 3.1415926535;

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double V = a * a * b;
  double M = (double)(a*a*b) / 2;
  double tan;
  if (x <= M) {
    tan = (2*x)/(a*b*b);
  } else {
    tan = (a*a*a)/(2*(V-x));
  }
  double ans = (double)90 - (180 * atan(tan) / pi);
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 512
#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>;

int main(){
    int n, in;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> in;
        a.at(i) = in;
    }
    rep(i, n){
        cin >> in;
        a.at(i) -= in;
    }
    int ans = 0;
    rep(i, n){
        if(a.at(i) > 0){
            ans += a.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

count = 0
for i in range(N):
    if A[i] >= B[i]:
        count = count + B[i]
    else:
        count = count + min(A[i]+A[i+1], B[i])
        A[i+1] = A[i+1] - min(A[i+1], B[i]-A[i])
print(count)


Measured memory_bytes: 18392
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int dif=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            dif += a[i];
        }else{
            dif -= a[i];
        }
    }

    cout << dif << endl;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_c

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, W, K;
  cin >> H >> W >> K;

  V<string> mat(H);
  rep(i, H) cin >> mat[i];

  VVL res(H, VL(W));

  {
    ll next_k = 1;

    rep(i, H) rep(j, W) {
      if (mat[i][j] == '#') {
        res[i][j] = next_k;
        next_k++;
      }
    }
  }

  rep(i, H) {
    rep(j, W) {
      if (j == 0) continue;
      if (res[i][j] == 0) res[i][j] = res[i][j - 1];
    }

    repr(j, W) {
      if (j == W - 1) continue;
      if (res[i][j] == 0) res[i][j] = res[i][j + 1];
    }
  }

  rep(i, H) {
    if (i == 0) continue;
    if (res[i][0] == 0) rep(j, W) res[i][j] = res[i - 1][j];
  }

  repr(i, H) {
    if (i == H - 1) continue;
    if (res[i][0] == 0) rep(j, W) res[i][j] = res[i + 1][j];
  }

  rep(i, H) print_ints(res[i]);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main() {
	char c;

	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
struct Graph{
  Graph(int n):E(n),d(n){}
  vector<vector<tuple<int,int,int>>>E;
  vector<int>d;
  void add_edge(int a,int b,int c,int d){
    E[a].push_back(make_tuple(b,c,d));
  }
  void dijkstra(int s,int f){
    priority_queue<P,vector<P>,greater<P>>q;
    fill(d.begin(),d.end(),1e9);
    q.push({d[s]=0,s});
    while(q.size()){
      auto p=q.top();q.pop();
      if(p.first>d[p.second])continue;
      for(auto& a:E[p.second]){
        int x=get<0>(a),y=get<1>(a)+p.first;
        if(f)y=get<2>(a)+p.first;
        if(y<d[x])d[x]=y,q.push({y,x});
      }
    }
  }
};
main(){
  int n,m,a,b,c,d,k;
  while(cin>>n>>m,n){
    Graph E(m);
    for(int i=0;i++<n;E.add_edge(--a,--b,c,d),E.add_edge(b,a,c,d))cin>>a>>b>>c>>d;
    cin>>k;
    for(int i=0;i++<k;cout<<E.d[--b]<<endl){
      cin>>a>>b>>c;
      E.dijkstra(--a,c);
    }
  }
}

Measured memory_bytes: 3140
N=int(input())
A=list(map(int,input().split()))
sum_=0
dic = {}
for i,x in enumerate(A):
    if dic.get(x-(i+1),0) == 0:
        dic[x-(i+1)] = 1
    else:
        dic[x-(i+1)] += 1
tup = sorted(dic.items(),key=lambda x:x[0])
num = 0
mid = 0

for i in range(len(tup)):
    num += tup[i][1]
    if num >= (N+1)//2:
        mid = tup[i][0]
        break

ans = 0
for i,x in enumerate(A):
    ans+=abs(x-mid-(i+1))
print(ans)

Measured memory_bytes: 48096
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 998244353;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e6 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e8;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1000+5;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=(res*x);

      y/=2;
      x=(x*x);
    }
    return res;
}

int main(){
    FAST
    string s;
    cin>>s;
    if(s.length()!=6){
        cout<<"No"; return 0;
    }
    if(s[2]==s[3] && s[2]<='z' && s[2]>='a' && s[5]==s[4] && s[4]<='z' && s[4]>='a') cout<<"Yes";
    else cout<<"No"; 
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <map>
#define itr(it,a) for(auto it=(a).begin();it!=(a).end();++it)

typedef std::pair<int, std::string> P;

std::map<std::string, int> m;
P maF( 0, "" ), maL( 0, "" );

int main()
{
    std::string s;
    while( std::cin >> s )
    {
        ++m[s];
    
        maL = std::max( maL, P( s.size(), s ) );
    }

    itr( it, m )
        maF = std::max( maF, P( it->second, it->first ) );

    std::cout << maF.second << ' ' << maL.second << std::endl;

    return 0;
}

Measured memory_bytes: 3020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            string[] strs = line.Split(' ');

            long X = long.Parse(strs[0]);
            long K = long.Parse(strs[1]);
            long D = long.Parse(strs[2]);

            long first = Math.Abs(X);
            long MAX_K = first / D;
            if (MAX_K >= K)
            {
                Console.WriteLine(first - K * D);
                return;
            }
            if ((K-MAX_K) % 2 == 1)
            {
                Console.WriteLine(Math.Abs(first - (MAX_K + 1) * D));
            }
            else
            {
                Console.WriteLine(first - MAX_K * D);
            }
        }
    }
}


Measured memory_bytes: 27448
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 200010;
const int mod = 1e9+7;
int Tmx[maxn<<2],Tmn[maxn<<2],T[maxn<<2];
void modify(int rt,int l,int r,int pos,int val){
    if(l == r){
        Tmx[rt] = Tmn[rt] = val;
        T[rt] += val;
        if(T[rt] >= mod) T[rt] -= mod;
        return ;
    }
    int mid = (l+r) >> 1;
    if(pos <= mid) modify(rt<<1,l,mid,pos,val);
    else modify(rt<<1|1,mid+1,r,pos,val);
    Tmx[rt] = max(Tmx[rt<<1],Tmx[rt<<1|1]);
    Tmn[rt] = min(Tmn[rt<<1],Tmn[rt<<1|1]);
    T[rt] = T[rt<<1] + T[rt<<1|1];if(T[rt] >= mod) T[rt] -= mod;
}
int query_min(int rt,int l,int r,int L,int R){
    if(L <= l && r <= R) return Tmn[rt];
    int mid = (l+r) >> 1;
    if(R <= mid) return query_min(rt<<1,l,mid,L,R);
    if(L >  mid) return query_min(rt<<1|1,mid+1,r,L,R);
    return min(query_min(rt<<1,l,mid,L,R),query_min(rt<<1|1,mid+1,r,L,R));
}
int query_max(int rt,int l,int r,int L,int R){
    if(L <= l && r <= R) return Tmx[rt];
    int mid = (l+r) >> 1;
    if(R <= mid) return query_max(rt<<1,l,mid,L,R);
    if(L >  mid) return query_max(rt<<1|1,mid+1,r,L,R);
    return max(query_max(rt<<1,l,mid,L,R),query_max(rt<<1|1,mid+1,r,L,R));
}
int query_sum(int rt,int l,int r,int L,int R){
    if(L <= l && r <= R) return T[rt];
    int mid = (l+r) >> 1;
    if(R <= mid) return query_sum(rt<<1,l,mid,L,R);
    if(L >  mid) return query_sum(rt<<1|1,mid+1,r,L,R);
    return (query_sum(rt<<1,l,mid,L,R) + query_sum(rt<<1|1,mid+1,r,L,R)) % mod;
}
struct Node{
    int x,v;
    bool friend operator < (const Node &a,const Node &b){
        return a.v < b.v;
    }
}a[maxn];
struct seg{
    int L,R;
    bool friend operator < (const seg &a,const seg &b){
        return a.R == b.R ? a.L < b.L : a.R < b.R;
    }
}se[maxn];
int seq[maxn];
int main(){
    int n;read(n);
    rep(i,1,n){
        read(a[i].x);read(a[i].v);
        seq[i] = a[i].x;
    }sort(seq+1,seq+n+1);sort(a+1,a+n+1);
    rep(i,1,n){
        a[i].x = lower_bound(seq+1,seq+n+1,a[i].x) - seq;
    }
    memset(Tmn,0x3f,sizeof Tmn);
    rep(i,1,n){
        if(a[i].x+1 <= n) se[i].L = query_min(1,1,n,a[i].x+1,n);
        else se[i].L = i;
        se[i].L = min(se[i].L,i);
        modify(1,1,n,a[i].x,i);
    }
    memset(Tmx,0,sizeof Tmx);
    per(i,n,1){
        if(a[i].x-1 >= 1) se[i].R = query_max(1,1,n,1,a[i].x-1);
        else se[i].R = i;
        se[i].R = max(se[i].R,i);
        modify(1,1,n,a[i].x,i);
    }
    sort(se+1,se+n+1);
    memset(T,0,sizeof T);
    int ans = 0;
    per(i,n,1){
        int res = 0;
        if(se[i].R == n) res ++ ;
        res += query_sum(1,1,n,1,min(se[i].R+1,n));
        if(res >= mod) res -= mod;
        modify(1,1,n,se[i].L,res);
        if(se[i].L == 1) ans += res;
        if(ans >= mod) ans -= mod;
    }printf("%d\n",ans);
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

template<class T,T op(T,T)> class segtree{
public:
    int n,size_;
    vector<T> dat;
    T id_;
    segtree()=default;
    segtree(int size,T id,T initial_value){ init(size,id,initial_value); }
    void init(int size,T id,T initial_value){
        size_=size;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,id);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    int size()const{ return size_; }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=op(dat[k*2+1],dat[k*2+2]);
        }
    }
    T at(int index){ return dat[index+n-1]; }
    void add(int k,T a){ update(k,at(k)+a); }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return op(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};


void solve(){
    int N;
    cin >> N;

    vector<int> P(N-1);
    vector<vector<int>> children(N);
    rep(i,0,N-1){
        cin >> P[i];
        --P[i];
        children[P[i]].push_back(i+1);
    }

    vector<int> X(N);
    rep(i,0,N) cin >> X[i];

    vector<int> a(N,inf),b(N,inf);
    function<bool(int)> dfs=[&](int u){
        if(children[u].empty()){
            a[u]=X[u];
            b[u]=0;
            return true;
        }

        for(int v:children[u]) if(!dfs(v)) return false;

        vector<int> dp(X[u]+1,inf);
        if(a[children[u][0]]<=X[u]) dp[a[children[u][0]]]=min(dp[a[children[u][0]]],b[children[u][0]]);
        if(b[children[u][0]]<=X[u]) dp[b[children[u][0]]]=min(dp[b[children[u][0]]],a[children[u][0]]);
        rep(i,1,children[u].size()){
            int v=children[u][i];
            vector<int> next(X[u]+1,inf);
            rep(j,0,X[u]+1){
                if(dp[j]==inf) continue;
                if(j+a[v]<=X[u]) next[j+a[v]]=min(next[j+a[v]],dp[j]+b[v]);
                if(j+b[v]<=X[u]) next[j+b[v]]=min(next[j+b[v]],dp[j]+a[v]);
            }
            dp=next;
        }

        a[u]=X[u];
        rep(i,0,X[u]+1) b[u]=min(b[u],dp[i]);
        
        if(b[u]==inf) return false;
        return true;
    };

    if(dfs(0)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;

char ans[105][105];

int main(){
    for(int i=0;i<=50;i++){
        for(int j=0;j<100;j++){
            if(i&1){
                if(j&1){
                    ans[i][j]='#';
                }
                else{
                    ans[i][j]='.';
                }
            }
            else{
                ans[i][j]='#';
            }
        }
    }
    for(int i=51;i<100;i++){
        for(int j=0;j<100;j++){
            if(i&1){
                ans[i][j]='.';
            }
            else{
                if(j&1){
                    ans[i][j] = '.';
                }
                else{
                    ans[i][j] = '#';
                }
            }
        }
    }

    int a,b; cin >> a >> b;
    a--,b--;
    for(int i=0;i<=50;i++){
        for(int j=0;j<100;j++){
            if(ans[i][j]=='.'){
                if(!a){
                    ans[i][j]='#';
                }
                else{
                    a--;
                }
            }
        }
    }
    for(int i=51;i<100;i++){
        for(int j=0;j<100;j++){
            if(ans[i][j]=='#'){
                if(!b){
                    ans[i][j]='.';
                }
                else{
                    b--;
                }
            }
        }
    }

    cout << "100 100" << endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    long long int a , b , k ;
    cin >> a >> b >> k ;
    if(a > k ){
        cout << a - k << " " << b << endl;
    }else if(a <= k && k <= a + b ){
        cout << 0 << " " << b - (k - a) << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : AMAN SAXENA *
* Nick : blue-meth *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
const long long N = 1e5 + 7;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

ll amanpower(ll a, ll b) {
	ll r = 1;
	while (b > 0) 
	{
		if (b & 1) r = r * a;
		a = a * a;
		b >>= 1;
	}
	return r;
}

ll amanlcm(ll a, ll b)
{
	 return a*(b/__gcd(a,b));
}
//Prime Numbers

vector<bool>prime(N+1,true);
void sieve()
{
	ll i,j,k;
	prime[0]=prime[1]=false;
	for(i=2;i*i<=N;i++)
	{
		if(prime[i])
		{
			for(j=i*i;j<=N;j+=i)
			{
				prime[j]=false;
			}
		}
	}
}

//Exponentiation

ll power(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2==1)
			r=r*a;
		b/=2;
		a*=a;
	}
	return r;
}
ll power(ll a,ll b,ll m)
{
	a=a%m;
	ll r=1;
	while(b)
	{
		if(b%2==1)
			r=(r*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return r;
}

//Prime Factors

vector<ll> factors(ll n)
{
	vector<ll>r;
	ll i,j;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			r.push_back(i);
			if(n/i!=i)
				r.push_back(n/i);
		}
	}
	return r;
}


//********* CODE START *********


void solve()
{
	ll n, x, t;
	cin >> n >> x >> t;
	ll ans = 0, sum = 0;
	while(sum < n)
	{
		ans += t;
		sum += x;
	}
	cout << ans;


}

void test()
{
	int t;
	cin>>t;
	while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
	{
		solve();
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	
	// test();
	solve();

	
	return 0;
}

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

int main() {
  int N, K, x, sum;
  cin >> N >> K;
  sum = 0;
  
  for (int i=0; i<N; i++){
    cin >> x;
    
     if (x < (K-x)){
       sum += 2*x;
     }
    else {
      sum += 2* (K-x);
    }
    
    
  }
  
    cout << sum << endl;
  }


    

    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;++i) {
    cin >> s[i];
  }
  int cnta = 0, cntu = 0;
  bool ok = true;
  for(int i=0;i<n;++i) {
    if(s[i] == "A") cnta++;
    else cntu++;
    if(cntu > cnta) {
      ok = false;
      break;
    }
  }
  ok &= cnta == cntu;
  cout << (ok ? "YES" : "NO") << endl;
}



Measured memory_bytes: 3240
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;


bool solve() {
    int n;
    cin >> n;

    VV<int> ls;
    map<V<int>, int> mp;
    for (int i = 0; i < n; i++) {
        int w;
        cin >> w;
        V<int> v(3);
        iota(begin(v), end(v), 0);
        for (int j = 0; j < w; j++) {
            int a;
            cin >> a;
            swap(v[2*a], v[1]);
        }
        ls.push_back(v);
        mp[v]++;
        if (v == V<int>{0, 1, 2}) return true;
        if (v == V<int>{1, 0, 2} && mp[v] >= 2) return true;
        if (v == V<int>{0, 2, 1} && mp[v] >= 2) return true;
        if (v == V<int>{2, 1, 0} && mp[v] >= 2) return true;
        if (mp[v] >= 3) return true;
    }
    sort(begin(ls), end(ls));
    do {
        V<int> v(3), v2(3);
        iota(begin(v), end(v), 0);
        for (auto &w: ls) {
            for (int i = 0; i < 3; i++) {
                v2[w[i]] = v[i];
            }
            for (int i = 0; i < 3; i++) {
                v[i] = v2[i];
            }
            if (v == V<int>{0, 1, 2}) return true;
        }

    } while (next_permutation(begin(ls), end(ls)));
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    if (solve()) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;

}



Measured memory_bytes: 3232
/* ex2_2
   kohei_suzuki */

#include <stdio.h>
int main(void){
    int N; //マス目
    int A; //白のマス数

    scanf("%d", &N);//入力受取
    scanf("%d", &A);//入力受取

    if(1<=N && N<=100 && 0<=A && A<=N*N){
        printf("%d", N*N-A);
    }
    return 0;
}

Measured memory_bytes: 128
using System;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        DateTime d = DateTime.Parse(s);
        DateTime u = new DateTime(2019 , 4 , 30, 0, 0,0);
        if (d <= u)
        {
            Console.WriteLine("Heisei");
        }
        else
        {
            Console.WriteLine("TBD");
        }
    }
}

Measured memory_bytes: 13660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int b; 
  b = a/100;
  int c;
  c = a % 100 / 10;
  int d;
  d = a % 100 % 10;
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;

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

	int max_count = 0;
	int ans = 1;
	for (int i = n; i > 0; i--) {
		int count = 0;
		int tmp = i;
		while (tmp != 0) {
			if (tmp % 2 == 0) {
				tmp /= 2;
				count++;
			}
			else break;
		}
		if (count > max_count) ans = i;
		max_count = max(max_count, count);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int ab = scanner.nextInt(), bc = scanner.nextInt();
			@SuppressWarnings("unused")
			int ac = scanner.nextInt();
			System.out.println(ab * bc / 2);
		}
	}
}


Measured memory_bytes: 35816
n,k=map(int,input().split())
if k<=(n-1)*(n-2)//2:
    print(n-1+((n-1)*(n-2))//2-k)
    for i in range(2,n+1):
        print(1,i)
    c=0
    for i in range(2,n+1):
        for j in range(i+1,n+1):
            if c==(n-1)*(n-2)//2-k:
                exit()
            print(i,j)
            c+=1
else:
    print(-1)

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;

int n;
char a[N];

void solv()
{
    scanf(" %s", a);
    n = strlen(a);
    int ans = n;
    int q = 0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 'S')
            ++q;
        else
        {
            if (q)
            {
                ans -= 2;
                --q;
            }
        }
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t, ans;
int main(){
	cin>>n>>k;
	for(i=1;i<=n;i++){
		cin>>t;
		if(t*2<=k) ans+=t;
		else{
			ans+=k-t;
		}
	}
	ans*=2;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N=3;
vector<int> v1;
int main(){
	int n;
	int i,j,k;
	int a[5][5];
	int b[5][5];
	bool s=true;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			cin>>a[i][j];
		}
		b[i][0]=a[i][1]-a[i][0];
		b[i][1]=a[i][2]-a[i][1];
	}
	for(i=0;i<2;i++){
		if(b[0][i]!=b[1][i] || b[1][i]!=b[2][i])s=false;
	}
	if(s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    n, x = map(int, input().split())
    l = list(map(int, input().split()))

    d = 0
    c = 1
    for i in range(n):
        d += l[i]
        if d > x:
            break
        c += 1

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5420
#include <iostream>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <stdio.h>
#include <string>
#include <string>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

	cout << (b - 1) * (a - 1) << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  vector<vector<int>> a(3, vi(3));
  for(int i=0;i<3;++i) {
    for(int j=0;j<3;++j) {
      cin >> a[i][j];
    }
  }

  vector<vector<bool>> sel(3, vector<bool>(3, false));

  int n; cin >> n;
  for(int i=0;i<n;++i) {
    int tmp; cin >> tmp;
    for(int j=0;j<3;++j) {
      for(int k=0;k<3;++k) {
        if(a[j][k] == tmp) {
          sel[j][k] = true;
        }
      }
    }
  }

  bool ok = false;

  for(int i=0;i<3;++i) {
    bool ok1 = true, ok2 = true;
    for(int j=0;j<3;++j) {
      ok1 &= sel[i][j];
      ok2 &= sel[j][i];
    }
    ok |= ok1 | ok2;
  }

  bool ok3 = sel[0][0] && sel[1][1] && sel[2][2];
  bool ok4 = sel[0][2] && sel[1][1] && sel[2][0];

  cout << (ok || ok3 || ok4 ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,x,y;
int dist[2005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int d;
			if(i<=x&&j>=y) d=(x-i)+(j-y)+1;
			else if(i<=x&&j<y&&j>x) d=(x-i)+min(j-x,y-j+1);
			else if(i<=x&&j<=x) d=j-i;
			else if(i<y&&i>x&&j<y&&j>x) d=min(j-i,(i-x)+(y-j)+1);
			else if(i<y&&i>x&&j>=y) d=(j-y)+min(y-i,i-x+1);
			else if(i>=y&&j>=y) d=j-i;
			dist[d]++;
		}
	for(int i=1;i<=n-1;i++)
		cout<<dist[i]<<endl;
	return 0;
}


Measured memory_bytes: 384
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();
      int c = sc.nextInt();
      int k = sc.nextInt();
      int ok = 0;
      while(k>0){
		  if(a >= b){
    	    b = b * 2;
        	k--;
	      }
          if(b >= c){
            if(k==0){
              break;
            } else {
	            c = c * 2;
	            k--;
            }
          }
//        System.out.println(k);
        if(a < b){
          if(b < c){
            System.out.println("Yes");
            ok = 1;
            break;
          }
        }
      }
      if(ok==0){
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35668
import math
a,b = map(int,input().split(" "))
if(abs(a-b)>1):
    print("0")
else:
    abikkuri = 1
    ans = 1
    for i in range(a):
        abikkuri = abikkuri * (i+1)
        abikkuri = abikkuri % 1000000007
    ans = abikkuri
    for i in range(b):
        ans = ans * (i+1)
        ans = ans % 1000000007
    if(a==b):
        ans = ans * 2 % 1000000007
    print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n, k;
	cin >> n>>k;
	vector<int> a(n);
	rep(i,n)scanf("%d", &a[i]); '\n';
	int cnt = k;
	int ans = 1;
	while (cnt < n) {
		cnt += k - 1;
		++ans;
	}
	cout << ans;
	}

	

Measured memory_bytes: 640
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    x, y = tuple(input_ints())
    # t + k == x
    # 2t + 4k == y

    r = False
    for t in range(x+1):
        k = x - t
        if 2 * t + 4 * k == y:
            r = True
            break

    print("Yes" if r else "No")

main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int h, w;
ll dp[1010][1010];
char c[1010][1010];

int main(){
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> c[i][j];
    
    dp[0][0] = 1;

    rep(i, h) rep(j, w){
        if (c[i][j] == '#') dp[i+1][j+1] = 0;
        else if (i == 0 && j > 0) dp[i][j] += dp[i][j-1];
        else if (j == 0 && i > 0) dp[i][j] += dp[i-1][j];
        else if (i > 0 && j > 0) dp[i][j] += dp[i-1][j] + dp[i][j-1];
        dp[i][j] %= MOD;
    }
    cout << dp[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)


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


Measured memory_bytes: 3576
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    ull n,k,ans;
    cin>>n>>k;
    ans=k;
    rep(i,n-1) ans*=(k-1);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256