akhauriyash/Code-Regression huggingface dataset:
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

#define int __int64_t

int a[MAXN];

int prem[MAXN];

int n;

vector <int> mult(const vector <int>& a, const vector <int>& b) {
    vector <int> c(a.size());
    for (int i = 0; i < a.size(); i++) {
        c[i] = a[b[i]];
    }
    return c;
}

vector <int> binpow(vector <int>& a, int K) {
    int sz = a.size();
    vector <int> ans(sz);
    for (int i = 0; i < sz; i++) ans[i] = i;
    while(K) {
        if (K & 1) {
            ans = mult(ans, a);
        }
        a = mult(a, a);
        K >>= 1;
    }
    return ans;
}

main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    n = readInt();
    vector <int> d(n - 1);
    vector <int> perm(n - 1);
    for (int i = 0; i < n; i++) {
        a[i] = readInt();
    }
    for (int i = 0; i < n - 1; i++) {
        d[i] = a[i + 1] - a[i];
        perm[i] = i;
    }

    int M = readInt(), K = readInt();
    for (int i = 1; i <= M; i++) {
        int x = readInt() - 1;
        swap(perm[x - 1], perm[x]);
    }

    vector <int> kekekek = binpow(perm, K);
    int cur = a[0];
    for (int i = 0; i < n - 1; i++) {
        cout << cur << endl;
        cur += d[kekekek[i]];
    }
    cout << cur;
    return 0;
}




Measured memory_bytes: 8528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int k = ReadAndParseInt();
            var x = ReadAndParseIntArr();

            int ans = 0;
            for(int i=0;i<n;++i)
            {
                int distA = x[i] * 2;
                int distB = Math.Abs(k - x[i]) * 2;
                ans += Math.Min(distA, distB);
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

/*
	last verified	: 2020/09/17, AtCoder
		problem			: https://atcoder.jp/contests/abc142/tasks/abc142_d
		submission		: https://atcoder.jp/contests/abc142/submissions/16791669
*/
#include <iostream>
#include <vector>

std::vector<long long> divisors(long long n) {
	std::vector<long long> ret(0), st(0);
	for (int i = 1; i <= n / i; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i < n / i) st.push_back(n / i);
		}
	}
	while (st.size()) {
		ret.push_back(st.back());
		st.pop_back();
	}
	return ret;
}

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

	int n;
	cin >> n;
	long long ans = 0;
	for (int a = 1; a < n; a++) {
		for (int b = 1; a * b < n; b++) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
h, w = list(map(int, input().split()))

masu = h * w

if h == 1:
    print(1)
elif w == 1:
    print(1)
elif h * w % 2 == 0:
    print(int(masu / 2))
else:
    print(int(masu / 2) + 1)


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
c = 0

for i in range(1,n):
    if a[i-1] > a[i]:
        c += a[i-1] - a[i]
        a[i] += a[i-1] - a[i]
        
# print(a)
print(c)


Measured memory_bytes: 32156
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,i,x,y,z;
    string s;
    cin>>s;
    n=s.length();
    vector<pair<char,int> > v;
    v.push_back({s[0],0});
    m=0;
    for(i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
            continue;
        else
        {
            v[v.size()-1].second=i-m;
            if(i!=(n-1))
            v.push_back({s[i],i-m});
            else
            {
                v.push_back({s[i],1});
            }
            
            m=i;
        }
        
    }
    if(m!=(n-1) || v.size()==1)
    {
        v[v.size()-1].second=n-m;
    }
    int k=0,d=0;
    for(i=0;i<v.size();i++)
    {
        //cout<<v[i].second<<" "<<d<<endl;
        if(d==1)
        {
            k++;
            v[i].second--;
        }
        if((v[i].second%3)==0)
        {
            k+=2*(v[i].second/3);
        }
        else
        {
            k+=(2*(v[i].second/3)+1);
            //cout<<i<<k<<endl;
        }
       // cout<<v[i].second<<endl;    
        if((v[i].second%3)==2)
        {
            d=1;
        }
        else
        {
            d=0;
        }
    }
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 5512
/*
  A - Iroha and Haiku (ABC Edition)
  Contest 042
  Rakesh Kumar --> 02/08/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int n = 0;
    std::cin >> n;
    std::vector<int> v;
    n <<= 1;
    while (n--) {
        int l = 0;
        std::cin >> l;
        v.emplace_back(l);
    }
    std::sort(v.begin(), v.end());
    int sum = 0;
    for (std::size_t i = 0; i < v.size(); i += 2)
        sum += v[i];
    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 3508
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

string alpha="abcdefghijklmnopqrstuwvxyz";

int N;

int pow(int a){
    if(a==0) return 1;
    else return 10*pow(a-1);
}

int main(){
    cin>>N;
    rep(i,5){
        if(N==pow(i)){
            cout<<10<<endl;
            return 0;
        }
    }
    int ans=0;
    for(int i=4;i>=0;i--){
        ans+=(N/pow(i));
        N=N-(N/pow(i))*pow(i);
    }
    cout<<ans<<endl;




    return 0;
}




Measured memory_bytes: 256
n=int(input())

remains = []
while n > 26:
    if (n%26 == 0):
        remains.append(26)
        n = n//26 - 1
    else:
        remains.append(n%26)
        n = n//26 

remains.append(n)

ans = ''
for rem in remains:
    ans = ans + chr(ord('a')+ rem - 1)

print(ans[::-1])

Measured memory_bytes: 9176
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
bool cmp(char a,char b)
{
    return a<b;
}
bool cmp2(char a,char b)
{
    return a>b;
}
int main()
{
    string s,t;
    int i;
    while(cin>>s>>t)
    {
        int cs=s.length(),ct=t.length();
        if(cs>ct)
        {
            for(i=0;i<cs-ct;i++)
            {
                t=t+'0';
            }
        }
        if(ct>cs)
        {
            for(i=0;i<ct-cs;i++)
            {
                s=s+'}';
            }
        }
        int m=max(cs,ct);
        char ss[200],tt[200];
        for(i=0;i<m;i++)
        {
            ss[i]=s[i];
            tt[i]=t[i];
        }
        sort(ss,ss+m,cmp);
        sort(tt,tt+m,cmp2);
        /*int g[200]={0};
        for(i=0;i<m;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(ss[i]==tt[j]&&g[j]==0){ss[i]='{',tt[j]='{',g[j]=1;break;}
            }
        }
        for(i=0;i<m;i++)
        {
            cout<<ss[i];
        }
        cout<<endl;
        for(i=0;i<m;i++)
        {
            cout<<tt[i];
        }
        cout<<endl;*/
        int k=2;
        for(i=0;i<min(cs,ct);i++)
        {
            if(ss[i]<tt[i]){k=1;break;}
            if(ss[i]>tt[i]){k=0;break;}
        }
        if(k==2){if(cs>ct)cout<<"No"<<endl;else if(ct>cs)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
        else if(k==1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

typedef long long ll;
const int inf = 1e9;

ll n, money, t, stock;

int main(){
	cin>>n;
    money= 1000;
	stock = 0;
	vector<ll> vec(n, 0);
	for(int i = 0; i < n; ++i)cin>>vec[i];
	for(int i = 0; i < n; ++i){
		money += vec[i] * stock;
		stock = 0;
		if(i < n - 1 && vec[i] < vec[i + 1]){
			stock += money / vec[i];
			money %= vec[i];
		}
	}
	cout<<money<<endl;
	return 0;
}



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

int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    cout<<'x';
  }
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  string s;
  int k;
  cin >> s >> k;

  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] != 'a' && 'z' - s[i] + 1 <= k)
    {
      k -= ('z' - s[i] + 1);
      s[i] = 'a';
      // cout << 'K' << k << endl;
    }
    // cout << ':' << s << endl;
  }
  if (k > 0)
  {
    k %= 26;
    s[s.length() - 1] = 'a' + (s[s.length() - 1] + k - 'a') % 26;
  }
  cout << s << endl;
}

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

int const N = 100000, M = N << 1, md = 1e9 + 7;
int fc[M + 1], inv[M + 1], fcin[M + 1];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline int ch(int a, int b) { return (ll)fc[a] * fcin[b] % md * fcin[a - b] % md; }
inline int pw(int a, int p){
	int an = 1;
	while (p){
		if (p & 1)an = (ll)an * a % md;
		a = (ll)a * a % md;
		p >>= 1;
	}
	return an;
}

int main(){
	fc[0] = 1;
	f(i, 1, M + 1)fc[i] = (ll)fc[i - 1] * i % md;
	inv[1] = 1;
	f(i, 2, M + 1)inv[i] = md - md / i * (ll)inv[md % i] % md;
	fcin[0] = 1;
	f(i, 1, M + 1)fcin[i] = (ll)fcin[i - 1] * inv[i] % md;
	
	int n, a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	a = (ll)a * pw(100, md - 2) % md;
	b = (ll)b * pw(100, md - 2) % md;
	c = (ll)c * pw(100, md - 2) % md;
	int z = pw(a + b, md - 2);
	a = (ll)a * z % md;
	b = (ll)b * z % md;
	int an = 0;
	f(i, 0, n)ad(an, (ll)(i + n) * ch(i + n - 1, i) % md * pw(a, n) % md * pw(b, i) % md);
	f(i, 0, n)ad(an, (ll)(i + n) * ch(i + n - 1, i) % md * pw(a, i) % md * pw(b, n) % md);
	an = (ll)an * pw(1 - c + md, md - 2) % md;
	printf("%d\n", an);;
}

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

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

    auto friends = vector<int>(N);
    for (auto& x : friends)
    {
        cin >> x;
        x--;
    }

    auto result = 0;
    for (auto i = 0; i < N; i++) if (friends[friends[i]] == i)
        result++;

    cout << result/2 << endl;
}


Measured memory_bytes: 640
from itertools import combinations

N = int(input())

march = list("MARCH")
S = {m: 0 for m in march}
for _ in range(N):
    s = input()
    if s[0] in S:
        S[s[0]] += 1

c = combinations(march, 3)
ans = 0
for i, j, k in c:
    ans += S[i] * S[j] * S[k]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint A, B, C, X;
    cin >> A >> B >> C >> X;
    lint num_combinations = 0;
    range(i, 0, A + 1) range(j, 0, B + 1) range(k, 0, C + 1) {
        lint amount = 500 * i + 100 * j + 50 * k;
        if (amount == X) num_combinations += 1;
    }
    cout << num_combinations << "\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
/*
 * 选择排序思路：
 * 1. 进行n-1次循环，执行2、3、4操作
 * 2. 设置变量i标记已排序位置的末尾后一位
 * 3. 设置pos变量标记未排序中最小（大）数的位置
 * 4. 将i位置的值与pos位置的值进行交换
 * */

int selectionSort(int a[], int n){
    int count = 0;
    for (int i = 0; i < n-1; i++){
        int pos = i;
        for (int j = i; j < n; j++){
            if (a[j] < a[pos]){
                pos = j;
            }
        }
        swap(a[pos], a[i]);
        if (a[pos] != a[i]){
            count++;
        }
    }
    return count;
}

int main(){
    int n, a[100];
    cin>>n;
    for (int i = 0; i < n; i++){
        cin>>a[i];
    }
    int count = selectionSort(a, n);
    for (int i = 0; i < n; i++){
        if (i != n-1){
            cout<<a[i]<<" ";
        }else{
            cout<<a[i]<<endl;
        }
    }
    cout<<count<<endl;
}


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

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 998244353;

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<vector<ModInt>> dp(n + 1, vector<ModInt>(s + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s + 1; j++) {
            dp[i + 1][j] += dp[i][j] * 2;
            if (j - a[i] >= 0) dp[i + 1][j] += dp[i][j - a[i]];
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 73664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
 
#define REP(i,n) for(i=0;i<n;i++)
 
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}
 
long long llin() {
    long long i;
    scanf("%lld", &i);
    return i; 
}
 
double din() {
    double i;
    scanf("%lf", &i);
    return i;
}
 
char cin() {
    char c;
    scanf("%c", &c);
    return c;
}
 
void stin(char *s) {
    scanf("%s", s);
}
 
void iout(int i) {
    printf("%d\n", i);
}
 
void llout(long long i) {
    printf("%lld\n", i);
}
 
void dout(double i) {
    printf("%lf\n", i);
}
 
void cout(char c) {
    printf("%c\n", c);
}
 
void stout(char *s) {
    printf("%s\n", s);
}
 
int main() {
  	int i, n = iin();
  	int preT = 0, nowT, diffT, l = 0, y, x, diffL;
  	REP(i, n) {
    	nowT = iin(), y = iin(), x = iin();
      	diffT = nowT - preT;
      	diffL = y + x - l;
      	if (diffT < diffL || (diffT % 2) != (diffL % 2)) {
        	stout("No");
          	return 0;
        }
    }
  	stout("Yes");
    return 0;
}

Measured memory_bytes: 128
n=int(input())
c = [0,0,0,0]
for i in range(n):
    s = input()
    if s == 'AC':
        c[0] += 1
    elif s == 'WA':
        c[1] += 1
    elif s == 'TLE':
        c[2] += 1
    else:
        c[3] += 1

print(f'''AC x {c[0]}
WA x {c[1]}
TLE x {c[2]}
RE x {c[3]}''')

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

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

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    REP(_, M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        g[A].push_back(B);
        g[B].push_back(A);
    }

    vector<int> d(N, N);
    vector<int> target(N);
    queue<int> q;

    d[0] = 0;
    q.push(0);

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v: g[u]) {
            if (d[v] > d[u] + 1) {
                d[v] = d[u] + 1;
                target[v] = u;
                q.push(v);
            }
        }
    }

    cout << "Yes" << '\n';
    FOR(i, 1, N) {
        cout << (target[i] + 1) << '\n'; // 1-based indexing
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 10680
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

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

    ll h,w;
    cin>>h>>w;
    vector<string> v(h);
    FOR(i,0,h)cin>>v[i];

    vector<vector<ll>> vh(h,vector<ll>(w,0));
    vector<vector<ll>> vw(h,vector<ll>(w,0));

    FOR(i,0,h){
      FOR(j,0,w){
        if(v[i][j] == '.'){
          vh[i][j] = 1;
          vw[i][j] = 1;
        }
      }
    }

    FOR(i,1,h){
      FOR(j,0,w){
        if(vh[i][j] != 0)vh[i][j] += vh[i-1][j];
      }
    }

    FORr(i,0,h-2){
      FOR(j,0,w){
        if(vh[i][j] != 0)vh[i][j] = max(vh[i+1][j],vh[i][j]);
      }
    }

    FOR(i,0,h){
      FOR(j,1,w){
        if(vw[i][j] != 0)vw[i][j] += vw[i][j-1];
      }
    }

    FOR(i,0,h){
      FORr(j,0,w-2){
        if(vw[i][j] != 0)vw[i][j] = max(vw[i][j+1],vw[i][j]);
      }
    }

    ll ans = 0;
    FOR(i,0,h){
      FOR(j,0,w){
        ans = max(ans, vh[i][j] + vw[i][j] - 1);
      }
    }
    cout<<ans<<endl;





}


Measured memory_bytes: 67200
def main(argv)
  s = gets.chomp
  k = s.size
  
  a = s.count('o')
  b = 15 - k
  if (a + b) >= 8 then
    puts 'YES'
  else
    puts 'NO'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
const int mod = 1e9+7;
char s[maxd];
int dp[maxd][20];
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	scanf("%s",s+1);
	dp[0][0] = 1;
	for(int i=1;s[i];i++)
	{
		if(s[i] != '?')
		{
			int k = s[i] - '0';
			for(int j=0;j<13;j++)
				dp[i][(j*10+k)%13] = (1ll * dp[i][(j*10+k)%13] + dp[i-1][j])%mod;
		}
		else 
		{
			for(int k=0;k<10;k++)
				for(int j=0;j<13;j++)
					dp[i][(j*10+k)%13] = (1ll * dp[i][(k+j*10)%13] + dp[i-1][j])%mod;
		}
	}
	printf("%d",dp[strlen(s+1)][5]);
	return 0;
}

Measured memory_bytes: 8192
n = gets.chomp.to_i
s = gets.chomp.split("")
half=s.length/2

fir = []
answer = true
s.each_with_index do |word, i|
  if i < half
    fir << word
  else
    if fir[i-half] != word
      answer = false
      break
    else
    end
  end
end
if answer
  puts "Yes"

else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5,mod=1e9+7;
std::vector<ll> vtr[M];
ll sub[M],ways[M],fact[M],ifact[M],ans[M];
ll power(ll a,ll b)
{
	ll val=1;
	while(b)
	{
		if(b%2)
			val=(val*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return val;
}
void dfs(ll x,ll p)
{
	sub[x]=1;
	ways[x]=1;
	for(auto u:vtr[x])
	{
		if(u!=p)
		{
			dfs(u,x);
			sub[x]+=sub[u];
			ways[x]=(ways[x]*ways[u])%mod;
		}
	}
	ll res = fact[sub[x]-1];
	for(auto u:vtr[x])
	{
		if(u!=p)
			res=(res*ifact[sub[u]])%mod;
	}
	ways[x]=(ways[x]*res)%mod;
}
void solve(ll x,ll p,ll z)
{
	ll res = ways[x];
	res = (res*ifact[sub[x]-1])%mod;
	res = (res*fact[sub[1]-1])%mod;
	res = (res*ifact[sub[1]-sub[x]])%mod;
	res = (res*z)%mod;
	ans[x] = res;
	for(auto u:vtr[x])
	{
		if(u==p)
			continue;
		ll tf = ways[x];
		tf = (tf*ifact[sub[x]-1])%mod;
		tf = (tf*fact[sub[1]-sub[u]-1])%mod;
		tf = (tf*ifact[sub[1]-sub[x]])%mod;
		tf = (tf*fact[sub[u]])%mod;
		tf = (tf*power(ways[u],mod-2))%mod;
		tf = (tf*z)%mod;
		solve(u,x,tf);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	fact[0]=1;
	ifact[0]=1;
	for(ll i=1;i<=n;i++)
	{
		fact[i]=(fact[i-1]*i)%mod;
		ifact[i]=power(fact[i],mod-2)%mod;
	}
	for(ll i=1;i<n;i++)
	{
		ll u,v;
		cin>>u>>v;
		vtr[u].pb(v);
		vtr[v].pb(u);
	}
	dfs(1,0);
	solve(1,0,1);
	for(ll i=1;i<=n;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 22512
import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())
g = [[] for _ in range(3*n)]
for i in range(m):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    g[u].append(v+n)
    g[u+n].append(v+2*n)
    g[u+2*n].append(v)
s, t = map(int, input().split())
s, t = s-1, t-1

from collections import deque
q = deque()
visit = [-1]*(3*n)
q.append(s)
visit[s] = 0
while q:
    u = q.popleft()
    for v in g[u]:
        if visit[v] == -1:
            visit[v] = visit[u]+1
            q.append(v)
if visit[t] == -1:
    print(-1)
else:
    print(visit[t]//3)


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	string s;
	cin >> s;

	ll ans = 0;

	ans += s[0] - '0';
//	cout << ans << "\n";
	ans += ((s.size()-1) * 9);

	for (int i = 1; i < s.size(); ++i) {
		if (s[i] != '9') {
			cout << --ans << "\n";
			return 0;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define moda 998244353
#define pi 3.14159265358979323846
#define io ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cout<<x<<"\n";
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define F first
#define S second

const int N = 100*1000 + 5;
int height[N];
int cost[N];
int n;

int ab(int a)
{
    if(a < 0)
        a = (-1) * a;
    return a;
}

int costtoreach(int stone)
{
    if(cost[stone] != -1)
        return cost[stone];
    else if(stone == 1)
        cost[stone] = ab(height[stone] - height[stone - 1]) + costtoreach(stone - 1);
    else
        cost[stone] = min(ab(height[stone] - height[stone - 1]) + costtoreach(stone - 1), ab(height[stone] - height[stone - 2]) + costtoreach(stone - 2));
    return cost[stone];
}

int main()
{
    io
    cin >> n;

    for(int i = 0 ; i < n ; ++i)
        cin >> height[i];

    for(int i = 1 ; i < n ; ++i)
        cost[i] = -1;

    cost[0] = 0;

    cout << costtoreach(n - 1);

return 0;
}



Measured memory_bytes: 6736
n1 = int(input())
na2 = [int(i) for i in input().split()]

r3 = 0
t4 = 0

for i4 in range(n1):
    if na2[i4] > t4:
        r3 += na2[i4] - t4
    
    t4 = na2[i4]

print(r3)

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

using namespace std;

int main(int argc, char const *argv[])
{
    // Parse N
    int p,q,r;
    cin >> p >> q >> r;

    // P: A->B
    // Q: B->C
    // R: C->A
    std::vector<int> combination;
    combination.push_back(p+q); // A->B->C
    combination.push_back(r+q); // A->C->B
    combination.push_back(p+r); // B->A->C
    combination.push_back(q+r); // B->C->A
    combination.push_back(r+p); // C->A->B
    combination.push_back(q+p); // C->B->A
    
    // Solve the problem. 
    auto answer = min_element(combination.begin(), combination.end());


    // Result
    cout << *answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
int main() {
  cin >> s;
  bool res = false;
  for (lli i=0; i<=7; ++i) {
    string t = s.substr(0, 7-i) + s.substr(s.size()-i);
    if (t == "keyence") res = true;
  }
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	

	int N,M;
	cin >> N >> M;

	if (M == 0 && N==1) {
		cout << 0 << endl;
		return 0;
	}

	vector<int> s(M), c(M);
	vector<int> num(N + 1); // 0は使わない
	rep(i, M) {
		cin >> s[i] >> c[i];
		if (num[s[i]] == 0) {
			num[s[i]] = c[i];
		}
		else if (num[s[i]] != c[i]) {
			cout << -1 << endl;
			return 0;
		}


		if (s[i] == 1 && c[i] == 0) {
			if (N == 1) {
				cout << 0 << endl;
				return 0;
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		
	}

	if (num[1] == 0) {
		ans += pow(10, N - 1);
		for (int i = 2; i <= N; i++) {
			ans += num[i] * pow(10, N - i);
		}
	}
	else {
		for (int i = 1; i <= N; i++) {
			ans += num[i] * pow(10, N - i);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, a, b, c;
    std::cin >> n >> a >> b >> c;

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    auto dfs = [=](auto f, int idx, int a_, int b_, int c_) {
        if (idx == n) {
            return (std::min({ a_, b_, c_ }) > 0 ? abs(a - a_) + abs(b - b_) + abs(c - c_) - 30 : 1e9);
        }

        return std::min({ f(f, idx + 1, a_ + l[idx], b_, c_) + 10, f(f, idx + 1, a_, b_ + l[idx], c_) + 10, f(f, idx + 1, a_, b_, c_ + l[idx]) + 10, f(f, idx + 1, a_, b_, c_) });
    };

    std::cout << dfs(dfs, 0, 0, 0, 0) << std::endl;
}


Measured memory_bytes: 888
fun main (args:Array<String>){
    val numOfClass = readLine()!!.toInt()

    val anser = IntArray(numOfClass)
    readLine()!!.split(" ").forEachIndexed { index, s -> anser[s.toInt() - 1] = index + 1 }
    for (ans in anser) {
        print("${ans} ")
    }
}


Measured memory_bytes: 58208
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        if (s[i] == '?')
            s[i] = 'D';
    cout << s << endl;

}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end()); //小さい順に入れ替える
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    int n = 0, i, j, k, v;
    int a[100];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    
    printf("%d",a[0]);
        for(k = 1; k < n; k++) {
            printf(" %d",a[k]);
        }
    printf("\n");
        
    for(i = 1; i <= n-1; i++) {
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j + 1] = v;
        
        printf("%d",a[0]);
        for(k = 1; k < n; k++) {
            printf(" %d",a[k]);
        }
        printf("\n");
    }
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    const auto& pow = [](auto i) -> unsigned long{
        unsigned long r{1}, a{10};
        while(i){
            if(i & 1)r *= a;
            a *= a;
            i >>= 1;
        }
        return r;
    };
    vector a(21, vector<unsigned long>(21));
    unsigned long ans{0};
    for(unsigned long i{0}; i < N; ++i){
        string S;
        cin >> S;
        pair<unsigned long, unsigned long> tmp;
        if(count(begin(S), end(S), '.')){
            string T(begin(S), find(begin(S), end(S), '.')), U(find(begin(S), end(S), '.') + 1, end(S));
            tmp = {stol(T) * pow(size(U)) + stol(U), pow(size(U))};
            auto g = gcd(tmp.first, tmp.second);
            tmp.first /= g;
            tmp.second /= g;
        }else tmp = {stol(S), 1};
        unsigned long a2{0}, a5{0}, b2{0}, b5{0};
        while(tmp.first % 2 == 0){
            ++a2;
            tmp.first /= 2;
        }
        while(tmp.first % 5 == 0){
            ++a5;
            tmp.first /= 5;
        }
        while(tmp.second % 2 == 0){
            ++b2;
            tmp.second /= 2;
        }
        while(tmp.second % 5 == 0){
            ++b5;
            tmp.second /= 5;
        }
        a2 = min(a2, 10UL);
        a5 = min(a5, 10UL);
        for(unsigned long j{10 - a2 + b2}; j <= 20; ++j)for(unsigned long k{10 - a5 + b5}; k <= 20; ++k)ans += a[j][k];
        a[10 - b2 + a2][10 - b5 + a5]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        // final String N = sc.next();

        // final int a = sc.nextInt();
        // final int m = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        int[] arr = new int[3];
        for (int i = 0; i < 3; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);

        System.out.println(arr[0] + arr[1]);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 23252
// 2011/01/13 Tazoe

#include <iostream>
using namespace std;

void bdg_insert(int bdg[300][2], int& n_bdg, int i_bdg, int a)
{
	for(int i=n_bdg; i>i_bdg; i--){
		bdg[i][0] = bdg[i-1][0];
		bdg[i][1] = bdg[i-1][1];
	}

	bdg[i_bdg][0] = a;
	bdg[i_bdg][1] = bdg[i_bdg-1][1];

	n_bdg++;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int bdg[300][2];
		bdg[0][0] = 0;
		bdg[0][1] = 0;
		int n_bdg = 1;

		for(int i=0; i<n; i++){
			int m, a, b;
			cin >> m >> a >> b;

			int i_bdg = 0;
			while(i_bdg<n_bdg&&bdg[i_bdg][0]<a){
				i_bdg++;
			}
			if(i_bdg==n_bdg){
				bdg[n_bdg][0] = a;
				bdg[n_bdg][1] = m;
				n_bdg++;
				bdg[n_bdg][0] = b;
				bdg[n_bdg][1] = 0;
				n_bdg++;
				continue;
			}
			if(bdg[i_bdg][0]>a){
				bdg_insert(bdg, n_bdg, i_bdg, a);
			}
			while(i_bdg<n_bdg&&bdg[i_bdg][0]<b){
				bdg[i_bdg][1] += m;
				i_bdg++;
			}
			if(i_bdg==n_bdg){
				bdg[n_bdg][0] = b;
				bdg[n_bdg][1] = 0;
				n_bdg++;
				continue;
			}
			if(bdg[i_bdg][0]>b){
				bdg_insert(bdg, n_bdg, i_bdg, b);
				bdg[i_bdg][1] -= m;
			}
		}

		bool flg = true;
		for(int i=0; i<n_bdg; i++)
			if(bdg[i][1]>150){
				flg = false;
				break;
			}

		if(flg)
			cout << "OK" << endl;
		else
			cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K;
    cin>>N>>K;
    
    map<ll,ll> Ks;
    for(int i=1;i<33;i++){
        if((1LL<<i)&K){
            ll k=K-(1LL<<i);
            k|=(1LL<<i)-1;
            if(k<K) Ks[k]=0;
        }
    }
    
    Ks[K]=0;
    rep(i,N){
        ll a,b; cin>>a>>b;
        for(auto k:Ks){
            if((k.first&a)==a) Ks[k.first]+=b;
        }
    }
    ll mx=0;
    for(auto k:Ks) if(mx<k.second) mx=k.second;
    cout1(mx);
}

Measured memory_bytes: 256
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}*/
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	double f[105][105];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=d;j++)
	cin>>f[i][j];
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{
		double dis=0;
		for(int k=1;k<=d;k++)
		dis+=(f[i][k]-f[j][k])*(f[i][k]-f[j][k]);
		dis=sqrt(dis);
		if(dis==ceil(dis)) ans++;
	}
	cout<<ans<<endl;
}*/
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}*/
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r;
	cin>>l>>r;
	int dis=min(r-l,2019);
	l%=2019;
	r=l+dis;
	int ans=999999999;
	for(int i=l;i<=r;i++)
	for(int j=i+1;j<=r;j++)
	ans=min(ans,(i*j)%2019);
	cout<<ans;
}*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum1=0,sum2=0;
	cin>>n;
	int a[100010],f[100010];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum1+=a[i];
		if(i%2!=0) sum2+=a[i];
	}
	f[1]=sum2-sum1/2;
	for(int i=1;i<=n;i++)
	f[i+1]=a[i]-f[i];
	for(int i=1;i<=n;i++) cout<<f[i]*2<<" ";
}

Measured memory_bytes: 2048
N = input()
i_list = list(N)
i_list = [int(i) for i in i_list]

if i_list[0] == i_list[1] and i_list[1] == i_list[2]:
    print('Yes')
elif i_list[1] == i_list[2] and i_list[2] == i_list[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9168
H, W = map(int, input().split())
S = [input() for h in range(H)]

dp = [[0] * W for h in range(H)]
if S[0][0] == '#':
    dp[0][0] = 1

for h in range(1, H):
  if S[h][0] == '.':
    dp[h][0] = dp[h-1][0]
  else:
    if S[h-1][0] == '#':
      dp[h][0] = dp[h-1][0]
    else:
      dp[h][0] = dp[h-1][0] + 1

for w in range(1, W):
  if S[0][w] == '.':
    dp[0][w] = dp[0][w-1]
  else:
    if S[0][w-1] == '#':
      dp[0][w] = dp[0][w-1]
    else:
      dp[0][w] = dp[0][w-1] + 1

for h in range(1, H):
    for w in range(1, W):
        if S[h][w] == '.':
            dp[h][w] = min(dp[h][w-1], dp[h-1][w])
        else:
            if S[h][w-1] == S[h-1][w] == '.':
                dp[h][w] = min(dp[h-1][w], dp[h][w-1]) + 1
            elif S[h][w-1] == '#' and S[h-1][w] == '.':
                dp[h][w] = min(dp[h][w-1], dp[h-1][w]+1)
            elif S[h][w-1] == '.' and S[h-1][w] == '#':
                dp[h][w] = min(dp[h][w-1]+1, dp[h-1][w])
            else:
                dp[h][w] = min(dp[h][w-1], dp[h-1][w])


print(dp[H-1][W-1])

Measured memory_bytes: 3192
#include <iostream>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;
long long sum[3][100010] = {},a[100010],ans[100010];
pair<int,int> p[100010];
int main(){
	int i,n,q;
	cin >> n >> q;
	for(i=0;i<n;i++){
		cin >> a[i];
		sum[0][i+1] = sum[0][i];
		sum[1][i+1] = sum[1][i];
		sum[i&1][i+1] += a[i];
	}
	for(i=n;i>=1;i--){
		sum[2][i] = sum[2][i+1] + a[i-1];
	}
	for(i=0;i<q;i++){
		int x; cin >> x;
		p[i] = {x,i};
	}
	sort(p,p+q);
	int r = 0;
	for(i=0;i<q;i++){
		while(r<n  && abs(a[r+1] - p[i].first)<abs(a[r] - p[i].first)) r++;
		while(1){
			if(r==n){
				ans[p[i].second] = sum[!(n&1)][n];
				break;
			}
			int l = 2*r - n + 2;
			if(l>=0 && abs(a[l]-p[i].first)<=abs(a[r+1] - p[i].first)){
				ans[p[i].second] = sum[!(l&1)][l] + sum[2][r+2];
				break;
			}
			l = 2*r - n + 3;
			if(l>=0 && abs(a[l] - p[i].first)<=abs(a[r+1] - p[i].first)){
				ans[p[i].second] = sum[(l&1)][l] + sum[2][r+2];
				break;
			}
			r++;
		}
	}
	for(i=0;i<q;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"<<en
#define out(value) cout<<value<<en

int building[105][105];
int ranking[105][105];
bool done[105][105];

int ilumi_x[2][6]={{1,0,-1,-1,-1,0},{1,0,-1,0,1,1}};
int ilumi_y[2][6]={{0,1,1,0,-1,-1},{0,1,0,-1,1,-1}};

int main(){
  int w,h;
  cin>>w>>h;
  
  for(int i=1; i<=h; i++) for(int j=1; j<=w; j++){
    cin>>building[i][j];
    done[i][j]=false;
    if(building[i][j]) continue;
    if(i==1||j==1||i==h||j==w) ranking[i][j]=1;
  }
  
//  cout<<endl<<en
//  for(int i=1; i<=h; i++){
//    for(int j=1; j<=w; j++){
//      if(i%2==0) cout<<building[i][j]<<" ";
//      else cout<<" "<<building[i][j];
//    }
//    cout<<en
//  }
//  cout<<en
  
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(done[i][j]) continue;
      if(building[i][j]) continue;
      if(i==1||i==h||j==1||j==w){
        ranking[i][j]=1;
        done[i][j]=1;
        stack<P> que;
        que.push(mk(i,j));
        while(!que.empty()){
          P p=que.top(); que.pop();
          int yy=p.first,xx=p.second;
//          cout<<"               yy: "<<yy<<"   xx: "<<xx<<en
          for(int k=0; k<6; k++){
            int x=xx+ilumi_x[yy%2][k];
            int y=yy+ilumi_y[yy%2][k];
            if(x<1||x>w||y<1||y>h) continue;
            if(done[y][x]==1) continue;
            if(building[y][x]==1) continue;
              
            done[y][x]=1;
            ranking[y][x]=1;
            que.push(mk(y,x));
          }
        }
      }
    }
  }
  
  
  
//  cout<<endl<<en
//  for(int i=1; i<=h; i++){
//    for(int j=1; j<=w; j++){
//      if(i%2==0) cout<<ranking[i][j]<<" ";
//      else cout<<" "<<ranking[i][j];
//    }
//    cout<<en
//  }
//  cout<<en
  
  int ans=0;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(building[i][j]==0) continue;
      for(int k=0; k<6; k++){
        int x=j+ilumi_x[i%2][k];
        int y=i+ilumi_y[i%2][k];
        
        if(y<1||y>h||x<1||x>w) {
          ans++;
          continue;
        }
        if(ranking[y][x]==1) ans++;
      }
    }
  }
  cout<<ans<<en
}



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

using ll = long long;
using P = pair<int, int>;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = 100; i > 0; i--)
    {
        if (A % i == 0 && B % i == 0)
        {
            K--;
            if (K == 0)
                cout << i << endl;
        }
    }
    return 0;
}

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

int main() {

  int a,b,c,d,e,f;

  cin >> a>>b>>c ;
  d=max(a,(max(b,c)));
  f=min(a,(min(b,c)));
  if(a!=max(a,(max(b,c)))&&a!=min(a,(min(b,c)))) {
    e=a;
  }
  else if(b!=max(a,(max(b,c)))&&b!=min(a,(min(b,c)))){
e=b;
  }
          else{
            e=c;
          }
  cout<<d-f<<endl;
}


Measured memory_bytes: 256