akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int f(int a,int b,int c,int i,int j)
{int x;
 if((j<=b)||(i>=c)){x=j-i;}
 else if(b<=i&&j<=c){x=min(j-i,c-b+1-j+i);}
 else if(i<=b&&b<=j&&j<=c){x=min(j-i,c+b+1-j-i);}
 else if(i<=b&&j>=c){x=j-c+b-i+1;}
 else if(b<=i&&i<=c&&c<=j){x=min(j-i,j-b-c+i+1);}
 return x;
  
/*  j-i 11,33
j-i <c-b+1-(j-i) 22
j-i<c-b+1-(j-b)+(b-i) 12
j-c+b-i+1 13
  j-i<j-c+c-b+1-c+i*/
}
 

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> k(a-1);
for(int j=0;j<a;j++){for(int i=0;i<j;i++){
k.at(f(a,b,c,i+1,j+1)-1)+=1;}}
 
for (int i = 0; i < a-1; i++) {
  cout<<k.at(i)<<endl;
}
 
}

Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

typedef std::vector<char> TLongInt;
TLongInt Decode(const std::string& Code)
{
    std::vector<char> Value(100, 0);
    for(int i = 0; i < Code.size(); ++i){
        Value[i] = Code[Code.size() -1 -i] - '0';
    }
    return Value;
}
TLongInt Add(const TLongInt& A, const TLongInt& B)
{
    assert(A.size() == B.size());
    TLongInt C(A.size(), 0);
    int kuriagari = 0;
    for(int i = 0; i < A.size(); ++i){
        int V = A[i] + B[i] + kuriagari;
        C[i] = V % 10;
        kuriagari = V / 10;
    }
    return C;
}

void Print(const TLongInt& Value, std::ostream& out)
{
    bool Left = true;
    for(int i = Value.size() - 1; i >= 0; --i){
        if(Value[i] == 0 && Left) continue;
        if(i >= 80){
            out << "overflow" << std::endl;
            return;
        }
        Left = false;
        out << int(Value[i]);
    }
    if(Left) out << "0";
    out << std::endl;
}

int main()
{
    int N;
    std::cin >> N;
    for(int i = 0; i < N; ++i){
        std::string first, second;
        std::cin >> first;
        std::cin >> second;
        Print(Add(Decode(first), Decode(second)), std::cout);
    }
    return 0;
}

Measured memory_bytes: 3220
#include <iostream>

void exchange(int a, int *n_1000, int *n_5000, int *n_10000){
    if (a == 1000) // 5*1000 to 5000
    {
        *n_1000 -= 5;
        *n_5000 += 1;
    }
    else if (a == 5000) // 2*5000 to 10000
    {
        *n_5000 -= 2;
        *n_10000 += 1;
    }
    else
    {
        std::cout << "Error" << std::endl;
    }
}

int main(){
    int n, y;
    std::cin >> n >> y;
    int n_1000 = y / 1000;
    int n_5000 = 0;
    int n_10000 = 0;

    if (n == n_1000)
    {
        std::cout << n_10000 << " " << n_5000 << " " << n_1000 <<std::endl;
        return 0;
    }
    
    while (n_1000 >= 5)
    {
        exchange(1000, &n_1000, &n_5000, &n_10000);
        if (n_1000 + n_5000 + n_10000 == n)
        {
            std::cout << n_10000 << " " << n_5000 << " " << n_1000 <<std::endl;
            return 0;
        }
        int count = 0;
        while (n_5000 >= 2)
        {
            exchange(5000, &n_1000, &n_5000, &n_10000);
            count++;
            if (n_1000 + n_5000 + n_10000 == n)
            {
                std::cout << n_10000 << " " << n_5000 << " " << n_1000 <<std::endl;
                return 0;
            }
        }
        n_5000 += 2 * count;
        n_10000 -= count;
    }
    std::cout << "-1 -1 -1" << std::endl;
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	string s;
	cin >> s;

	int ans = 0;
	int pre = s[0];

	rep(i, sz(s)) {
		if (pre != s[i]) {
			ans++;
			pre = s[i];
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> a;
  tools::read(a, N);
  std::vector<i64> b({0});
  std::partial_sum(a.begin(), a.end(), std::back_inserter(b));
  std::vector<i64> c;
  for (i64 i = 0; i < N; ++i) {
    for (i64 j = i + 1; j <= N; ++j) {
      c.push_back(b[j] - b[i]);
    }
  }
  i64 answer = 0;
  for (i64 shift = 63; shift >= 0; --shift) {
    std::vector<i64> d;
    for (const i64& c_i : c) {
      if ((c_i >> shift) & 1) {
        d.push_back(c_i);
      }
    }
    if (static_cast<i64>(d.size()) >= K) {
      answer |= static_cast<i64>(1) << shift;
      c = std::move(d);
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 6524
#include <cstdio>
#include <cstring>
#include <algorithm>

int n, m, c;
int a[22][22];
int b[22];

int main(){
	scanf("%d %d %d", &n, &m, &c);
	for(int i = 1; i <= m; i++) scanf("%d", &b[i]);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int tmp = 0;
		for(int j = 1; j <= m; j++)
			tmp += a[i][j] * b[j];
		if(tmp + c > 0) ans++;
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    vector<int> a(n+1);
    rep(i,n) cin>>a[i+1];
    ll dp[n+1][3];
    rep(i,n+1){
        rep(j,3) dp[i][j]=0;
    }
    ll ans=1;
    for(int i=1;i<=n;i++){
        int target=a[i];
        int cnt=0;
        int idx=-1;
        rep(j,3){
            if(dp[i-1][j]==target){
                cnt++;idx=j;
            }
        }
        if(cnt==0){
            cout<<0<<endl;return 0;
        }
        ans=(ans*cnt)%mod;
        rep(j,3){
            if(j==idx)dp[i][j]=dp[i-1][j]+1;
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    if( (s[0] == s[1] || s[2] == s[3] ) && s[1] == s[2] ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

char s[200002];
int main(){
	int n,a,b,c,d;
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	int r1=a,r2=b;
	for(;;){
		if(r1<n&&s[r1+1]!='#')r1++;
		else if(r1<n-1&&s[r1+2]!='#')r1+=2;
		else if(r2<n&&s[r2+1]!='#')r2++;
		else if(r2<n-1&&s[r2+2]!='#')r2+=2;
		else break;
	}
	if(!(c<=r1)||!(d<=r2)){
		printf("No\n");
		return 0;
	}
	if(c>d){
		bool ok=1;
		for(int i=b-1;i+1<=d;i++)
			if(i+2<=r1&&s[i]!='#'&&s[i+1]!='#'&&s[i+2]!='#')
				ok=0;
		if(ok){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	
}

Measured memory_bytes: 1784
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
ans = []
for i in range(a, a+k):
  if i >= a and i <= b:
    ans.append(i)

for i in range(b-k+1, b+1):
  if not i in ans and i >= a and i <= b:
    ans.append(i)

for i in ans:
  print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
ll modfact(ll x,ll mod){
    ll res = 1;
    for (ll i = 1; i <= x;i++){
        (res *= i) %= mod;
    }
    return res;
}
int main() {
ll n,m;
cin >> n >> m;
ll ans = 1;
if(abs(n-m)>1){
    cout << "0" << endl;
    return 0;
}
if(n!=m){
    ans *= modfact(n, MOD);
    ans %= MOD;
    ans *= modfact(m, MOD);
    ans %= MOD;
}
else{
    ans *= modfact(n, MOD);
    ans %= MOD;
    ans *= modfact(m, MOD);
    ans %= MOD;
    ans *= 2;
    ans %= MOD;
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;


int main(){
    int N,M;cin >> N >>M;
    vector<vector<int> >G(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    int s,t;
    cin >> s >> t;
    s--;t--;
    vector<vector<int> > dist(N,vector<int>(3,-1));
    dist[s][0]=0;
    queue<pair<int,int> >que;
    que.push(make_pair(s,0));
    while(!que.empty()){
        pair<int,int> v = que.front();que.pop();

        for(auto &&nv:G[v.first]){
            if(v.second<2){
                if(dist[nv][v.second+1]!=-1)continue;
                dist[nv][v.second+1]=dist[v.first][v.second];
                que.push(make_pair(nv,v.second+1));
            }else{
                if(dist[nv][0]!=-1)continue;
                dist[nv][0]=dist[v.first][v.second]+1;
                que.push(make_pair(nv,0));
            }
        }
    }

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

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll n;
    cin>>n;
    ll num=n;
    ll x=0;
    while(n!=0)
    {
        x+=(n%10);
        n/=10;
    }

    if(num%x==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
#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++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    for (int i = 0; i < N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    ll t;
    for (int i = 0; i < N; i++) {
        t = 0; //S[i] + F[i];
        for (int j = i; j < N-1; j++) {
            if (t <= S[j]) {
                t = S[j];
            }
            else if (t % F[j] == 0) ;
            else t += F[j] - t%F[j];
            t += C[j];
        }
        cout << t << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll h; cin >> h;
    ll w; cin >> w;
    ll n; cin >> n;
    ll nagai = max(h, w);
    cout << (n+nagai-1) / nagai << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = [0]*n
g = [0]*n
b = [0]*n
if s[0] == "R": r[0] = 1
elif s[0] == "G": g[0] = 1
else: b[0] = 1
for i in range(1,n):
    if s[i] == "R": r[i] = 1
    elif s[i] == "G": g[i] = 1
    else: b[i] = 1
    r[i] += r[i-1]
    g[i] += g[i-1]
    b[i] += b[i-1]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]: continue
        d = j - i
        t = (s[i],s[j])
        if "R" not in t:
            ans += r[n-1]-r[j]
            if j+d >= n: continue
            if s[j+d] == "R": ans -= 1
        elif "G" not in t:
            ans += g[n-1]-g[j]
            if j+d >= n: continue
            if s[j+d] == "G": ans -= 1
        else:
            ans += b[n-1]-b[j]
            if j+d >= n: continue
            if s[j+d] == "B": ans -= 1
        
print(ans)
            






Measured memory_bytes: 74480
<?php
  fscanf(STDIN, "%s", $s);
  fscanf(STDIN, "%s", $t);

  $s .= $s;
  $n = strlen($t);

  $ans = false;
  for ($i=0; $i<$n; $i++) {
    if (substr($s, $i, $n) == $t) $ans = true;
  }

  echo ($ans? "Yes" : "No") . "\n";

Measured memory_bytes: 4604
import java.util.*;
import java.io.*;

class Main{
	public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
    	while(sc.hasNext()){
         int ans=sc.nextInt()%39;
         if(ans==0)ans=39;
         if(ans<10)System.out.println("3C0"+ans);
         else System.out.println("3C"+ans);
    	}    
	}
	}

Measured memory_bytes: 17172
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;
const int mod = 998244353;
vector<ll> fac;
vector<ll> ifac;

ll binmodulo(ll x, ll y){
    
    ll res = 1;
    while(y){
        if(y&1){
            res = res*x%mod;
        }
        y>>=1;
        x = x*x%mod;
    }
    return res;
}

void precompute(int n){
    fac.resize(n+1,1);
    ifac.resize(n+1,1);
    for(int i =1; i <=n; i++){
        fac[i] = i*fac[i-1]%mod;
    }
    ifac[n] = binmodulo(fac[n], mod-2);
    for(int i = n-1; i>0; i--){
        ifac[i] = (i+1)*ifac[i+1]%mod;
    }
}

ll ncr(ll n, ll r){
    if(r==0) return 1;
    return fac[n]*ifac[n-r]%mod*ifac[r]%mod;
}

int main(){
    Shazam;
    ll n,m,k; 
    cin>>n>>m>>k;
    precompute(4e5 + 10);
    auto add = [&](ll &a, ll b){
        a = (a%mod + b%mod)%mod;
    };
    ll ans = 0;
    for(int i = 0 ; i <= k ; i++){
        add(ans, m*ncr(n-1,i)%mod*binmodulo(m-1,n-1-i)%mod);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

ll d(string a, string b)
{
  return llabs(stoll(a) - stoll(b));
}

int main()
{
  string S; cin >> S;
  string T = "0123456789";
  string ans = S;
  int sz = S.size();
  do {
    string t = T.substr(0, sz);
    if(min(d(S, ans), (ll)pow(10, sz) - d(S, ans)) <
       min(d(S, t), (ll)pow(10, sz) - d(S, t))) {
      ans = t;
    }
  } while(next_permutation(T.begin(), T.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3400
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

const int nmax=100010;
const int alone = -1; 
int N,M;
int uni[nmax]; // if the value is less than 0, node i is a root node, and -uni[i] is the number of node conneced to node[i] including itsself. 
ll hight[nmax]; 
bool good[nmax];
int n, m;

int main() {
    int i,j; 
    int a,b;

    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m ;
    rep(i,n) uni[i]= alone;

    rep(i,n){
        ll x;
        cin >> x;
        hight[i] = x;
        good[i] = true;
    }
    rep(i,m){
        cin >> a >> b;
        a --; 
        b --;
        if (hight[a]<hight[b]){
            good[a] = false;
        } else if (hight[a] > hight[b]){
            good[b] = false;
        } else {
            good[a] = false; 
            good[b] = false;
        }
    }
    
    int ans = 0; 
    rep(i,n){
        if (good[i]){
            // cout << "good " << i+1 << endl;
            ans ++;}
    }
    cout << ans << endl;
        
}


Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS

    while(true) {
        int n, r;
        cin >> n >> r;
        if (n == 0) break;
        vector<int> v(n);
        iota(RALL(v),1);
        REP(i,r) {
            int p, c;
            cin >> p >> c;
            p--;
            vector<int> tmp(v.begin()+p,v.begin()+p+c);
            tmp.insert(tmp.end(),v.begin(),v.begin()+p);
            tmp.insert(tmp.end(),v.begin()+p+c,v.end());
            swap(v,tmp);
        }
        cout << v[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			seconchutd
#define 	ll 			long long
#define     ld 			long double
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		100005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
ll a[105],n;
ll dp[100008];
bool fun(ll i){
	bool ans=0;

	if(dp[i]!=-1)return dp[i];
	for(int j=0;j<n;++j){
		if(i>=a[j])ans=(ans||!fun(i-a[j]));
	}
	return dp[i]=ans;
}
int main() {

  boost;
  ll k,mn=99999999;
  ms(dp,-1);
  cin>>n>>k;
  for(ll i=0;i<n;i++){cin>>a[i];mn=min(mn,a[i]);dp[a[i]]=1;}
  for(ll i=0;i<mn;++i)dp[i]=0;
  if(fun(k))cout<<"First";
  else cout<<"Second";
  //cout<<"\n";for(ll i=0;i<=k;++i)cout<<i<<" "<<dp[i]<<"\n"

     return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, val;
    cin >> n;
    vector<pair<int, int>> arr;
    for(int i = 0; i < n; i++) {
        cin >> val;
        arr.push_back({val, i+1});
    }
    sort(arr.begin(), arr.end());
    for(auto& p: arr)
        cout << p.second << " ";
    return 0;
}




Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    sort(a,a+n);
    long long int ans=0,j=0;
    while(k--)
    {
        ans+=a[j];
        j++;
    }
    cout<<ans;
return 0;
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    struct Task {
        ll A, B;
    };
    vector<Task> tasks(N);
    for (ll i = 0; i < N; i++) {
        cin >> tasks[i].A >> tasks[i].B;
    }
    sort(tasks.begin(), tasks.end(), [](Task& lhs, Task& rhs) {
        return lhs.B < rhs.B;
    });

    bool ans = true;
    ll time = 0;
    for (Task t : tasks) {
        if ((time += t.A) > t.B) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int T = 1, A = 1;
    int t, a;
    rep(i, N) {
        cin >> t >> a;
        int K = max(T / t, A / a);
        while(true) {
            if (K * t < T || K * a < A) {
                K++;
                continue;
            }
            else {
                T = K * t;
                A = K * a;
                break;
            }
        }
    }
    cout << T + A << endl;

    return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1 + (n - k) / (k - 1);
    if ((n - k) % (k - 1) != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

ll n, m;
long double a[114514];

int main(){
  cin >> n >> m;
  priority_queue<long double> pq;
  for(int i=0;i<n;i++){
    cin >> a[i];
    pq.push(a[i]);
  }
  
  for(int i=0;i<m;i++){
    long double top = pq.top(); pq.pop();
    pq.push(top / 2);
  }
  ll ans = 0;
  for(int i=0;i<n;i++){
   	ans += (ll) (pq.top()); pq.pop();
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll s=0;
  rep(i,n) s^=a[i];
  rep(i,n) {
    if(i) cout << " ";
    cout << (s^a[i]);
  }
  ln;
}

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


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

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

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

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    ll H,W,N;
    cin>>H>>W>>N;
    map<P,ll> m;
    vector<P> v(N);
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        m[make_pair(a,b)] = 1;
        v[i] = make_pair(a,b);
    }
    vector<ll> ans(10,0);
    rep(i,N){
        ll x = v[i].first, y = v[i].second;
        rep(j,9){
            ll cnt = 0;
            bool E = true;
            rep(k,9){
                ll nx = x+((j+k)%3-j%3);
                ll ny = y + (((j+k)%9)/3-j/3);
                if(nx<0||nx>=H||ny<0||ny>=W) E = false;
                else if(m[make_pair(nx,ny)]) cnt++;
            }
            if(E) ans[cnt]++;
        }
    }
    for(int i = 1; i < 10; i++) ans[i]/=i;
    ans[0] = (H-2)*(W-2);
    for(int i = 1; i < 10; i++) ans[0]-=ans[i];
    for(auto x:ans) cout<<x<<endl;
}

Measured memory_bytes: 160968
from collections import deque

line1 = input()
n, k = [int(num) for num in line1.split(" ")]
line2 = input()
h = [int(num) for num in line2.split(" ")]

d = deque([0], k)

for i in range(1, len(h)):
    min_cost = float("inf")
    for j,cost in enumerate(reversed(d)):
        steps_taken = j+1
        if i-steps_taken < 0: break
        step_cost = abs(h[i]-h[i-steps_taken])
        min_cost = min(min_cost, cost + abs(h[i]-h[i-steps_taken]))
        if step_cost == 0: break
    d.append(min_cost)

print(d[-1])

Measured memory_bytes: 55684
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b;
      cin >> a >> b;
      if((a*b)%2==1) cout << "Odd" << endl;
      else cout << "Even" << endl;
      return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INF 1ll<<63 - 1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair<pair<ll,ll>, ll> 
#define pii pair< int, pair<int,int> >
vector<ll> v[100005];
vector<ll> path;
ll flag;
ll dis[100005];
void dfs(ll top, ll par,ll des){
	if(flag) return;
	path.pb(top);
	if(top == des){
		flag = 1;
		return;
	}
	for(ll i=0;i<v[top].size();i++){
		if(v[top][i] != par){
			dfs(v[top][i], top,des);
		}
	}
	if(flag) return;
	path.pop_back();
}
void dfs2(ll top, ll par){
	dis[top] = 0;
	for(ll i=0;i<v[top].size();i++){
		if(v[top][i] != par){
			dfs2(v[top][i],top);
			dis[top] = max(dis[top],dis[v[top][i]]+1);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,x,y,q,z,k,n,m,xx,yy;
    cin>>n>>xx>>yy;
    rep(i,1,n-1){
    	cin>>x>>y;
    	v[x].pb(y);
    	v[y].pb(x);
	}
	dfs(yy,-1,xx);
	z = (int)path.size();
	ll mid  = path[(z+1)/2 ];
	ll par  = path[(z+1)/2 - 1];
	dfs2(mid,par);
	ll ans = dis[mid] + z/2;
	if(z%2 == 0){
		ans--;
	}
	cout<<ans;
}

Measured memory_bytes: 14496
import sys
input = sys.stdin.readline

N=int(input())
xyh = sorted([ list(map(int,input().split())) for _ in range(N)],key = lambda x:-x[2])

if N==1:
    print(xyh[0],xyh[1],xyh[2])
else:
    for cx in range(101):
        for cy in range(101):
            flag = 0
            dx = abs(cx - xyh[0][0])
            dy = abs(cy - xyh[0][1])
            hmax = xyh[0][2]+dx+dy
            for i in range(1,N):
                if max(hmax -( abs(cx - xyh[i][0])+abs(cy - xyh[i][1])),0) !=  xyh[i][2]:
                    flag = 1
                    break
            if flag == 0:
                print(cx,cy,hmax)
                exit()

        


Measured memory_bytes: 9128
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll dp[100001];
int a[100000],m;
ll dfs(int p,int n){
  ll tmp;
  if(p==n) return 1;
  if(p>n) return 0;
  tmp+=dfs(p+1,n);
  tmp+=dfs(p+2,n);
  return tmp;
}
int main() {
  int n;
  ll ans=1;
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>a[i];
  dp[0]=1;dp[1]=1;
  int p=0;
  if(a[0]==1) {
    dp[1]=0;
    p++;
  }//cout<<dp[0]<<" "<<dp[1]<<endl;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+dp[i-2];
    dp[i]%=1000000007;//cout<<i<<" "<<dp[i]<<endl;
    if(dp[i]==0) break;
    if(i==a[p]){
      p++;
      dp[i]=0;
    }
  }
  cout<<dp[n]%1000000007;
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
string st;
int c;
int main()
{
    cin>>st;
    for(int i=0;i<st.size();i++)
    {
        if(st[i]=='C') c++;
        if(c!=0) 
          if(st[i]=='F') {cout<<"Yes"<<endl;return 0;}

    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
	int N,K;
	cin >> N>>K;
	vector<int>A(N);
	for (int i = 0;i<N;++i) {
		cin >> A[i];
	}
	int ans = (N-1)/(K-1);
	if (0 != (N-1)%(K-1)) {
		ans++;
	}
	cout << ans <<  endl;
}


Measured memory_bytes: 3728
# -*- coding: utf-8 -*-
	
def isSmall(c):
	return ord(c)>= ord('a') and ord(c)<=ord('z')

# 文字列の入力
s = raw_input()
sl=list(s)

if sl[0]=='A' and sl[2:-1].count('C')==1 and len([c for c in sl if not isSmall(c)] )==2:
	print 'AC'
else:
	print 'WA'


Measured memory_bytes: 2568
N, M = map(int, input().split())

ans = dict()
for i in range(1, N+1):
    ans[i] = 0

for i in range(M):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += 1
    if b in ans:
        ans[b] += 1
        
ans = sorted(ans.items(), key=lambda x:x[0])
for k, v in ans:
    print(v)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 10001;
vii edges;
int c[N], label[N], ans=0;

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    memset(label, -1, sizeof(label));
    cin>>n; edges.resize(n-1);
    FOR(i, 0, n-1) {
    	cin>>edges[i].ff >> edges[i].ss;
    	edges[i].ff--; edges[i].ss--;
    }
    FOR(i, 0, n) cin>>c[i];
    sort(c, c+n, greater<int>());
    label[edges[0].ff]=c[0]; label[edges[0].ss]=c[1];
    FOR(i, 2, n) {
    	ans += c[i];
    	int curr = -1;
    	FOR(j, 0, n-1) {
    		if(label[edges[j].ff] != -1 ^ label[edges[j].ss] != -1) {
    			curr = edges[j].ff;
    			if(label[curr] != -1) curr = edges[j].ss;
    			break;
    		}
    	}
    	label[curr]=c[i];
    }
    ans += c[1];
    cout<<ans<<endl;
    FOR(i, 0, n) {
    	cout<<label[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll dp[3333][3333][4];
ll a[3333][3333];

void Main() {
  ll n,m,t;
  cin >> n >> m >> t;
  rep(i,t) {
    ll x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    a[x][y]=z;
  }
  rep(i,n)rep(j,m)rep(k,4) dp[i][j][k]=-MAXL;
  dp[0][0][0]=0;
  ll ans=0;
  rep(i,n) {
    rep(j,m) {
      rrep(k,4) {
        if(k+1<4) dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      }
      rep(k,4) {
        if(j+1<m) dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        if(i+1<n) dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
      }
      rep(k,4) ans=max(ans,dp[i][j][k]);
    }
  }
  pr(ans);
}

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


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

using namespace std;

int main() {
	int a[3], k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a + 3);
	for(int i = 0; i < k; i++) a[2] *= 2;
	int sum = 0;
	for(int i = 0; i < 3; i++) sum += a[i];
	cout << sum << endl;
	return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int MAX = 1000000;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            var hamming = new List<int>();
            int j2 = 0, j3 = 0, j5 = 0;
            int x2 = 1, x3 = 1, x5 = 1;
            int min = 0;

            for (int i = 0; min < MAX; i++)
            {
                min = x2;
                if (x3 < min) min = x3;
                if (x5 < min) min = x5;

                hamming.Add(min);

                while (x2 <= min) x2 = 2 * hamming[j2++];
                while (x3 <= min) x3 = 3 * hamming[j3++];
                while (x5 <= min) x5 = 5 * hamming[j5++];
            }

            while (true)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if (input[0] == 0) break;

                int l = LowerBound(hamming, input[0]);
                int r = UpperBound(hamming, input[1]);

                sb.AppendLine((r - l).ToString());
            }
            Console.Write(sb);
        }

        static int LowerBound(List<int> arr, int value)
        {
            int low = 0, high = arr.Count;

            while (low < high)
            {
                int mid = ((high - low) >> 1) + low;

                if (arr[mid] < value) low = mid + 1;
                else high = mid;
            }
            return low;
        }

        static int UpperBound(List<int> arr, int value)
        {
            int low = 0, high = arr.Count;

            while (low < high)
            {
                int mid = ((high - low) >> 1) + low;

                if (arr[mid] <= value) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

Measured memory_bytes: 9236
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	int i;
	string op;
	for(;;){
		cin>>a>>op>>b;
		if(op == "+"){
			i = a+b;
		} else if(op == "-"){
			i = a-b;
		} else if(op == "*"){
			i = a*b;
		} else if(op == "/"){
			i = a/b;
		} else if(op == "?"){
			break;
		}
		cout<<i<<endl;
	}

	return 0;
}

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

int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    // クエリ処理
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 4456
#include <stdio.h>

int main(){
	int x, y, X, Y, I;
	int A[100];
	int B[100];
	int C[100];
	int i=0;
	int tmp;
	while(scanf("%d%d", &x, &y)!=EOF)
	{
		X=x;
		Y=y;
		if(y>x)
		{
			tmp=x;
			x=y;
			y=tmp;
		}
		while(1)
		{
			x=x%y;
			tmp=x;
			x=y;
			y=tmp;
			if(y==0)
			{
				I=i;
				break;
			}
		}
		A[i]=x;
		B[i]=X/A[i]*Y;
		i++;
	}
	for(i=0;i<I+1;i++)
	{
		printf("%d %d\n", A[i], B[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    char c_k = s[k - 1];
    for(int i = 0; i < n; ++i){
        if(s[i] != c_k){
            s[i] = '*';
        }
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n, s, sum = 0, min = 105;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        sum += s;
        if (s % 10 != 0) {
            if (s < min) min = s;
        }
    }
    if (min == 105) cout << 0;
    else if (sum % 10 != 0) cout << sum;
    else cout << sum - min;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = sc.nextInt();
      
      int[] pos = new int[n];
      for(int i = 0; i < n; i++)
        pos[i] = sc.nextInt();
      Arrays.sort(pos);
      
      int minItv = Integer.MAX_VALUE;
      for(int p : pos) {
          minItv = Math.min(minItv, Math.abs(x - p));
      }

      int[] intervals = new int[n-1];
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n-1; i++) {
        intervals[i] = pos[i+1] - pos[i];
        min = Math.min(min, intervals[i]);
      }
      
      Arrays.sort(intervals);
      while(minItv > 1) {
          boolean flag = true;
          for(int itv : intervals) {
            if(itv % minItv != 0) {
                flag = false;
                break;
            }
          }
          if(flag == true) {
              System.out.println(minItv);
              return;
          }
          minItv--;
      }
      
      System.out.println(1);
  }

}

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

using namespace std;

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

  int n;
  cin >> n;

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

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#define max 10000000;
typedef long long int lli;
int main() {
  lli k,cnt=1,x=7;
  scanf("%lld", &k);
  while(x%k){
      cnt++;
      if(cnt>=1e7)
        break;
      x*=10;
      x+=7;
      x%=k;
  }

  if(x%k==0)
    printf("%d\n",cnt);
  else
    printf("%d\n", -1);
  return 0;
}



Measured memory_bytes: 1728
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
int getLast(int x){
	return x%10;
}
int getFirst(int x){
	while (x >= 10) x /= 10; 
	return x; 
}
int cnt[11][11];
int main(){
	int n; cin>>n; int sum = 0;
	for(int i = 1; i <= n; i++){
		int a = getFirst(i);
		int b = getLast(i);
		if(b == 0) continue;
		cnt[b][a]++;
	}
	for(int i = 1; i <= n; i++){
		int a = getFirst(i);
		int b = getLast(i);
		sum += cnt[a][b];
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 256
N,M=map(int,input().split())
SC=[input().split() for _ in range(M)]
ans=["0"]*N
for s,c in SC:
  if ans[int(s)-1]!="0" and ans[int(s)-1]!=c:
    print(-1)
    exit()
  if N>1 and int(s)==1 and c=="0":
    print(-1)
    exit()
  ans[int(s)-1]=c
if N>1 and ans[0]=="0":
  ans[0]="1"
print("".join(ans))

Measured memory_bytes: 9176
N,L = map(int,input().split())

if(L>=0):
    print((N*L +N*(N-1)//2 - L))
if(L<0 and L+N-1>=0):
    print((N*L +N*(N-1)//2))
if(L<0 and L+N-1<0):
    print(N*L +N*(N-1)//2 - (L+N-1))



Measured memory_bytes: 38384
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner kbd = new Scanner(System.in);

    void run(){
	while(kbd.hasNext()){
	    String a = kbd.next();
	    String b = kbd.next();
	    if(!a.equals("0")) solve(a, b);
	}
    }

    void solve(String a, String b){
	int hit = 0;
	int blow = 0;
	int[] aa = new int[4];
	int[] bb = new int[4];
	for(int i=0; i<4; i++){
	    aa[i] = Integer.parseInt(a.substring(i, i+1));
	    bb[i] = Integer.parseInt(b.substring(i, i+1));
	}
	for(int i=0; i<4; i++){
	    for(int j=0; j<4; j++){
		if(aa[i]==bb[j]){
		    if(i==j) hit++;
		    else  blow++;
		}
	    }
	}
	System.out.println(hit+" "+blow);
    }
}

Measured memory_bytes: 46528
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n + 1);
    rep(i, 1, n) cin >> vec[i];
    int pos = 1;
    vi vis(n + 1, 0);
    vis[1] = true;
    vi seq;
    seq.pb(1);
    int st = -1;
    while (1) {
      pos = vec[pos];
      if (!vis[pos]) {
        seq.pb(pos);
      } else {
        st = pos;
        break;
      }
      vis[pos] = true;
    }
    // dbv(seq);
    // db1(st);
    int s = seq.size();
    int temp = vec[st];
    int cycle = 1;
    while (temp != st) {
      cycle++;
      temp = vec[temp];
    }
    // db1(cycle);
    int start = s - cycle;
    //  db1(start);
    if (k < s) {
      die(seq[k]);
    }
    k -= start;
    if (cycle == 1) {
      die(st);
    }
    //    db1(k);
    int p = start;
    int ind = p + ((k) % (cycle));
    //   db1(ind);
    die(seq[ind]);
  }

  return 0;
}


Measured memory_bytes: 8464
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

int gcd(int a, int b){
  if(b == 0) return a;
  return gcd(b, a%b);
}

int main()
{
  int N,minuscount = 0;
  ll abssum=0,absmin,num;
  cin >> N >> num;
  abssum = absmin = llabs(num);
  if(num < 0) minuscount++;
  for(int i=1;i<N;i++){
    cin >> num;
    abssum += llabs(num);
    if(absmin > llabs(num)) absmin = llabs(num);
    if(num < 0) minuscount++;
  }
  if(minuscount %2 == 0) cout << abssum;
  else cout << abssum - absmin*2;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,c,d,e,f,t;
    scanf("%d",&n);
    a=n%10;
    b=n/10;
    c=b%10;
    d=b/10;
    if(a==7 || c==7 || d==7)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 1612