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

#define NMAX 201
#define INF 2000000000

using namespace std;

int apples;
int range;
int flavours[NMAX];

int nSum;
int n1Sum;
int maxDiff = INF;

int main()
{
    cin >> apples >> range;
    for(int i = 1; i <= apples; i++)
    {
        flavours[i] = range + i - 1;
        nSum += flavours[i];
    }

    for(int i = 1; i <= apples; i++)
    {
        int sum = nSum - flavours[i];
        if(abs(nSum - sum) < maxDiff)
        {
            maxDiff = abs(nSum - sum);
            n1Sum = sum;
        }
    }
    cout << n1Sum << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n, k;
  cin >> n >> k;
  for(int i=k-n+1; i<k+n; i++){
    cout << i <<" ";
  }
  cout << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b, c, d = Is()
def calc(num, x, y):
    l = (x*y)//gcd(x, y)
    return num - num//x - num//y + num//l

print(calc(b, c, d) - calc(a-1, c, d))


Measured memory_bytes: 64108
#include<stdio.h>
int main(void)
{
	
	long long int S,C,ans=0;
	scanf("%lld %lld", &S, &C);
	if (2*S>C) {
		ans += C / 2;
		S -= C / 2;
		C = C / 2;
	}
	else {
		ans += S;
		C -= S * 2;
		ans += C / 4;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
//const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    int n;
    cin >> n;
    vector<int> t(n);
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
        res += t[i];
    }
    int m;
    cin >> m;
    int p, x;
    for (int i = 0; i < m; ++i) {
        cin >> p >> x;
        cout << res + x - t[p - 1] << "\n";
    }
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;



int main() {
	long long int n, m, d = 0, q, t[200006] = {}, time=0, b[200006] = {}, leng = 0, goal, two = 0, three = 0, temp = 0,mi=100000000000000;

	cin >> n>>m;
	cin >> t[0];
	for (int i = 1; i < n; i++) {
		cin >> t[i];
		if (t[i]-t[i-1] > m) {
			time += m;
		}
		else {
			time += t[i] - t[i - 1];
		}
	}
	cout << time + m;
} 

Measured memory_bytes: 1792
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)


n,m = map(int,input().split())

G=[[] for i in range(n)]

for i in range(m):
    a,b=input().split()
    G[int(a)-1]+=[int(b)-1]
    G[int(b)-1]+=[int(a)-1]

#print(G)

dist=[-1 for i in range(n)]
# que=deque([0])
# dist[0]=0

count=0
def bfs(G):
    global count
    #print(que)
    if not que:
        return
    v = que.popleft()

    for nv in G[v]:
        if dist[nv] != -1:
            continue
        dist[nv]=dist[v]+1
        que.append(nv)
    count+=1
    
    bfs(G)

ans=0
for i in range(n):
    count=0
    if dist[i] != -1:
        continue
    else:
        que=deque([i])
        dist[i]=0
        bfs(G)
        if ans < count:
            ans=count

print(ans)


Measured memory_bytes: 208104
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int gcd = a > b ? gcd(a, b) : gcd(b, a);
            System.out.println(gcd + " " + (long)a * b / gcd);
        }
    }

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


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

int main(){
    long long a = 2;
    long long b = 1;
    long long c = 0;
    int n;
    cin >> n;

    if(n == 1){
        c = 1;
    }else{
        for(int i = 2; i <= n; i++){
            c = a + b;
            a = b;
            b = c;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
# print(n)
# print(a)

# - 色iのりんごの個数 ai
# - 1つ以上取る
# - 最後を取ったら勝ち

flag = all(a[i] % 2 == 0 for i in range(n))
if flag:
    print("second")
else:
    print("first")

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

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

  string s, t;
  cin >> s >> t;

  int n = s.length();
  int m = t.length();

  vector<vector<int>> dp(n+1, vector<int>(m+1));

  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      if(s[i] == t[j])
        dp[i+1][j+1] = dp[i][j] + 1;
      else
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
  }

  string ans = "";
  int i=n, j=m;
  while(i && j) {
    if(s[i-1]==t[j-1]) {
      ans = s[i-1] + ans;
      i--; j--;
    } else {
      (dp[i-1][j] > dp[i][j-1] ? i-- : j--);
    }
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 38904
from functools import lru_cache
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int,read().split())

@lru_cache(None)
def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret

print(F(N, K))

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll h,w;
vvs s;
signed main()
{   
    gearup;
    cin >> h >> w;
    s.resize(h,vs(w,"."));
    ll n;cin >> n;
    vl a(n);
    rep(i,n)cin >> a[i];
    
    int idx = 0;
    string ca = to_string(idx+1);
    rep(i,h){
        rep(j,w){
            int k = j;
            if(i%2) k = w-1-j;
            s[i][k]= ca;
            a[idx]--;
            if(a[idx] == 0){
                idx++;
                ca = to_string(idx+1);
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(j)cout << " ";
            cout << s[i][j];
        }
        cout << endl;
    }
}

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

int main(){
  char ans;
  char right,left;
  
  ans = 'A';
  
  while(cin >> left >> right >> right){
    //cout << "now no is " << left <<":"<< right <<endl;
    
    if(ans=='A' && (right=='A'||left=='A')){
      
      //cout << "frgA" << endl;
      
      if(right!='A'){
	//cout << "frgA1=" << right << endl;
	  ans = right;
	}else{
	//cout << "frgA2" << endl;
	  ans = left;
	}
    }else if(ans=='B' && (right=='B'||left=='B')){
      if(right!='B'){
	    ans = right;
	  }else{
	    ans = left;
	  }
    }else if(ans=='C' && (right=='C'||left=='C')){
      if(right!='C'){
	ans = right;
      }else{
	ans = left;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
	  
	  
	  
	  



Measured memory_bytes: 3008
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m, max = 0;
  cin >> n;
  string blue[n];
  for(int i = 0; i < n; i++){
  	cin >> blue[i];
  }
  cin >> m;
  string red[m];
  for(int i = 0; i < m; i++){
  	cin >> red[i];
  }
 
  for(int i = 0; i < n; i++){
    int c = 0;
    for(int j = 0; j < n; j++){
      if(blue[j] == blue[i]) c++;
    }
    for(int j = 0; j < m; j++){
      if(red[j] == blue[i]) c--;
    }
    if(c > max) max = c;
  }
  
  cout << max;
}

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

using namespace std;

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  int x = K;
  while (x <= B) {
    if (A <= x && x <= B) {
      cout << "OK" << endl;
      return 0;
    }
    x += K;
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    int main()
    {
     
   int n,cnt=0;
   cin>>n;
   int a[n+1];
   for(int i=1;i<=n;i++) 
   {
   cin>>a[i];
   if(i%2!=0 && a[i]%2!=0) cnt++; 
}
cout<<cnt<<endl;
    }
    
     

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
typedef long long ll;

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

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int N,l,r,s,t,co;
  string S,L="",R="";
  cin >> N;
  cin >> S;
  t = 0;
  s = 0;
  co = 0;
  REP(i,N){
    if(S[i] == '('){
      t++;
    }else{
      if(t >= 1){
        t--;
      }else{
        co++;
      }
    }
      
  }
  REP(i,co)L = L + "(";

  t = 0;
  s = 0;
  co = 0;
  for(int i=N-1;i>=0;i--){
    if(S[i] == ')'){
      t++;
    }else{
      if(t >= 1){
        t--;
      }else{
        co++;
      }
    }
      
  }
  REP(i,co)R = R + ")";
  cout << (L + S +  R) << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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



Measured memory_bytes: 256
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
const ll mod = 1e9+7;

int a[maxn];
int b[maxn]={};

int main(){
    ll n;
    scanf("%lld",&n);
    printf("%lld\n",n*(n-1)/2);
    return 0;
}


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

int main(){
  string t;
  cin >> t;
  
  vector<string> v(0);
  int ans = 0;
  for(int i = 0; i < 10000; i++){
    string s;
    cin >> s;

    if(s == "END_OF_TEXT"){ break; }
    else{
      for(int i = 0; i < s.size(); i++){
        if(s[i] >= 'A' && s[i] <= 'Z'){
          s[i] += 32;
        }
      }
      if(t == s){ ans++; }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
	
	
	public static void main(String[] args) {
		
		FastScanner fs = new FastScanner();
		int x= fs.nextInt();
		if(x==1)
			System.out.println("0");
		else
			System.out.println("1");
	}
	
	
	
	static class FastScanner 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	

}


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

int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  
  for(int i=0; i<s.size(); i++){
    mp[s[i]]++;
    if(mp[s[i]] > 1){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

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

#define MAX 100002

int n;

vector<long long int> d;
vector<int> v[MAX];

map<long long int,int> mp;

int sz[MAX];

bool vis[MAX];

long long int dp[MAX];
int cnt[MAX];

inline void dfs(int b,int pr=-1){
	cnt[b]++;
	vis[b]=true;
	for(int go:v[b]){
		if(go==pr)continue;
		if(vis[go]){
			puts("-1");
			exit(0);
		}
		dfs(go,b);
		dp[b]+=dp[go]+cnt[go];
		cnt[b]+=cnt[go];
	}
}
long long int ans[MAX];

inline void dfs2(int b,int pr=-1,long long int weight=0){
	ans[b]=dp[b]+weight;
	weight+=dp[b];
	for(int go:v[b]){
		if(go==pr)continue;
		dfs2(go,b,weight-dp[go]-cnt[go]+(n-cnt[go]));
	}
}
vector<pair<int,int> > ed;
int main() {
	// your code goes here
	cin>>n;
	for(int i=0;i<n;i++){
		long long int a;
		scanf("%lld",&a);
		d.push_back(a);
		mp[a]=i;
	}
	for(auto it=mp.rbegin();it!=mp.rend();it++){
		int node=(*it).second;
		long long int val=(*it).first;
		sz[node]++;
		long long int op=n-sz[node];
		if(op==0)continue;
		long long int nex=val+sz[node]-op;
		if(mp.count(nex)){
			int ne=mp[nex];
			sz[ne]+=sz[node];
			v[ne].push_back(node);
			v[node].push_back(ne);
			if(ne>node)swap(ne,node);
			ed.push_back(make_pair(ne+1,node+1));
		}
	}
	dfs(0);
	dfs2(0);
	for(int i=0;i<n;i++){
		if(vis[i]==false){
			puts("-1");
			return 0;
		}
		if(ans[i]!=d[i]){
			puts("-1");
			return 0;
		}
	}
	for(int i=0;i<ed.size();i++){
		printf("%d %d\n",ed[i].first,ed[i].second);
	}
	return 0;
}


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

    typedef long long ll;
    typedef long double ld;
    ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
    ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
    #define endl '\n'
    #define max3(a,b,c) max(a,max(b,c))
    #define min3(a,b,c) min(a,min(b,c))
    #define FOR(i,a,n,j) for(int i=a;i<n;i+=j)

    const int INF = 1e9+9;




    int main()
    {
        string s;
        cin>>s;
        cout<< ( s[1] == 'B' ? "ARC" : "ABC" )<<endl;


    return 0;
    }
        // gotcha;


Measured memory_bytes: 3592
n = gets.to_i
#n = gets.to_i.map(&:to_i)
amari = n % 10
if amari == 2 || amari == 4 || amari == 5 || amari == 7 || amari == 9
  puts "hon"
elsif amari == 0 || amari == 1 || amari == 6 || amari == 8
  puts "pon"
elsif amari == 3
  puts  "bon"
else
end


Measured memory_bytes: 14428
#include <stdio.h>

int main(){
  int N,A[100],i,j,minj,tmp,count=0;
  scanf("%d",&N);

  if(1<=N && N<=100){
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }

    for(i=0;i<=N-1;i++){
      minj = i;
      for(j=i;j<=N-1;j++){
	if(A[j] < A[minj]){
	  minj = j;
	}
      }
      if(i!=minj){
	tmp = A[i];
	  A[i] = A[minj];
	  A[minj] = tmp;
	  count++;
      }
      
    }

    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n", A[N-1]);
    printf("%d\n", count);
  }

  return 0;
}
	   



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());

    int ma = accumulate(l.begin(), l.begin() + K, 0);
    cout << ma << endl;

    return 0;
}


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

int bucket[9];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if(x < 3200) bucket[x / 400]++;
		else bucket[8]++;
	}
	int ans = 0;
	for(int i = 0; i < 8; i++) {
		if(bucket[i] != 0) ans++;
	}
	printf("%d %d\n", (ans == 0) ? 1 : ans, ans + bucket[8]);
}


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

int main() {
    int a, b; cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int i = 1;
    while (true) {
        if (a + (i - 1) * (a - 1) >= b) {
            cout << i << endl;
            return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 998244353
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[300];
void Calc(){
	int N = rei();
	int sum = 0;
	long ans = 1;
	for(int i=0;i<N;i++){
		A[i] = rei();
		sum += A[i];
		ans *= 3;
		ans %= mod;
	}
	{
		vector<long> DP(90001);
		vector<long> DP2(90001);
		DP[0] = 1;
		for(int i=0;i<N;i++){
			for(int j=0;j<=90000;j++){
				long c = DP[j]*2;
				if(j >= A[i]){
					c += DP[j-A[i]];
				}
				DP2[j] = c % mod;
			}
			swap(DP,DP2);
		}
		for(int i=(sum+1)/2;i<=90000;i++){
			ans += mod*3LL - DP[i]*3;
		}
	}
	if(sum % 2 == 0){
		vector<long> DP(90001);
		vector<long> DP2(90001);
		DP[0] = 1;
		for(int i=0;i<N;i++){
			for(int j=0;j<=90000;j++){
				long c = DP[j];
				if(j >= A[i]){
					c += DP[j-A[i]];
				}
				DP2[j] = c % mod;
			}
			swap(DP,DP2);
		}
		ans += DP[sum/2]*3;
	}
	ans %= mod;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1664
n, l = map(int, input().split())

zero_include = False

ans = 0
current = l - 1

for i in range(n):
    current += 1
    ans += current

    if current == 0:
        zero_include = True
    
if zero_include == False:
    if current < 0:
        ans -= current
    else:
        ans -= l

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MN = 1e6+2;
int main () {
	int a,b;
  	scanf ("%d %d",&a,&b);
  	for (int i = 1; i <= 3; i++) if (a != i && b != i) return !printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,s,t,x,y,z,g,top,head,tail,top1,top2,top3,min1,i,j,ans,ans2,
		  o=1000000000,zz[2100000+10],zz2[2100000+10],zz3[2100000+10],
		  to[2100000+10],nex[2100000+10],fir[2100000+10],fei[2100000+10],
		  liu[2100000+10],d[40000000+10],book[2100000+10],vis[2100000+10];
long long rx[1005],ry[1005],rc[1005],bx[1005],by[1005],bc[1005],a,b,c,e;
int lj(long long u,long long v,long long w,long long f){
	top++;
	to[top]=v;
	liu[top]=w;
	fei[top]=f;
	nex[top]=fir[u];
	fir[u]=top;
	return 0;
}
int lj2(long long u,long long v,long long w,long long f){
	lj(u,v,w,f);
	lj(v,u,0,-f);
	return 0;
}
int main(){
	scanf("%lld",&n);
	s=(n<<1)+1;
	t=s+1;
	a=t+1;
	b=a+1;
	c=b+1;
	e=c+1;
	for(i=1;i<=n;i++)
		scanf("%lld%lld%lld",&rx[i],&ry[i],&rc[i]);
	for(i=1;i<=n;i++)
		scanf("%lld%lld%lld",&bx[i],&by[i],&bc[i]);
	for(i=1;i<=n;i++){
		lj2(i,a,rc[i],rx[i]+ry[i]);
		lj2(i,b,rc[i],rx[i]-ry[i]);
		lj2(i,c,rc[i],-rx[i]+ry[i]);
		lj2(i,e,rc[i],-rx[i]-ry[i]);
	}
	for(i=1;i<=n;i++){
		lj2(a,i+n,bc[i],-bx[i]-by[i]);
		lj2(b,i+n,bc[i],-bx[i]+by[i]);
		lj2(c,i+n,bc[i],bx[i]-by[i]);
		lj2(e,i+n,bc[i],bx[i]+by[i]);
	}
	for(i=1;i<=n;i++)
		lj2(s,i,rc[i],0);
	for(i=1;i<=n;i++)
		lj2(i+n,t,bc[i],0);
	n=e;
	o*=o;
	while(1)
	{
		head=1;tail=1;
		d[1]=s;
		
		for(i=1;i<=n;i++)
			vis[i]=-o;
		vis[s]=0;
		book[s]=1;
		while(head<=tail){
			top2=d[head];
			top1=fir[top2];
			while(top1!=0){
				if(vis[top2]+fei[top1]>vis[to[top1]]&&liu[top1]!=0){
					vis[to[top1]]=vis[top2]+fei[top1];
					zz[to[top1]]=top2;
					zz2[to[top1]]=liu[top1];
					zz3[to[top1]]=top1;
					if(book[to[top1]]==0)
					{
						tail++;
						d[tail]=to[top1];
						book[to[top1]]=1;
					}
				}
				top1=nex[top1];
			}
			head++;
			book[top2]=0;
		}
		if(vis[t]<0)
			break;
		top1=t;
		min1=o;
		while(top1!=s){
			min1=min(min1,zz2[top1]);
			top1=zz[top1];
		}
		top1=t;
		ans+=min1;
		ans2+=min1*vis[t];
		while(top1!=s){
			top2=zz3[top1];
			if(top2%2==1)
				top3=top2+1;
			else
				top3=top2-1;
			top1=zz[top1];
			liu[top2]-=min1;
			liu[top3]+=min1;
		}
	}
	cout<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 20736
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		HashMap<String,Integer> ans = new HashMap<>();
		long a = 0;
		for(int i = 0;i < n;i++){
			char[] c = saori.nextHayami().toCharArray();
			Arrays.sort(c);
			String s = new String(c);
			if(ans.containsKey(s)){
				int num = ans.get(s);
				a += num;
				num += 1;
				ans.put(s, num);
			} else {
				ans.put(s, 1);
			}
		}
		System.out.println(a);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 45512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5;

int N;
ll dp[MAX+1][4];
/// dp[i][0]は?が出て来るたびに3倍する。文字列の種類の数
/// dp[i][1]はi文字目までで取れるAの種類の数
/// dp[i][2]、dp[i][3]はそれぞれiまでのB、Cの組み合わせの数

int main() {

  string s;
  cin >> s;
  N = s.size();

  dp[0][1] = dp[0][2] = dp[0][3] = 0;
  dp[0][0] = 1;

  FOR (i, 1, N+1) {
    char x = s[i-1];
    dp[i][0] = dp[i-1][0];
    if (x == '?') dp[i][0] = dp[i][0]*3%MOD;

    FOR (j, 1, 4) {
      dp[i][j] = dp[i-1][j];
      if (x == '?') {
        dp[i][j] = (dp[i-1][j]*3 + dp[i-1][j-1])%MOD;
      } else if (x == "ABC"[j-1]) {
        dp[i][j] = (dp[i-1][j]+dp[i-1][j-1])%MOD;
      }
    }
  }

  /*
  FORR (j, 0, 4) {
    REP (i, N+1) cout << dp[i][j] << " ";
    cout << endl;
  }
  */
  cout << dp[N][3] << endl;
  return 0;

}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cmath>
#include <float.h>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Point {
  double y;
  double x;

  Point(double y = -1, double x = -1) {
    this->y = y;
    this->x = x;
  }
};

bool compareY(const Point &p1, const Point &p2) {
  return p1.y < p2.y;
}

bool compareX(const Point &p1, const Point &p2) {
  return p1.x < p2.x;
}

double closestPair(Point *points, int n) {
  if (n <= 1) return DBL_MAX;

  int m = n / 2;
  double x = points[m].x;
  double d = min(closestPair(points, m), closestPair(points + m, n - m));
  inplace_merge(points, points + m, points + n, compareY);

  vector<Point> b;
  for (int i = 0; i < n; ++i) {
    if (fabs(points[i].x - x) >= d) continue;

    for (int j = 0; j < b.size(); ++j) {
      double dx = points[i].x - b[b.size() - j - 1].x;
      double dy = points[i].y - b[b.size() - j - 1].y;

      if (dy >= d) break;
      d = min(d, sqrt(dx * dx + dy * dy));
    }
    b.push_back(points[i]);
  }

  return d;
}

int main() {
  int N;
  cin >> N;
  Point points[N];

  double x, y;
  for (int i = 0; i < N; ++i) {
    cin >> x >> y;
    points[i] = Point(y, x);
  }

  sort(points, points + N, compareX);

  cout << fixed << setprecision(10) << closestPair(points, N) << endl;

  return 0;
}



Measured memory_bytes: 7684
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll N;
void Divisors(ll n , vector<ll> &values) 
{ 
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            
            if (n/i == i) 
                values.push_back(i);
  
            else 
                {
                	values.push_back(i);
                	values.push_back(n/i);
                } 
        } 
    } 
} 

bool isPerfectSquare(long double x) 
{  
  long double sr = sqrt(x); 
  
  
  return ((sr - floor(sr)) == 0); 
} 

void solve(){
	cin>>N;

	vector<ll> values;
    ll ans = LONG_LONG_MAX;
	
	if(isPerfectSquare(N))
	{
      ll val1 = sqrt(N);
      ans = 2*(val1-1);
	}

	else{
		Divisors(N , values);
    
    sort(values.begin() , values.end());

    for(ll i = 0 ; i<values.size()/2 ; i++){
    	ll vala = (values[i] - 1) + ( (N/values[i])  - 1);
    	ans = min(vala , ans);
    }
	}

    cout<<ans<<'\n';

}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
   solve();

	return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;
	int N = 1 << n;
	vector<int> s(N);
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
	}
	sort(s.rbegin(), s.rend());
	multiset<int> used, unused;
	used.insert(s[0]);
	for (int i = 1; i < N; ++i) {
		unused.insert(s[i]);
	}
	for (int i = 0; i < n; ++i) {
		vector<int> add;
		for (int x : used) {
			auto lb = unused.upper_bound(x - 1);
			if (lb == unused.begin()) {
				cout << "No";
				return 0;
			}
			--lb;
			add.push_back(*lb);
			unused.erase(lb);
		}
		for (int x : add) {
			used.insert(x);
		}
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 15872
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}



int main() {
	string s;
	int a, b;
	cin >> a >> b;
	while (cin >> s) {
		pp(s);
		pp(s);
	}
	return 0;
}

Measured memory_bytes: 256
import itertools

N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]

def score(x,NOW):
    L=len(NOW)
    ITE=list(itertools.product([0,1],repeat=L))

    ANS=10**15
    CANDI=[]

    for ite in ITE:
        if max(ite)==0:
            continue
        SUM=sum([NOW[i] for i in range(L) if ite[i]==1])        
        MAGIC=(ite.count(1)-1)*10
        

        if ANS>MAGIC+abs(x-SUM):
            ANS=MAGIC+abs(x-SUM)
            CANDI=ite

    return ANS,[NOW[i] for i in range(L) if CANDI[i]==0]

X=[[A,B,C],[A,C,B],[B,A,C],[B,C,A],[C,A,B],[C,B,A]]
ANS=10**15

for x in X:
    ANS1,L1=score(x[0],L)
    if len(L1)==0:
        continue
    ANS2,L2=score(x[1],L1)
    if len(L2)==0:
        continue
    ANS3,L3=score(x[2],L2)

    #print(ANS,ANS1,ANS2,ANS3,L1,L2,L3,A,B,C)

    if ANS>ANS1+ANS2+ANS3:
        ANS=ANS1+ANS2+ANS3

print(ANS)

Measured memory_bytes: 3064
S = input()
first = S[:2]
second = S[2:]
if 0 < int(first) and int(first) <= 12 and 0 < int(second) and int(second) <= 12:
    print("AMBIGUOUS")
elif 0 < int(second) and int(second) <= 12:
    print("YYMM")
elif 0 < int(first) and int(first) <= 12:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int n,num;
void dfs(int sum,int dept){
  if(dept==4){
    if(sum==n)
      num++;
    return;
  }
  for(int i=0;i<=9;i++)
    dfs(sum+i,dept+1);
}
int main(){
  while(cin>>n){
    num=0;
    for(int i=0;i<=9;i++)
      dfs(i,1);
    cout<<num<<endl;
  }
  return 0;
}

Measured memory_bytes: 2960
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

int n, m, k;
int tmp;
bool ans = 0;

int main(void) {
  scanf("%d %d %d",&n, &m, &k);
  if(n>m) tmp=n, n=m, m=tmp;

  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if( n*j + m*i - 2*i*j == k ){
        ans = 1;
        break;
      }
    }
  }

  if(ans) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        System.out.println(solver.solve(S) ? YES : NO);
    }
}

class Solver {
    public boolean solve(String S) {
        return S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5);
    }
}



Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		String n = sc.next();
		long sum = 0;
		for(int i = 0; i < n.length(); i++) {
			sum+= (n.charAt(i)-'0');
		}
		
		System.out.println((sum%9==0)?"Yes":"No");
		
	}
	
}

Measured memory_bytes: 31004
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

def choose(x):
  return factorial(x)/(2*factorial(x-2))

words = {}

for i in range(int(input())):
    s = "".join(sorted(si()))
    if s not in words:
        words[s] = 1
    else:
        words[s] += 1
ans = 0
for i in words:
    if words[i] == 1: continue
    ans += choose(words[i])
print(int(ans))

Measured memory_bytes: 17848
// atcoder/agc016/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());

    if (1 < abs(a.front() - a.back())) {
      cout << "No" << endl;
      continue;
    }

    if (a.front() == a.back()) {
      if (a.back() == n - 1) {
        cout << "Yes" << endl;
        continue;
      }
      cout << (n < a.front() * 2 ? "No" : "Yes") << endl;
      continue;
    }

    int x = count(a.begin(), a.end(), a.front());
    int y = count(a.begin(), a.end(), a.back());

    unless (x < a.back()) {
      cout << "No" << endl;
      continue;
    }
    cout << (((int)a.back() - x) * 2 <= y ? "Yes" : "No") << endl;
  }

  return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  string s; cin>>s;
  if(s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
      
}


Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
  
N, M = gets.split.map(&:to_i)
S = gets.chomp
smax = Array.new(N + 1, N)
(0 .. N).inject(0) do |m,i|
  if i > m + M
    puts -1
    exit
  end
  smax[i] = S[i] == '0' ? i : m
end

dp = Array.new(N + 1, 0)
(0 ... N).reverse_each do |i|
  dp[i] = dp[smax[min(N, i + M)]] + 1
end

A = Array.new(dp[0], 0)
dp[0].times.inject(0) do |pos, c|
  A[c] = (1 .. M).find do |j|
    S[pos + j] == '0' && dp[pos + j] + (c + 1) <= dp[0]
  end
  pos + A[c]
end
puts A * ' '


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    bool ans = true;
    rep(i, n){
        cin >> v[i];
        if(v[i] % 2 == 0){
            if(v[i] % 3 != 0 && v[i] % 5 != 0){
                ans = false;
            }
        }
    }
    if(ans)cout << "APPROVED" << endl;
    else{
        cout << "DENIED" << endl;
    }
    system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   string s;
   cin>>s;
  ll len=s.size();
   string p;
   ll sum=0,sum1=0;
   //cout<<1 << (len-1);
   for (int mask = 0; mask < 1 << (len-1); mask++) {
       //cout<<mask<<endl;
	   p=" ";
	   ll a[22]={0};
       for(int i=0;i<len;i++)
       a[2*i]=s[i]-'0';
       
       sum1=0;
       for (int i = 0; i < len-1; i++) {
            if (mask & 1 << i) {
                a[(2*i)+1]=-1;
            }
        }
	   
        for(int i=0;i<22;i++){
			if(a[i]>0 || a[i]==-1){
            if(a[i]==-1)
            {sum+=stoll(p);p=" ";}
            else if(a[i]!=-1) p+=to_string(a[i]);
			}
            //cout<<endl;
        }
	  // cout<<p<<endl;
	   //p=to_string(9);
	   sum+=stoll(p);
	   //p=" ";
                //for(int i:a)
                  //cout<<i<<" ";
	  // cout<<endl<<sum<<endl;
        //sum += num;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>

using namespace std;

bool check(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int x = 2; x <= 55555; x++) {
        bool flag = true;
        for (int p = 2; p * p <= x; p++) {
            if (x%p == 0)
                flag = false;
        }
        if (flag && x % 5 == 1)
            v.push_back(x);
    }

    for (int i = 0; i < n; i++)
        cout << v[i] << " ";
    cout << endl;

    return 0;
}

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

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

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

    rep(i, 10) {
        rep(j, 10) {
            if (n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,i,j,k,n,m,x,y,z,t;
    double a1,a2,a3,a4,ans=0.0;
    cin>>n;
    double aa[100][100];
    pair<long long,long long>pp[10];
    for(i=1;i<=n;i++)
    {
        cin>>pp[i].first>>pp[i].second;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i!=j)
            {
                aa[i][j]=(sqrt(pow((pp[i].first-pp[j].first),2)+pow((pp[i].second-pp[j].second),2)))*(n-1);
                ans=ans+aa[i][j];
            }
        }
    }
    a1=ans/(n*(n-1));
    printf("%.10lf\n",a1);

}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
using namespace std;
 
int main() {
    double a, b;
    double ans;
    cin >> a;

    if((int)(a)%2 == 1){
        b = (int)(a/2) + 1;
    }
    else
    {
        b = (int)(a/2);
    }
    ans = (double)(b/a);
    std::cout<<std::fixed<<std::setprecision(10) << ans << endl;

}

Measured memory_bytes: 256
import heapq
n, m, s = map(int, input().split())
s = min(s, 2499)
UV = [[] for _ in range(n)]
A_cost = []
B_dist = []
for i in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    UV[u].append((v, i))
    UV[v].append((u, i))
    A_cost.append(a)
    B_dist.append(b)

C_income = []
D_dist = []
for _ in range(n):
    c, d = map(int, input().split())
    C_income.append(c)
    D_dist.append(d)

NV = 2500*n
edges = [[] for _ in range(NV)]

for i in range(n):
    c = C_income[i]
    d = D_dist[i]
    for j in range(2500-c):
        edges[2500*i+j].append((d, 2500*i+j+c))

for i in range(n):
    for j, k in UV[i]:
        a = A_cost[k]
        b = B_dist[k]
        for x in range(2500-a):
            edges[2500*i+x+a].append((b, 2500*j+x))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*(NV)
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


INF = 10**18
dist = dijkstra(s)
for i in range(1, n):
    ans = INF
    for j in range(2500):
        ans = min(ans, dist[2500*i+j])
    print(ans)


Measured memory_bytes: 95284
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=998244353;
const int L=300*300+1;
LL dp[301][L];
LL dp2[301][L];
int main() {
	int N;
	cin >> N;
	dp[0][0]=1;
	dp2[0][0]=1;
	LL ret=1;
	LL sum=0;
	for(int i=1;i<=N;i++){
		ret*=3;
		ret%=M;
		for(int j=0;j<L;j++){
			dp[i][j]=2*dp[i-1][j];
			dp[i][j]%=M;
			dp2[i][j]=dp2[i-1][j];
		}
		int v;
		cin >> v;
		sum+=v;
		for(int j=0;j+v<L;j++){
			dp[i][j+v]+=dp[i-1][j];
			dp[i][j+v]%=M;
			dp2[i][j+v]+=dp2[i-1][j];
			dp2[i][j+v]%=M;
		}
	}
	//cerr << ret << ", " << sum << endl;
	for(int i=0;i<L;i++){
		if(i>=sum-i){
			ret+=M-(3*dp[N][i]%M);
			ret%=M;
		}
		if(2*i==sum){
			//cerr << dp2[N][i] << endl;
			ret+=3*dp2[N][i]%M;
			ret%=M;
		}
	}
	cout << ret << endl;




	return 0;
}



Measured memory_bytes: 422784
#include<stdio.h>

int main(){
  int i,j,r,t;
  
  scanf("%d%d",&i,&j);
 
if(i < j){
      t = i;
      i = j;
      j = t;   

    }

  


    while(1){

      r = i % j;
      if( r == 0 )break;   
    i = j;
    j = r;
   }
  printf("%d\n",j);

  return 0;
 }

Measured memory_bytes: 592
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let n = iter.next().unwrap().parse::<i64>().unwrap();
    let m = iter.next().unwrap().parse::<i64>().unwrap();
    if n == 1 || m == 1 {
        if n * m == 1 {
            println!("1");
        } else if n * m == 2 {
            println!("0");
        } else {
            println!("{}", n * m - 2);
        }
    } else if n == 2 || m == 2 {
        println!("0");
    } else {
        println!("{}", (n - 2) * (m - 2));
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main (void){
int a_b,b_c,c_a,min;
scanf("%d",&a_b);
scanf("%d",&b_c);
scanf("%d",&c_a);

if(a_b+b_c>=b_c+c_a){
min=b_c+c_a;
}else{
min=a_b+b_c;
}
if(min>=c_a+a_b){
min=c_a+a_b;
}

printf("%d",min);

}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        long K = in.nextLong();
        long toPrint = 0L;
        long dif = 1L;
        for(int i=1;i<=K;i++){
            toPrint += dif;
            if(helper(toPrint+dif)>helper(toPrint+2*dif)) dif *= 10L;
            System.out.println(toPrint);
        }

    }
    public static double helper(long n){
        double s = (double) n;
        double sum = 0.0;
        while(n!=0){
            sum += (double) n%10;
            n = n/10;
        }
        return s/sum;
    }
}

Measured memory_bytes: 19924