akhauriyash/Code-Regression huggingface dataset:
open Printf
open Scanf

let id x = x

let print_ans (a, b, c, d) =
  printf "AC x %d\n" a;
  printf "WA x %d\n" b;
  printf "TLE x %d\n" c;
  printf "RE x %d\n" d

let solve n =
  let ss = List.init n (fun _ -> scanf "%s " id) in
  let ht = Hashtbl.create n in
  Hashtbl.replace ht "AC" 0;
  Hashtbl.replace ht "WA" 0;
  Hashtbl.replace ht "TLE" 0;
  Hashtbl.replace ht "RE" 0;
  List.iter (fun s -> let v = Hashtbl.find ht s in Hashtbl.replace ht s (v + 1)) ss;
  (Hashtbl.find ht "AC", Hashtbl.find ht "WA", Hashtbl.find ht "TLE", Hashtbl.find ht "RE")
  

let () =
  scanf "%d " solve |> print_ans


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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

void solve(long long H, long long W, long long N, std::vector<long long> a) {
  vector<vector<ll>> ans(H, vector<ll>(W));
  ll h = 0, w = 0, c = 0;
  while (w < W) {
    while (a[c] <= 0) ++c;
    ans[h][w] = c;
    --a[c];
    ll dh = w % 2 ? -1 : 1;
    if (h + dh < 0 || h + dh >= H) {
      ++w;
    } else {
      h += dh;
    }
  }
  rep(h, H) {
    rep(w, W) cout << ans[h][w] + 1 << ' ';
    cout << endl;
  }
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(H, W, N, std::move(a));
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e6+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int &i:a) cin>>i;
	set<int> s;
	int g=a[0];
	bool cp=true;
	for(int i=0;i<n;i++){
		g=__gcd(a[i],g);
		if(!cp) continue;
		for(int j=2;j*j<=a[i];j++){
			if(a[i]%j==0){
				if(s.find(a[i]/j)==s.end() and s.find(j)==s.end()){
					s.insert(a[i]/j);
					s.insert(j);
				}
				else{
					cp=false;
					break;
				}
			}
		}
		if(s.find(a[i])==s.end()) s.insert(a[i]);
		else if(a[i]!=1) cp=false;
	}
	if(cp) cout<<"pairwise coprime";
	else if(g==1) cout<<"setwise coprime";
	else cout<<"not coprime";
}  


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

using ull = unsigned long long;

vector<ull> g,g2;
ull x = 1;

ull pow(ull a, ull n){
  if(n==0){
    return 1;
  }else if(n==1){
    return a;
  }else if(n%2==0){
    ull t = pow(a, n/2);
    return (t*t)%x;
  }else{
    return (a*pow(a, n-1))%x;
  }
}

ull route(int _h, int _w){
  int h = _h-1;
  int w = _w-1;
  ull ret = 1;
  return (((g[h+w]*g2[h])%x)*g2[w])%x;
}

int main() {
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  for(int i=0;i<9;++i){
    x *= 10;
  }
  x += 7;

  g.push_back(1);
  g.push_back(1);
  g2.push_back(1);
  g2.push_back(1);

  for(int i=2;i<=H+W;++i){
    g.push_back((g[i-1]*i)%x);
    g2.push_back(pow(g[i], x-2));
    // cout<<g[i]<<" "<<g2[i]<<endl;
  }

  ull ret = 0;
  for(int h=1;h<H-A+1;++h){
    ull tmp = route(h, B);
    tmp *= route(H-h+1, W-B);
    ret = (ret+tmp)%x;
  }
  cout<<ret;
}


Measured memory_bytes: 3564
def solve(a: int, b: int, c: int) -> bool:
   if a == b and b != c:
       return "Yes"
   if a == c and c != b:
       return "Yes"
   if b == c and c != a:
       return "Yes"
   return "No"             


def main():
    a, b, c = [int(num) for num in input().split(' ')]
    print(solve(a, b, c))


main()

    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
long long  mod = 1000000007;
int N, K;
string S;
vector<int> P;
int main()
{
	cin >> N >> K >> S;
	int an = 0;
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == S[i + 1]) {
			an++;
		}
	}
	int count = 0;
	if (S[0] == S[N - 1]) {
		for (int i = 0; i < K; i++) {
			if (an < N - 1) {
				an += 2;
			}
			else {
				break;
			}
		}
		cout << an;
	}
	else if (S[0] != S[N - 1]) {
		P.push_back(1);
		for (int i = 0; i < K; i++) {
			if (an < N - 2) {
				an += 2;
			}
			else {
				an++;
				break;
			}
		}
		cout << an;
	}
}

Measured memory_bytes: 512
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
using P = pair<int, pair<int, int>>;
int n, q;
vector<P> v;
queue<P> events;
vector<int> d;
set<int> stops;
int main()
{
    cin >> n >> q;
    REP(i, n) {
        int s, t, x;
        cin >> s >> t >> x;
        v.push_back(make_pair(s - x, make_pair(1, x)));
        v.push_back(make_pair(t - x, make_pair(-1, x)));
    }
    sort(v.begin(), v.end());
    for (auto e : v) {
        events.push(e);
    }
    REP(i, q) {
        int di;
        cin >> di;
        d.push_back(di);
    }
    for(auto di : d) {
        while(!events.empty() && events.front().first <= di) {
            P e = events.front();
            events.pop();
            int x = e.second.second;
            if (e.second.first == 1) {
                stops.insert(x);
            } else {
                stops.erase(x);
            }
        }
        cout << (stops.empty() ? -1 : *stops.begin()) << endl;
    } 
}


Measured memory_bytes: 18924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
  public static void main(String[] args) throws IOException {
    try {
      BufferedReader input = new BufferedReader(new InputStreamReader(System.in), 1);
      int x = Integer.valueOf(input.readLine());
      if (1 <= x && x <= 100) {
        System.out.println(cubic(x));
      }
    } catch (Exception e) {
      System.exit(0);
    }
 
  }
 
  private static int cubic(int x) {
    return x * x * x;
  }
}


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

string func(long long n) {
    char alp[26];
    for (char c = 'a';  c <= 'z'; c++) alp[c - 'a'] = c;
    string ans;
    while (n > 0) {
        ans = alp[(n-1) % 26] + ans;
        n = (n-1) / 26;
    }
    return ans;
}

int main() {
    long long N; cin >> N;
    cout << func(N) << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define INF 1e18
#define int long long
 
signed main() {
    string s; cin >> s;
    int n = s.size() + 1;
    vector<int> v(n, 0);
 
    int cnt1 = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == '<') {
            v[i] = cnt1;
            cnt1++;
        } else {
            v[i] = cnt1;
            cnt1 = 0;
        }
    }
 
    int cnt2 = 0;
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == '>') {
            cnt2++;
            v[i] = max(v[i], cnt2);
        } else {
            cnt2 = 0;
            v[i] = max(v[i], cnt2);
        }
    }
 
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans += v[i];
    }
    
    cout << ans << endl;;
    return 0;
}

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

typedef long long ll;

int friends[100050];
vector<int> to[100050];

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int root(int x){
        if(d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y){
        x = root(x); y = root(y);
        if(x==y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x)==root(y);}
    int size(int x) {return -d[root(x)];}
};

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

    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        friends[a]++; friends[b]++;
        uf.unite(a,b);
    }
    for(int i=0;i<k;i++){
        int c,d;
        cin >> c >> d;
        c--; d--;
        to[c].emplace_back(d);
        to[d].emplace_back(c);
    }
    for(int i=0;i<n;i++){
        int ans = uf.size(i) - 1 - friends[i];
        for(auto x : to[i]){
            if(uf.same(i,x)) ans--;
        }
        cout << ans << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6784
#include<stdio.h>

int main(){
  //tousakyuusuu!!
  int a[210], b[210], m, n_min, n_max, diff_max, i, ans;

  while(scanf("%d%d%d", &m, &n_min, &n_max), m){
    for(i=0; i<m; i++){
      scanf("%d", &a[i]);
      if(i!=0){
	b[i]=a[i-1]-a[i];
      }
    }

    diff_max=0;
    ans=n_min;
    for(i=n_min; i<=n_max; i++){
      if(diff_max<=b[i]){
	ans=i;
	diff_max=b[i];
      }
    }

    printf("%d\n", ans);
    
  }

  
  return 0;
}

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


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

    ll i,j,k,l,m,n;

    cin >> n;

    ll ans = 0;

    for(i=1;i<n;i++)
    {
        k = (n-1)/i;

        ans += k;


    }

    cout << ans << '\n';


}

Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, p[100010];
int a[100010];

void solve(){
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", p+i);
	for(int i=1;i<=n;i++) a[i] = 1;
	int ans = 0;
	for(int i=1;i<=n;i++) {
		while(a[i] != p[i]) {
			++ans;
			if(a[i] * 2 <= p[i]) a[i] *= 2;
			else a[i] = p[i];
			for(int j=i+1;j<=n;j++) {
				if(a[j] * 2 <= p[j]) a[j] *= 2;
				else { a[j] = p[j]; break; }
			}
		}
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
  ll N, K;
  cin >> N >> K;
  if (N - K <= 0) {
      cout << 0 << endl;
      return 0;
  }
  ll sum = 0;
  vector<ll> v(N);
  for(ll i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  for(ll i = 0;i<N-K;i++){sum += v[i];}
  cout << sum << endl;
  return 0;
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  int m = 0;
  int M = 300000;
  
  for(int i = 0; i < S.size() - T.size() + 1; i++)
  {
    for(int j = 0; j < T.size(); j++)
    {
      if(S.at(i + j) != T.at(j)){m += 1;}
    }
    if(m < M){M = m;}
    m = 0;
  }
  cout << M << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int a[4];

bool Ok(string s){
  int sum = a[0];
  for(int i = 0; i < 3; ++i){
    if(s[i] == '+')sum += a[i+1];
    else sum -= a[i+1];
  }
  return sum == 7;
}

int main(){
  for(int i = 0; i < 4; ++i){
    char c; cin >> c;
    a[i] = c - '0';
  }
  char c[2] = {'+','-'};
  string s = "   ";
  for(int i = 0; i < 2; ++i){
    s[0] = c[i];
    for(int j = 0; j < 2; ++j){
      s[1] = c[j];
      for(int k = 0; k < 2; ++k){
	s[2] = c[k];
	if(Ok(s)){
	  for(int l = 0; l < 3; ++l){
	    cout << a[l] << s[l];
	  }
	  cout << a[3] << '=' << 7 << endl;
	  return 0;
	}
      }
    }
  }
}



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

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) {
        char c;
        std::cin >> c;
        x = (c - '1');
    }

    int p = 0;
    for (int i = 0; i < n; ++i) {
        int e = ((~(n - 1) & i) == 0);
        (p += e * xs[i]) %= 2;
    }

    if (p == 1) {
        std::cout << 1 << std::endl;
        return;
    }

    if (std::any_of(xs.begin(), xs.end(),
                    [](auto x) { return x == 1; })) {
        std::cout << 0 << std::endl;
        return;
    }

    p = 0;
    for (int i = 0; i < n; ++i) {
        int e = ((~(n - 1) & i) == 0);
        (p += e * xs[i] / 2) %= 2;
    }

    std::cout << (p == 0 ? 0 : 2) << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 4224
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner entrada = new Scanner(System.in);
        int A = entrada.nextInt();
        int B = entrada.nextInt();
        if(A<=9&&B<=9){
            System.out.println(A*B);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 22740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,k,s;cin>>n>>k>>s;
    if(k==n){
        for(int i=0;i<n;i++){
            if(i==n-1)cout<<s<<endl;
            else cout<<s<<" ";
        }return 0;
    }
    if(s==1){
        for(int i=0;i<k;i++){
            cout<<1<<" ";
        }
        for(int i=k;i<n;i++){
            cout<<10;
            if(i==n-1)cout<<endl;
            else cout<<" ";
        }return 0;
    }
    int age=(s+1)/2;
    int sage=s/2;
    for(int i=0;i<=k;i++){
        if(i%2==0)cout<<age;
        else cout<<sage;
        if(i==n-1)cout<<endl;
        else cout<<" ";
    }
    for(int i=0;i<n-(k+1);i++){
        if(s==1000000000)cout<<999999999;
        else cout<<1000000000;
        if(i==n-(k+1)-1)cout<<endl;
        else cout<<" ";
    }
}


Measured memory_bytes: 3656
s = input()

txt = "YAKI"

for i in range(4):
    if(len(s) < 4):
        flag = 0
        break
    if(s[i] == txt[i]):
        flag = 1
    else:
        flag = 0
        break

if(flag == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 棒の本数
        int N = sc.nextInt();
        // 選ぶ本数
        int K = sc.nextInt();
        // 棒の長さを格納
        Integer[] card = new Integer[N];
        // 棒の長さを入力
        for (int i = 0; i < N; i++) {
            card[i] = sc.nextInt();
        }
        // 降順に並び替える
        Arrays.sort(card, Collections.reverseOrder());

        // 長さの合計値
        int totalLength = 0;
        for (int j = 0; j < K; j++) {
            totalLength = card[j] + totalLength;
        }

        System.out.println(totalLength);

    }
}

Measured memory_bytes: 35580
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	  a -= Modulus;
	}
	return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	  a += Modulus;
	}
	a -= rhs.a;
	return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	  if (exp % 2) {
		*this *= rhs;
	  }
	  rhs *= rhs;
	  exp /= 2;
	}
	return *this;
  }
};

using mint = modint<mod>;

int main(){
	int n; cin >> n;
	mint s = 0;
	vl a(n); rep(i,n) cin >> a[i], s += a[i];
	mint ans = 0;
	rep(i,n){
		ans += (s - a[i]) * a[i];
	}
	ans /= 2;
	cout << ans.value() << "\n";
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt=1;
    while(a>0&&c>0){
        if(cnt&1)c-=b;
        else a-=d;
        cnt^=1;
    }
    if(a<=0)cout<<"No";
    else cout<<"Yes";
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int a=read(),b=read();
	if(a+b==15) printf("+\n");
	else if(a*b==15) printf("*\n");
	else printf("x\n");
	return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  bool a[n][m];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      a[i][j] = false;
    }
  }
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int p;
      cin >> p;
      a[i][p-1] = true;
    }
  }
  int ans = 0;
  for(int j = 0; j < m; j++){
    bool flag = true;
    for(int i = 0; i < n; i++){
      if(a[i][j] == false) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int n,r; cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
constexpr int MAX=510000;
ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}


int main()
{
	ll M;
	cin>>M;
	int happy;
	int a,b;
	
	a=int(M/500);
	
	M=M-a*500;
	b=int(M/5);
	
	happy=1000*a+b*5;
	cout<<happy;
	
	
	
	
	
	return 0;
}  

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,N,A[100],tmp,count=0,min;
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  for(i = 0; i < N; i++){
    min = i;
    for(j = i; j < N; j++){
      if(A[j] < A[min]){
	min = j;
      }
    }  
	tmp = A[i];
	A[i] = A[min];
	A[min] = tmp;
	if(min != i){
	  count++;
	} 
  }
  for(i = 0; i < N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	string s;
	cin >> s;
	int mn = 753;
	for (int i=0; i<s.length()-2; i++) {
		int sub = stoi(s.substr(i, 3));
		mn = min(abs(753-sub), mn);
	}
	cout << mn << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
static const int MAX_N = 50;
static const int MAX_X = 50;

int N, A;
int x[MAX_N];
ll memo[MAX_N + 1][MAX_N + 1][MAX_N * MAX_X + 1];

int main(){
	cin >> N >> A;
	for(int i = 0; i < N; i++) cin >> x[i];
	memo[0][0][0] = 1;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= i; j++){
			for(int k = 0; k <= N * MAX_X + 1; k++){
				if(j == 0 || k < x[i - 1]) memo[i][j][k] = memo[i - 1][j][k];
				else memo[i][j][k] = memo[i - 1][j][k] + memo[i - 1][j - 1][k - x[i - 1]];
			}
		}
	}
	ll ans = 0;
	for(int i = 1; i <= N; i++){
		ans += memo[N][i][i * A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 49152
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	double now = 0;
	vector<double> p(n);
	for(int i = 0;i < n;i++){
		cin >> p[i];
		if(i < k)now += (p[i]+1) / 2;
	}

	double ans = now;
	for(int i = k;i < n;i++){
		now = now + (p[i] + 1) / 2 - (p[i-k] + 1) / 2;
		ans = max(ans,now);
	}

	printf("%.14lf\n",ans);
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    int n=0;
    cin>>n;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="Y"){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
    return 0;
}


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

using namespace std;

const int maxn=2e5+5;
typedef long long ll;

priority_queue<double,vector<double>,greater<double> > q;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		double x;
		scanf("%lf",&x);
		q.push(x);
	}
	while(q.size()>1){
		double x=q.top();
		q.pop();
		double y=q.top();
		q.pop();
		q.push((x+y)/2);
	}
	printf("%.5lf",q.top());
	return 0;
} 

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
t1,t2,a1,a2= list(map(int,readline().rstrip().split()))
nnn = lambda x: 0 if x == 0 else 1  
if a1//t2 + nnn(a1%t2) <= t1//a2 + nnn(t1%a2):
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
//#define ivorysi
#define MAXN 100005
#define eps 1e-8
#define pb push_back
using namespace std;
typedef long long int64;
typedef double db;
int N,M;
int P[MAXN],fa[MAXN];
int getfa(int x) {
    return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    scanf("%d%d",&N,&M);
    for(int i = 1 ; i <= N ; ++i) scanf("%d",&P[i]);
    for(int i = 1 ; i <= N ; ++i) fa[i] = i;
    int x,y;
    for(int i = 1 ; i <= M ; ++i) {
	scanf("%d%d",&x,&y);
	fa[getfa(x)] = getfa(y);
    }
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(getfa(P[i]) == getfa(i)) ++cnt;
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 100010

using namespace std;

int n,cnt;
int G[N],p[N];
struct edge{
	int t,nx;
}E[N<<1];

inline void Insert(int x,int y){
	E[++cnt].t=y; E[cnt].nx=G[x]; G[x]=cnt;
	E[++cnt].t=x; E[cnt].nx=G[y]; G[y]=cnt;
}

void dfs(int x,int f){
	for(int i=G[x];i;i=E[i].nx)
		if(E[i].t!=f) dfs(E[i].t,x);
	if(p[x]) return ;
	if(p[f]) { puts("First"); exit(0); }
	p[x]=p[f]=1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		Insert(x,y);
	}
	p[0]=1;
	dfs(1,0);
	puts("Second");
	return 0;
}

Measured memory_bytes: 2560
n, m = map(int, input().split())
a = [[0] * m for i in range(n)]
b = [0] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for j in range(m):
    b[j] = int(input())
for i in range(n):
    s = 0
    for j in range(m):
        s += a[i][j] * b[j]
    print(s)


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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

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

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

ll N,Q;
ll X[200000],L[200000],D[200000];
ll bit[2][200001];

void add(ll b,ll i,ll x){
	i++;
	while(i<=N){
		bit[b][i]+=x;
		i+=i&-i;
	}
}

ll sum(ll b,ll i){
	ll res=0;
	i++;
	i=min(i,N);
	while(i>0){
		res+=bit[b][i];
		i-=i&-i;
	}
	return res;
}


int main()

{

	cin>>N>>Q;
	rrep(i,Q){
		cin>>X[i]>>D[i]>>L[i];
		if(D[i]==1) X[i]--;
	}
	rep1(i,N-1){
		add(0,i,1);
		add(1,i,1);
	}
	ll lb,ub,mid;
	rep(i,Q){
		if(D[i]==1){
			lb=-1;
			ub=N;
			while(ub-lb>1){
				mid=(ub+lb)/2;
				if(sum(0,mid)>X[i]){
					ub=mid;
				}
				else lb=mid;
			}
			add(1,0,2*(-L[i]));
			add(1,ub,2*(L[i]));
		}
		else{
			lb=-1;
			ub=N;
			while(ub-lb>1){
				mid=(ub+lb)/2;
				if(sum(1,mid)>=X[i]){
					ub=mid;
				}
				else lb=mid;
			}
			add(0,ub,2*(L[i]));
		}
	}
	rep(i,N){
		cout<<(sum(0,i)-sum(1,i))/2<<endl;
	}
}

Measured memory_bytes: 10916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

ll mod = 1000000007;
int n, k;
vector<vector<int>> v;
ll ans;

void dfs(int pre, int crt)
{
  rep(i, v[crt].size() - 1)
    ans = ans * (k - i - 2) % mod;
  for (int i : v[crt])
    if (i != pre)
      dfs(crt, i);
}

int main()
{
  cin >> n >> k;
  v.resize(n);
  rep(i, n - 1)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ans = k;
  rep(i, v[0].size())
    ans = ans * (k - i - 1) % mod;
  for (int i : v[0])
    dfs(0, i);
  cout << ans << endl;
  return 0;
}

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

void k_large(ll x, ll k){
    cout << min(x,(ll)abs(k-x)) << endl;
}

int main(void){
    ll n,k;
    cin >> n >> k;
    if (n > k) {
        k_large(n%k, k);
    } else {
        k_large(n, k);
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i,n) cin >> w[i];
  
  int ans = 1e12;
  
  for(int i=1;i<n;i++){
    int l = 0, r = 0;
    for(int j=0;j<i;j++) l += w[j];
    for(int k=i;k<n;k++) r += w[k];
    
    ans = min(ans,abs(r-l));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import *
h, w = map(int, input().split())
s = [input() for _ in range(h)]
p = [[-1] * w for _ in range(h)]
p[0][0] = 1
d = ((1, 0), (-1, 0), (0, 1), (0, -1))
white = sum(row.count('.') for row in s)
queue = deque([(0, 0)])
clearable = False
while queue:
  x, y = queue.popleft()
  if x == w-1 and y == h-1:
    clearable = True
    break
  for dx, dy in d:
    nx, ny = x + dx, y + dy
    if not (0 <= nx < w and 0 <= ny < h):
      continue
    if s[ny][nx] == '#' or p[ny][nx] > 0 :
      continue
    p[ny][nx] = p[y][x] + 1
    queue.append((nx, ny) )
if clearable:
  print(white - p[h-1][w-1])
else:
  print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ksor = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        ksor ^= a[i];
    }
    for (int i = 0; i < n; ++i)
        cout << (ksor ^ a[i]) << " ";
    return 0;
}


Measured memory_bytes: 4840
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    char array[n];
    for(int i = 0; i < n; i++)
    {
        scanf(" %c", &array[i]);
    }
    if(n % 2 != 0)
    {
        printf("No\n");
        return 0;
    }
    int x = 0;
    for(int i = 0, j = n / 2; i < n / 2; i++, j++)
    {
        if(array[i] != array[j])
        {
            x = 1;
            break;
        }
    }
    if(x == 1)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
map<string,int> mp; 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string a,b,u;
	cin>>a>>b;
	cin>>mp[a]>>mp[b];
	cin>>u;
	if(a==u) mp[a]--;
	if(b==u) mp[b]--;
	printf("%d %d\n",mp[a],mp[b]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

void solve() {
    char b;
    cin >> b;
    char ans;
    if (b == 'A') {
        ans = 'T';
    } else if (b == 'T'){
        ans = 'A';
    } else if (b == 'C') {
        ans = 'G';
    } else if (b == 'G') {
        ans = 'C';
    }
    print(ans);
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 256
s = list(input())
k = int(input())

if list(s[0]*len(s))==s:
	#print('a')
	print(len(s)*k//2)
	exit()

res = [1]
for i in range(len(s)-1):
	if s[i]==s[i+1]:
		res[-1] += 1
	else:
		res.append(1)
ans = 0
for i in res:
	ans += (i//2)*k
if s[0]==s[-1]:
	diff = (res[0]+res[-1])//2 -(res[0]//2 + res[-1]//2)
	ans += diff*(k-1)
print(ans)


Measured memory_bytes: 9148
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;	cin>>s;
	for(int i=1;i<s.size();i++){
		if(s[i-1]==s[i]){
			s.erase(s.begin()+i,s.begin()+i+1);
			i--;
		}
	}
	cout<<s.size()-1<<endl;
	return 0;
}


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

int main() {
    int N;
    cin>>N;//costs 個数
    int T; //max time
    cin>>T;
    int cost;
    int flag = 0;
    std::vector<int> c;//costs
    std::vector<int> t;//times
    
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        c.push_back(x);
        t.push_back(y);
    }
    cost=c[0];
    for(int i=0;i<N;i++){
        if(t[i]<T||t[i]==T){
            flag=1;
            if(c[i]<cost){
                cost=c[i];
            }
        }
    }
    if(flag==0){
        cout<<"TLE"<<endl;
    }else{
        cout<<cost<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
  
int walk(int index, int time, int w[101][101], int *d, int *f) {
    int *p;
  
    d[index] = ++time;
    for (p = w[index]; *p != 0; p++) {
        if (!d[*p]) {
            time = walk(*p, time, w, d, f);
        }
    }
    f[index] = ++time;
    return time;
}
  
int main(void) {
    int num, i, j, u, k, tm = 0;
    int d[101] = {0}, f[101] = {0};
    int w[101][101] = {{0}};
  
    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &w[u][j]);
        }
    }
  
    for (i = 1; i <= num; i++) {
        if (!d[i]) {
            tm = walk(i, tm, w, d, f);
        }
    }
  
    for (i = 1; i <= num; i++) {
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}

Measured memory_bytes: 648
## import

## function definition 

## main process
if __name__ == '__main__':
    
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            tuple(map(int,input().split()))
        )
    
    ## business logic
    ans = [1] * N
    for j in list(range(M)):
        point_a = ROAD_LIST[j][0]
        point_b = ROAD_LIST[j][1]

        point_a -= 1
        point_b -= 1

        height_a = HEIGHT_LIST[point_a]
        height_b = HEIGHT_LIST[point_b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    ## output
    print(sum(ans))

Measured memory_bytes: 31244
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(string S) {
  vector<int> cnt(26);
  for (char c: S) cnt[c - 'a']++;
  REP(i,26) {
    if (cnt[i] == 0) {
      cout << char(i + 'a') << endl;
      return;
    }
  }
  cout << "None" << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string S;
	cin >> S;
	solve(S);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 1000
//<<fixed << setprecision(9)
 
int main()
{
    int n,i,j,t,a;
    boost;
    ll r,d,x;
    cin>>r>>d>>x;
    t=10;
    while(t--)
    {
        x=r*x-d;
        cout<<x<<'\n';
    }
 
}



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

int main() {
    int n, m;
    cin >> n >> m;
    int c[21];
    int t[50001];
    int ini = (1 << 29);
    for (int i = 1; i <= m; i++) {
        cin >> c[i];
    }
    t[0] = 0;
    for (int i = 1; i <= 50000; i++) {
        t[i] = ini;
    }

    for(int i=1;i<=m;i++){
        for(int j=0;j+c[i]<=n;j++){
            t[j+c[i]]=min(t[j+c[i]],t[j]+1);
        }
    }

    cout << t[n] << endl;
    return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define reps(i, n , m) for(ll i = n; i <= m; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
 
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	int N,K;
	cin>>N>>K;
	vector<int> h(N);
	rep(i,N) cin>>h[i];
	int ans=0;
	rep(i,N){
		if(K<=h[i]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	long long sum=0;
	scanf("%d",&n);
	int f=0,mn=1e9+1;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(x<0)
			f++;
		sum+=abs(x);
		mn=min(mn,abs(x));
	}
	if(f%2==1)
		sum-=2*mn;
	printf("%lld\n",sum);
} 

Measured memory_bytes: 3792
import copy
import random
D = int(input())
cs = list(map(int,input().split()))
ss =[]
for i in range(D):
  ss.append(list(map(int,input().split())))
for r in range(100):
  ts = []
  for i in range(D):
    ts.append(random.randint(1, 26))
  if r ==0:
    maxts = copy.copy(ts)
  last = [0] * 26
  total =0
  for i in range(D):
    t = ts[i]
    last[t-1] = i+1
    genten=0
    for j in range(26):
      genten += cs[j] *(i+1 - last[j])
      total += ss[i][t-1]-genten
    if r==0:
      maxtsscore = total
    else:
      if maxtsscore < total:
        maxtsscore = total
        maxts = copy.copy(ts)
for z in maxts:
  print(z)
  
 


Measured memory_bytes: 10044
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
const int n=100+10;
int a[n][n];
int b[n];
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	
	int n,m;scanf("%d%d", &n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			scanf("%d", &a[i][j]);
	}
	for(int i=1;i<=m;i++){
		scanf("%d", &b[i]);
	}
	for(int i=1;i<=n;i++){
		int sum=0;
		for(int j=1;j<=m;j++){
			sum+=a[i][j]*b[j];
		}
		cout<<sum;
		cout<<endl;
	}
	//insert code above
	return 0;
}
//1_6_d.cc

Measured memory_bytes: 1252
#include<iostream>

int main(){
  int n;
  int temp,max,a;

  while(1){
    std::cin >> n;
    if(n==0){
      break;
    }
    int a[n];
    for(int i=0;i<n;i++){
      std::cin >> a[i];
    }
    max = a[0];
    for(int i=0;i<n;i++){
      temp = a[i];
      if(max < temp){
        max = temp;
      }
      for(int j=i+1;j<n;j++){
        temp += a[j];
        if(max < temp){
          max = temp;
        }
      }
    }
    std::cout << max << std::endl;
  }
}

Measured memory_bytes: 3012
s = input()
ans = "NO"
ls = len(s)
if s[:7] == "keyence":
    ans = "YES"
elif s[-7:] == "keyence":
    ans = "YES"
else:
    for i in range(6):

        if s[:i+1]+s[ls-6+i:] == "keyence":
            ans = "YES"
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
bool prime(long x){
  for(int i = 2; i * i <= x; i++){
    if(x % i == 0) return false;
  }
  return true;
}
int main(){
  long  x; cin >> x;
  for(long i = x; ; i++){
    if(prime(i)){
      cout << i;
      return 0;
    }
  } 
}

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

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int a,b;
    cin >> a >> b;

    cout << (a+b)%24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll A;
    ll b1, b2;
    scanf("%lld %lld.%lld", &A, &b1, &b2);
    cout << A * b1 + (A * b2) / (ll)100 << endl;
}


Measured memory_bytes: 3764
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.buff = [n for n in dice]
    def east(self):
        self.dice[0] = self.buff[3]
        self.dice[2] = self.buff[0]
        self.dice[5] = self.buff[2]
        self.dice[3] = self.buff[5]
        self.buff = [n for n in self.dice]
    def west(self):
        self.dice[0] = self.buff[2]
        self.dice[2] = self.buff[5]
        self.dice[5] = self.buff[3]
        self.dice[3] = self.buff[0]
        self.buff = [n for n in self.dice]
    def north(self):
        self.dice[0] = self.buff[1]
        self.dice[1] = self.buff[5]
        self.dice[5] = self.buff[4]
        self.dice[4] = self.buff[0]
        self.buff = [n for n in self.dice]
    def south(self):
        self.dice[0] = self.buff[4]
        self.dice[1] = self.buff[0]
        self.dice[5] = self.buff[1]
        self.dice[4] = self.buff[5]
        self.buff = [n for n in self.dice]

nums = list(map(int, input().split()))
d = Dice(nums)
way = input()

for w in way:
    if w == "E":
        d.east()
    if w == "W":
        d.west()
    if w == "N":
        d.north()
    if w == "S":
        d.south()

print(d.dice[0])



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll N;
    cin>>N;
    cout<<(800*N)-(N/15)*200;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

int main() {
    int a, b, c;
    while (cin >> a >> b >> c) {
        dump(a, b, c);
        bool res = false;
        rep(i, 1000) {
            int aa = a * i;
            if (aa % b == c) {
                res = true;
            }
        }
        puts(res ? "YES" : "NO");
    }
}


Measured memory_bytes: 256