akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

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

const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};

int w,h;
char field[22][22];
int ans,sx,sy;

inline bool inside(char x, char y){
  return (!(x<0 || x>=w || y<0 || y>=h));
}

void dfs(char x, char y, char cnt){
  char tx,ty;
  if( cnt>=ans ) return;
  
#if DEB
  printf("(%d,%d)  cnt:%d\n",x,y,cnt);
  rep(i,h){
    rep(j,w){
      printf("%d ",field[i][j]);
    }
    puts("");
  }
#endif

  rep(k,4){
    tx = x;
    ty = y;
    if( !inside(tx+dx[k],ty+dy[k]) || field[ty+dy[k]][tx+dx[k]]==1 )continue;
    REP(j,1,30){
      tx += dx[k];
      ty += dy[k];
      if( !inside(tx,ty) ) break;
      if( field[ty][tx]==1 ){
	field[ty][tx] = 0;
	dfs(tx-dx[k], ty-dy[k], cnt+1);
	field[ty][tx] = 1;
	break;
      }else if( field[ty][tx]==3 ){
	ans = cnt+1;
	return;
      }
    }
  }
}

int main(){
  int t;
  while(scanf("%d%d",&w,&h),w|h){
    ans = 11;
    rep(i,h){
      rep(j,w){
	scanf("%d",&t);
	field[i][j] = (char)t;
	if( field[i][j]==2 ){
	  sx=j; sy=i;
	}
      }
    }
    dfs(sx,sy,0);
    printf("%d\n",ans==11?-1:ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(ki, k) {
		vector<int> b(n + 1);
		rep(i, n) {
			int l = max(0, i - a[i]);
			int r = min(i + a[i] + 1, n);
			b[l]++; b[r]--;
		}
		rep(i, n) b[i + 1] += b[i];
		b.pop_back();
		if (a == b) break;
		a = b;
	}
	rep(i, n) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 4436
public class Main {

  private static void solve() {
    int n = ni();
    int m = ni();


    int min, max;
    if (n == 1) {
      min = 0;
      max = 9;
    } else if (n == 2) {
      min = 10;
      max = 99;
    } else {
      min = 100;
      max = 999;
    }

    int[][] s = ntable(m, 2);

    outer: for (int i = min; i <= max; i++) {
      char[] x = ("" + i).toCharArray();
      for (int[] p : s) {
        if (x[p[0] - 1] - '0' != p[1]) {
          continue outer;
        }
      }

      System.out.println(i);
      return;
    }
    System.out.println(-1);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22800
#include<cstdio>
#include<iostream>
using namespace std;
string s;
int main(){
	cin>>s;
	for(register int i=0;i<s.length();i+=2){
		if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
			puts("No");
			return 0;
		}
	}
	for(register int i=1;i<s.length();i+=2){
		if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<int> ans(n);
  rep(i,n){
    ans[a[i]-1] = i;
  }
  rep(i,n)cout<<ans[i]+1<<" \n"[i==n-1];
  return 0;
} 

Measured memory_bytes: 1664
#include<bits/stdc++.h>
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 P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int r, g, b;
  cin >> r >> g >> b;
  int a = r * 100 + g * 10 + b;
  if(a % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}






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

using namespace std;
using ll = long long;

const ll INF = 4e18;

struct Node {
    typedef Node* NP;
    NP l, r;
    int sz;
    ll ma, lz;
    Node(int _sz) : sz(_sz), ma(-INF), lz(0) {
        if (sz == 1) return;
        l = new Node(sz/2);
        r = new Node(sz-sz/2);
    }
    void apply(ll d) {
        ma += d;
        lz += d;
    }
    void push() {
        l->apply(lz);
        r->apply(lz);
        lz = 0;
    }
    void pull() {
        ma = max(l->ma, r->ma);
    }
    void set(int k, ll x) {
        if (sz == 1) {
            ma = max(ma, x);
            return;
        }
        push();
        if (k < sz/2) {
            l->set(k, x);
        } else {
            r->set(k-sz/2, x);
        }
        pull();
    }
    void add(int a, int b, ll x) {
        if (b <= 0 || sz <= a) return;
        if (a <= 0 && sz <= b) {
            apply(x);
            return;
        }
        push();
        l->add(a, b, x);
        r->add(a-sz/2, b-sz/2, x);
        pull();
    }
    ll get(int a, int b) {
        if (b <= 0 || sz <= a) return -INF;
        if (a <= 0 && sz <= b) return ma;
        push();
        return max(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

using P = pair<int, int>;
const int MN = 233333;
int n, m;
vector<P> g[MN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        g[y].push_back(P(x, z));
    }

    Node* tr = new Node(n+1);
    tr->set(0, 0);
    for (int i = 1; i <= n; i++) {
        tr->set(i, tr->get(0, i));
        for (auto &p : g[i]) {
            tr->add(p.first, i+1, p.second);
        }
    }
    cout << tr->get(0, n+1) << "\n";
    return 0;
}

Measured memory_bytes: 30720
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[][] g    = new int[n+1][n+1];
        int[] find   = new int[n+1];
        int[] finish = new int[n+1];
        
        for (int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt();
                g[u][v] = 1;
            }
        }
        
        Deque<Integer> deq = new ArrayDeque<Integer>();
        int time = 0;
        deq.push(1);
        
        while(!deq.isEmpty()) {
            int top = deq.peek();
            if (find[top] == 0) find[top] = ++time;
            
            int j;
            for (j = 1; j <= n; j++) {
                if (g[top][j] == 1 && find[j] == 0) {
                    deq.push(j);
                    find[j] = ++time;
                    break;
                }
            }
            if (j == n + 1) {
                deq.pop();
                finish[top] = ++time;
            }
            
            if (deq.isEmpty()) {
                for (int i = 1; i <= n; i++) {
                    if (find[i] == 0) {
                        deq.push(i);
                        find[i] = ++time;
                        break;
                    }
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + find[i] + " " + finish[i]);
        }
    }
}


Measured memory_bytes: 28280
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
        String s2 = sc.next();
        int min = s2.length();
        for(int i = 0; i <= s1.length() - s2.length(); i++){
        	String s3 = s1.substring(i, i + s2.length());
            int count = 0;
            for(int j = 0; j < s2.length(); j++){
            	if(s2.charAt(j) != s3.charAt(j)){
                	count++;
                }
            }
            min = Math.min(min, count);
        }
        System.out.println(min);
	}
}

Measured memory_bytes: 36612
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	string S;
	cin >> S;
	N = S.length();
	rep(i, N) {
		S[i] = 'x';
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0) {
		cout << "Possible";
		return 0;
	}
	if (b % 3 == 0) {
		cout << "Possible";
		return 0;
	}
	if ((a+b) % 3 == 0) {
		cout << "Possible";
		return 0;
	}
	cout << "Impossible";
}

Measured memory_bytes: 256
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var n = p.length;
  var r = [0, 0];
  for (var i = 0; i < n; i++) {
    var a = p.shift().split(',').map(Number);
    var x1 = a.shift();
    var x2 = a.shift();
    var x3 = a.shift();
    if (x3 * x3 === x1 * x1 + x2 * x2) {
      r[0]++;
    } else if (x1 === x2) {
      r[1]++;
    }
  }
  console.log('%s\n%s', r[0], r[1]);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

#define uni int;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

ll cnt[100001];

signed main() {
    LCIN(N);
    VL A(N);
    VECCIN(A);
    REP(i, N) cnt[A[i]]++;
    ll ans = 0, even = 0;
    sort(All(A));
    FOR(i, 1, 100001) {
        if(cnt[i]) {
            ans++;
            if(cnt[i] % 2 == 0) even++;
        }
    }
    ans -= even % 2;
    cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==5  && b==5 && c<=7)
  {
    printf("YES\n");
  }
  else if(a==5  && b==7 && c<=5)
  {
    printf("YES\n");
  }
  else if(a==7  && b==5 && c<=5)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
}


Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	char w;
	scanf("%c",&w);
	if(w=='A'){
		printf("T");
	}
	if(w=='T'){
		printf("A");
	}
	if(w=='G'){
		printf("C");
	}
	if(w=='C'){
		printf("G");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::vector<ll> G[100010];
ll r = -1;

ll dfs( ll v, ll p = -1 ) {
  ll ret = 0;
  ll leaf = 0;

  for( auto u : G[v] ) if( u != p ) {
    ll x = dfs( u, v );

    if( !x )
      ++leaf;

    ret += x;
  }

  if( leaf > 1 ) {
    ret += leaf-1;
  }

  return ret;
}

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

  rep( i, N-1 ) {
    ll a, b;
    std::cin >> a >> b;

    G[a].emplace_back( b );
    G[b].emplace_back( a );

    if( G[a].size() >= 3 ) {
      r = a;
    }
    if( G[b].size() >= 3 ) {
      r = b;
    }
  }

  if( r == -1 ) {
    puts("1");

    return 0;
  }

  std::cout << dfs( r ) << endl;

  return 0;
}

Measured memory_bytes: 11860
def main():
    N = int(input())
    info = [tuple(map(int, input().split())) for _ in range(N)]

    info.sort(key=lambda x: -(x[0]+x[1]))
    takahashi = sum([val for i, (val, _) in enumerate(info) if i % 2 == 0])
    aoki = sum([val for i, (_, val) in enumerate(info) if i % 2 == 1])
    print(takahashi-aoki)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21384
#include <iostream>

inline int gcd(int a, int b){
  if(b<a) std::swap(a, b);
  int r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int cnt[1000001];
int main(){
  int n = read();
  int num = read();
  int o = 0, g = num;
  if(num==1) o++;
  int ex = (n-1)/4;
  cnt[num] = 1;

  for(int i=0;i<ex;i++){
    int num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;

    num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;
  }

  for(int i=0;i<(n-1)%4;i++){
    int num = read();
    if(num==1) o++;
    g = gcd(g, num);
    cnt[num]++;
  }

  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    if(max_S<S) max_S = S;
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


Measured memory_bytes: 7500
A,B,K = map(int,input().split())
s = set()
for i in range(K):
    tmp = A+i
    if (tmp >= A)and(tmp <= B):
        s.add(tmp)

for i in range(B-K,B):
    tmp = i+1
    if (tmp >= A)and(tmp <= B):
        s.add(tmp)

l = list(s)
l.sort()

for i in l:
    print(i)


Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

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

    int f[110][15] = {0};

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }

    vector<vector<int>> p(n, vector<int>(11));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }

    int ans = -1e9;
    for(int bit = 1; bit < (1 << 10); bit++){
        vector<int> l;
        bool empty = true;
        for(int i = 0; i < 10; i++){
            if(bit & (1 << i)){
                l.push_back(i);
                empty = false;
            }
        }
        if(empty) continue;

        int totalprofit = 0;
        for(int i = 0; i < n; i++){
            int totalopen = 0;
            for(int j = 0; j < l.size(); j++){
                if(f[i][l[j]] == 1){
                    totalopen++;
                }
            }
            totalprofit += p[i][totalopen];
        }

        if(totalprofit > ans){
            ans = totalprofit;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0].split(" ")[0];
    const K = ~~arg[0].split(" ")[1];
    
    console.log(K * (Math.pow((K-1), N-1)));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = (long)vals[0];
            var B = (long)vals[1];
            var C = (long)vals[2];
            var X = (long)vals[3];
            var Y = (long)vals[4];

            var prices = new List<long>();

            //そのまま
            prices.Add(A * X + B * Y);

            if(X>=Y)
            {
                prices.Add(A * (X - Y) + 0 + 2 * C * Y);
                prices.Add(0 + 0 + 2 * C * X);
            }
            else
            {
                prices.Add(0 + B * (Y - X) + 2 * C * X);
                prices.Add(0 + 0 + 2 * C * Y);
            }

            Console.WriteLine(prices.Min());
        }
    }

}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;
V C(500),S(500),F(500);
ll jikan(ll x,ll y){
    if(x==y)return S.at(x)+C.at(x);
    else{
        if(S.at(x)+C.at(x)<=S.at(x+1))return jikan(x+1,y);
        else{
            ll shusei=(S.at(x)+C.at(x))/F.at(x+1);
            ll saikai=shusei*F.at(x+1);
            if((S.at(x)+C.at(x))%F.at(x+1))saikai+=F.at(x+1);
            S.at(x+1)=saikai;
            return jikan(x+1,y);
        }
    }
}
int main(){
    ll N;
    cin>>N;
    
    rep(i,0,N-1)cin>>C.at(i)>>S.at(i)>>F.at(i);
    
    V ans(N-1);
    for(ll j=N-2;j>=0;j--)ans.at(j)=jikan(j,N-2);
    rep(i,0,N-1)cout<<ans.at(i)<<endl;
    cout<<0<<endl;
}



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

typedef long long ll;

 
int main(){
  ll n, m;
  cin >> n >> m;
  ll mod = 1e9+7;
  if(abs(n-m)>1){
    cout << 0 << endl;
    return 0;
  }
  ll ans;
  if(abs(n-m)==1) ans = 1;
  else ans = 2;
  for(int i=1; i<=n; i++){
    ans *= i;
    ans %= mod;
  }
  for(int i=1; i<=m; i++){
    ans *= i;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "5 4 2", "2 1 1", "3 3 4" ].parse.expand.solve == 9 );
	assert( [ "5 4 3", "2 1 1", "3 3 4", "1 4 2" ].parse.expand.solve == 0 );
	assert( [ "10 10 5", "1 6 1", "4 1 3", "6 9 4", "9 4 2", "3 1 3" ].parse.expand.solve == 64 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto whn = input.front.split.to!( long[] );
	auto xyas = new long[][]( whn[ 2 ] );
	foreach( ref xya; xyas )
	{
		input.popFront;
		xya = input.front.split.to!( long[] );
	}
	return tuple( whn[ 0 ], whn[ 1 ], xyas );
}

auto solve( long w, long h, long[][] xyas )
{
	auto css = new bool[][]( w, h );
	foreach( xya; xyas )
	{
		switch( xya[ 2 ] )
		{
			case 1 : css.fill( 0, 0, xya[ 0 ], h ); break;
			case 2 : css.fill( xya[ 0 ], 0, w, h ); break;
			case 3 : css.fill( 0, 0, w, xya[ 1 ] ); break;
			case 4 : css.fill( 0, xya[ 1 ], w, h ); break;
			default: assert( false );
		}
	}
	return css.joiner.count( false );
}

void fill( ref bool[][] css, long x1, long y1, long x2, long y2 )
{
	for( auto x = x1; x < x2; x++ )
	{
		for( auto y = y1; y < y2; y++ )
		{
			css[ x ][ y ] = true;
		}
	}
}


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

#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define REP(i, n) for(int i = 0;i < (int)(n);i++)
#define REPD(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, a, b) for(int i = a;i <= (int)(b);i++)
#define FORD(i, a, b) for(int i = a;i >= (int)(b);i--)
int main() {
  char s;
  cin >> s;
  if(isupper(s)) cout << "A" << endl;
  else cout << "a" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
using namespace std;
char a[200050];
int main()
{
   scanf("%s",a);
    
        int pre=-1;
        int back=-1;
        int n=strlen(a);
        for(int i=0;i<n;i++)
        {
            if(a[i]=='A'&&pre==-1)pre=i;
            if(a[i]=='Z')back=i;
        }
        if(pre==-1||back==-1)
        {
            printf("0\n");
        }
        else printf("%d\n",back-pre+1);
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define min_value(type) numeric_limits<type>::min()
#define max_value(type) numeric_limits<type>::max()
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

void solve() {
  rd(int, n);
  rdv(int, a, n + 1);
  rdv(int, b, n);
  long long ans = 0;
  rep(i, 0, n) {
    int pick_cur = min(b[i], a[i]);
    b[i] -= pick_cur;
    int pick_next = min(a[i + 1], b[i]);
    a[i + 1] -= pick_next;
    ans += pick_cur + pick_next;
  }
  pr(ans);
}

Measured memory_bytes: 1024
/* 
* ID: juryc
* PROG: Greedy Takahashi
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll a,b,k; cin>>a>>b>>k;
if(k<=a) cout<<a-k<<"  "<<b<<"\n"; 
else if(k<=a+b) cout<<0<<" "<<b-(k-a)<<"\n"; 
else cout<<0<<" "<<0<<endl;
return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c=0,i;
  cin >>a>>b;
  for(i=a;i<=b;i++){
    int n,m,o,p;
    a=i;
    n=a%10;
    a/=10;
    m=a%10;
    a/=100;
    o=a%10;
    a/=10;
    p=a;
    if(n==p&&m==o){
      c++;
    }
  }
  cout <<c<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.BitSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int m = in.nextInt();
			int money = in.nextInt();
			if(n==0) break;
			int[][] e = new int[n][n];
			int[][] d = new int[n][n];
			Node[] node = new Node[n];
			for(int i=0; i<n; i++) node[i] = new Node(i);
			for(int i=0; i<m; i++){
				int a = in.nextInt()-1;
				int b = in.nextInt()-1;
				int dist = in.nextInt();
				int enemy = in.nextInt();
				d[a][b] = d[b][a] = dist;
				e[a][b] = e[b][a] = enemy;
				node[a].createEdge(node[b]);
				node[b].createEdge(node[a]);
			}
			Queue<Pos> qu = new PriorityQueue<Pos>();
			BitSet bs = new BitSet(n);
			bs.set(0);
			qu.add(new Pos(0, 0, money, 0, bs));
			boolean[][] used = new boolean[n][money+1];
			final int INF = 100000000;
			int res = INF;
			while(!qu.isEmpty()){
				Pos p = qu.poll();
				if(used[p.id][p.m]) continue;
				if(p.id == n-1){
					res = Math.min(p.e, res);
					continue;
				}
				used[p.id][p.m] = true;
				for(Node v: node[p.id].edge){
					if(p.state.get(v.id)) continue;
					BitSet bs1 = (BitSet) p.state.clone();
					bs1.set(v.id);
					BitSet bs2 = (BitSet) bs1.clone();
					qu.add(new Pos(v.id, p.d+d[p.id][v.id], p.m, p.e+e[p.id][v.id], bs1));
					if(p.m - d[p.id][v.id] < 0) continue;
					qu.add(new Pos(v.id, p.d+d[p.id][v.id], p.m-d[p.id][v.id], p.e, bs2));
				}
			}
			System.out.println(res);
		}
	}
}

class Pos implements Comparable<Pos>{
	int id;
	int d, m, e;
	BitSet state;
	public Pos(int id, int d, int m, int e, BitSet state){
		this.id = id;
		this.d = d;
		this.m = m;
		this.e = e;
		this.state = state;
	}
	@Override
	public int compareTo(Pos o) {
		return e-o.e;
	}
}

class Node{
	int id;
	ArrayList<Node> edge = new ArrayList<Node>();
	public Node(int id){
		this.id = id;
	}
	public void createEdge(Node nd){
		edge.add(nd);
	}
}

Measured memory_bytes: 109612
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using Dp = vector<vector<vector<double>>>;

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

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

  int m = accumulate(begin(cnt), end(cnt), 0);
  Dp dp(m + 1, vector<vector<double>>(m + 1, vector<double>(m + 1, 0.0)));
  for (int k = 0; k <= m; k++) {
    for (int j = 0; j <= m; j++) {
      for (int i = 0; i <= m; i++) {
        if (i + j + k == 0) continue;
        if (i + j + k > m) continue;

        double sum = i + j + k;
        double& ans = dp[i][j][k];
        ans = n / sum;
        // cout << i << " " << j << " " << k << endl;
        if (i > 0) ans += i / sum * dp[i - 1][j][k];
        if (j > 0) ans += j / sum * dp[i + 1][j - 1][k];
        if (k > 0) ans += k / sum * dp[i][j + 1][k - 1];
      }
    }
  }
  cout << setprecision(10) << fixed << dp[cnt[0]][cnt[1]][cnt[2]] << endl;

  return 0;
}


Measured memory_bytes: 216832
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    int N,h[100000],dp[100000]={0},i;
    scanf("%d",&N);
    for(i=1;i<N;i++){
        dp[i]=1e9;
    }
    for(i=0;i<N;i++){
        scanf("%d",h+i);
    }
    for(i=0;i<N;i++){
        if(i+1<N){dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));}
        if(i+2<N){dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));}
    }
    printf("%d\n",dp[N-1]);
    return 0;
}


Measured memory_bytes: 896
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
B, C = [A[0]], [A[N - 1]]

for i in range(1, N):
    B.append(gcd(B[i - 1], A[i]))

AA = list(reversed(A))
for i in range(1, N):
    C.append(gcd(C[i - 1], AA[i]))
C.reverse()
ans = 0
for i in range(1, N - 1):
    ans = max(ans, gcd(B[i - 1], C[i + 1]))
ans = max(ans, B[N - 2], C[1])
print(ans)

Measured memory_bytes: 16152
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll a, b, k,ra,rb;
	bool f=0;
	cin>>a;
	cin>>b;
	cin>>k;
	
	if(k==0){
		cout<<a<<" "<<b<<endl;
		f=1;
	}
	else if(k>a){
		k-=a;
		ra=0;
		
		if(k>b){
			rb=0;
		}
		else{
			rb=(b-k);
		}
	}
	else{
		ra=(a-k);
		k=0;	
		rb=b;
	}
	if(f==0)
	cout<<ra<<" "<<rb<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20
#define yes "Yes"
#define no "No"

constexpr lint MOD = 1e9 + 7;
lint A, B, C, D, E, F, G, H, I, J, K, L, M, N;
lint O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans = 1;
lint sum = 0;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;

	rep1(i, N) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
    cin>>s>>t;
    ll n = s.size();
    ll m = t.size();
    ll dp[n+1][m+1];
    for (ll i = 0;i<=n;i++){
        for (ll j = 0;j<=m;j++)dp[i][j] = 0;
    }
    for (ll i = 1;i<=n;i++){
        for (ll j = 1;j<=m;j++){
            if (s[i-1]==t[j-1])dp[i][j] = 1+dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    ll i = n;
    ll j = m;
    string ans = "";
    while (i>0 && j>0){
        if (s[i-1]==t[j-1]){ans+=s[i-1];i--;j--;}
        else if (dp[i][j-1]>dp[i-1][j])
            j--;
        else i--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 73892
import java.util.*;
public class Main {
    public static void main(String[]$) {
        Scanner sc = new Scanner(System.in);
        int n=Integer.parseInt(sc.next());
        long[] a=new long[n+1];
        a[0]=0;
        HashMap<Long,Integer> m=new HashMap<>();
        m.put(a[0],0);
        for (int i = 1; i <n+1; i++) {
            a[i]=a[i-1]+Long.parseLong(sc.next());
            m.put(a[i],0);
        }
        long ans=0;
        for(int i=0;i<=n;i++){
            ans+=m.get(a[i]);
            m.put(a[i],m.get(a[i])+1);
        }
        System.out.println(ans);
    }
}


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

int main() {
  int A,B,C;
  cin >> A>>B>>C;
  
  if (A==B&&B==C) {
      cout << "No" << endl;
    }
  else if (A==B&&A!=C) {
      cout << "Yes" << endl;
  }
  else if (A==C&&A!=B){
      cout << "Yes" << endl;
  }
  else if (B==C&&A!=C) {
      cout << "Yes" << endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      int N = sc.nextInt();
      int ans =0;
      for (int i=N; i<=999; i++) {
        int i3 = i % 10;
        int i2 = (i % 100 - i3) /10;
        int i1 = (i - i2 * 10 - i3) / 100;
        if (i3 == i2 && i2 == i1) {
          ans = i;
          break;
        }
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 22740
s = input()
N = int(input())
len_s = len(s)

sub_set = set()

for start in range(len_s):
    k = 1
    while k <= min(len_s-start, N):
        sub_set.add(s[start:start+k])
        k += 1
        

sub_list = list(sub_set)
sub_list.sort()

print(sub_list[N-1])

Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,k;string s;cin>>n>>s>>k;
  char c=s[k-1];
  rep(i,n){
    if(s[i]!=c)s[i]='*';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

#define pb push_back

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define MOD(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	char S[10];
	scanf("%s", S);
	int L = strlen(S);
	int n = 0;
	int N = 0;
	for (int i = L - 1; i >= 0; i--) {
		n += S[i] - '0';
		N += (S[i] - '0') * pow(10, L - 1 - i);
	}
	printf("%s\n", N % n == 0 ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *
from functools import reduce,partial
from time import time

def readln():
    return list(map(int,input().split(' ')))

def identity(x):
    """Return the input itself."""
    return x

def constant(c):
    """Return an function which always
    returns the input constant c."""
    def const_function(const,*args):
        return const
    return partial(const_function,c)

def inc(c = 1):
    """Return a function which reads an input x and returns x + c as output.
    By default, c equals 1."""
    return lambda x: x + c

def add(*args):
    """Return the sum of the input."""
    def add2(x,y): return x + y
    return reduce(add2,args)

def mapv(f,*lst):
    """Return a vector of the result of map."""
    return list(map(f,*lst))

def vector(*args):
    """Return a vector of input parameters."""
    return args

def sequence(n,f = constant(0)):
    """Return a vector of length n, and initialize the i'th
    item with f(i).By default the vector will initialized with 0."""
    return [f(i) for i in range(0,n)]

def matrix(n,m,f = constant(0)):
    """Return a 2-dim vector which contains n vectors with length m.
    The j's item of vector i will be initialized by f(i,j).By default,
    the vector will be initialized with 0."""
    return [[f(i,j) for j in range(0,m)] for i in range(0,n)]

def flat(v):
    """Return a flat vector which contains the elements of v in their
    origin order.If the input is not a vector, return a vector which
    only contains the input."""
    if not isinstance(v,list): return [v]
    if not v: return []
    return reduce(add,mapv(flat,v))

def partition(v,f = identity):
    """Partition vector v by f(v[i]).
    e.g. partition([1,2,3,1,2,3],identity()) == {1:[1,1,1], 2:[2,2], 3:[3]}
    By default, the vector will be partitioned by identity function."""
    result = {}
    for item in v:
        key = f(item)
        s = result.get(key)
        if s:
            s.append(item)
        else:
            result.update({key:[item]})
    return result

def getValue(key):
    """Return a function which returns the value of key in a hash-map.
    If the key do not exist, it will throw an error."""
    return lambda x: x[key]

def mapValue(f,m):
    """Replace each value in hash-map m with f(value).
    Return the new hash-map."""
    res = {}
    for key in m:
        res.update({key: f(m[key])})
    return res

p = 1000000000 + 7

n,t = readln()
a = readln()
prev = 0
ans = t
for item in a:
    if item > prev + t:
        ans = ans + t
    else:
        ans = ans + item - prev
    prev = item
print(ans)


Measured memory_bytes: 26596
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
  int N[3],K;
  cin >> N[0] >> N[1] >> N[2] >> K;
  sort(N,N+3);
  REP(i,K) N[2]*=2;
  cout << N[0]+N[1]+N[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int sai(int a,int b){
  if(a==0||b==0) return 0;
  if(a<0) a*=-1;
  if(b<0) b*=-1;
  int buf;
  while(a%b!=0){
    buf=b;
    b=a%b;
    a=buf;
  }
  return b;
}
int main(){
  int q;
  cin >> q;
  int i,j,k;
  /*
  int ma[20001]={};
  for(i=0;i<151;i++){
    for(j=0;j<151;j++){
      int y=i*i+j*j;
      if(y==0||y>20000) continue;
      ma[y]=1;
    }
  }
  */
  for(i=0;i<q;i++){
    int n,m,o=0;
    cin >> m >> n;
    int x=m*m+n*n;
    int bm=m,bn=n;
    if(bm<0) bm*=-1;
    if(bn<0) bn*=-1;
    bm=max(bm,bn);
    //cout << bm <<endl;
    for(j=-bm;j<=bm;j++){
      for(k=-bm;k<=bm;k++){
	if(j==0&&k==0) continue;
	int y=(j*j+k*k);
	if(x%y==0) {
	  //cout << j << ":"<< k << endl;
	  int z=sai((j*m+k*n),(j*n-k*m));
	  //cout <<j*m+k*n<<":"<<j*n-k*m<< ":"<<y << ":"<<z<<endl;
	  //o++;
	  
	  if(z==y||j*m+k*n==0||j*n-k*m==0){
	    //cout << j <<":"<< k << endl;
	    //cout <<j*m+k*n<<":"<<j*n-k*m<< ":"<<y<<endl;
	    o++;
	  }
	  
	}
      }
    }
    //cout << o <<endl;
    if(o<=8) cout << "P" << endl;
    else cout << "C" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

//Black-and-White
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next();
			if(s.equals("0"))break;
			char[][] m = new char[3][3];
			m[0] = s.toCharArray();
			for(int i=1;i<3;i++)m[i]=sc.next().toCharArray();
			int[][] c = new int[4][5];
			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){
					int x = m[i][j]=='b'?1:m[i][j]=='w'?-1:0;
					c[i+1][0]+=x;
					c[0][j+1]+=x;
					if(i==j)c[0][0]+=x;
					if(i==2-j)c[0][4]+=x;
				}
			}
			String ans = "NA";
			for(int i=0;i<4;i++)if(Math.abs(c[i][0])==3)ans=c[i][0]==3?"b":"w";
			for(int j=0;j<5;j++)if(Math.abs(c[0][j])==3)ans=c[0][j]==3?"b":"w";
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    onoff = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                if j + 1 in ks[k][1:]:
                    onoff[k] +=1
    cnt = 0
    for l in range(m):
        if onoff[l] % 2 == p[l]:
            cnt += 1
        if cnt == m:
            ans += 1
print(ans)

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

int main() {
  int a,b;
  char c;
  cin >> a >> c >> b;
  
  if (c == '+') {
    cout << a + b << endl;
  } else if (c == '-') {
    cout << a - b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;

int n,A[100001],L[100001];//Aに数列の値を入れてLは増加部分列の最後の要素の最小値を保持する配列
int lis(){
    L[0]=A[0];
    int length=1;
    REP(i,1,n){
        if(L[length-1]<A[i]){
            L[length]=A[i];
            length++; //Lの最後の要素よりも大きいものが来たら増加列は増える
        }
        else{
            *lower_bound(L,L+length,A[i])=A[i];
            //そうでなければ、Lのうち、A[i]未満であるようなものの最大値をA[i]で置き換える
        }
    }
    return length;

}

int main(){
    cin>>n;
    rep0(i,n){
        cin>>A[i];
    }
    cout<<lis()<<endl;
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> Num(N);
  for(int i=0;i<N;i++){
  cin>>Num.at(i);
  }
  sort(Num.begin(),Num.end());
  reverse(Num.begin(),Num.end());
  int a=0;
  int A=0;
  while(a<N){
    A+=Num.at(a);
    a+=2;
  }
  int b=1;
  int B=0;
  while (b<N){
    B+=Num.at(b);
    b+=2;
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256