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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};



int main(){
    int N;
    cin >> N;
    VVI yes(N);
    VVI no(N);

    REP(i, N) {
        int a;
        cin >> a;
        REP(j, a) {
            int x, y;
            cin >> x >> y;
            if(y == 1) {
                yes[i].PB(x-1);
            } else {
                no[i].PB(x-1);
            }
        }
    }

    int result = 0;
    REP(i, (1<<N)) {
        int cnt = 0;
        bool flag = true;
        REP(j, N) {
            if(i&(1<<j)){
                cnt++;
                REP(k, yes[j].size()) {
                    if((i&(1<<yes[j][k])) == 0) {
                        flag = false;
                        break;
                    }
                }
                if(!flag) break;
                
                REP(k, no[j].size()) {
                    if(i&(1<<no[j][k])) {
                        flag = false;
                        break;
                    }
                }
                if(!flag) break;
            }
        }

        if(flag) result = max(result, cnt);
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# l = list(map(int, input().split()))
# n = int(input())
# l = list(map(int, input().split()))
# l = np.array(list(map(int, input().split())))
# l = np.array(list(map(int, input().split())))
s = input()
min = sys.maxsize
for i in range(len(s)-2):
    div = int(s[i:i+3])
    # if abs(sum-753) = :
    min = abs(div-753) if abs(div-753)<min else min
print(min)


Measured memory_bytes: 14296
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}



struct UnionFind{
    int par[MAX];
    int kosuu[MAX];
    UnionFind(int n){
        REP(i,n) par[i]=i;
        REP(i,n) kosuu[i] = 1;
    }

    int root(int x){
        int tmp;
        if(par[x]==x) return x;
        else{
            tmp=root(par[x]);
            par[x]=tmp;
            return tmp;
        }
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    void unite(int x,int y){
        if(not same(x,y)){ 
        kosuu[root(y)] += kosuu[root(x)];
        par[root(x)] = root(y);
        }
    }

    int renketu_kosuu(int x){
        return kosuu[root(x)];
    }
};

signed main(){
    int n;
    cin >> n;
    int x, y;
    vector<int> gyou[MAX];
    vector<int> retu[MAX];
    bool isretu[MAX];
    REP(i,MAX) isretu[i] = false;
    REP(i,n){
        cin >> x;
        cin >> y;
        gyou[x].push_back(y);
        retu[y].push_back(x);
        isretu[y] = true;
    }
    UnionFind U(MAX);
    REP(i,MAX){
        if(gyou[i].size() == 0) continue;
        int tmp = *(gyou[i].begin());
        itrfor(itr,gyou[i]){
            if(tmp != *itr){
                U.unite(tmp,*itr);
            }
        }
    }

    int oya[MAX] = {};
    set<int> oyaa[MAX];
    REP(i,MAX){
        if(isretu[i]){
            oya[U.root(i)] += 1;
            itrfor(itr,retu[i]){
                oyaa[U.root(i)].insert(*itr);
            }
        }

    }

    int res = 0;
    REP(i,MAX){
        res += oya[i] * oyaa[i].size();
    }


    cout << res - n << endl;
}

Measured memory_bytes: 18048
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-08-29 19:58:34
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    s = input()
    t = input()
    n,m = len(s), len(t)
    ans = n
    for i in range(n-m+1):
        c = 0
        for j in range(m):
            if s[i+j] != t[j]:
                c += 1
        ans = min(ans, c)
    print(ans)
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


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

int main() {
  int A, B, C, X, Y, sum1, sum2, count;
  cin >> A >> B >> C >> X >> Y;
  sum1 = A * X + B * Y;
  for(int i = 0; i <= max(X,Y); i++) {
    if(i <= X && i <= Y) {
      sum2 = (X - i) * A + (Y - i) * B + (2 * i) * C;
      if(sum2 <= sum1) {
        sum1 = sum2;
      }
    }
    else if(i >= max(X,Y)) {
      sum2 = 2 * i * C;
      if(sum2 <= sum1) {
        sum1 = sum2;
      }
    }
  }
  cout << sum1 << endl;
}


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

bool is_sqrt(int n) {
   if(floor(sqrt(n))==sqrt(n)) {
       return true;
   } else {
       return false;
   }
}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string a, b;
   cin >> a >> b;
   string c = a + b;
   int x = stoi(c);
   if(is_sqrt(x)) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int A[2][maxn];
int main(){
#ifdef DEBUG
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;++i){
    cin>>A[0][i];
    //if(i==1)A[0][i]=1;
    int L=max(i-A[0][i],1),R=min(i+A[0][i]+1,n+1);
    A[1][L]++;A[1][R]--;
  }
  int cur=1;
  while(k--){
    int cnt=0;
    for(int i=0;i<=n+1;++i)A[cur^1][i]=0;
    for(int i=1;i<=n;++i){
      A[cur][i]+=A[cur][i-1];
      int L=max(i-A[cur][i],1),R=min(i+1+A[cur][i],n+1);
      A[cur^1][L]++;
      A[cur^1][R]--;
      cnt+=A[cur][i]==n;
    }
    //for(int i=1;i<=n;++i)cout<<A[cur][i]<<' ';
    //cout<<endl;
    cur^=1;
    if(cnt==n)break;
  }
  for(int i=1;i<=n;++i)cout<<A[cur^1][i]<<" ";
  cout<<'\n';
  return 0;
}
//2020.06.13 20:08:36


Measured memory_bytes: 5164
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  def next(): String = sc.next()
  def nextInt(): Int = next().toInt
  def nextLong(): Long = next().toLong

  def taskD(): Unit = {
    val n = nextInt()
    val as = Seq.fill(n)(nextInt())
    val firstWins = as.exists(_ % 2 == 1)
    println(if (firstWins) "first" else "second")
  }

  taskD()
}


Measured memory_bytes: 56508
//解説AC
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
int N; cin >> N;
  pair<int,int> AB[101];
  pair<int,int> CD[101];
  bool flag[101] = {false}; int cnt = 0;
  
  for(int i = 0 ; i < N; i++){ cin >> AB[i].first >> AB[i].second;}
  for(int j = 0; j < N; j++){ cin >> CD[j].first >> CD[j].second;}
  
  sort(CD,CD+N);
  
  for(int i = 0; i < N; i++){
    int x = CD[i].first ;
    int y = CD[i].second;
   int min_val = -1;
    int min_num = -1;
    for(int j = 0; j < N; j++){
      if( AB[j].first < x && AB[j].second < y && flag[j] == false){
        if(min_val < AB[j].second){
          min_val = AB[j].second; min_num = j;} }}
      if( min_val != -1){ flag[min_num] = true; cnt++;} }
  
  cout << cnt << endl;
  return 0;}
                               
          
      
  

Measured memory_bytes: 256
#include <climits>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int N, M, X;

int dfs(vector<int>& C, vector<vector<int>>& A, int idx, int cost,
        vector<int>& Y) {
  if (idx == N) {
    rep(i, M) {
      if (Y[i] < X) return INT_MAX;
    }
    return cost;
  }
  int ret = INT_MAX;
  ret = min(ret, dfs(C, A, idx + 1, cost, Y));
  rep(i, M) { Y[i] += A[idx][i]; }
  ret = min(ret, dfs(C, A, idx + 1, cost + C[idx], Y));
  rep(i, M) { Y[i] -= A[idx][i]; }
  return ret;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));

  rep(i, N) {
    cin >> C[i];
    rep(j, M) cin >> A[i][j];
  }

  vector<int> Y(M, 0);
  int answer = dfs(C, A, 0, 0, Y);
  if (answer == INT_MAX) answer = -1;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
using namespace std;
int main()
{
    char str1[15]={0};
    char str2[15]={0};
    scanf("%s",str1);
    scanf("%s",str2);
    int i,flag=1;
    for(i=0;str1[i]!=0;i++)
    {
        if(str1[i]!=str2[i])
        {
            flag=0;
            break;
        }
    }
    if(flag)printf("Yes");
    else printf("No");

    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c,d,x,y,p,q;
    cin>>a>>b>>c>>d;
    x=a*c;
    y=a*d;
    p=b*c;
    q=b*d;
    long long int ans=max(p,q);
    ans=max(y,ans);
    ans=max(x,ans);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int ans=0;
  int X;
  //Xに一回受け取る
  
  for(int i=0;i<N;i++){
    cin >> X;
    if(i%2==0 && X%2==1){
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;
vector<vector<int> > tree;

void solve(int curr, deque<vector<long long> >& dp, deque<int>& cnt)
{
    int n = 0;
    int maxLen = 0;
    dp.clear();

    for(int next : tree[curr]){
        deque<vector<long long> > dp2;
        deque<int> cnt2;
        solve(next, dp2, cnt2);

        int m = cnt2.size();
        if(n < m){
            swap(n, m);
            dp.swap(dp2);
            cnt.swap(cnt2);
        }

        for(int i=0; i<m; ++i){
            vector<long long> v(3, 0);
            for(int j=0; j<3; ++j){
                for(int k=0; k<3; ++k){
                    v[min(2,j+k)] += dp[i][j] * dp2[i][k];
                    v[min(2,j+k)] %= MOD;
                }
            }
            dp[i] = v;
            cnt[i] += cnt2[i];
        }
        maxLen = max(maxLen, m);
    }

    for(int i=0; i<maxLen; ++i){
        dp[i][0] += dp[i][2];
        dp[i][2] = 0;
    }
    dp.push_front({1, 1, 0});
    cnt.push_front(1);
}

int main()
{
    int n;
    cin >> n;
    tree.assign(n+1, vector<int>());
    for(int i=1; i<=n; ++i){
        int p;
        cin >> p;
        tree[p].push_back(i);
    }

    deque<vector<long long> > dp;
    deque<int> cnt;
    solve(0, dp, cnt);

    vector<long long> pow2(n+1);
    pow2[0] = 1;
    for(int i=1; i<=n; ++i){
        pow2[i] = pow2[i-1] * 2;
        pow2[i] %= MOD;
    }

    long long ans = 0;
    for(unsigned i=0; i<dp.size(); ++i){
        ans += dp[i][1] * pow2[n+1-cnt[i]];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 326784
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N, M;
int A[100000 + 10];
int S[100000 + 10];
map<int, int> cnt;

double sign(double A){
    return (A>0)-(A<0);
}

signed main(void) {
    cin>>N>>M;
    rep(i, N) {
        cin >> A[i];
        if (i==0) S[i] = A[i];
        else S[i] = S[i-1] + A[i];
        cnt[S[i] % M] += 1;
    }

    int ans = 0;
    for (auto a : cnt) {
            if (a.fi == 0) {
                ans += a.se;
            }
            ans += a.se*(a.se-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
/* AtCoder Beginner Contest 060. Task A - Shiritori, by Abreto <m@abreto.net>. */
#include <stdio.h>
#include <string.h>

#define MAXN    16

int main(void)
{
    char A[MAXN] = {0}, B[MAXN] = {0}, C[MAXN] = {0};
    int lA = 0, lB = 0;
    int ok = 1;

    scanf("%s %s %s", A, B, C);
    lA = strlen(A); lB = strlen(B);
    ok = ok && (A[lA-1] == B[0]);
    ok = ok && (B[lB-1] == C[0]);

    printf("%s\n", ok?"YES":"NO");
    return 0;
}


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

int n,m;
long long tmp;
long long sum = 0;
priority_queue<long long> q;
int main() {

    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        q.push(tmp);
    }
    for (int i = 0; i < m; ++i) {
        tmp = q.top();
        q.pop();
        q.push(tmp / 2);
    }
    for (int i = 0; i < n; ++i) {
        sum += q.top();
        q.pop();
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 4244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Knocker of the Gigas Cedar
 * PCK2013 ??¬???4
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int D, N;
			D = parseInt(line.substring(0, line.indexOf(' ')));
			N = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((D | N) == 0) break;

			int[] A = new int[N];
			int[] E = new int[N];
			int[] R = new int[N];

			for (int i = 0; i < N; i++) {
				words = br.readLine().split(" ");
				A[i] = parseInt(words[0]);
				E[i] = parseInt(words[1]);
				R[i] = parseInt(words[2]);
			}

			//?¨?????????????????????????, ????¨????
			int[][] dp = new int[D + 1][101];

			for (int i = 0; i < dp.length; i++) {
				Arrays.fill(dp[i], INF);
			}

			dp[0][0] = 0;

			for (int i = 0; i <= D; i++) {
				for (int j = 0; j <= 100; j++) {
					for (int k = 0; k < N; k++) {
						int nd = Math.min(i + A[k], D);
						int ne = Math.min(j + E[k], 100);
						if (j >= R[k]) {
							dp[nd][ne] = Math.min(dp[nd][ne], dp[i][j] + 1);
						}
					}
				}
			}

			int ans = INF;

			for (int i = 0; i <= 100; i++) {
				ans = Math.min(ans, dp[D][i]);
			}

			System.out.println(ans != INF ? ans : "NA");
		}
	}
}

Measured memory_bytes: 32200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
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; }
const int INF = 1001001001;
typedef unsigned long long ll;

ll power(ll x, ll y, ll m){
  ll res = 1;
  if(y == 0) return res;
  ll p = power(x, y/2, m);
  if(y%2 == 0){
    res *= p * p;
    res %= m;
  }
  else{
    res *= p * p;
    res %= m;
    res *= x;
    res %= m;
  }
  return res;
}


int main(){
  ll m, n;
  cin >> m >> n;

  cout << power(m, n, 1000000007) << endl;

  return 0;

}





Measured memory_bytes: 3096
ans = [0] * 26
loop do
  str = gets
  unless str
    break
  end
  str.length.times do |i|
    tmp = str[i]
    if "a" <= tmp && tmp <= "z"
      ans[tmp.ord - "a".ord] += 1
    elsif "A" <= tmp && tmp <= "Z"
      ans[tmp.ord - "A".ord] += 1
    end
  end
end

26.times do |i|
  puts "#{("a".ord + i).chr} : #{ans[i]}"
end



Measured memory_bytes: 6884
N=int(input())
A=list(map(int,input().split()))
a=1
b=0
for i in range(1,N):
    d=A[i]-A[i-1]
    if b==0:
        b=d
        continue
    if d>0:
        if b<0:
            a+=1
            b=0
    elif d<0:
        if b>0:
            a+=1
            b=0
print(a)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
vector<ll> t;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  int ans = 0;
  rep(i,n){
    cin >> p[i];
    if(i + 1 == p[i]){
      cnt++;
    }else if(i > 0 && i == p[i - 1]){
      if(cnt % 2 == 0){
        ans += cnt / 2;
      }else{
        ans += int(cnt / 2) + 1;
      }
      cnt = 0;
    }
  }
  if(cnt){
    if(cnt % 2 == 0){
      ans += cnt / 2;
    }else{
      ans += int(cnt / 2) + 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll gcd(ll a,ll b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
int main() {
	ll n,m;
	cin>>n>>m;
	ll GCD=0;
	ll ma=0;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ma=max(x,ma);
		GCD=gcd(max(GCD,x),min(GCD,x));
	}
	if(ma>=m&&m%GCD==0){
		cout <<"POSSIBLE";
	}
	else{
		cout << "IMPOSSIBLE";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    ll n,m;
    cin>>n>>m;
    ll a[n],i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll lcm=a[0]/2,even=0;
    for(i=1;i<n;i++)
    {
        lcm=(lcm*a[i]/2)/__gcd(lcm,a[i]/2);
    }
    set<ll>s;
    ll x,count=0;
    for(i=0;i<n;i++)
    {
        x=a[i]/2;
        count=0;
        while(x%2==0)
        {
            count++;
            x/=2;
        }
        s.insert(count);
    }
    ll ans,val,val1;
    //cout<<lcm<<'\n';
    if(s.size()==1)
    {
        val=m/lcm;
        ans=val;
        ans-=val/2;
        cout<<ans<<'\n';
    }
    else
    {
        cout<<0<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	int k, n;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		v.push_back(temp);
	}
	sort(v.begin(), v.end(), greater<int>());


	int answer = 0;
	for (int i = 0; i < k; i++) {
		answer += v[i];
	}

	cout << answer;
	return 0;
}

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

int main() {
  int width, height, x, y, r;
  cin >> width >> height >> x >> y >> r;

  if(((x - r) < 0) || ((x + r) > width) || ((y - r) < 0) || ((y + r) > height)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3100
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        String s=sc.nextString();
        HashMap<String,Boolean> map = new HashMap<String,Boolean>();
        map.put(s,true);
        String ans="Yes";
        for(int i=1; i<n; i++) {
            String x=sc.nextString();
            if(s.charAt(s.length()-1)!=x.charAt(0) || map.containsKey(x)){ans="No";break;}
            else map.put(x,true);
            s=x;
        }
      
        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UF {
  vector<Pi> data;
  UF(int n):data(n, Pi(-1, 0)){}
  Pi find(int x) {
    //cout<<x<<" "<<data[x].first<<" "<<data[x].second<<endl;
    if(data[x].first < 0) return Pi(x, 0);
    Pi p = find(data[x].first);
    //cout<<p.first<<" "<<p.second<<endl;
    data[x].first = p.first;
    data[x].second += p.second;
    return data[x];//Pi(p.first, data[x].second);
  }
  void unite(int a, int b, int w) {
    int x = find(a).first, y = find(b).first;
    if(x == y) return;
    if(data[x].first > data[y].first) swap(x, y), swap(a, b), w = -w;
    w += data[a].second-data[b].second;
    data[x].first += data[y].first;
    data[y].first = x;
    data[y].second += w;
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  while(cin >> N >> M, N || M) {
    UF uf(N);
    rep(i, M) {
      //cout << i << endl;
      char c; int a, b, w;
      cin >> c >> a >> b;
      --a, --b;
      if(c == '!') {
	cin >> w;
	uf.unite(a, b, w);
      } else if(c == '?') {
	Pi x = uf.find(a), y = uf.find(b);
	if(x.first != y.first) {
	  cout << "UNKNOWN" << endl;
	} else {
	  cout << y.second - x.second << endl;
	}
      }
    }
  }

  return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> c >> b >> d;
  if(max(a-b,b-a)<=d) cout << "Yes" << endl;
  else if(max(a-c,c-a)<=d&&max(b-c,c-b)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
  var output = "";
  for(var i = 0; i < input.length; i++){
    if(input.slice(i , i + 1) == "1"){
       output += "9";
    }else{
      output += "1";
    }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    var(string, s, t);
    var(int, a, b);
    var(string, u);

    if (u == s) --a;
    if (u == t) --b;
    print(a, b);


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int [] a = new int[n];
    for (int i=0; i<n-1;i++){
      int g =scan.nextInt();
      a[g-1] += 1;
    }

    for (int m=0; m<n; m++){
      System.out.println(a[m]);
    }
  }
}


Measured memory_bytes: 60144
#include<stdio.h>
int main()
{
	int b,j,i;
	for(i=1;i<=9;i++)
 	    for(j=1;j<=9;j++)
	    {b=i*j;
             printf("%dx%d=%d\n",i,j,b);
     	}
    return 0; 	
}

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

int main(){
	ios::sync_with_stdio(false);

	int N; cin>>N;
	vector<int> vec(N+1);
	for(int x=1; x*x<=N; x++){
		for(int y=1; y*y<=N; y++){
			for(int z=1; z*z<=N; z++){
				if(x*x + y*y + z*z + x*y + y*z + z*x > N) break;
				vec[x*x + y*y + z*z + x*y + y*z + z*x]++;
			}
		}
	}
	for(int i=1; i<=N; i++){
		cout << vec[i] << endl;
	}

}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        String command  = input.readLine();
        Point [] val = new Point[n];

        val[0] = new Point(0, 0, 0, 0 , command.charAt(0));

        for (int i = 1; i < n; i++) {
            int prevEast = val[i - 1].eastleft + (val[i - 1].me == 'E' ? 1 : 0);
            int prevWest = val[i - 1].westleft + (val[i - 1].me == 'W' ? 1 : 0);

            val[i] = new Point(prevEast, prevWest, 0, 0, command.charAt(i));
        }

        for (int i = n - 2 ; i >  -1 ; i--) {
            int prevEast = val[i + 1].eastRight + (val[i + 1].me == 'E' ? 1 : 0);
            int prevWest = val[i + 1].westRight + (val[i + 1].me == 'W' ? 1 : 0);

            val[i].eastRight = prevEast;
            val[i].westRight = prevWest;
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int leftWest = val[i].westleft;
            int wright = val[i].eastRight;
            min = Math.min(leftWest+ wright , min);
        }
        System.out.println(min);

    }
}


class Point {

    int eastleft;
    int westleft;
    int eastRight;

    public Point(int eastleft, int westleft, int eastRight, int westRight, char me) {
        this.eastleft = eastleft;
        this.westleft = westleft;
        this.eastRight = eastRight;
        this.westRight = westRight;
        this.me = me;
    }

    int westRight;

    char me;


}

Measured memory_bytes: 37588
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

    string S;
    cin >> S;
    string tp = "";
    vector<string> SL;
    rep(i, len(S) - 1){
        if(S[i] == 'A') tp += 'A';
        else if(S[i] == 'B' and S[i + 1] == 'C') tp += 'X', ++i;
        else if(tp != "") SL.pb(tp), tp = "";
    }
    if(tp != "") SL.pb(tp);

    ll ans = 0;
    for(auto s : SL){
        ll cta = 0;
        for(auto c : s){
            if(c == 'A') ++cta;
            else ans += cta;
        }
    }
    print(ans);

    return 0;
}

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

int main() {
  int N, X, m[128];
  cin >> N >> X;
  int S = 0;
  int M = 10000;
  for (int i = 0; i < N; i++) {
    cin >> m[i];
    S += m[i];
    if (M > m[i]) {
      M = m[i];
    }
  }
  int ans = N + (X - S) / M;
  cout << ans << endl;
}


Measured memory_bytes: 256
// include
#include <bits/stdc++.h>
using namespace std;
// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;
////////////////////////////////////////////////////////////////////////////////////////////////////


int main(int argc, char const* argv[]) 
{
    int N; cin >> N;
    int ans = N / 3;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef struct{
	int g,t,p;
}gtp;
int A[10];
gtp cnt;
void Search(int x);
void Answer(void);
int main(void){
	int n,i;
	char str[10];

	while(1){
		cnt.g=0; cnt.t=0; cnt.p=0;
		for(i=0;i<5;i++){
			fgets(str,sizeof(str),stdin);
			sscanf(str,"%d",&n);
			switch(n){
				case 0: return 0;
				case 1: cnt.g+=1; break;
				case 2: cnt.t+=1; break;
				case 3: cnt.p+=1; break;
			}
			A[i]=n;
		}
		Answer();
	}
	return 0;
}			

void Answer(void){
	int j;
	if((cnt.g!=0 && cnt.t!=0 && cnt.p!=0) || (cnt.g==0 && cnt.t==0)
			|| (cnt.t==0 && cnt.p==0) || (cnt.p==0 && cnt.g==0)){
		for(j=0;j<5;j++)
			A[j]=3;
	}
	else if(cnt.g==0)
		Search(2);
	else if(cnt.t==0)
		Search(3);
	else if(cnt.p==0)
		Search(1);
	for(j=0;j<5;j++)
		printf("%d\n",A[j]);
}
void Search(int x){
	int j;
	for(j=0;j<5;j++){
		if(A[j]==x)
			A[j]=1;
		else
			A[j]=2;
	}
}

Measured memory_bytes: 612
N, M = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(M)]

lsts = [[] for _ in range(N)]

for a, b in ab:
    lsts[a-1].append(b-1)
    lsts[b-1].append(a-1)

ans = 0

for i, lst in enumerate(lsts):
    h_lst = []
    for j in lst:
        h_lst.append(h[j])
    if h_lst == []:ans += 1
    elif h[i] > max(h_lst):
        ans += 1

print(ans)


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

int N,a,b,inf = 1e9,d[200010];

vector<vector<int>> v(200010);

void dfs(int n){
	for(int i=0;i<v[n].size();i++){
		if(d[v[n][i]]==inf){
			d[v[n][i]] = d[n]+1;
			dfs(v[n][i]);
		}
	}
}

int main(){
	cin >> N;
    if(N==1){
        cout << "First" << endl;
        return 0;
    }
	for(int i=1;i<=N-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
		d[i] = inf;
	}
	d[N] = inf;
	d[1] = 0;
	dfs(1);
	int ma = 0;
	for(int i=1;i<=N;i++){
		if(ma<d[i]){
			ma = d[i];
			a = i;
		}
		d[i] = inf;
	}
	d[a] = 0;
	dfs(a);
	ma = 0;
	for(int i=1;i<=N;i++){
		if(ma<d[i]){
			ma = d[i];
			b = i;
		}
	}
//    cerr << ma << endl;
    cout << (ma%3==1? "Second":"First") << endl;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	bool ans=true;
	range(i,1,n){
		if(v[i-1]>v[i]){
			v[i]++;
		}
		ans&=(v[i-1]<=v[i]);
	}
	Yn(ans);
}


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

int main(){
  int N,A;
  cin >> N >> A;
  int L,R;
  L = A;
  R = A + N - 1;
  int ans = 0;
  if (L > 0) ans = L;
  else if(R < 0) ans = R;
  else ans = 0;
  cout << ((L+R)*N)/2 - ans << endl;
}

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

def dfs(s):
    if int(s) > n:
        return 0
        
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret
    
print(dfs('0'))

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int []a = new int [n+1];
		int []b = new int [n];
		
		for(int i = 0; i<= n ;i++) {
			a[i] = sc.nextInt();
		}
		
		for(int j = 0; j< n ;j++) {
			b[j] = sc.nextInt();
		}
		
		long hunt = 0;
		for(int i = 0; i < n ; i++) {
			if(a[i] >= b[i]) {
				hunt += b[i];
			}
			if(a[i] < b[i]) {
				b[i] = b[i] - a[i];
				hunt += a[i];
				
				if(a[i+1] >= b[i]) {
					a[i+1] = a[i+1] - b[i];
					hunt += b[i];
				}
				else {
					hunt += a[i + 1];
					a[i + 1] = 0;
				}
				
			}
		   }
		System.out.println(hunt);
		}
		
		

	}




Measured memory_bytes: 64896
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int MAX = 100000;
static const int INF = 100000000;

static const int WHITE = 0;
static const int BLACK = 1;

typedef pair<int, int> P;
typedef pair<P, int> PP;

vector<P> G[MAX];
int n;
int d[100000];
int f,s;
int result_f,result_s;
int max_d;

int dijkstra(int start){
  priority_queue<pair<int,int> > PQ;
  bool color[100000];
  for( int i = 0; i < n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }

  d[start] = 0;
  PQ.push(make_pair(0,start));

  while( !PQ.empty() ){
    pair<int,int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if( d[u] < f.first * (-1) ) continue;

    for ( int j = 0; j < G[u].size(); j++ ){
      int v = G[u][j].first;
      if ( color[v] == BLACK ) continue;
      if ( d[v] > d[u] + G[u][j].second ){
        d[v] = d[u] + G[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
      }
    }
  }
  //????????????????????????return_i
  int return_i;
  max_d = 0;
  rep(i,n){
  //  cout << d[i] << endl;
    if(d[i] > max_d){
      max_d = d[i];
      return_i = i;
    }
  }

  return return_i;

}

int main(void){
  cin >> n;

  int a,b,c;
  rep(i,n-1){
    cin >> a >> b >> c;
    G[a].pb(make_pair(b,c));
    G[b].pb(make_pair(a,c));
  }
  dijkstra(dijkstra(0));
  cout << max_d << endl;

  return 0;
}

Measured memory_bytes: 9932
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    H,W,M = LMIIS()
    targets_row = []
    targets_column = []
    targets = []
    for i in range(M):
        column,row = LMIIS()
        targets_row.append(row)
        targets_column.append(column)
        targets.append((column,row))

    common_columns = Counter(targets_column).most_common()
    common_rows = Counter(targets_row).most_common()
    max_columns = defaultdict(bool)
    num_max_column = common_columns[0][1]
    for k,v in common_columns:
        if v < num_max_column:
            break
        max_columns[k] = True
    max_rows = defaultdict(bool)
    num_max_row = common_rows[0][1]
    for k,v in common_rows:
        if v < num_max_row:
            break
        max_rows[k] = True
    dbg(max_columns)
    dbg(max_rows)
    num_candidates = len(max_columns)*len(max_rows)
    

    num_target_on_intersection = 0
    for column, row in targets:
        if max_columns[column] and max_rows[row]:
            num_target_on_intersection += 1
    
    ans = common_columns[0][1] + common_rows[0][1]
    dbg(num_target_on_intersection)
    dbg(num_candidates)
    print(ans if num_target_on_intersection < num_candidates else ans - 1)
    

    
    
    

    
main()

Measured memory_bytes: 274668
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
  char a[20],b[20];
  cin>>a>>b;
  int x,y;
  cin>>x>>y;
  char c[20];
  cin>>c;
  if (strcmp(a,c)==0)
    cout<<x-1<<"\n"<<y;
    else cout<<x<<" "<<y-1;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    long long int count(long long int wt[],long long int val[],long long int n,long long int W){
      long long int dp[W+1];
      for(long long int i=0;i<=W;i++){
           dp[i]=0;
      }
      for(long long int i=0;i<n;i++){
          for(long long int j=W;j>=wt[i];j--){
              dp[j]=max(dp[j],val[i]+dp[j-wt[i]]);
          }
      }
      return dp[W];
    }
    int main(){
        long long int n;long long int W;
        cin>>n>>W;
        long long int wt[n];long long int val[n];
        for(long long int i=0;i<n;i++){
            cin>>wt[i]>>val[i];   
        }
        long long int res=count(wt,val,n,W);
        cout<<res;
    }

Measured memory_bytes: 1024
import math
from functools import reduce

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def prime(n1):
	for i in range(2, int(math.sqrt(n1))+1):
		if n1%i == 0:
			return False
	return True

n = int(input())
if prime(n):
	print(n - 1)
else:
	k = sorted(list(factors(n)))
	#print(k)
	if len(k) % 2 != 0:
		if k[len(k)//2]*k[len(k)//2] == n:
			print(2*k[len(k)//2] - 2)
		#else:

	else:
		s = k[len(k)//2 - 1] + k[len(k)//2]
		print(s - 2)


Measured memory_bytes: 4588
#include<bits/stdc++.h>       
using namespace std;          
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                              
#define pb push_back          
#define PII pair<int,int>     
                              
#define VS vector<string>     
#define VI vector<int>        
#define ll long long int      
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {              
    ll n,a,b; cin >> n >> a >> b;
    if(a > b or (n==1 and a != b)) {
        cout << 0 << endl;    
    } else if(a == b or n == 2) {                                                                                               
        cout << 1 << endl;    
    } else {                  
        cout << (n-2)*(b-a) + 1 << endl; 
    }                         
} 

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

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    
    bool judge = true;
    vector<int> x = {a[0][0] - a[0][1], a[0][1] - a[0][2]};
    REP(i, 3) rep(j, 2) {
        if (x[j] != a[i][j] - a[i][j + 1]) judge = false;
    }
    vector<int> y = {a[0][0] - a[1][0], a[1][0] - a[2][0]};
    REP(i, 3) rep(j, 2) {
        if (y[j] != a[j][i] - a[j + 1][i]) judge = false;
    }
    if (judge) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256