akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r,t, h, w;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> s;
    sans = "AC";

    if(s[0] != 'A'){
        std::cout << "WA" << endl;
        return;
    }

    int co = 0;
    int it;
    Rep(i,2,s.size()-1){
        if(s[i]=='C'){
            co++;
            it=i;
        }
    }
    if(co!=1){
        std::cout << "WA" << endl;
        return;
    }

    rep(i,s.size()){
        if(i!=0 && i!=it){
            if(s[i] >='a' && s[i] <= 'z'){
            }
            else{
                std::cout << "WA" << endl;
                return;
            }

        }
    }

    // std::cout << ans << endl;

    std::cout << sans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 1005;
int mat[N][N];
int cnt[N], vis[N], visid;
vii cur, nxt;
int ans, n;

void process() {
    ans++;
    for (auto p : cur) {
        cnt[p.fr]++;
        cnt[p.sc]++;
//        cout << p.fr << "vs" << p.sc << endl;
    }
}


void check(int i) {
    if (cnt[i] == n - 1 || vis[i] == visid)return;
    int want = mat[i][cnt[i]];
    if (vis[want] != visid && cnt[want] != n - 1 && mat[want][cnt[want]] == i) {
        nxt.pb({i, want});
        vis[i] = vis[want] = visid;
    }
}


int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    loop(i, n) {
        loop(j, n - 1) {
            cin >> mat[i][j];
            mat[i][j]--;
        }
    }

    visid++;
    loop(i, n)check(i);
    cur = nxt;

    while (true) {
        if (SZ(cur) == 0)break;
        process();
        visid++;
        nxt.clear();
        for (auto p : cur) {
            check(p.fr);
            check(p.sc);
        }
        cur = nxt;
    }

    loop(i, n) {
        if (cnt[i] != n-1) {
//            cout << i << " " << cnt[i] << endl;
            cout << -1 << endl;
            return 0;
        }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

#define all(v) (v).begin() + 1, (v).end()
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n + 1)
using namespace std;

struct query_info
{
    int left, right, query_no;

    query_info(int L, int R, int N)
    {
        left = L, right = R, query_no = N;
    }

    int operator<(const query_info &A)
    {
        return (right < A.right);
    }
};

struct train_info
{
    int left, right;

    train_info(int L, int R)
    {
        left = L, right = R;
    }

    int operator<(const train_info &A)
    {
        return (right < A.right);
    }
};

const int MAX_N = 515;
int sum_tree[4*MAX_N];

void update(int n, int left, int right, int position, int value)
{
    if(position < left || right < position)
        return;

    if(left == right)
    {
        sum_tree[n] += value;
        return;
    }

    int mid = (left + right) >> 1;

    update(LEFT(n), left, mid, position, value);
    update(RIGHT(n), mid + 1, right, position, value);

    sum_tree[n] = sum_tree[LEFT(n)] + sum_tree[RIGHT(n)];
}

int get_sum(int n, int left, int right, int query_left, int query_right)
{
    if(right < query_left || query_right < left)
        return 0;

    if(query_left <= left && right <= query_right)
    {
        return sum_tree[n];
    }

    int mid = (left + right) >> 1;
    int left_sum = get_sum(LEFT(n), left, mid, query_left, query_right);
    int right_sum = get_sum(RIGHT(n), mid + 1, right, query_left, query_right);

    return (left_sum + right_sum);
}

int main()
{
    int no_of_cities, no_of_trains, no_of_queries;
    scanf("%d %d %d", &no_of_cities, &no_of_trains, &no_of_queries);

    vector <train_info> train(no_of_trains + 1, train_info(0, 0));
    for(int i = 1; i <= no_of_trains; i++)
        scanf("%d %d", &train[i].left, &train[i].right);

    sort(all(train));

    vector <query_info> query(no_of_queries + 1, query_info(0, 0, 0));
    for(int i = 1; i <= no_of_queries; i++)
    {
        scanf("%d %d", &query[i].left, &query[i].right);

        query[i].query_no = i;
    }

    sort(all(query));

    memset(sum_tree, 0, sizeof(sum_tree));
    vector <int> answer(no_of_queries + 1);

    int last_train = 1;
    for(int i = 1; i <= no_of_queries; i++)
    {
        while(last_train <= no_of_trains && train[last_train].right <= query[i].right)
        {
            update(1, 1, no_of_cities, train[last_train].left, 1);

            last_train++;
        }

        answer[query[i].query_no] = get_sum(1, 1, no_of_cities, query[i].left, query[i].right);
    }

    for(int i = 1; i <= no_of_queries; i++)
        printf("%d\n", answer[i]);

    return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    vector<LL> abc(3);
    cin>>abc;
    sort(ALL(abc));
    set<vector<LL>> s;

    s.insert(abc);
    int cnt=0;
    
    while(1){
        if((abc[0]&1)||(abc[1]&1)||(abc[2]&1))break;
        abc={(abc[0]+abc[1])/2,(abc[1]+abc[2])/2,(abc[0]+abc[2])/2};
        sort(ALL(abc));
        if(s.count(abc)){
            cnt=-1;
            break;
        }
        s.insert(abc);
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
# ABC109D - Make Them Even (str-format style)
def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(lambda x: int(x) % 2, input().split())) for _ in range(H))
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j] ^= 1
                A[i][j + 1] ^= 1
                ans += ["{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)]

    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i][W - 1] ^= 1
            A[i + 1][W - 1] ^= 1
            ans += ["{} {} {} {}".format(i + 1, W, i + 2, W)]
    print(len(ans))
    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 16432
#include <stdio.h>

int main()
{
  int num;
  char junk;
  scanf("%d%c", &num, &junk);
  char color;
  for(int i = 0; i < num; i++) {
    scanf("%c%c", &color, &junk);
    if(color == 'Y') {
      puts("Four");
      return 0;
    }
  }
  puts("Three");
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() {

    ll N; cin >> N;
    vector<map<ll, ll > > v(N);
    vector<ll > tr(N, 0);
    vector<ll > fl(N, 0);


    for(ll i = 0; i < N; i++){
        ll t; cin >> t; 
        for(ll j = 0; j < t; j++){
            ll a, b; cin >> a >> b;
            a--;
            v[i][a] = b;
        }
    }

    ll ans = 0;
    for(ll i = 0; i < (1<<N); i++){
        //ビットの位置を数える
        ll t_ans = 0;
        ll shogen = 0;
        bool f = true;
        for(ll j = 0; j < N; j++){
            //右シフトして最下位で立っているかどうか判定
            //syogen
            //cout << i << ":" << bitset<8>(i) << endl;
            //cout << (1 << j) << endl;
            if(i & (1 << j)){
                t_ans++;
                auto begin = v[j].begin(), end = v[j].end();
                for (auto iter = begin; iter != end; iter++) {
                    if( (0 != (i & (1 << iter->first))) != iter->second){
                        f = false;
                    }
                    //if(iter->second == 1) shogen |= (1 << iter->first);
                }
            }
        } 

        //cout << i << " " << shogen << endl;

        if(f == true){
            ans = max(t_ans, ans);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
//struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long A, long long B){
	ll res = 6-(A+B);
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
def main():
  n,m = map(int,input().split())
  array = [-1] * n

  h = list(map(int,input().split()))

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

      array[a] = max(array[a], h[b])
      array[b] = max(array[b], h[a])


  count = 0

  for i in range(n):
    if array[i] == -1:
      count += 1

    elif h[i] > array[i]:
      count += 1
        
  print(count)
    
main()
        

Measured memory_bytes: 85808
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<utility>
#include<algorithm>
using namespace std;

typedef long long ll;
const int maxn = 1e4 + 10;
int a[maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while (scanf("%d", &n) == 1 && n)
	{
		int sum = 0;
		for (int i = 1; i <= n; i++)
		{
			scanf("%d", &a[i]);
			sum += a[i];
		}
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			if (n*a[i] <= sum) cnt++;
		printf("%d\n", cnt);
	}
	return 0;
}


Measured memory_bytes: 3252
#include <stdio.h>
int main(){
	long long n;
	scanf("%lld",&n);
	long long luc[n],i;
	luc[0]=2;
	luc[1]=1;
	for(i=2;i<=n;i++){
		luc[i]=luc[i-1]+luc[i-2];
		}
	printf("%lld",luc[n]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(t.begin(),t.end());

   int ans = 0;
   int num = 0;

    while (num < n){
        int time_limit = t[num] + k;
        int passenger = 1;
        while (passenger <= c && num < n && t[num] <= time_limit){
            passenger++;
            num++;
        }
        ans++;
    }
    print(ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fio;
	int n, m;
	cin >> n >> m;
	map<int, int> h;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		h[i] = x;
	}
	list<int> *adj;
	adj = new list<int>[n + 1];
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int k = i;
		int flag = 0;
		for (auto it = adj[k].begin(); it != adj[k].end(); it++)
		{
			if (h[i] > h[*it])
				continue;
			else
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0)
			ans++;
	}
	cout << ans << endl;
}

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

int main() {
	vector<P> a;
	rep(i, 5) {
		int x;
		cin >> x;
		int r = x % 10;
		if (r == 0) r = 10;
		a.push_back(make_pair(r, x));
	}
	sort(a.begin(), a.end());

	int ans = 0;
	rep(i, 5) {
		if (i != 4) {
			int x = a[4-i].second;
			ans += ((x + 9) / 10) * 10;
		}
		else {
			ans += a[0].second;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> c(n, 0);
	vector<int> s(n, 0);
	vector<int> f(n, 0);
	for (int i = 1; i < n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	int t = 0;
	for (int i = 1; i < n; i++) {
		t = 0;
		for (int j = i; j < n; j++) {
			if (t <= s[j]) {
				t = s[j];
				t += c[j];
				if (i == n - 1) { break; }
			}
			else {
				while (1) {
					if ((t - s[j]) % f[j] == 0) {
						t += c[j];
						break;
					}
					t++;
				}
			}

		}
		cout << t << endl;
	}
	cout << 0 << endl;
}

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

using namespace std;

int main() {
	int n;

	cin >> n;

	vector<int> next(n);
	vector<bool> visited(n + 1, false);
	for (int i = 0; i < n; ++ i) {
		cin >> next[i];
	}

	int ans = 0;
	int pos;
	for (pos = 1; pos != 2 && next[pos - 1] != 1; pos = next[pos - 1]) {
		++ ans;
		if (visited[pos]) {
			break;
		}
		visited[pos] = true;
	}

	cout << (pos == 2 ? ans : -1) << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    String[] s = new String[H];
    for (int i = 0; i < H; i++) {
      s[i] = scanner.next();
    }
    for (int i = 0; i < H * 2; i++) {
      System.out.println(s[i / 2]);
    }
  }
}


Measured memory_bytes: 24084
#include <array>
#include <iostream>
#include <string>

int main() {
  std::array<char, 4> suits{'S', 'H', 'C', 'D'};
  std::array<std::string, 52> cards;
  for (std::size_t i = 0; i < suits.size(); i++) {
    for (int j = 0; j < 13; j++) {
      cards[i * 13 + j] = std::string{suits[i]} + " " + std::to_string(j + 1);
    }
  }

  int n;
  std::cin >> n;
  std::string s, c;
  for (int i = 0; i < n; i++) {
    std::cin >> s >> c;
    for (std::size_t j = 0; j < cards.size(); j++) {
      if ((s + " " + c) == cards[j]) {
        cards[j] = "";
      }
    }
  }

  for (auto c : cards) {
    if (c != "") {
      std::cout << c << std::endl;
    }
  }
}



Measured memory_bytes: 3252
from collections import deque
n = int(input())
a = list(map(int,input().split()))
q = deque(a)
count = 1
ans = 0
for i in range(n):
    if q[0] == count:
        count += 1
        q.popleft()
    else:
        q.popleft()
if count == 1:
    print(-1)
else:
    print(len(a)-count+1)

Measured memory_bytes: 26780
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
const int maxn=200000;
long long int a[maxn];
int main()
{
    long long int i,j,n,sum=0,sum1=0,sum2=0,min;
    scanf("%lld",&n);
    long long int c[n-1];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        min+=fabs(a[i]);
        sum+=a[i];
    }
    for(j=n-1;j>0;j--)
    {
        sum1+=a[j];
        if(fabs(2*sum1-sum)<min)
        {
            min=fabs(2*sum1-sum);
        }
    }
    printf("%lld\n",min);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N, K;
  cin >> N >> K;
  
  cout << (N%K == 0 ? 0 : 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[222222];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); 
	string s; cin>>s;
	int n=s.length();
	int currun=0;
	int curstate=-1;
	ll ans=0;
	for(int i=n-1;i>=0;i--)
	{
		char c = s[i];
		if(c=='A')
		{
			if(curstate==1) ans+=currun;
			else {currun=0;curstate=-1;}
			continue;
		}
		if(c=='C')
		{
			if(curstate!=1) currun=0;
			curstate=0;
		}
		else
		{
			if(curstate==0) {curstate=1; currun++;}
			else 
			{
				curstate=-1; currun=0;
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 720
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll K, X; cin >> K >> X;
    cout << (500*K >= X ? "Yes" : "No") << endstr;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9;

double minokowski(vector<int>& x, vector<int>& y, int p) {
  int n = x.size();
  double res = 0;
  if (p == INF) {
    rep(i, n) res = max(res, (double)abs(x[i] - y[i]));
  } else {
    double sum = 0;
    rep(i, n) {
      double d = 1;
      rep(j, p) d *= abs(x[i] - y[i]);
      sum += d;
    }
    res = pow(sum, 1.0 / p);
  }
  return res;
}

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

  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i];
  rep(i, n) cin >> y[i];

  printf("%.9f\n", minokowski(x, y, 1));
  printf("%.9f\n", minokowski(x, y, 2));
  printf("%.9f\n", minokowski(x, y, 3));
  printf("%.9f\n", minokowski(x, y, INF));
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const ll x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        while (p > 0) {
            if (p & 1) *this *= r;
            r *= r;
            p >>= 1;
        }
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        ll a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

template <typename T>
T fact(std::uint_fast32_t n) {
    static vector<T> factorial(1, 1);

    if (n < factorial.size())
        return factorial[n];
    else
        for (T i = factorial.size(); i <= n; i++) {
            factorial.push_back(factorial.back() * i);
        }
    return factorial[n];
}

int main() {
    int N;
    cin >> N;
    vector<mint> A(N), S(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S[i + 1] = S[i] + mint(i + 1).inv();
    }
    mint ans = 0;
    for (int i = 0; i < N; i++) {
        mint p;
        p = S[i + 1] + S[N - i] - 1;
        ans += fact<mint>(N) * p * A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#define MAX 400010

int A[MAX];

int main(void)
{
	int q, com, x, y, s = 0, t = 0;
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &com, &x);
		if (com == 0) {
			scanf("%d", &y);
			if (x == 0) {
				--s;
				if (s < 0) s += MAX;
				A[s] = y;
			}
			else {
				A[t++] = y;
				if (t >= MAX) t -= MAX;
			}
		}
		else if (com == 1) {
			printf("%d\n", A[(s + x) % MAX]);
		}
		else {
			if (x == 0) {
				++s;
				if (s >= MAX) s -= MAX;
			}
			else {
				--t;
				if (t < 0) t += MAX;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node
{
	int l,r;
	ll v;
}t[800010];
int n,h[200010],a[200010],q[200010];
ll f[200010];
void pushup(int k)
{
	t[k].v=max(t[k<<1].v,t[k<<1|1].v);
}
void build(int k,int l,int r)
{
	t[k].l=l;
	t[k].r=r;
	if (l==r)
	{
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}
void update(int k,int x,ll v)
{
	int l=t[k].l;
	int r=t[k].r;
	if (l==r)
	{
		t[k].v=v;
		return;
	}
	int mid=(l+r)>>1;
	if (x<=mid)
	{
		update(k<<1,x,v);
	}
	else
	{
		update(k<<1|1,x,v);
	}
	pushup(k);
}
ll query(int k,int x)
{
	int l=t[k].l;
	int r=t[k].r;
	if (x>=r)
	{
		return t[k].v;
	}
	int mid=(l+r)>>1;
	if (x<=mid)
	{
		return query(k<<1,x);
	}
	else
	{
		return max(t[k<<1].v,query(k<<1|1,x));
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	build(1,1,n);
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		ll v=query(1,h[i]);
		ans=max(ans,v+a[i]);
		update(1,h[i],v+a[i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        if(i==0) b[i] = a[i];
        else b[i] = b[i-1] ^ a[i];
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        c[i] = b[n-1] ^ b[i];
        if(i!=0) c[i] = c[i] ^ b[i-1];
    }
    for (int i = 0; i < n; i++){
        if(i != 0) cout << " ";
        cout << c[i];
    }
    cout << endl;
  
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 5528
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







void dfs(vvi &edges, vi &seen, int start, int color){
    seen.at(start)=color;
    for (int next:edges.at(start)){
        if (seen.at(next)==-1){
            dfs(edges,seen,next,color);
        }
    }
}





int main(){

  
  
    int n,m;
    cin>>n>>m;
  
  	vector<vector<int>> edges(n+1,vi(0));

    rep(i,m){
        int a,b;
        cin>>a>>b;
        edges.at(a).pb(b);
        edges.at(b).pb(a);
    }

    vi seen(n+1,-1);

    int count=0;


    for (int i=1;i<=n;i++){
        if (seen.at(i)==-1){
            dfs(edges,seen,i,count);
            count++;
        }
    }

    vi result(count+1,0);

    for (int i=1;i<=n;i++){
        result.at(seen.at(i))++;
    }

    sort(ALL(result));

    cout<<result.at(count)<<endl;








}

Measured memory_bytes: 24300
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    const i64 MOD=1e9+7;
    modint(i64 a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a,MOD=_.MOD;
    while(b){
        if(b&1) (n*=A)%=MOD;
        (A*=A)%=MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

class FSmallProducts {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k,m;
        in>>n>>k;
        m=(int)sqrt(n);
        vector<modint> c(2*m),s(2*m+1),ns(2*m+1);
        fr(i,m) c[i]=1,c[i+m]=n/(m-i)-n/(m-i+1);
        if(n/m==m) c[m]-=1;
        s[0]=1;
        fr(_,k){
            ifr(i,2*m) ns[i]=ns[i+1]+(s[0]-s[2*m-i])*c[i];
            s.swap(ns);
        }
        out<<s[0]<<endl;
    }
};

int main() {
    FSmallProducts solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3200
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n===0)break;
   var arr=(Arr.shift()).split(" ").map(Number);
   for(var i=0;i<n+1;i++){
      var a=arr.filter(function(v,index){return i!=index;});
      var h=a[1]-a[0];
      var flag=true;
      for(var j=1;j<n;j++){
         if(h!=a[j]-a[j-1])flag=false;
      }
      if(flag==true)break;
   }
   console.log(arr[i]);
}

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define rep0(i,n)       for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rep(i,x,y)      for(int i=x;i<=y;i++)
#define reprev1(i,n)    for(int i=n;i>0;i--)
#define reprev0(i,n)    for(int i=n-1;i>=0;i--)
#define reprev(i,x,y)   for(int i=x;i>=y;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);rep0(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M             (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j;
int dp[M][105]={};

int profit(int weight,int w[],int v[],int i)
{

    if(i<0)return 0;

    if(dp[weight][i]!=0)return dp[weight][i];
    if(w[i]>weight)return dp[weight][i]=profit(weight,w,v,i-1);
    int op1=profit(weight,w,v,i-1);
    int op2=v[i]+profit(weight-w[i],w,v,i-1);

    return dp[weight][i]=max(op1,op2);
    
}


void sol()
{   int weight;
    cin>>n>>weight;
    int w[n],v[n];
    rep0(i,n)cin>>w[i]>>v[i];
    
    
    
    cout<< profit(weight,w,v,n-1) <<endl;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 82176
def dv(x, y, mod):
    # x / y = x * (y ** (mod - 2))
    return x * pow(y, mod - 2, mod) % mod

def comb(n, r, mod):
    # p / q = p * (q ** (mod - 2))
    p, q = 1, 1
    if n < r or n < 0 or r < 0: return 0
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return dv(p, q, mod)

mod = 1000000007
n, a, b = map(int, input().split())
# pow(a, b, c) = (a ** b) % c
ans = pow(2, n, mod) - 1
if 0 <= n: ans -= comb(n, a, mod)
if 0 <= n: ans -= comb(n, b, mod)
print(ans % mod)

Measured memory_bytes: 3064
n, m = map(int,input().split())
H = [int(i) for i in input().split()]
ans = [True]*n
for i in range(m):
  a, b = map(int, input().split())
  if H[a-1] < H[b-1]:
    ans[a-1] = False
  elif H[a-1] > H[b-1]:
    ans[b-1] = False
  elif H[a-1] == H[b-1]:
    ans[a-1] = False
    ans[b-1] = False
print(ans.count(True))

Measured memory_bytes: 20100
#include <iostream>

int main() {
    unsigned long long n, m; std::cin >> n >> m;
    unsigned long long ret = 0;
    if (n != 1 && m != 1) {
        ret = (n-2) * (m - 2);
    } else if (n == 1 && m == 1) {
        ret = 1;
    } else {
        ret = std::max(m, n) - 2;
    }
    std::cout << ret << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n;
    scanf("%d",&n);
    int A[n];
 
    for(int i = 0; i < n; i++) scanf("%d",&A[i]);
 
    for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
    printf("%d\n",A[0]);
}


Measured memory_bytes: 2608
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll N = 55, inf = 1e9;
typedef long long ll;
ll n,X,D,m[N],fa[N];
ll sum[N], size[N], f[N * N * N];
struct item{
	ll cost, value, gs, gs1;
	bool operator < (const item b) const {
		return (double)value / cost > (double)b.value / b.cost;
	}
} is[N];
ll min(ll a,ll b) {
	return a > b ? b : a;
}
ll max(ll a,ll b) {
	return a > b ? a : b;
}

ll Q[N * N * N], h, t, v[N * N * N];
ll gre(ll a) {
	if (a <= 0) return 0;
	ll ret = 0;
	for (ll i = 1; i <= n; i++) {
		ll gs = min(a / is[i].cost, is[i].gs);
		ret += gs * is[i].value;
		a -= gs * is[i].cost;
	}
	return ret;
}

int main() {
	cin>>n>>X>>D;
	scanf("%lld\n",&m[1]);
	for (ll i = 2; i <= n; i++) 
		scanf("%lld %lld\n",&m[i],&fa[i]);
	for (ll i = n; i>1; i--) {
		sum[i] += m[i], size[i] ++;
		sum[fa[i]] += sum[i];
		size[fa[i]] += size[i];
	}
	
	sum[1]+=m[1],size[1]++;
	for (ll i = 1; i <= n; i++) {
		is[i] = (item) {sum[i], size[i], i == 1 ? inf : D, 0};
	}

	sort(is + 1, is + 1 + n);
	memset(f, 127/3 ,sizeof f); f[0] = 0;
	
	ll n2 = n * n * n;
	for (ll i = 1; i <= n; i++) {
		is[i].gs1 = min(is[i].gs, n);
		for (ll y = 0; y < is[i].value; y++) {
			t = 0, h = 1;
			for (ll j = y; j <= n2; j += is[i].value) {
				while (h <= t && Q[h] < j - is[i].gs1 * is[i].value) h++;
				ll tf = 1e18;
				if (h <= t) {
					tf = v[h] + j / is[i].value * is[i].cost;
				}
				ll vv = f[j] - j / is[i].value * is[i].cost;
				while (h <= t && v[t] >= vv) t--;
				Q[++t] = j, v[t] = vv;
				
				f[j] = min(f[j], tf);
			}
		}
		is[i].gs -= is[i].gs1;
	};
 	ll ans = 0;
	for (ll i = 0; i <= n2; i++) {
		if (f[i] <= X)
			ans = max(ans, i + gre(X - f[i]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
const int M=2e3+5;
int que[M],order[M],tmp[M],now[M],tot,top,n,k,q;
void in()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i)scanf("%d",&que[i]),order[i]=que[i];
}
void add(int le,int ri)
{
	tot=0;
//	printf("%d %d\n",le,ri);
	if(le>ri||ri-le+1<k)return;
//	printf("%d %d\n",le,ri);
	for(int i=le;i<=ri;++i)tmp[++tot]=que[i];
	sort(tmp+1,tmp+1+tot);
	for(int i=ri-le+2-k;i>=1;--i)now[++top]=tmp[i];
}
int test(int mn)
{
//	printf("test:%d\n",mn);
	int p=1;top=0;
	for(int i=1;i<=n;++i)if(que[i]<mn)add(p,i-1),p=i+1;
	if(top<q)return INT_MAX; 
	sort(now+1,now+1+top);
	return now[q]-mn;
}
void ac()
{
	int ans=INT_MAX;
	sort(order+1,order+1+n);que[++n]=-INT_MAX;
	for(int i=1;i<n;++i)ans=min(test(order[i]),ans);
	printf("%d",ans);
}
int main()
{
	in();ac();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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

  set<string> word;
  bool rule = true;
  char last_chara = '0';
  for (int i = 0; i < N; ++i)
  {
    string w;
    cin >> w;

    if (word.count(w) == 1) rule = false;
    else word.insert(w);

    if (i == 0)
    {
      last_chara = w[w.size() - 1];
      continue;
    }
    
    if (last_chara != w[0]) rule = false;
    last_chara = w[w.size() - 1];
  }

  if (rule == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
S = IS()
x = 0
max = 0
for s in S:
    if s =="I":
        x += 1
    else:
        x -= 1
    if max < x:
        max = x
print(max)

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

int main() {
    int N;
    cin >> N;
    int sum = 0, min_score = 1000;
    for (int i = 0; i < N; i++) {
        int s;
        cin >> s;
        sum += s;
        if (s % 10 != 0) {
            min_score = min(min_score, s);
        }
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
    } else {
        if (min_score != 1000) {
            cout << sum - min_score << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	SORT(A);

	int ans = 0;
	VI P, F;

	P.push_back(A[N - 1]);
	F.push_back(A[0]);

	ans += A[N - 1];
	ans -= A[0];

	FOR(i, 1, N - 1) {
		if (A[i] >= 0) {
			P.push_back(A[i]);
			ans += A[i];
		}
		else {
			F.push_back(A[i]);
			ans -= A[i];
		}
	}


	cout << ans << endl;

	FOR(i, 1, N - 1) {
		if (A[i] < 0) {
			cout << A[N - 1] << " " << A[i] << endl;
			A[N - 1] -= A[i];
		}
		else {
			cout << A[0] << " " << A[i] << endl;
			A[0] -= A[i];
		}
	}

	cout << A[N - 1] << " " << A[0] << endl;


	
	return 0;
}



Measured memory_bytes: 3572
#include<stdio.h>
int n,i;
int a[300000],b[300000],c[300000],d[300000];
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for (i=1;i<=n;i++)
	  scanf("%d",&b[i]);
	for (i=1;i<=n;i++)
	  c[i]=b[n-i+1];
	int flag=1;
	for (i=1;i<=n;i++)
	  if (c[i]==a[i])
	    flag=0;
	if (flag==1){
		printf("Yes\n");
		for (i=1;i<=n;i++)
		  printf("%d ",c[i]);
		return 0;
	}
	for (i=1;i<=n;i++)
	  d[(i+n/2)%n+1]=b[i];
	flag=1;
	for (i=1;i<=n;i++)
	  if (d[i]==a[i])
	    flag=0;
	if (flag==1){
		printf("Yes\n");
		for (i=1;i<=n;i++)
		  printf("%d ",d[i]);
		return 0;
	}
	printf("No");
}

Measured memory_bytes: 4872
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  char b;
  cin >> b;
  if(b == 'A')
    cout << 'T' << endl;
  else if(b == 'T')
    cout << 'A' << endl;
  else if(b == 'C')
    cout << 'G' << endl;
  else if(b == 'G')
    cout << 'C' << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

n = ni()
abc = []
for _ in range(n-1):
    a,b,c = li()
    a -= 1
    b -= 1
    abc.append((a,b,c))
q,k = li()
k -= 1
query = [li_() for _ in range(q)]

# 隣接リストつくる
graph = [[] for _ in range(n)]
for frm,to,cost in abc:
    graph[frm].append((cost,to))
    graph[to].append((cost,frm))

# 頂点Kをスタートとするダイクストラ
dist = dijkstra(graph, n, k)

# クエリ処理
for frm,to in query:
    print(dist[frm] + dist[to])

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

using namespace std;

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

    // solution comes here
    long long N, K, a, b, ans=0;
    cin >> N >> K;
    for(int i=1; i<=N; i++) {
        a = i%K;
        if(2*(K-a) == K) {
            b = N/K + (a <= N%K);
            ans += b*b;
        }
        if(0==a) {
            b = N/K;
            ans += b*b;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    char ch = scanner.next().charAt(0);
    if(ch >= 'a' && ch <= 'z')
      System.out.println('a');
    else
      System.out.println('A');
  }
}

Measured memory_bytes: 35648
#include <stdio.h>

int main(int argc, char *argv[])
{
	int S = 0;
	int h, m, s = 0;

	scanf("%d", &S);
	h = S / 3600;
	S %= 3600;
	m = S / 60;
	S %= 60;
	s = S;

	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int main(void){

double a,b;
string nam[] = {"AAA","AA","A","B","C","D","E"};
double r05[] ={35.5,37.5,40.0,43.0,50.0,55.0,70.0}; 
double r10[] ={71.0,77.0,83.0,89.0,105.0,116.0,148.0}; 
	while(cin >> a >> b){
		if(a==0 && b==0 || cin.eof()) break;
		string ans = "NA";
		rep(i,7) 
			if( a<r05[i] && b<r10[i] ){
				ans = nam[i];
				break;
			}
		cout << ans << endl;
	}
	
	
	return 0;
	
}

Measured memory_bytes: 1232