akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int l[30];
ll c[30],s[400][30],ans[3];

int main(void){
	int d,i,j,n=26,k,m=100;
	ll ansm = -INFLL;
	std::vector<int> v[m];
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			v[k].push_back(j);
		}
		std::random_device seed_gen;
		std::mt19937 engine(seed_gen());
		std::shuffle(v[k].begin(), v[k].end(), engine);
	}
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
	}
	for(k=0; k<m; ++k){
		for(j=0; j<n; ++j){
			l[j] = -1;
		}
		for(i=0; i<d; ++i){
			ans[k] += s[i][v[k][i%26]];
			l[v[k][i%26]] = i;
			for(j=0; j<n; ++j){
				ans[k] -= c[j]*(i-l[j]);
			}
		}
		ansm = std::max(ansm,ans[k]);
	}
	for(k=0; k<m; ++k){
		if(ans[k] == ansm){
			for(i=0; i<d; ++i){
				std::cout << v[k][i%26]+1 << std::endl;
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k;
  cin >> n >> k;
  vector<ll>p(n);
  rep(i,n)cin>>p[i];
  sort(p.begin(),p.end());
  if(p[n-1]<=0 && k&1){
    ll ans = 1;
    rep(i,k){
      ans*=p[n-1-i];
      ans%=MOD;
    }
    while(ans<0)ans+=MOD;
    cout << ans << endl;
    return 0;
  }
  ll ans = 1;
  ll nowp=n-1,nowm=0;
  ll cnt = 0;
  while(cnt<k){
    if(nowp-nowm>=1 && cnt+2<=k){
      ll resp=p[nowp]*p[nowp-1];
      ll resm=p[nowm]*p[nowm+1];
      if(resp>resm){
        cnt+=2;
        nowp-=2;
        resp%=MOD;
        ans*=resp;
        ans%=MOD;
      }
      else{
        cnt+=2;
        nowm+=2;
        resm%=MOD;
        ans*=resm;
        ans%=MOD;
      }
    }
    else{
      cnt++;
      p[nowp]%=MOD;
      ans*=p[nowp];
      ans%=MOD;
      nowp--;
    }
  }
  while(ans<0)ans+=MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4792
for i in range(input()):
    base = 0
    result = 0
    out = 0
    while out != 3:
        cmd = raw_input()
        if cmd == "HIT":
            if base == 3:
                result += 1
            else:
                base += 1
        elif cmd == "HOMERUN":
            result += base + 1
            base = 0
        elif cmd == "OUT":
            out += 1
    print result

Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef pair<int,int> P;
#pragma GCC optimize("Ofast")

const int MAX_N = 205;

int N;
char G1[MAX_N][MAX_N];
vector<vector<int>> G;

int bfs(int v){
    
    vector<bool> used(N,0);
    vector<int> id(N, -10);
    priority_queue<int> res;

    queue<P> Q;
    Q.push({v,1});
    while(!Q.empty()){
        auto now = Q.front();Q.pop();
        int vn = now.first;
        int group = now.second;
        if(used[vn]) return -1;
        id[vn] = group;
        //cout << vn << endl;
        int cnt = 0;
        for(auto next: G[vn]){
            if(id[next] == group - 1 ) continue;
            if(used[next] && id[next] < group - 1) return -1;
            if(used[next] && id[next] == group + 1) continue;
            Q.push({next, group + 1});
            cnt++;
        }
        if(cnt == 0) res.push(group);
        
        used[v] = true;
    }
    //cout << "yes\n";
    /* int ans = -1;
    rep(i,N) ans = max(ans, id[i]); */
    int a1 = res.top(); res.pop();
    int a2;
    if(res.empty()) a2 = 0;
    else a2 = res.top();
    cout << a1 << " " << a2 << endl;

    return a1 + a2;
}
int BipartiteGraph(const vector<vector<int>> &g) {
        int n = g.size();
        vector<int> color(n, -1);
        int white_cnt = 0;
        function<bool (int, int, int)> dfs = [&](int u, int prev, int c) {
                color[u] = c;
                if (c == 1) white_cnt ++;
                for (auto v : g[u]) if (v != prev) {
                        if (color[v] == -1) {
                                if (!dfs(v, u, 1 - c)) return false;
                        } else if (color[v] != 1 - c) {
                                return false;
                        }
                }
                return true;
        };
        if (!dfs(0, -1, 0)) return -1;
        return white_cnt;
}

int d[MAX_N][MAX_N];
int V;
const int INF = 1e9;

int warshall_floyde(){
    int ans = -1;
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    rep(i, V) rep(j, V) {
        if(i == j) continue;
        if(d[i][j] >= INF) continue;
        ans = max(d[i][j], ans);
    }
    return ans + 1;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    V = N;
    G.resize(N);
    rep(i,N){
        rep(j,N){
            cin >> G1[i][j];
            if(G1[i][j] == '1')G[i].push_back(j);
            if(G1[i][j] == '0') d[i][j] = INF;
            else d[i][j] = 1;
        }
    }
    
    if(BipartiteGraph(G) == -1){
        cout << -1 << endl;
        return 0;
    }
    cout << warshall_floyde() << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int n, a[10005], S, c, i;
    while (1) {
        scanf("%d", &n);
        if (n==0) break;
        S=0;
        for (i=1; i<=n; i++) {
            scanf("%d", &a[i]);
            S+=a[i];
        }
        c=0;
        for (i=1; i<=n; i++) {
            if (a[i]<=S/n) c++;
        }
        printf("%d\n", c);
    }
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

int n,m,k,a,b;
string s,t;

int main() {
  cin >> a >> b;
  cout << a*b << endl; 
}

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

using namespace std;

int mdist(int xi, int yi, int xj, int yj) {
    return abs(xi - xj) + abs(yi - yj);
}

int main() {
    int N; cin >> N;
    vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];

    // 基準を取る
    int xs, ys, hs;
    for (int i = 0; i < N; i++) {
        if (h[i] > 0) {
            xs = x[i];
            ys = y[i];
            hs = h[i];
            break;
        }
    }

    // 頂点の候補
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            // 頂点の高さを決める
            int hc = hs + mdist(i, j, xs, ys);
            // 他の点の高さを計算し, 矛盾したら次へ
            bool conf = 0;
            for (int k = 0; k < N; k++) {
                int ht = max(0, hc - mdist(i, j, x[k], y[k]));
                if (ht != h[k]) {
                    conf = 1;
                    break;
                }
            }
            if (conf) continue;
            else {
                cout << i << " " << j << " " << hc << endl;
                return 0;
            }
        }
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool rev = false;
    string tp;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) rev = !rev;
        else {
            int f;
            char c;
            cin >> f >> c;
            if (rev) f = 3-f;
            if (f == 1) tp.pb(c);
            else s.pb(c);
        }
    }
    string ans;
    if (!rev) {
        reverse(all(tp));
        ans = tp + s;
    }
    else {
        reverse(all(s));
        ans = s + tp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;
ll n,a[N],b[N],c[N],ans;
int main()
{

	ios::sync_with_stdio(0);

	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=1;i<n;i++){
		cin>>c[i];
	}
	
	for(int i=1;i<=n;i++){
		ans+=b[a[i]];
		if(a[i-1]+1==a[i]){
			ans+=c[a[i-1]];
		}
	}
	
	cout<<ans<<endl;
return 0;
}




Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int h[109];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int cnt=0;
  while(1){
    int s=0;
    for(int i=0;i<n;i++){
      if(h[i]<=0)s++;
    }
    if(s==n)break;
    for(int i=0;i<n-1;i++){
      if(h[i]>0&&h[i+1]<=0){
	cnt++;
      }
    }
    if(h[n-1]>0)cnt++;
    for(int i=0;i<n;i++){
      h[i]--;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
 
#include <complex>
 
#include <functional>
#include <cassert>
 
typedef long long ll;
using namespace std;
 
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010
 
 
int main(){
  int n, m;
  vector<pair<int,int> > vec[SIZE];
  char ans[SIZE][13];
  
  scanf("%d%d", &n, &m);
 
  for(int i=0;i<m;i++){
    int p, y;
    scanf("%d%d", &p, &y);
    vec[p].push_back({y, i});
  }
 
  for(int i=0;i<=n;i++){
    sort(vec[i].begin(), vec[i].end());
 
    for(int j=0;j<vec[i].size();j++){
      sprintf(ans[vec[i][j].second], "%06d%06d", i, j+1);
    }
  }
 
  for(int i=0;i<m;i++){
    printf("%s\n", ans[i]);
  }
  
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

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

    ll ans = b - a;

    if (k % 2 == 0) ans *= -1;

    if (abs(ans) > 1e18)
        print("Unfair");
    else
        print(ans);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


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

#define endl "\n"
#define INF INT_MAX
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

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

   ll q, n, m, sum = 0, b, c;
   cin >> n;
   map<ll, ll> data;
   for (int i = 0; i < n; ++i) {
      cin >> m;
      sum += m;
      data[m]++;
   }
   cin >> q;
   
   while (q--) {
      cin >> b >> c;
      ll count = data[b];
      if (count > 0) {
         data[b] = 0;
         data[c] += count;
         sum -= b*count;
         sum += c*count;
      }
      cout << sum << endl;
   }
    
   return 0;
} //AntiD2ta




Measured memory_bytes: 9276
from collections import defaultdict
from math import gcd
N = int(input())
d = defaultdict(int)
s = set()
ans = 0
mod = 1000000007

def change(A, B):
    if A == 0 and B == 0:
        return (0, 0)
    if A == 0:
        return (0, 1)
    if B == 0:
        return (1, 0)
    GCD = gcd(A, B)
    A //= GCD
    B //= GCD
    if A < 0:
        A *= -1
        B *= -1
    return (A, B)

def pair(key):
    if key == (1, 0):
        return (0, 1)
    A, B = key
    return (B, -A)

for i in range(N):
    A, B = map(int,input().split())
    A, B = change(A, B)
    if A == 0 and B == 0:
        ans += 1
    else:
        d[(A, B)] += 1
        if A == 0:
            A, B = B, A
        elif B < 0:
            A, B = -B, A
        s.add((A, B))

cnt = 1
for k in s:
    cnt *= pow(2, d[k], mod) + pow(2, d[pair(k)], mod) - 1
    cnt %= mod
cnt -= 1
ans += cnt
ans %= mod

print(ans)

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

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};



int main(){
  ll n,q;
  cin >> n >> q;
  segtree T(n);
  
  for(ll i=0;i<q;i++){
    ll type,a,b,c;
    cin >> type >> a >> b;
    if(type==0){
      cin >> c;
      T.Add(a,b+1,c);
    }
    else {
      cout << T.Getmin(a,b+1) << endl;
    }
  }
  return 0;
}


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

void Kari(int unko,int &t,int n,vector<int> &h)
{
  int i=0;
  int hmin=0;
  
  for(i=unko;i<n;i++)
  {
    if(i==unko)
      hmin=h.at(i);
    if(h.at(i)==0)
      break;
    
    if(h.at(i)<hmin)
      hmin=h.at(i);
  }
  
  for(int j=0;j<hmin;j++)
  {
    for(int k=unko;k<i;k++)
      h.at(k)--;
    t++;
    //cout<<"Yes"<<endl;
  }
}
  

int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  int hmin=0;
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
    if(i==0)
      hmin=h.at(i);
    else
      if(h.at(i)<hmin)
        hmin=h.at(i);
  }
  int t=0;
  //vector<int> f(n,0);
  
  //for(int i=0;i<hmin;i++)
  //{
    //for(int j=0;j<n;j++)
      //f.at(j)++;
    //t++;
  //}
  
  //ここに入れる
  
  for(int i=0;i<n;i++)
  {
    while(h.at(i)!=0)
      Kari(i,t,n,h);
  }
  
  //for(int i=0;i<n;i++)
    //cout<<h.at(i)<<endl;
  cout<<t<<endl;
}

Measured memory_bytes: 256
package main
import "fmt"

func main() {

  var n string
  fmt.Scan(&n)
  var digits = make([]int,0)
  for _,val := range n {
    digits = append(digits,int(val-'0'))
  }
  heap := createHeap(digits)
  i:= 8
  for i<17 {
    if heap[i] == 7 {
      break
    }
    i++
  }
  var ops = make([]string,3)
  for j := 2; j>= 0; j-- {
    if i % 2 == 1 {
      ops[j] = "-"
    } else {
      ops[j] = "+"
    }
    i /= 2
  }
  fmt.Printf("%d%s%d%s%d%s%d=7",digits[0],ops[0],digits[1],ops[1],digits[2],ops[2],digits[3])
}
func createHeap(digits []int) []int {
  var heap = make([]int,17)
  heap[1] = digits[0]
  heap[2] = heap[1] + digits[1]
  heap[3] = heap[1] - digits[1]
  dn := 2
  for i:= 4;i <= 16; i++ {
    if i > 7 {
      dn = 3
    }
    if i % 2 == 0{
      heap[i] = heap[i/2] + digits[dn]
    } else {
      heap[i] = heap[i/2] - digits[dn]
    }
  }
  return heap
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,0,n) cin>>a.at(i);
    sort(all(a));
    
    int ans=0;
    rep(i,0,n){
        x-=a.at(i);
        if(x<0) break;
        if(i==n-1 && x!=0) break;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict

inputs = list(map(int, sys.stdin.readline().split()))

n = inputs[0]
m = inputs[1]

ai = defaultdict(list)

for i in range(m):
	inputs = list(map(int, sys.stdin.readline().split()))
	a = inputs[0]
	b = inputs[1]
	ai[a].append(b)
	ai[b].append(a)


pos = 1

for dst in ai[pos]:
	if dst == n:
		print("POSSIBLE")
		sys.exit()

	for dst2 in ai[dst]:
		if dst2 == n:
			print("POSSIBLE")
			sys.exit()

print("IMPOSSIBLE")


Measured memory_bytes: 61568
#include<bits/stdc++.h>
using namespace std;
#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define laglo cerr << "Ti : " << clock() * 1.0 / CLOCKS_PER_SEC  << endl;
struct prob{
	int num;
	string ver;
};
prob pro[100001];
bool cmp(prob pr1, prob pr2) {
	if(pr1.ver!=pr2.ver) return pr1.ver<pr2.ver;
	else return pr1.num<pr2.num;
}
int main() {
	ioso; //kholo;
	long long n,m,pr;
	string ver;
	cin >> n >> m;
	int ar[100001],ar1[100001];
	memset(ar,0,sizeof(ar));
	for(int i=0;i<m;i++) {
		cin >> pro[i].num >> pro[i].ver;
	}
	//sort(pro,pro+m,cmp);
	long long cnt=0,cnt2=0;
	for(int i=0;i<m;i++) {
		if(pro[i].ver=="AC") ar[pro[i].num]=1;
	}
	for(int i=1;i<=n;i++) {
		if(ar[i]==1) cnt++;
	}
	for(int i=0;i<m;i++) {
		if(pro[i].ver=="AC") ar1[pro[i].num] = 1;
		else {
			if(ar1[pro[i].num]!=1 and ar[pro[i].num]==1) {
				cnt2++;
			}
		}
	}
	/*for(int i=0;i<m;i++) {
		//cout << pro[i].num << pro[i].ver;
		if(pro[i].ver == "AC" and ar[pro[i].num]!=1) {
			ar[pro[i].num] = 1; cnt++;
		}

		if(pro[i].ver == "WA") {
			if(ar[pro[i].num]==1) {
				cnt2++;
			}
		}
	}*/
	cout << cnt << " " << cnt2 << endl;

	//laglo;
}

Measured memory_bytes: 7296
n = int(input())
a = list(map(int, input().split()))

lr = [[0,0] for i in range(n)]

for i in range(n):
  l = i+a[i]
  if l < n:
    lr[l][0] += 1
  r = i-a[i]
  if r > 0:
    lr[r][1] += 1
count = 0
for i in range(n):
  count += lr[i][0] * lr[i][1]
print(count)

Measured memory_bytes: 105124
/**
 * @author: Jun
 * @date  : 03-14-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n;
int arr[100005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    int gc;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
    }
    gc=arr[1];
    for(int i=2;i<=n;i++){
        gc = __gcd(gc, arr[i]);
    }
    cout << gc << el;
    return 0;
}

Measured memory_bytes: 640
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val MAX = 100000

  val(n, k) = br.readLine().split(" ").map { it.toLong() }

  val table = LongArray(MAX+1)
  for(i in 1L..n) {
    val(a, b) = br.readLine().split(" ").map { it.toInt() }
    table[a] += b.toLong()
  }

  tailrec fun rec(acc: Long, i: Int, t: Long): Int {
    val v = acc + table[i]
    if(v >= t) return i
    return rec(v, i+1, t)
  }

  val ans = rec(0L, 0, k)
  println(ans)
}

Measured memory_bytes: 54996
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
for ($i = $n - 1; $i >= 0; $i -= 2) {
	$b[] = $a[$i];
}
$s = $n % 2 ? 1 : 0;
for ($i = $s; $i < $n; $i += 2) {
	$b[] = $a[$i];
}
echo implode(' ', $b);

Measured memory_bytes: 33520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef vector<int> vi;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,x,y;
int cnt[2005];
inline int dist(int i,int j){
	return min(j-i,abs(i-x)+1+abs(y-j));
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>x>>y;
	for (int i=1;i<=n-1;++i) for (int j=i+1;j<=n;++j){
		++cnt[dist(i,j)];
	}
	REP(i,n-1) cout<<cnt[i]<<endl;
	
	
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<ctime>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<tuple>
#include<cassert>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<climits>
#include<typeinfo>
#include<utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
double pi = 3.141592653589793238;
using ll = long long;
using namespace std;

ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpcombination[10000][10000];

ll modi = 1000000007;
ll combination(ll n, ll r) {
	if (n == r) { return dpcombination[n][n] = 1; }
	else if (r == 0) { return dpcombination[n][0] = 1; }
	else if (r == 1) { return dpcombination[n][1] = n; }
	else if (dpcombination[n][r]) { return dpcombination[n][r]; }
	else { return dpcombination[n][r] = combination(n - 1, r - 1) % modi + combination(n - 1, r) % modi; }
}

void clockman(int time1) {

	cout << 1.0*(clock() - time1) / CLOCKS_PER_SEC << endl;
	return;
}
//cout << fixed << setprecision(10)



int main() {


	vector<int>a(5);
	for (int i = 0;i < 5;i++) {
		cin >> a[i];
		if (a[i] == 0){
			cout << i + 1 << endl;
			return 0;
	}

	}
	



	
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll N, K;
    cin >> N >> K;
    vector<pair<ll, int>> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end(), [](auto x, auto y) {
        return x.first > y.first;
    });
    ll ans = 0;
    set<int> s;
    ll r = 0;
    set<pair<ll, int>> t;
    for (int i = 0; i < K; i++) {
        if (s.find(v[i].second) != s.end()) {
            t.insert(make_pair(v[i].first, i));
        }
        else {
            s.insert(v[i].second);
        }
        r += v[i].first;
    }
    ans = r + (s.size())*(s.size());
    for (int i = K; i < N; i++) {
        if (t.size() == 0) break;
        if (s.find(v[i].second) == s.end()) {
            r -= (*t.begin()).first;
            t.erase(t.begin());
            r += v[i].first;
            s.insert(v[i].second);
            ans = max(ans, r+(ll)s.size()*(ll)s.size());
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    X += ((D - 1) / A.at(i) + 1);
  }
  cout << X << endl;
}


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

using namespace std;
	
int main() {
	int a, b;

	cin >> a >> b;

	for (int i = 1; i <= 3; ++i) {
		if ( (i != a)  && (i != b) ) {
			printf("%d\n", i);
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k,v,u,V[101][101]={};
  int i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      V[u][v] = 1;
    }
  }
    
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",V[i][j]);
      if(j!=n) printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2088
n, k, s = map(int, input().split())
a = []

if n == k:
  print(*[s]*n)
  exit()
if s == 1:
  print(*([1]*k+[2]*(n-k)))
  exit()
cnt = -1
for i in range(n):
  if cnt >= k:
    if s != 10**9:
      a.append(10**9)
    else:
      a.append(10**9-2)
    continue
  if i % 2 == 0:
    a.append(s-1)
  else:
    a.append(1)
  cnt += 1
print(*a)

Measured memory_bytes: 7764
#include <iostream>
#include <string>

using namespace::std;

void string_change(char *A, char *B, char *C, int i, int *num) {

	if (A[i] == B[i] && B[i] == C[i] && A[i] == C[i]){}
	else if (A[i] == B[i]) {
		C[i] = A[i];
		*num += 1;
	}
	else if (A[i] == C[i]) {
		B[i] = A[i];
		*num += 1;
	}
	else if (B[i] == C[i]) {
		A[i] = B[i];
		*num += 1;
	}
	else {
		C[i] = A[i];
		*num += 1;
		B[i] = A[i];
		*num += 1;
	}

}


int main()
{
	int N;
	int num = 0;

	cin >> N;

	char A[101], B[101], C[101];

	cin >> A;
	cin >> B;
	cin >> C;
	

	for (int n = 0; n < N; n++) {
		string_change(A, B, C, n, &num);
	}


	cout << num << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin >> N;
	int ng = ((N % 2)? N:N+1);
	vector<P> ans;
	REP(i,N){
		for(int j = i+1; j <= N; ++j){
			if(j == ng-i)continue;
			ans.push_back(make_pair(i,j));
		}
	}
	cout << ans.size() << endl;
	for(auto x:ans){
		cout << x.first << ' ' << x.second << endl;
	}
	return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <typeinfo>

std::vector<std::string> fill_road(int height, int width) {
	std::vector<std::string> state(height, std::string(width, '.'));
	for (auto i = 0; i < height; i += 2) {
		if (i > 0) {
			if (i % 4 != 0) state[i - 1][width - 1] = '#';
			else state[i - 1][2] = '#';
		}
		for (auto j = 2; j < width; ++j) state[i][j] = '#';
	}
	for (auto i = 0; i < height; ++i) state[i][0] = '#';
	state[0][1] = '#';
	state[height - 1][1] = '#';
	return state;
}
void overlay(std::vector<std::string>& base, const std::vector<std::string>& over) {
	for (auto i = 0; i < base.size(); ++i) for (auto j = 0; j < base[i].size(); ++j) {
		if (base[i][j] == '.') base[i][j] = over[i][j];
	}
}
struct Coordinate {
	int x, y;
	std::vector<Coordinate> neighbors() const {
		return std::vector<Coordinate>{ Coordinate{x + 1, y}, Coordinate{x - 1, y}, Coordinate{x, y + 1}, Coordinate{x, y - 1} };
	}
};
int main() {
	int height, width; std::cin >> height >> width;
	std::vector<std::string> state(height); for (auto& line : state) std::cin >> line;
	int h, w; 
	for (auto i = 0; i < height; ++i) for (auto j = 0; j < width; ++j) {
		if (state[i][j] == '@') {
			h = i; w = j; break;
		}
	}
	overlay(state, fill_road(height, width));
	for (const auto neighbor : Coordinate{ h, w }.neighbors()) {
		if (0 <= neighbor.x && neighbor.x < height && 0 <= neighbor.y && neighbor.y < width && state[neighbor.x][neighbor.y] == '#') {
			std::queue<Coordinate> queue; queue.push(neighbor);
			while (!queue.empty()) {
				auto top = queue.front(); queue.pop();
				if (0 <= top.x && top.x < height && 0 <= top.y && top.y < width && state[top.x][top.y] == '#') {
					state[top.x][top.y] = '.';
					for (const auto next : top.neighbors()) {
						queue.push(next);
					}
				}
			}
			break;
		}
	}
	for (const auto line : state) std::cout << line << '\n';
}


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

int main()
{
  int n;
  scanf("%d", &n);
  int arr[n];
  for(int a=0;a<n;a++)
    scanf("%d", &arr[a]);
  long long int sum=0;
  for(int a=1;a<n;a++)
  {
    if(arr[a]<arr[a-1])
   {
         sum+=arr[a-1]-arr[a];
         arr[a]+=arr[a-1]-arr[a];
   }     
  }
       
       printf("%lld", sum);
}

Measured memory_bytes: 4484
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
lisA = [0] + list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

if K<=N:
    i = K
    j = 1
    while i > 0:
        j = lisA[j]
        i -= 1
    print(j)
    exit()

checked = {1:0}
roopstnum = 0
i = 1
for n in range(1,N+2):
    if not lisA[i] in checked:
        checked[lisA[i]] = n
        i = lisA[i]
    else:
        roopstnum = lisA[i]
        roopstidx = checked[roopstnum]
        rooplen = n - roopstidx
        break

# print(roopstnum,rooplen,roopstidx,checked)
warukazu = rooplen
for k,v in checked.items():
    if (K-roopstidx) % warukazu == v - roopstidx:
        ans = k
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 32376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = 1e5 + 5, MAXM = 2e6 + 5, BOUND = 2e5, MOD = 10000, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-6;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define lc(x) c[x][0]
#define rc(x) c[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
char gdffsaw;
#define G gdffsaw=getchar()
#define GO G;while(gdffsaw<'-')G
#define in(z) GO;z=gdffsaw&15;G;while(gdffsaw>'-')z*=10,z+=gdffsaw&15,G
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
ll n, m;
ll GEt_ans(ll a)
{
	if (a < 1)return 0;
	if (a % 4 == 1)
		return 1;
	else if (a % 4 == 2)
		return a + 1;
	else if (a % 4 == 3 || a == 0)
		return 0;
	else
		return a;
}
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	cout << (GEt_ans(m) ^ GEt_ans(n - 1)) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int t, p, r, x, y, z; string s;
	while (cin >> t >> p >> r) {
		if (t == 0)break;
		int pena[51] = {}; int score[51] = {}; int wa[51][11];
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 11; j++) {
				wa[i][j] = 0;
			} 
		}
		for (int i = 1; i <= r; i++) {
			cin >> x >> y >> z >> s;
			if (s == "WRONG") {
				wa[x][y]++;
			}
			else {
				score[x]++;
				pena[x] += wa[x][y] * 1200 + z;
			}
		}
		int used[51] = {};
		for (int i = 1; i <= t; i++) {
			int check = 0;
			for (int j = 1; j <=t ; j++) {
				if (used[j] == 0) {
					if (check == 0 || score[j] > score[check] || (score[j] == score[check] && pena[j] < pena[check])) {
						check = j;
					}
				}
			}
			used[check] = 1;
			cout << check << " " <<score[check] << " " <<pena[check] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';
template <typename T>
T pow(T k,ll l) {
	T ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	double L;
	cin >> L;
	cout << fixed;
	cout << setprecision(6) << pow(L/3,3) << '\n';
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
answer = float('inf')
araisan_sum = sum(a) - a[0]
snuke_sum = a[0]
if len(a) == 2:
    answer = abs(snuke_sum - araisan_sum)
else:
    for i in range(1, n-1):
        snuke_sum += a[i]
        araisan_sum -= a[i]
        if answer >= abs(snuke_sum - araisan_sum):
            answer = abs(snuke_sum - araisan_sum)

print(answer)

Measured memory_bytes: 24832
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/10/20 23:28:18
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c,k; cin>>a>>b>>c>>k;
  int s = min(a,k);
  k -= a;
  k -= min(k,b);
  s -= min(k,c);
  cout << s << endl;

  return 0;
}


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


#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int


int main()
{	
	fast();

	long long int x,y,z,a,b,c;
	cin>>x>>y>>z;


	if(x+y+2*sqrtl(x*y)<z)
		cout<<"Yes";
	else
		cout<<"No";
return 0;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    even = a[::2]
    odd = a[1::2]

    odd.reverse()
    odd.extend(even)

    if len(a)%2:
        odd.reverse()

    print(*odd, sep=" ")



if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int cnt;
    cin >> cnt;
    int pcount = 0;
    for(int i = 0; i < cnt; i++) {
        int tmp;
        int flag = true;
        cin >> tmp;
        for(int i = 2; i <= sqrt(tmp); i++) {
            if (tmp % i == 0) {
                flag = false;
            }
        }
        if (flag) pcount++;
    }
    cout << pcount << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define de cout<<1
#define FOR(NAME,FIRST,END) for(int NAME=FIRST;NAME<=END;NAME++)
#define openi(s) freopen(s,"r",stdin)
#define openo(s) freopen(s,"w",stdout)
const bool debug=false;
const bool INJUDGE=false;
int n;
int main(){
	if(INJUDGE){
        openi(".in");
        openo(".out");
    }
    cin>>n;
    char a[50]={};
    sprintf(a,"%d",n);
    int s=0;
    for(int i=0;i<strlen(a);i++)s+=(a[i]-'0');
    cout<<(n%s?"No":"Yes")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int x=0;
  for(int i=0;i<3;i++){
    if(s.at(i)==s.at(i+1)){
      x++;
      break;
    }
  }
  if(x==0){
    cout<<"Good"<<endl;
  }
  else{
    cout<<"Bad"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
	return a<b?a:b;
}

int main(){
  int P,Q,R;
  scanf("%d%d%d",&P,&Q,&R);
  printf("%d\n",min(min(P+Q,R+Q),P+R));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <list>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int res = 0;
	if (a > b)
	{
		res = a;

		if (a - 1 > b)
			res += a - 1;
		else
			res += b;
	}
	else
	{
		res = b;
		if (a > b - 1)
			res += a;
		else
			res += b - 1;
	}

	printf("%d", res);
	 
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N, K;
int V[60];


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> V[i];

    int ans = 0;
    repe(a, 0, min(N, K)){
        repe(b, 0, min(N, K)-a){
            VI v;
            int sum = 0;
            rep(i, 0, a){
                sum += V[i];
                if(V[i] < 0) v.pb(V[i]);
            }
            rep(i, 0, b){
                sum += V[N-1-i];
                if(V[N-1-i] < 0) v.pb(V[N-1-i]);
            }
            sort(ALL(v));
            rep(i, 0, min(K-(a+b), SZ(v))) sum -= v[i];
            chmax(ans, sum);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// AOJ Volume 0 Problem 0065

#include <stdio.h>
#include <string.h>

typedef struct {
	int costomer;
	int no;
} DATA;


int main(void)
{
    char in_str[81];
	DATA data[1000];
	int costomer_no;
	int costomer;
	int day;
	int i, j;
	DATA tmp;
	
	memset(data, 0, sizeof(data));
	costomer_no = 0;
	while (1){
		fgets(in_str, 100, stdin);
		
		if (in_str[0] == '\n'){
			break;
		}
		
		sscanf(in_str, "%d,%d", &costomer, &day);
		
		for (i = 0; i < costomer_no; i++){
			if (data[i].costomer == costomer){
				data[i].no--;
				break;
			}
		}
		if (i == costomer_no){
			data[i].costomer = costomer;
			data[i].no--;
			costomer_no++;
		}
	}

	for (i = 0; i < costomer_no - 1; i++){
		for (j = i; j < costomer_no - 1; j++){
			if (data[j].costomer > data[j + 1].costomer){
				tmp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = tmp;
			}
		}
	}
	
	while (scanf("%d,%d", &costomer, &day) != EOF){
		for (i = 0; i < costomer_no; i++){
			if (data[i].costomer == costomer){
				if (data[i].no < 0){
					data[i].no = data[i].no * -1 + 1;
				}
				else {
					data[i].no++;
				}
			}
		}
	}
	
	for (i = 0; i < costomer_no; i++){
		if (data[i].no > 0){
			printf("%d %d\n", data[i].costomer, data[i].no);
		}
	}
	
	return (0);
}

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

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)

typedef long long int llint;

int n;
int i, j;
llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

llint a[200001];

int gcd(int a, int b)
{
  return (b ? gcd(b, a % b) : a);
}

int lcm(int a, int b)
{
  return a / gcd(a, b) * b;
}

int main()
{
  I >> n;

  for(i = 0; i < n; i++) {
    I >> a[i];
  }

  for(i = n - 1; i >= 0; i -= 2) O << a[i] << ' ' ;

  for(i = n % 2; i < n; i += 2) {
    O << a[i];
    if(i + 2 < n) O << ' ';
  }

  ln;
  
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

vector<P> primes(ll a){
    vector<P> res;
    for(int i=2; i<=sqrt(a)+1; i++){
        if(a%i==0){
            res.push_back(P(i,1));
            a/=i;
            while(a%i==0){
                res.back().second++;
                a/=i;
            }
        }
    }
    if(a!=1) res.push_back(P(a,1));
    return res;
}

vector<ll> divisor(ll a){
    vector<ll> res;
    for(int i=2; i<=sqrt(a); i++){
        if(a%i==0){
            res.push_back(i);
            if(i!=a/i) res.push_back(a/i);
        }
    }
    res.push_back(a);
    // sort(all(a));
    return res;
}

int main(){
    ll n; cin >> n;
    vector<ll> dv;
    dv=divisor(n);
    //rep(i,dv.size()) cout << dv[i] << endl;
    ll ans=0;

    rep(i,dv.size()){
        ll tmp=n;
        while(tmp%dv[i]==0) tmp/=dv[i];
        if(tmp%dv[i]==1) ans++;
    }
    vector<P> ps;
    ps=primes(n-1);
    ll tmp=1;
    rep(i,ps.size()) tmp*=ps[i].second+1;
    ans+=tmp-1;
    cout << ans << endl;
return 0;
}


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

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;

    long long int x = c - a - b;
    if (x < 0)
    {
        cout << "No";
        return 0;
    }

    if (x * x > 4 * a * b)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c;
    string s,t;

    cin>>a;
    cout<<2.0*a*PI<<endl;



}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


Measured memory_bytes: 3764
/**
 * C - Streamline
 * https://atcoder.jp/contests/abc117/tasks/abc117_c
 **/
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i=0; i<M; i++) cin >> X[i];
    sort(X.begin(), X.end());
    vector<long> diffs;
    for(int i=1; i<X.size(); i++) diffs.push_back(X[i]-X[i-1]);
    sort(diffs.begin(), diffs.end(), greater<long>());

    int res = X.back() - X[0];
    for(int i=0; i<min((int)diffs.size(), N-1); ++i) res -= diffs[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1784