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

int main() {
  int H, W;
  cin >> H >> W;
  int cnt = 0;
  for (int i=0; i<H; i++) {
    string s;
    cin >> s;
    for (int i=0; i<W; i++) {
      if (s[i] == '#') cnt++;
    }
  }

  if (cnt == H + W - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
    }
    int m = 10000;
    vector<ll> t(m+1,1),p;
    t[0] = t[1] = 0;
    for ( int i = 2; i <= 100; i++ ) {
        for ( int k = i; k * i <= m; k++ ) {
            t[i*k] = 0;
        }
    }
    for ( int i = 0; i < t.size(); i++ ) {
        if ( t[i]==1 ) {
            p.push_back(i);
        }
    }
    int count_p = 0;
    for ( int i = 0; i < n; i++ ) {
        bool is_com = false;
        for ( int j = 0; j < p.size(); j++ ) {
            if ( a[i] == 1 ) {
                is_com = true;
                break;
            } else if ( a[i] == 2 ) {
                break;
            } else if (a[i] % p[j] == 0) {
                is_com = true;
                break;
            } else if (p[j] * p[j] > a[i]) {
                break;
            }
        }
        if ( is_com == false ) {
            count_p++;
        }
    }

    cout << count_p << '\n';
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    while (h!=0&&w!=0){
     for(int i=0;i<w;i++){
         cout << "#";
     }
     cout << endl;
     for(int j=0;j<h-2;j++){
         cout << "#";
         for(int k=0;k<w-2;k++){
             cout << ".";
         }
         cout << "#" << endl;
     }
     for(int l=0;l<w;l++){
         cout << "#";
     }
     cout << endl;
     cout << endl;
     cin >> h >> w;
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

signed main(void){
    int n; cin>>n;
    vector <pair <int,int>> data(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        data[i] = {a,b};
    }
    vector <int> town(n);
    long double kaijo=1;
    rep(i,n){
        town[i] = i;
        kaijo *= (i+1);
        
    }
    long double ans = 0;
    do {
        long double path = 0; 
        rep(i,n-1){
            int now = town[i], next = town[i+1];
            path += sqrtl(powl(data[now].F - data[next].F, 2) + powl(data[now].S - data[next].S, 2));
        }
        ans += path;
    } while( next_permutation(town.begin(), town.end()) );
    //cout<<kaijo<<endl;
    printf("%.10Lf\n", ans/kaijo);
}


Measured memory_bytes: 256
N = int(input())
S = 0

for i in range(1, N + 1):
    if i % 15 == 0:
        S += 0
    elif i % 3 == 0:
        S += 0
    elif i % 5 == 0:
        S += 0
    else:
        S += i
print(S)


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

int main() {
    int n, q; cin >> n >> q;
    string name[n];
    int time[n];

    rep(i, n){
        cin >> name[i] >> time[i];
    }

    queue<int> Q;
    rep(i, n){
        Q.push(i);
    }

    int total = 0;

    while(!Q.empty()){
        int num = Q.front();
        Q.pop();
        int temp = time[num];
        if (temp <= q){
            total += temp;
            cout << name[num] << " " << total << endl;
        } else {
            total += q;
            time[num] -= q;
            Q.push(num); 
        }
    }

    return 0;
}


Measured memory_bytes: 6168
n = int(input())
people = {}

for i in range(n):
    sentenses = int(input())
    if sentenses > 0:
        for j in range(sentenses):
            v = list(map(int, input().split()))
            if i in people.keys():
                people[i].append(v)
            else:
                people[i] = [v]
            
ans = 0

for i in range(2**n):
    speaker = []
    p_list = [0] * n
    for j in range(n):
        if ((i >> j) % 2) == 1:
            speaker.append(j)
            p_list[j] = 1

    continue_flag = True
    for s in speaker:
        if continue_flag:
            if s in people.keys():
                sentenses = people[s]
            else:
                continue
            for sent in sentenses:
                if p_list[sent[0]-1] == sent[1]:
                    p_list[sent[0]-1] = sent[1]
                else:
                    continue_flag = False
                    break
        else:
            break
        
    if continue_flag:
        temp_ans = len(speaker)
        ans = max(temp_ans, ans)

print(ans)
       

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll a,b,c;
  cin >> a >> b >> c;

  if(b<a)swap(a,b);

  if(a<c && c<b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}




Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int a[3],sum,ans;
  REP(i,3)
    cin>>a[i];
  sort(a,a+3);
  sum=a[2]*3-a[0]-a[1]-a[2];
  if(sum%2==1)sum+=3;
  
  ans=sum/2;
  
  
    cout << ans << endl;

    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 K=sc.nextInt();
		String S=sc.next();
		sc.close();
		if(S.length()<=K) {
			System.out.println(S);
		}else {
			String[] name = S.split("");
			for(int i=0;i<K;i++) {
				System.out.print(name[i]);
			}
			System.out.print("...");
		}
	}
}


Measured memory_bytes: 35744
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  int l = 0, r = 0;
  int XOR = 0;
  ll ans = 0;
  while (l < n) {
    while (r < n && (XOR & a[r]) == 0) {
      XOR |= a[r];
      r++;
    }
    ans += r - l;
    XOR -= a[l];
    l++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  long long  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

int arr[200005];

int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>arr[i];
  if(n%2==0)

{
  for(int i=n;i>=2;i-=2)
    cout<<arr[i]<<" ";
  for(int i=1;i<=n-1;i+=2)
    cout<<arr[i]<<" ";
  cout<<endl;
}
else
{
  for(int i=n;i>=1;i-=2)
    cout<<arr[i]<<" ";
  for(int i=2;i<=n-1;i+=2)
    cout<<arr[i]<<endl;
}




return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
const int N = 1000007;
vector<int> e[N];
 
int memo[N];
 
int solve(int u) {
	int & st = memo[u];
    if(st == -1) {
      	st = 0;
		for(int v : e[u]) {
          	st = max(st, 1 + solve(v));
        }
    }
  	return st;
}
 
int main() {
  	memset(memo, -1, sizeof memo);
  	ios::sync_with_stdio(0); cin.tie(0);
 	int n, m; cin >> n >> m;
  
  	for(int i = 0; i < m; ++i) {
     	int u, v; cin >> u >> v;
      	e[u].push_back(v);
    }
  
  	int ans = 0;
  	for(int i = 1; i <= n; ++i) ans = max(ans, solve(i));
  	cout << ans << endl;
}

Measured memory_bytes: 32128
while True:
    m, f, r = map(int, raw_input().split())
    if m == -1 and f == -1 and r == -1:
        break
    else:
        result = str()
        if m == -1 or f == -1:
            result = 'F'
        elif m + f >= 80:
            result = 'A'
        elif 65 <= m + f < 80:
            result = 'B'
        elif 50 <= m + f < 65:
            result = 'C'
        elif 30 <= m + f < 50 <= r:
            result = 'C'
        elif 30 <= m + f < 50 and r < 50:
            result = 'D'
        elif m + f < 30:
            result = 'F'
        print(result)

Measured memory_bytes: 6380
/**
 * C - Strange Bank
 */

#include <iostream>
#include <vector>

using namespace std;

const int INF = 1 << 29;
int dp[13][100001];

int main() {

    int N;
    vector<int> v;

    //
    cin >> N;
    v.push_back(1);
    for (int i = 6; i <= N; i *= 6) { v.push_back(i); }
    for (int i = 9; i <= N; i *= 9) { v.push_back(i); }
    sort(v.begin(), v.end());

    //
    fill(dp[0], dp[13], INF);
    dp[0][0] = 0;

    for (int i = 1; i <= v.size(); i++) {
        for (int j = 0; j <= N; j++) {
            if (j < v[i - 1]) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - v[i - 1]] + 1);

            }
        }
    }
    cout << dp[v.size()][N] << endl;
}

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

long long const c = 1e18;

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        long long b; cin >> b;
        if (b == 0) {cout << 0 << endl; return 0;}
        a.at(i) = b;
    }
    
    long long m = 1;
    for (int i = 0; i < n; i++ ) {
        if(a.at(i) > c/m) {cout << -1 << endl; return 0;}
        else if (m > c) {cout << -1 << endl; return 0;}
        m *= a.at(i);
    }
    cout << m << endl;
}


Measured memory_bytes: 4056
/*************************************************************************
    > File Name: aoj2249.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???20??\ ????????? 15??¶23???28?§?
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;

const int MAX_N = 12345;
const int MAX_M = 20010;
const int INF = 1e9;

struct edge{
	int to , cost , money;
	edge(int tt , int tc , int tm) : to(tt) , cost(tc) , money(tm) {} ;
};
typedef pair<int,int> P;

vector< edge > G[MAX_N];
int dis[MAX_N];
int n , m;

void Dijkstra(){
	fill(dis,dis+n+1,INF);
	dis[1] = 0;
	priority_queue< P , vector<P> , greater<P> >	que;
	que.push( P(0,1) );
	while(!que.empty()){
		P p = que.top();	que.pop();
		int v = p.second;
		if( dis[v] < p.first )	continue;
		for(int i = 0 ; i < G[v].size() ; i++){
			edge e = G[v][i];
			if( dis[e.to] > dis[v] + e.cost ){
				dis[e.to] = dis[v] + e.cost;
				que.push( P(dis[e.to] , e.to) );
			}
		}
	}
}
int main(){
	int u , v , cost , money;
	while(~scanf("%d%d",&n,&m) && (n+m)){
		for(int i = 0 ; i <= n ; i++)	G[i].clear();
		for(int i = 0 ; i < m ; i++){
			scanf("%d%d%d%d",&u,&v,&cost,&money);
			G[u].push_back( edge(v,cost,money) );
			G[v].push_back( edge(u,cost,money) );
		}
		Dijkstra();
		int ans = 0;
		for(int i = 2 ; i <= n ; i++){
			int min_money = 0x3f3f3f3f;
			// ????????????????¶???????????????¶????´???¨???????????£??????????´???¨
			for(int j = 0 ; j < G[i].size() ; j++){
				edge e = G[i][j];
				if( dis[ e.to ] + e.cost == dis[i] && min_money > e.money ){
					min_money = e.money;
				}
			}
			if( min_money != 0x3f3f3f3f )
				ans += min_money;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
  int i;
  string S,T;
  cin >> S >> T;
  map<char,char> m,n;
  
  for(i=0; i<S.size(); i++) {
    if(m.count(S.at(i))) {
      if(m[S.at(i)] != T.at(i)) {
        cout << "No" << endl;
        return 0;
      }
    } else
      m[S.at(i)] = T.at(i);
  }
  for(i=0; i<T.size(); i++) {
    if(n.count(T.at(i))) {
      if(n[T.at(i)] != S.at(i)) {
        cout << "No" << endl;
        return 0;
      }
    } else
      n[T.at(i)] = S.at(i);
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
ll h,w;
vector<string> b;
vector<vector<bool>> visited;

bool isvm(ll r,ll c){ //r,cは移動先
    if(r<0||r>=h||c<0||c>=w){
        return false;
    }
    if(visited[r][c]) return false;
    return true;
}

int main(){
    cin >> h >> w;
    b.resize(h);
    visited.resize(h,vector<bool>(w,0));
    rep(i,h) cin >> b.at(i);

    ll ans = 0;
    rep(i,h){
        rep(j,w){ //i,jはスタートの座標
            if(visited[i][j]) continue;
            ll blackcnt = 0, whitecnt = 0;
            ll dist = 0;
            queue<pair<ll,ll>> q;
            q.push(make_pair(i,j));
            visited[i][j] = 1;
            while(q.size()){
                ll y = q.front().first;
                ll x = q.front().second;
                q.pop();
                if(b[y][x]=='.'){
                    whitecnt++;
                }else{
                    blackcnt++;
                }
                if(isvm(y+1,x) && b[y][x]!=b[y+1][x]){
                    q.push(make_pair(y+1,x)); 
                    visited[y+1][x] = 1;
                }
                if(isvm(y-1,x) && b[y][x]!=b[y-1][x]){
                    q.push(make_pair(y-1,x));
                    visited[y-1][x] = 1;
                } 
                if(isvm(y,x+1) && b[y][x]!=b[y][x+1]){
                    q.push(make_pair(y,x+1));
                    visited[y][x+1] = 1;
                } 
                if(isvm(y,x-1) && b[y][x]!=b[y][x-1]){
                    q.push(make_pair(y,x-1));
                    visited[y][x-1] =1;
                } 
            }
            //cout << i << j << whitecnt << blackcnt << endl;
            ans += whitecnt * blackcnt;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> V(N);
	for(int i=0;i<N;i++)	cin >> V.at(i);

	int ans=0;
	for(int i=0;i<=min(N,K);i++){
		priority_queue<int,vector<int>,greater<int>> pq;
		for(int j=0;j<=i;j++){
			for(int left=0;left<=j-1;left++){
				pq.push(V.at(left));
			}
			for(int right=N-1;right>=N-(i-j);right--){
				pq.push(V.at(right));
			}

			int de=min(K-i,i);
			int sum=0;
			for(int k=0;k<de;k++){
				if(pq.top()<0)	pq.pop();
				else	break;
			}
			while(!pq.empty()){
				sum+=pq.top();
				pq.pop();
			}
			ans=max(ans,sum);
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    lint X, K, D;
    cin >> X >> K >> D;

    if (X < 0) {
        lint k = min(K, -X / D);
        K -= k;
        X += k * D;

        if (K % 2 == 0) cout << abs(X) << endl;
        else cout << abs(X + D) << endl;
    }
    else {
        lint k = min(K, X / D);
        K -= k;
        X -= k * D;

        if (K % 2 == 0) cout << abs(X) << endl;
        else cout << abs(X - D) << endl;
    }
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
int main()
{
    char str[4];
    int count=0,i,j;

    scanf("%s",str);

    for(i=0;i<3;i++)
         for(j=i+1;j<4;j++)
    {
        if(str[j]==str[i])
            count++;
    }
        if(count==2)
            printf("Yes");
        else
            printf("No");
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
typedef complex<long double> point;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k,q;
	cin >> n >> k >> q;
    vector <ll> arr(n,k-q);
	for (int z=0;z<q;z++){
		ll temp;
		cin >> temp;
		arr[temp-1]++;
	}
	for (int z=0;z<arr.size();z++){
		if (arr[z] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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


int main(){
  
  long long W, H, x, y;
  int flag = 0;
  cin >> W >> H >> x >> y;
 
  
  if(2 * x == W && 2 * y == H){
    flag = 1;
  }
  
  cout << (long double) W * H / 2 << " " << flag << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  int ans = 0;
  
  for(int i=0;i<n;i++){
    if(s[i] == '1')
      ans++;
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 100001;
int dp[N][2];
vector<vector<int>> adj;

int solve(int u, int c, int p){
  if(dp[u][c] != -1)return dp[u][c];
//  if(dp[u][c] != -1)return dp[u][c];
  int res = 1;

  bool ch = 0;
  for(auto el : adj[u]){
    if(el == p)continue;
    ch = 1;
    if(c == 0){
      res = 1LL * res * solve(el, 1, u) % MOD;
    }else{
      res = 1LL * res * (solve(el, 1, u) + solve(el, 0, u)) % MOD;
    }
  }
  return dp[u][c] = res;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  adj.resize(n);
  for(int i = 0;i < n - 1;i++){
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(dp, -1, sizeof(dp));
  cout << (1LL * solve(0, 0, -1) + solve(0, 1, -1)) % MOD;
  return 0;
}


Measured memory_bytes: 13440
n = int(input())
x = list(map(int,input().split()))
S = sum(x)
Ave = sum(x) // n
m = 10**6
score = 0

for p in range(Ave,Ave+1001): 
    for i in range(n):
        score += (x[i]-p)**2
    if score < m:
        m = score
        score = 0
print(m)

Measured memory_bytes: 3060
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-04-04 21:00:02
 * @LastEditTime: 2020-04-04 21:01:20
 * @FilePath: \VSCode\C++\Practice\AC abc161 A.cpp
 */
#include<bits/stdc++.h>
using namespace std;

int x,y,z;
signed main(){
    scanf("%d%d%d",&x,&y,&z);

    printf("%d %d %d\n",z,x,y);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sm = sum(a)
hm = [0] * (10 ** 5 + 1)
for i in a:
    hm[i] += 1
for _ in range(q):
    b, c = map(int, input().split())
    sm += (c - b) * hm[b]
    hm[c] += hm[b]
    hm[b] = 0
    print(sm)

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

const long long INF = 1LL << 60;
int N;
long long h[100010];
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    for (int i = 0; i < 100100; ++i) dp[i] = INF;

    dp[0] = 0;
   for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a * b) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int H, W;
	cin >> H >> W;

	vector<vector<Int>> A(H+1, vector<Int>(W+1));
	vector<vector<Int>> B(H+1, vector<Int>(W+1));
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> B[i][j];
		}
	}

	auto dp = make_vec(H+1, W+1, 13000, 0);
	dp[0][0][abs(A[0][0]-B[0][0])] = 1;

	
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			for (Int k = 0; k < 13000; k++) {
				if (dp[i][j][k]) {
					dp[i + 1][j][k + abs(A[i + 1][j] - B[i + 1][j])] = 1;
					dp[i + 1][j][abs(k - abs(A[i + 1][j] - B[i + 1][j]))] = 1;//kが負になる場合は正に切り返す

					dp[i][j + 1][k + abs(A[i][j + 1] - B[i][j + 1])] = 1;
					dp[i][j + 1][abs(k - abs(A[i][j + 1] - B[i][j + 1]))] = 1;//kが負になる場合は正に切り返す

				}
			}
		}
	}

	Int ans;
	for (Int k = 0; k < 13000; k++) {
		if (dp[H-1][W-1][k]) {
			cout << k << "\n";
			return 0;
		}
	}

}


Measured memory_bytes: 339968
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll x;

struct test {
	ll b, l, u;
	ll val() {
		return l * b + u * (x - b);
	}
	bool operator < (const test &t) const {
		return l * b + u * (x - b) < t.l * t.b + t.u * (x - t.b);
	}
};

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

	ll n;
	cin >> n >> x;
	vector<test> a(n);
	rep(i, n) cin >> a[i].b >> a[i].l >> a[i].u;
	sort(all(a)); reverse(all(a));
	ll sum = 0;
	rep(i, n) sum += a[i].b * a[i].l;
	ll cnt = 0, tmp = 0;
	rep(i, n) {
		tmp += a[i].val();
		if (tmp >= sum) {
			cnt = i;
			break;
		}
	}
	ll ng = -1, ok = x;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		vector<ll> s(n);
		rep(i, n) {
			if (a[i].b >= mid) s[i] = mid * a[i].l;
			else s[i] = a[i].b * a[i].l + (mid - a[i].b) * a[i].u;
		}
		bool check = false;
		rep(i, cnt) {
			ll cur = tmp - a[i].val();
			cur += s[i];
			if (cur >= sum) check = true;
		}
		for (int i = cnt; i < n; i++) {
			ll cur = tmp - a[cnt].val();
			cur += s[i];
			if (cur >= sum) check = true;
		}
		if (check) ok = mid;
		else ng = mid;
	}
	cout << ok + cnt * x << '\n';
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, A, B);
  print(min(A * N, B));
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
struct P{
  int x,y;
  P(){}
  P(int x,int y) : x(x),y(y){}
};
struct Piece{
  P p1,p2;
  Piece(){}
  Piece(P p1,P p2) : p1(p1),p2(p2){}
  int area(){
    return (p2.x-p1.x)*(p2.y-p1.y);
  }
  int wide(){
    return (p2.x-p1.x);
  }
  int depth(){
    return (p2.y-p1.y);
  }
};
bool operator < (Piece p1,Piece p2){
  return p1.area() < p2.area();
}
int main(void){
  int n,W,D;
  while(cin>>n>>W>>D,!(!n&&!W&&!D)){
    vector<Piece> pc;
    pc.push_back(Piece(P(0,0),P(W,D)));
    while(n--){
      int p,s;
      cin>>p>>s;
      Piece cut = pc[p-1];
      int w = cut.wide();
      int d = cut.depth();
      Piece c1,c2;
      pc.erase(pc.begin()+p-1);
      s = s%(2*(w+d));
      if(s<w){
        int cutx = cut.p1.x+s;
        c1 = Piece(cut.p1,P(cutx,cut.p2.y));
        c2 = Piece(P(cutx,cut.p1.y),cut.p2);
      }else if(s<w+d){
        int cuty = cut.p1.y+s-w;
        c1 = Piece(cut.p1,P(cut.p2.x,cuty));
        c2 = Piece(P(cut.p1.x,cuty),cut.p2);
      }else if(s<w+d+w){
        int cutx = cut.p1.x+w-(s-(w+d));
        c1 = Piece(cut.p1,P(cutx,cut.p2.y));
        c2 = Piece(P(cutx,cut.p1.y),cut.p2);
      }else if(s<2*(w+d)){
        int cuty = cut.p1.y+d-(s-(w+d+w));
        c1 = Piece(cut.p1,P(cut.p2.x,cuty));
        c2 = Piece(P(cut.p1.x,cuty),cut.p2);
      }
      if(c1.area()<0||c2.area()<0) {
        abort();
      }
      if(c1.area()>c2.area()){
        swap(c1,c2);
      }
      pc.push_back(c1);
      pc.push_back(c2);
    }
    sort(pc.begin(),pc.end());
    REP(i,pc.size()){
      if(i) cout<<" ";
      cout<<pc[i].area();
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

X, N = rl()
P = rl()

h = {}
for p in P:
	h[p] = 1

for i in range(105):
	if X-i not in h:
		print(X-i)
		exit()
	if X+i not in h:
		print(X+i)
		exit()

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

int main() {
  string S;
  cin >> S;
  vector<string> V { "SUN","MON","TUE","WED","THU","FRI","SAT" };
  int tmp = 0;
  for (int i = 0; i < V.size(); i++) {
    if (V.at(i) == S) tmp = i;
  }
  cout << 7 - tmp << "\n";
}

Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }
    println(problem068c(n, m, ab))
}

fun problem068c(n: Int, m: Int, ab: List<Pair<Int, Int>>): String {
    val nSet = ab.filter { it.second == n }.map { it.first }.toSet()
    val oneList = ab.filter { it.first == 1 }
    return if (oneList.find { nSet.contains(it.second) } != null)
        "POSSIBLE" else
        "IMPOSSIBLE"
}

Measured memory_bytes: 82652
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int N, W;
    int v[101], w[101], dp[10005];
    fill(dp, dp + 10005, INF);
    dp[0] = 0;

    cin >> N >> W;
    rep(i,N) cin >> v[i] >> w[i];

    rep(i,N){
        for(int j = 10005 - 1; j >= 0; j--){
            if(j - v[i] >= 0) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }

    int ans = 0;
    rep(i,10005) if(dp[i] <= W) ans = max(ans, i);
    cout << ans << endl;
}

Measured memory_bytes: 3144
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long X = sc.nextLong();
        long sum = 0;

        for (long i = 1;; i++) {
            sum += i;
            if (sum >= X) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

const int MAX_N = 2000;
const int MAX_M = 2000;

int N, M, Q;
int node[MAX_N][MAX_M];
int edge_h[MAX_N][MAX_M];
int edge_v[MAX_N][MAX_M];

int cumsum[MAX_N+1][MAX_M+1];
int cumsum_h[MAX_N+1][MAX_M+1];
int cumsum_v[MAX_N+1][MAX_M+1];

int main()
{
  ios::sync_with_stdio(false);
  cin >> N >> M >> Q;
  std::string s;
  for (int i = 0; i < N; i++)
  {
    cin >> s;
    for (int j = 0; j < M; j++)
    {
      node[i][j] = s[j] - '0';
    }
  }
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      if (j + 1 < M){
        if (node[i][j] == 1 && node[i][j+1] == 1) {
          edge_h[i][j] = 1;
        } else {
          edge_h[i][j] = 0;
        }
      }
      if (i > 0){
        if (node[i][j] == 1 && node[i-1][j] == 1) {
          edge_v[i][j] = 1;
        } else {
          edge_v[i][j] = 0;
        }
      }
    }
  }

  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cumsum[i+1][j+1] = node[i][j] + cumsum[i][j+1] + cumsum[i+1][j] - cumsum[i][j];
      cumsum_h[i+1][j+1] = edge_h[i][j] + cumsum_h[i][j+1] + cumsum_h[i+1][j] - cumsum_h[i][j];
      cumsum_v[i+1][j+1] = edge_v[i][j] + cumsum_v[i][j+1] + cumsum_v[i+1][j] - cumsum_v[i][j];
    }
  }

  int y1, x1, y2, x2;
  int sum_node, sum_edge_h, sum_edge_v;
  for (int i = 0; i < Q; i++){
    cin >> y1 >> x1 >> y2 >> x2;
    sum_node = cumsum[y2][x2] - cumsum[y1-1][x2] - cumsum[y2][x1-1] + cumsum[y1-1][x1-1];
    sum_edge_h = cumsum_h[y2][x2-1] - cumsum_h[y1-1][x2-1] - cumsum_h[y2][x1-1] + cumsum_h[y1-1][x1-1];
    sum_edge_v = cumsum_v[y2][x2] - cumsum_v[y1-1+1][x2] - cumsum_v[y2][x1-1] + cumsum_v[y1-1+1][x1-1];
    cout << sum_node - sum_edge_h - sum_edge_v << endl;
  }
  return 0;
}


Measured memory_bytes: 95864
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
int n,m,w;
int a[500005];
int temp[500005];
bool check(int cm)
{
	for(int i=1;i<=2*n-1;i++)
	{
		temp[i]=0;
		if(a[i]>cm)
		{
			temp[i]=1;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(temp[n+i]==temp[n+i+1])
		{
			return temp[n+i];
		}
		else if(temp[n-i]==temp[n-i-1])
		{
			return temp[n-i];
		}
	}
	if(n%2==1)
	{
		return temp[n];
	}
	else
	{
		return 1-temp[n];
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n-1;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(check(mid)) l=mid+1;
		else r=mid;
	}
	printf("%d",l);
    return 0;
}

Measured memory_bytes: 1792
import copy


def warshalFloyd(n):
    G=[list(map(int,input().split())) for _ in range(n)]
    D=copy.deepcopy(G)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                G[i][j]=min(G[i][j],G[i][k]+G[k][j])

    return G if G==D else -1


n=int(input())
Graph=warshalFloyd(n)
if Graph==-1:print(-1);exit()

for k in range(n):
    for i in range(n):
        for j in range(n):
            if Graph[i][j]!=0 and Graph[i][k]!=0 and Graph[k][j]!=0:
                if Graph[i][j]==Graph[i][k]+Graph[k][j]:
                    Graph[i][j]=0

ans=0
for i in range(n):
    for j in range(i,n):
        ans +=Graph[i][j]
print(ans)

Measured memory_bytes: 57564
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long unsigned int ll;
using namespace std;
int main()
{
  ll n;
  cin >> n;
  ll m, a, r, c, h; 
  m = a = r = c = h =0;
  string tmp;
  vector<ll > vec(5,0);
  REP(i,n){
    cin >> tmp;
    char f = tmp[0];
    if(f == 'M'){
      vec[0] ++;
    }else if(f == 'A'){
      vec[1] ++;
    }else if(f == 'R'){
      vec[2] ++;
    }else if(f == 'C'){
      vec[3] ++;
    }else if(f == 'H'){
      vec[4] ++;
    }
  }
  // cout << m << endl;
  // cout << a << endl;
  // cout << r << endl;
  // cout << c << endl;
  // cout << h << endl;

  ll ans = 0;
  for(int i = 0; i < 5;i++){
    for(int j = i + 1; j < 5;j++){
      for(int k = j + 1; k < 5;k++){
	ans += vec[i]*vec[j]*vec[k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    V ng(k);
    rep(i,k){
        cin>>ng[i];
    }
    rep3(i,n,1e7){
        string s=to_string(i);
        bool h=true;
        rep(j,k){
            rep(l,s.size()){
                if(s[l]-'0'==ng[j]){
                    h=false;
                }
            }
        }
        if(h){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i, n) { cin >> l[i]; }

  sort(RALL(l));

  ll sum = 0;
  FOR(a, 0, n - 2) {
    FOR(b, a + 1, n - 1) {
      FOR(c, b + 1, n) {
        if (l[a] < l[b] + l[c] && l[b] < l[c] + l[a] && l[c] < l[a] + l[b]) {
          sum++;
        }
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 7 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 2;
		C[0] = '0';
		C[1] = '\n';
		K[1] = 2;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int i = keta - 1; i >= 0; i--)* di++ = (*(c + i));
			*di++ = '\n';
			K[i + 1] = K[i] + keta + 1;
		}
	}
} f;
inline void putint(int X) {
	for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
}

int N;
int E[400001], ne[400001], he[200001], cnt[2];
bool D[200001], d;
void dfs(int p, int prev) {
	D[p] = d;
	cnt[d]++;

	d = !d;
	for (int i = he[p]; i; i = ne[i]) {
		int to = E[i];
		if (to != prev) {
			dfs(to, p);
		}
	}
	d = !d;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		E[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	dfs(1, 0);

	int k0 = 0, k1 = 0, k2 = 0;
	int n0 = (N + 2) / 3;
	int n1 = (N + 1) / 3;
	int n2 = N / 3;

	if (cnt[0] < cnt[1]) {
		if (cnt[0] > N / 3) {
			rep1(i, N) {
				if (D[i] == 0) {
					if (k0 < n0) putint(k0++ * 3 + 1);
					else putint(k2++ * 3 + 3);
				}
				else {
					if (k1 < n1) putint(k1++ * 3 + 2);
					else putint(k2++ * 3 + 3);
				}
			}
		}
		else {
			rep1(i, N) {
				if (D[i] == 0) {
					putint(k2++ * 3 + 3);
				}
				else {
					if (k0 < n0) putint(k0++ * 3 + 1);
					else if (k1 < n1) putint(k1++ * 3 + 2);
					else putint(k2++ * 3 + 3);
				}
			}
		}
	}
	else {
		if (cnt[1] > N / 3) {
			rep1(i, N) {
				if (D[i] == 0) {
					if (k0 < n0) putint(k0++ * 3 + 1);
					else putint(k2++ * 3 + 3);
				}
				else {
					if (k1 < n1) putint(k1++ * 3 + 2);
					else putint(k2++ * 3 + 3);
				}
			}
		}
		else {
			rep1(i, N) {
				if (D[i] == 1) {
					putint(k2++ * 3 + 3);
				}
				else {
					if (k0 < n0) putint(k0++ * 3 + 1);
					else if (k1 < n1) putint(k1++ * 3 + 2);
					else putint(k2++ * 3 + 3);
				}
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    int z, w;
    cin >> n >> z >> w;

    vs32 a(n);
    rep (i, n) cin >> a[i];

    vs32 M(n, 0);
    vs32 m(n, 1e9);
    M[n - 1] = m[n - 1] = abs(a[n - 1] - w);
    for (int i = n - 2; i >= 0; --i)
    {
        if (i < n - 2)
        {
            M[i] = M[i + 1];
            m[i] = m[i + 1];
        }
        for (int j = i + 1; j < n; ++j)
        {
            M[i] = MAX(M[i], abs(a[i] - a[j]));
            m[i] = MIN(m[i], abs(a[i] - a[j]));
        }
    }

    int x = 0, y = 0;
    int flag = 1;
    while (x != n - 1 && y != n - 1)
    {
        if (flag == 1)
        {
            int temp = -1;
            for (int i = y; i < n; ++i)
            {
                if (temp <= m[i])
                {
                    temp = m[i];
                    x = i;
                }
            }
        }
        else
        {
            int temp = 1e9 + 1;
            for (int i = x; i < n; ++i)
            {
                if (temp >= M[i])
                {
                    temp = M[i];
                    y = i;
                }
            }
        }
        flag ^= 1;
    }

    int ans = (y == 0 ? abs(w - a[n - 1]) : abs(a[x] - a[y]));
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
def is_palindrome(s):
    for i in range(len(s) // 2 + 1):
        if s[i] != s[-i-1]:
            return False
    return True


a,b = map(int, input().split())

ans = 0
for i in range(a,b+1):
  if is_palindrome(str(i)):
  	ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	short A, B, C, result = 0;
	scanf("%hd %hd %hd", &A, &B, &C);
	if (A == 5) {
		if (B == 5 && C == 7) {
			result = 1;
		} else if (B == 7 && C == 5) {
			result = 1;
		}
	} else if (A == 7) {
		if (B == 5 && C == 5) {
			result = 1;
		}
	}
	if (result) {
		printf("YES");
	} else {
		printf("NO ");
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mxn 200005

using namespace std;
typedef long long ll;

int N;
string cad;
set<string>S;

int main(){
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    cin >> N;
    while (N--){
        cin >> cad;
        S.insert(cad);
    }
    cout << S.size() << "\n";

    return 0;
}

Measured memory_bytes: 19228
// AOJ 0545
#include<cstdio>
#include<cstring>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

int n, m;
std::vector<int> G[500];
bool used[500];

void dfs( int d, int v )
{
	used[v] = true;

	if( !d )
		return;

	rep( i, G[v].size() )
		dfs( d-1, G[v][i] );
	
	return;
}

int main()
{
	while( scanf( "%d%d", &n, &m ), n|m )
	{
		memset( used, false, sizeof( used ) );
		rep( i, 500 )
			G[i].clear();

		rep( i, m )
		{
			int a, b;
			scanf( "%d%d", &a, &b );
			--a; --b;
			G[a].push_back( b );
			G[b].push_back( a );
		}

		dfs( 2, 0 );

		int ans = 0;
		repi( i, 1, n )
			ans += used[i];

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

	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
#define Max 100005
using namespace std;
ll dp[Max][4];
int a[Max],b[Max],c[Max],n;
ll Max_value(int i,int k)
{
    if(i>=n)
        return 0;
    if(dp[i][k]!=0)
        return dp[i][k];
    ll x;
    if(k==1)
    {
        x = Max_value(i+1,2)+b[i];
        x = max(x,Max_value(i+1,3)+c[i]);
    }
    else if(k==2)
    {
        x = Max_value(i+1,1)+a[i];
        x = max(x,Max_value(i+1,3)+c[i]);
    }
    else if(k==3)
    {
        x = Max_value(i+1,2)+b[i];
        x = max(x,Max_value(i+1,1)+a[i]);
    }
    return dp[i][k] = x;
}


int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i]>>c[i];
    ll m1 = Max_value(1,1)+a[0];
    ll m2 = Max_value(1,2)+b[0];
    ll m3 = Max_value(1,3)+c[0];
    cout<<max(m1,max(m2,m3))<<endl;
    return 0;
}

Measured memory_bytes: 9216
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc032/tasks/agc032_b

//参考：
//ポイント：
//https://drken1215.hatenablog.com/entry/2019/03/24/110200

//全体から引く
//完全グラフを考えて、そこから引いて考える

//ただ2部グラフ、完全グラフ、スター、パスなどを考えるだけでなく
//そこから辺や点を取り除くことも重要


#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

vector<pair<LL,LL>> ans;

void solve(){
	if(N==3){
		ans.push_back(pair<LL,LL>(1,3));
		ans.push_back(pair<LL,LL>(2,3));
		return;
	}
	for(int i=1;i<=N - N%2;i++){
		for(int j=i+1;j<=N - N%2;j++){
			if((1+N - N%2)!=(i+j)) ans.push_back(pair<LL,LL>(i,j));
		}
	}
	if(N%2==1){
		for(int k=1;k<=N-1;k++) ans.push_back(pair<LL,LL>(k,N));
	}
}
 
int main(){
    cin >> N;
 
    solve();

    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++) cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        System.out.println(getSum(n) ? "Yes" : "No");
    }

    public static boolean getSum(int n){
        int copyN = n;
        int sum = 0;
        while (n > 9){
            sum += n % 10;
            n /= 10;
        }
        if (n > 0)
            sum+= n;

        return copyN % sum == 0;
    }
}


Measured memory_bytes: 21204