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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int x;
    cin>>x;
    if ( x >= 400 && x < 600 ){
        cout<<"8"<<endl;
    }
    else if ( x < 800 && x >= 600 ){
        cout<<"7"<<endl;
    }
    else if ( x >= 800 && x < 1000 ){
        cout<<"6"<<endl;
    }
    else if ( x >= 1000 && x < 1200 ){
        cout<<"5"<<endl;
    }
    else if ( x >= 1200 && x < 1400 ){
        cout<<"4"<<endl;
    }
    else if ( x >= 1400 && x < 1600 ){
        cout<<"3"<<endl;
    }
    else if ( x >= 1600 && x < 1800 ){
        cout<<"2"<<endl;
    }
    else if ( x >= 1800 && x < 2000 ){
        cout<<"1"<<endl;
    }

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

const int INF = 1e9+7;
ll dp[1005][10005];//dp[i][j] iまでを使って残りの体力がjになるのに用いる最小の魔力

int main(){
    ll h,n;
    
    cin >> h >> n;
    ll a[n], b[n];
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,n+1)rep(j,h+1){
        dp[i][j] = INF;
    }
    dp[0][0] = 0;//0個を使って与えるダメージが0の時の魔力消費
    rep(i,n)rep(j,h+1){
        dp[i+1][j] = min(dp[i][j],dp[i+1][j]);//i種類めを使わない
        dp[i+1][min(h,j+a[i])] = min(dp[i+1][j]+b[i], dp[i+1][min(h,j+a[i])]);//使う
        //iを一回使うことにした場合、dp[i+1][j] + b[i] でdp[i+1][j+a[i]]になる
    }

    cout << dp[n][h] << endl;

}

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

void print_frame(int h, int w)
{
  cout << string(w, '#') << endl;
  for (int i = 1; i < h - 1; i++)
  {
    cout << '#' << string(w - 2, '.') << '#' << endl;
  }
  cout << string(w, '#') << endl;
  cout << endl;
}

int main()
{
  int H, W;
  while (true)
  {
    cin >> H >> W;
    if (H == 0 && W == 0)
    {
      break;
    }
    print_frame(H, W);
  }
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int ar[200005];
int k,n;

int far(int x){
	if(x==1){
		return n;
	}
	else {
		return x-1;
	}
}

int dist(int x, int y){
	if(x>y){
		return k+y-x;
	}
	else {
		return y-x;
	}
}

int32_t main(){
	cin>>k>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	int mn = 1e15;
	for(int i=1;i<=n;i++){
		mn = min(mn,dist(ar[i],ar[far(i)]));
	}
	cout<<mn;
}


Measured memory_bytes: 1792
K=int(input())
*A, = map(int,input().split())
m,M = 2,2
for a in A[::-1]:
    M = M//a*a+(a-1)
    m = ((m-1)//a+1)*a
    if m>M:
        print(-1)
        break
else:print(m,M)

Measured memory_bytes: 14252
#include <stdio.h>
#include <string.h>

#define abs(a) (a > 0 ? a : -a )

#define M 1046527
#define L 14

char h[M][L];

long long makeKey(char *);
int hash1(int);
int hash2(int);
int hash(int, int, int);

int insert(char *);
int find(char *);

int main() {
  char command[9];
  char str[L];

  int n, key, h1, h2;
  int i, j;

  for (i = 0; i < M; i++) {
    h[i][0] = '\0';
  }

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", command, str);

    if(command[0] == 'i') {
      insert(str);
    }
    else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}

int insert(char *str) {
  long long key, i, ha;
  key = makeKey(str);
  for (i = 0; ; i++) {
    ha = hash(hash1(key), hash2(key), i);
    if (strcmp(h[ha], str) == 0) return 1;
    else if (strlen(h[ha]) == 0) {
      strcpy(h[ha], str);
      return 0;
    }
  }
  return 0;
}

int find(char *str) {
  long long key, i, ha;
  key = makeKey(str);
  for (i = 0; ; i++) {
    ha = hash(hash1(key), hash2(key), i);
    if (strcmp(h[ha], str) == 0) return 1;
    else if (strlen(h[ha]) == 0) return 0;
  }
  return 0;
}

int getChar(char c) {
  if (c == 'A') return 1;
  else if (c == 'C') return 2;
  else if (c == 'G') return 3;
  else if (c == 'T') return 4;
  return 0;
}

long long makeKey(char *s) {
  long long key = 0;
  int p = 1, j;

  j = 0;
  while (s[j] != '\0') {
    j++;
    key += getChar(s[j]) * p;
    p *= 5;
  }

  return key;
}

int hash(int h1, int h2, int i) {
  // printf(">>> %d\n", ((h1 + i) * h2) % M);
  return abs(((h1 + i) * h2) % M);
}

int hash1(int k) {
  return k % M;
}

int hash2(int k) {
  return 1 + (k % (M - 1));
}


Measured memory_bytes: 16052
from sys import stdin
sx,sy,tx,ty = [int(x) for x in stdin.readline().rstrip().split()]
ans = ""
ans += (ty-sy)*"U"
ans += (tx-sx)*"R"
ans2 = ans.replace("R","tmp").replace("L","R").replace("tmp","L")
ans2 = ans2.replace("U","tmp").replace("D","U").replace("tmp","D")
ans = ans + ans2 +"LU"+ans+"RD" + "RD" + ans2 + "LU"
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];

  long long int x = a[0];
  long long int y = a[0];
  long long int z = 0;
  for(int i=0; i<n; i++){
    x = min(x, a[i]);
    y = max(y, a[i]);
    z += a[i];
  }

  cout << x << " ";
  cout << y << " ";
  cout << z << endl;

  return 0;
}








// EOF

Measured memory_bytes: 3152
#include "bits/stdc++.h"

using namespace std;

int func(int i, int j){
    int left = 0, right = 0;
    while(i){
        left += i%10;
        i/=10;
    }
    while(j){
        right += j%10;
        j/=10;
    }
    return left + right;
}

int main()
{
   // clock_t start, end;
   // start = clock();
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int minn = 0x3f3f3f3f;
    for(int i = 1; i <= n/2; i++){
        int tmp = func(i, n-i);
        if(tmp < minn)
            minn = tmp;
    }
    cout << minn << endl;
   // end = clock();
   // cout << (end - start) / CLOCKS_PER_SEC << 's' << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
struct Edge{
    Edge(){};
    Edge(int _to,int _cost){
        to = _to;
        cost = _cost;
    }
    int to;
    int cost;
};
struct Data{
    Data(){};
    Data(int _pos,int _t){
        pos = _pos;
        t = _t;
    }
    int pos;
    int t;
    bool operator < (const Data &a)const{
        return t > a.t;
    }
};
int main(){
    int n,k;
    while(cin>>n>>k,n){
        int vis[120];
        vector<Edge> Node[120];
        priority_queue<Data> Q;
        for(int i = 0;i < k;i++){
            int z;
            cin>>z;
            if(z == 0){
                int x,y;
                cin>>x>>y;
                for(int i = 0;i < 120;i++)vis[i] = 1e+9;
                Q.push(Data(x,0));
                while(!Q.empty()){
                    Data D = Q.top();Q.pop();
                    int p = D.pos;
                    if(vis[p] < D.t)continue;
                    for(int i = 0;i < Node[p].size();i++){
                        Edge e = Node[p][i];
                        if(vis[e.to] <= D.t + e.cost)continue;
                        vis[e.to] = D.t + e.cost;
                        Q.push(Data(e.to,vis[e.to]));
                    }
                }
                if(vis[y] == 1e+9)vis[y] = -1;
                cout<<vis[y]<<endl;
            }
            if(z == 1){
                int x,y,t;
                cin>>x>>y>>t;
                Node[x].push_back(Edge(y,t));
                Node[y].push_back(Edge(x,t));
            }
        }
    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h, w; cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

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

    REP(y, h) {
        REP(x, w) {
            if (s[y][x] == '.') continue;

            bool isok = false;
            REP(i, 4) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx <= w-1 && 0 <= ny && ny <= h-1) {
                    if (s[ny][nx] == '#') isok = true;
                }
            }

            if (!isok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>


using namespace std;
typedef long long ll;

ll N = 0;

int main(){

    cin >> N;

    vector<ll > A;

    ll t  = 0;
    ll m  = 0;

    for(int i = 0; i < N; i++){
        cin >> t;
        A.push_back(t);
    }

    ll min = *std::min_element(A.begin(), A.end());
    ll max = *std::max_element(A.begin(), A.end());
    m = abs(min - max);

    cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L long long
#define LL long long
#define SS string
#define PB push_back
#define pp pair<L,L>
#define f(x,n) for (L i = x ; i <= n ; i++)
#define N 100005
using namespace std;
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    L n ,k;
    cin >> n >> k;
    L h[n+1] , a[n+1];
    L i;
    f(1,n)
    {
        a[i] = INT_MAX;
        cin >> h[i];
    }

    a[1] = 0;
    if (n == 1)
    cout << 0;
    else
    {
        f(2,n)
        {
            L tk = k;
            L b = 1;
            while(tk--)
            {
                if ((i - b) <= 0)
                break;
                a[i] = min(a[i],a[i-b] + abs(h[i] - h[i-b]));
                b++;
            }
        }
        // f(1,n-1)
        // cout << a[i] << " ";
        cout << a[n];
    }
    return 0; 
}

Measured memory_bytes: 1792
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    B = list(map(int,input().split()))
    A = [[] for _ in range(N)]
    A[0].append(B[0])
    for i in range(1,N-1):
        A[i].append(B[i-1])
        A[i].append(B[i])
    A[-1].append(B[-1])
    # print(A)
    print(sum([min(a) for a in A]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 38448
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    vl cnt(n, 1);
    vl v(n);
    v[0] = 1;
    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        if(v[x]) {
            v[y] = 1;
        }
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == 0) {
            v[x] = 0;
        }
    }

    ll ans = 0;
    rep(i, n) {
        if(v[i]) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using Point = complex<double>;

istream &operator>>(istream &is, Point &p)
{
    double a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}

#define curr(P, i) P[i]
#define next(P, i) P[(i + 1) % P.size()]
#define prev(P, i) P[(i - 1 + P.size()) % P.size()]

const double EPS = 1e-10, PI = acos(-1);
inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

//二つのスカラーが等しいか
#define EQ(a, b) (abs((a) - (b)) < EPS)
//二つのベクトルが等しいか
#define EQV(a, b) (EQ((a), real(), (b).real()) && EQ((a), imag(), (b).imag()))

namespace std
{
bool operator<(const Point &a, const Point &b)
{
    return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
}
} // namespace std

struct Line
{
    Point a, b;
    Line() {}
    Line(Point a, Point b) : a(a), b(b) {}
    //a, bはそれぞれ座標を指す. これより一つの「line」に対して二個の点を持つことになる
    Line(double A, double B, double C) // Ax + By = C
    {
        if (eq(A, 0))
            a = Point(0, C / B), b = Point(1, C / B);
        else if (eq(B, 0))
            b = Point(C / A, 0), b = Point(C / A, 1);
        else
            a = Point(0, C / B), b = Point(C / A, 0);
    }

    friend ostream &operator<<(ostream &os, Line &p)
    {
        return os << p.a << " to " << p.b;
    }

    friend istream &operator>>(istream &is, Line &a)
    {
        return is >> a.a >> a.b;
    }
};

struct Segment : Line
{
    Segment() {}

    Segment(Point a, Point b) : Line(a, b) {}
};

struct Circle
{
    Point p;
    double r;

    Circle() {}

    Circle(Point p, double r) : p(p), r(r) {}
};

using Points = vector<Point>;
using Polygon = vector<Point>;
using Segments = vector<Segment>;
using Lines = vector<Line>;
using Circles = vector<Circle>;

double dot(const Point a, const Point b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(const Point a, const Point b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}
bool orthogonal(const Line &a, const Line &b)
{
    return abs(dot(a.a - a.b, b.a - b.b)) < EPS;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    Point p1, p2, p3, p4;
    while (cin >> p1 >> p2 >> p3 >> p4)
    {
        Line l1(p1, p2);
        Line l2(p3, p4);
        if (orthogonal(l1, l2))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3232
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

bool comp[100005];
int dp[100005];
void solve() {
	comp[0] = true;
	comp[1] = true;
	for(int i = 2; i * i < 100000; i++) {
		for(int j = i*i; j < 100000; j += i) {
			comp[j] = true;
		}
	}
	for(int i = 3; i <= 100000; i++) {
		if(i%2 && !comp[i] && !comp[(i+1)/2]) dp[i]++;
		dp[i] += dp[i-1];
	}
	int q;
	cin >> q;
	while(q--) {
		int lhs, rhs;
		cin >> lhs >> rhs;
		cout << dp[rhs] - dp[lhs-1] << "\n";
	}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
	/*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
	*/
	solve();
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

long *tree[100001];

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);

	long tree_s[n+1];
	for (long i = 1; i <= n; i++) {
		tree_s[i] = 0;
	}
  long a,b;
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
		tree_s[a]++;
		tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
		tree_s[b]++;
  }

  long vertices[n+1];
  for (long i = 1; i <= n; i++) {
    vertices[i] = -1;
  }
	vertices[1] = 0;

	long visited[n+1];
	visited[0] = 1;
	long head = 0;
	long tail = 0;
	long tmp_tail = 0;

  long cur;
	int flag;
  while (1) {
		flag = 0;
    for (long i = head; i <= tail; i++) {
			cur = visited[i];
    	for (long j = 0; j <= tree_s[cur]-1; j++) {
				if (vertices[tree[cur][j]] != -1) {
					continue;
				}
				vertices[tree[cur][j]] = cur;
				tmp_tail++;
				visited[tmp_tail] = tree[cur][j];
				flag = 1;
    	}
    }
		if (flag == 0) {
			break;
		}
		head = tail+1;
		tail = tmp_tail;
  }

	printf("Yes\n");

  for (long i = 2; i <= n; i++) {
  	printf("%ld\n", vertices[i]);
  }

  return 0;
}

Measured memory_bytes: 10568
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
char s[N];
int n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int tot=0;
	LL ans=0;
	for (int i=1;i<=n;i++){
		if (s[i]=='W')
			ans+=tot;
		else
			tot++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<list>
using namespace std;

int main(){
	string s;
	list<char>newstring;
	int q;
	bool reversed = false;
	cin>>s>>q;
	for(int i=0; s[i]; i++) newstring.push_back(s[i]); 
	for(int i=0; i<q; i++){
		int qi;
		cin>>qi;
		if(qi==1) reversed = !reversed;
		else{
			int f;
			char c; 
			cin>>f>>c;
			if(f==1){ //문자열의 앞에 추가  
				if(reversed) newstring.push_back(c);
				else newstring.push_front(c);
			}
			else{ //문자열의 뒤에 추가  
				if(reversed) newstring.push_front(c);
				else newstring.push_back(c);
			}
		}
	}
	list<char>::iterator it;
	if(reversed){
		it = newstring.end();
		it -- ; 
		while(it!=newstring.begin()){
			cout<<*it;
			it--;
		}
		cout<<*it;
	}
	else{
		for(it=newstring.begin(); it!=newstring.end(); it++) cout<<*it;
	}
}

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

using namespace std;

int A, B, C, D, P;

int main() {
	int totalX, totalY;

	cin >> A >> B >> C >> D >> P;
	totalX = A*P;
	totalY = B + max(0, P - C)*D;
	cout << min(totalX, totalY) << endl;

	return 0;
}


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

int main() {
	
	int n, x;	
	
	while (cin >> n >> x) {
		if ((n == 0)&&(x == 0)) break;
		int ct = 0;
		for (int a = 1; a <= n; a++) {
			for (int b = 1; b <= n; b++) {
				for (int c = 1; c <= n; c++) {
					if (a + b + c == x && a < b && b < c) {
						ct++;
					}
				}
			}
		}
		cout << ct << "\n";
	}	
	return 0;
}


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

int main(){
    long long int H,N,input;
    cin >> H >> N;

    for(int i=0;i<N;i++){
        cin >> input;
        H = H - input;
    }

    if(H<=0){
        cout << "Yes";
    }else {
        cout << "No";
    }

}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}


#define MAX_N 12000000
/*
ll euler[MAX_N];

//MAX_Nまで全生成
void euler_phi2(){
  for(ll i=0;i<MAX_N;i++)euler[i] = i;
  for(ll i=2;i<MAX_N;i++){
    if(euler[i] == i){
      for(ll j=i;j<MAX_N;j+=i)euler[j]=euler[j]/i*(i-1);
    }
  }
}
*/

ll getDiv(ll n){
  ll res = 0;
  int cnt = 0;
  for(ll i=1;i*i<=n;i++) {
    if(n%i == 0)
      {
	++res;
	if(i*i != n) {
	  ++res;
	}
      }
  }
  return res;
}


int diva[MAX_N];
void findDivisors(int n) 
{ 

  for (ll i = 1; i <= n; i++) { 
    // Increase divisors count for 
    // every number divisible by i 
    for (ll j = 1; j * i <= n; j++)  {
      diva[i * j]++;
    }
  } 
  
  //// Print the divisors 
    //for (int i = 1; i <= n; i++) 
  //cout << div[i] << " "; 
} 
  

int main() {
  //euler_phi2();
  findDivisors(10000010);
  /*
  REP(i,1,20) {
    cout << i << "th: " << getDiv(i) << " " << diva[i] << endl;
  }
  */
  int N;
  cin >> N;
  ll ans = 0;
  REP(i,1,N+1) {
    //ll v = (ll)i - (euler[i]-1LL);
    //ans += ((ll)i * v);
    ans += ( (ll)i * (ll)diva[i] );
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 42696
#include<iostream>
#include<string>
using namespace std;
int n,m,q;
bool d[1100][40],y[1100][1100],x[1100][1100];int p[1100];
int main(){
	while(true){
		cin>>n>>m>>q;
		if(n==0 && m==0 && q==0)break;
		for(int i=0;i<1100;i++){
			p[i]=0;
			for(int j=0;j<40;j++)d[i][j]=false;
			for(int j=0;j<1100;j++){
				x[i][j]=false;y[i][j]=false;
			}
		}
		for(int i=0;i<q;i++){
			string S="",T="";
			cin>>S>>T;
			for(int j=0;j<n;j++){
				if(S[j]=='0')d[i][j]=false;
				if(S[j]=='1')d[i][j]=true;
			}
			for(int j=0;j<m;j++){
				if(T[j]=='0')y[i][j]=false;
				if(T[j]=='1')y[i][j]=true;
			}
			if(i>=1){
				for(int j=0;j<m;j++){
					x[i][j]=y[i-1][j]^y[i][j];
				}
			}
			else{
				for(int j=0;j<m;j++)x[i][j]=y[i][j];
			}
		}
		for(int i=0;i<m;i++){
			int siz=0,h=0;
			for(int j=0;j<n;j++){
				int G=0;
				for(int k=0;k<q;k++){
					if(d[k][j]!=x[k][i])G=1;
				}
				if(G==0){siz++;h=j;}
			}
			if(siz==1)p[i]=h;
			else{p[i]=-1;}
		}
		for(int i=0;i<m;i++){
			if(p[i]==-1)cout<<'?';
			else if(p[i]<10)cout<<(char)('0'+p[i]);
			else{cout<<(char)('A'+p[i]-10);}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var N = LnInt();
        var dict = new Dictionary<string, int>();
        for (int i = 0; i < N; i++)
        {
            var kind = LnStr();
            if (!dict.ContainsKey(kind))
            {
                dict.Add(kind, 0);
            }
        }
        Console.WriteLine(dict.Count);
    }
   

public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 45372
#include<stdio.h>
int a[100];
int main(){
	int now;
	int max=0;
	while(~scanf("%d",&now)){
		a[now-1]++;
		if(a[now-1]>max)max=a[now-1];
	}
	for(int i=0;i<100;i++){
		if(a[i]==max)printf("%d\n",1+i);
	}
}



Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  long long r,d,x;
  cin>>r>>d>>x;
  
  REP(i,10){
    x = r*x -d;
    cout<<x<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
#define int ll

void init();
void solve();

signed main()
{
    init();
    solve();
}

#define INF INT_MAX

struct LSGT {
    int n;
    vector<int> node, lazy;
    void init(int sz) {
        n = 1;
        while (n < sz) n <<= 1;
        node.RS(2*n-1, 0);
        lazy.RS(2*n-1, 0);
    }
    void eval(int k, int l, int r) {
        node[k] += lazy[k];
        if (r - l > 1) {
            lazy[k*2+1] += lazy[k] / 2;
            lazy[k*2+2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
    void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] = x * (r - l);
            eval(k, l, r);
        } else {
            add(a, b, x, k*2+1, l, (l+r) / 2);
            add(a, b, x, k*2+2, (l+r) / 2, r);
            node[k] = node[k*2+1] + node[k*2+2];
        }
    }
    int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        } else {
            int vl = getsum(a, b, k*2+1, l, (l+r) / 2);
            int vr = getsum(a, b, k*2+2, (l+r) / 2, r);
            return vl + vr;
        }
    }
};

int N, Q;

void init()
{
    cin >> N >> Q;
}

void solve()
{
    LSGT seg;
    seg.init(N);
    rep(i, Q) {
        int q;
        cin >> q;
        if (q == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            seg.add(s-1, t, x);
        } else {
            int s, t;
            cin >> s;
            cout << seg.getsum(s-1, s) << endl;
        }
    }
}




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

static const ULL M = 1000000007;

struct Problem {
public:

	UL N;
	vector<UL> E[100000];
	ULL dp[100000][2];
	bool F[100000] = {};

	void DFS(UL p) {
		F[p] = true;
		dp[p][0] = dp[p][1] = 1;
		for (UL e : E[p]) {
			if (F[e]) continue;
			DFS(e);
			dp[p][0] = dp[p][0] * dp[e][1] % M;
			dp[p][1] = dp[p][1] * (dp[e][0] + dp[e][1]) % M;
		}
	}

	void Solve() {
		scanf("%u", &N);
		rep(i, N - 1) {
			UL u, v; scanf("%u%u", &u, &v); u--; v--;
			E[u].push_back(v);
			E[v].push_back(u);
		}
		DFS(0);
		printf("%llu", (dp[0][0] + dp[0][1]) % M);
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
string t[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
string s;
cin>>s;
rep(i,7){
    if(t[i]==s){
        cout<<7-i<<endl;
        return 0;
    }
}


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s[15];
    while(scanf("%s",s)!=-1)
    {
        int ans=0,sum=0;
        int i=0;
        while(s[i]!='\0')
        {
            if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
                sum++;
            else
            {
                if(ans<sum)
                    ans=sum;
                sum=0;
            }
            i++;
        }
        ans=max(ans,sum);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func p1(h, w int) int {
	ans := h * w
	for x := 1; x < w; x++ {
		h1 := h / 2
		h2 := h - h1
		s1 := (w - x) * h1
		s2 := (w - x) * h2
		s3 := x * h
		smin := min(s1, min(s2, s3))
		smax := max(s1, max(s2, s3))
		ans = min(ans, smax-smin)
		// fmt.Printf("p1 - x %d, s3 %d, s1 %d, s2 %d, smax-smin %d\n", x, s3, s1, s2, smax-smin)
	}
	return ans
}

func p2(h, w int) int {
	ans := h * w
	for y := 1; y < h; y++ {
		h1 := (h - y) / 2
		h2 := h - y - h1
		s1 := w * h1
		s2 := w * h2
		s3 := w * y
		smin := min(s1, min(s2, s3))
		smax := max(s1, max(s2, s3))
		ans = min(ans, smax-smin)
		// fmt.Printf("p2 - x %d, s3 %d, s1 %d, s2 %d, smax-smin %d\n", y, s3, s1, s2, smax-smin)
	}
	return ans
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	fmt.Println(min(p1(h, w), min(p2(h, w), min(p1(w, h), p2(w, h)))))
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, '%s', $s);
$splited_s = str_split($s);
fscanf(STDIN, '%s', $t);
$splited_t = str_split($t);

$count = 0;
foreach ($splited_s as $key => $val) {
  if ($val == $splited_t[$key]) {
    $count += 1;
  }
}
echo $count;

Measured memory_bytes: 4728
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    """
    sum[Al,,,Ar] = Sの部分和がちょうどK個。
    """
    n, k, s = map(int, input().split())
    if n == k:
        r = [s] * k
    else:
        if s == 1000000000:
            r = [1000000000] * k + [1] * (n - k)
        else:
            r = [s] * k + [1000000000] * (n - k)

    print(*r, sep=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 11652
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 220
// 44

using namespace std;

inline int get(int x) {
    int sum = 0;
    while(x > 0) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n;
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = 1e9;
    for(int a = 1; a < n; a++) {
        int b = n - a;
        ans = min(ans, get(a) + get(b));
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 15

int sq[MAX_N][MAX_N];
int n;

void reset() {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      sq[i][j] = -1;
    }
  }
}

void fill(int count, int x, int y) {
  if (count > n * n) return;
  if (x < 0) x = n - 1;
  if (x >= n) x = 0;
  if (y >= n) y = 0;
  if (sq[x][y] != -1) {
    fill(count, x - 1, y + 1);
  } else {
    sq[x][y] = count;
    fill(count + 1, x + 1, y + 1);
  }
}

void printSq() {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf(j ? "%4d" : "%4d", sq[j][i]);
    }
    puts("");
  }
}

void solve() {
  int center = n /  2;
  reset();
  sq[center][center + 1] = 1;
  fill(2, center + 1, center + 2);
  printSq();
}

int main() {
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
    
    solve();
  }
  return 0;
}

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

int main()
{
    int H, W, h, w;
    scanf("%d%d%d%d",&H, &W, &h,&w);
    printf("%d\n", (H*W-(h*W+w*H-h*w)));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin>>n;
    
    int p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    
    int c=0;
    int m=p[0];
    for(int i=0;i<n;i++){
        m=min(m,p[i]);
        if(p[i]<=m)
            c++;
    }
    /*
    for(int i=0;i<n;i++){
        bool f=false;
        for(int j=0;j<i;j++){
            if(p[i]<=p[j]){
                continue;
                cout<<p[i]<<" "<<p[j]<<endl;
            }
            else{
                f=true;
                break;
            }
        }
        if(!f){
            c++;
        }
    }
    */
    cout<<c;
    
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    char a[n], b[n];
    scanf("%s%s", &a, &b);
    for(i=0; i<n; i++)
    {
        printf("%c%c", a[i], b[i]);
    }
    printf("\n");

    return 0;
}


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

string s, t;

int main() {
  cin >> s >> t;
  int ans = 10000;
  for (int i = 0; i <= (s.size() - t.size()); i++) {
    int cnt = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s[i+j] != t[j]) {
        cnt++; 
      }
    }
    ans = min(ans, cnt);
  }
  
  cout << ans;
}

Measured memory_bytes: 3144
A,B,H,M = map(int,input().split())
minute = H * 60 + M
k1 = 360*minute/(12*60)
k2 = 360*minute/ 60
import math
c = math.cos(math.radians(max(k1-k2,k2-k1)))
print((A*A+B*B-2*A*B*c)**(1/2))


Measured memory_bytes: 9504
#include <stdio.h>

int min(a,b){
  if (a<=b){
    return a;
  }else{
    return b;
  }
}
int max(a,b){
  if (a<=b){
    return b;
  }else{
    return a;
  }
}

int main()
{
  int i,x,ans;
  char a[1000010];
  scanf("%s",a);
  x = strlen(a);
  ans = x;
  for(i=0;i<=x-2;i++)
  {
    if(a[i] != a[i+1]){
    ans = min(ans,max(i+1,x-i-1));
    }
  }
  printf("%d",ans);
  return 0;
}
      

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[True for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    wa,wb=h[a-1],h[b-1]
    if wa>wb:ans[b-1]=False
    elif wa<wb:ans[a-1]=False
    else : ans[a-1]=False;ans[b-1]=False
print(ans.count(True))

Measured memory_bytes: 20048
def sol(inp=input):
    n=int(inp())
    lines=[list(map(int,inp().split())) for _ in range(n)]
    lines=sorted(lines,key=lambda l:l[1])
    
    for i in range(n-1):
        lines[i+1][0]+=lines[i][0]

    return('Yes' if all(l[0]<=l[1] for l in lines) else 'No')

print(sol())

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int n=sz(s);
	VI zz(n+1);
	
	int su = 0,  ks= 1;
	repr(i, n-1, 0){
		int d = s[i] - '0';
		su = (d * ks + su ) %2019;
		zz[i] = su;
		(ks *= 10) %=2019;
	}
	VI sk(2020);
	rep(i, sz(zz)) sk[zz[i]]++;
	//for(auto x :sk) if(x>1) cerr<<x<<" "; dbg();
	ll ans =0;
	for(auto x :sk) if(x>1){
		ans += (ll)x * (x-1) / 2;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4424
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int x, y;
  bool aru[N];
  for(int i=0;i<N;++i) aru[i] = false;
  aru[0] = true;
  int num[N];
  for(int i=0;i<N;++i) num[i] = 1;
  for(int i=0;i<M;++i) {
    cin>>x>>y;
    x--;
    y--;
    if(aru[x]) aru[y] = true;
    if(aru[x] && num[x]==1) aru[x] = false;
    num[x]--;
    num[y]++;
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(aru[i]) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j,m,a;
	cin>>n;
	int flag=0;
	for(i=0;i<n;i++){
		cin>>a;
		if(a%2==0){
			if(a%5!=0&&a%3!=0)flag=1;
		}
	}
	if(flag==0)cout<<"APPROVED";
	else cout<<"DENIED";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
      int n = in.nextInt();

      int max = 0;
      int min = 0;

      for (int i = 0; i < n; i++) {
        int newScan = in.nextInt();

        if (min == 0 ) {
          min = newScan;
        } else if( min > newScan) {

          int tmp =  newScan - min;
          if (max == 0 || tmp > max) {
            max = tmp;
          }
          min = newScan;

        } else {
          int tmp = newScan - min;
          if (max == 0 || tmp > max) {
            max = tmp;
          }

        }
      }


      System.out.println(max);
    }
}



Measured memory_bytes: 99440
def sort_print (arr)
  i = 1
  while i < arr.size
    key = arr[i].to_i
    j = i - 1
    while  j >= 0 and arr[j].to_i > key
      arr[j+1] = arr[j]
      j = j - 1
    end
    arr[j+1] = key
    i = i + 1
    puts arr.join(' ')
  end
end

arr = []
size = gets.chomp.to_i
arr = gets.chomp.split(' ').each{|x| x.to_i}
puts arr.join(' ')

sort_print(arr)

Measured memory_bytes: 6124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                int[,] calls = new int[n, 3];
                int[,] called = new int[101, 3];
                for (int i = 0; i < n; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    calls[i, 0] = ints[0];
                    called[ints[0], 0]++;
                    calls[i, 1] = ints[1];
                    called[ints[1], 1]++;
                    calls[i, 2] = ints[2];
                    called[ints[2], 2]++;
                }

                for(int i =0; i<n;i++){
                    int score = 0;
                    int call0 = calls[i, 0];
                    if(called[call0,0]<=1){score+=call0;}
                    int call1 = calls[i, 1];
                    if (called[call1, 1] <= 1) { score += call1; }
                    int call2 = calls[i, 2];
                    if (called[call2, 2] <= 1) { score += call2; }
                    Console.WriteLine(score);
                }
                break;


                
            }
        }

        
    }



    
}

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

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

    if (a > 0)
    {
        if (a > k)
        {
            a -= k;
            k = 0;
        }
        else
        {
            k -= a;
            a = 0;
        }
    }
    if (b > 0)
    {
        if (b > k)
        {
            b -= k;
            k = 0;
        }
        else
        {
            b = 0;
            k -= b;
        }
    }

    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}

void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}

int main(void)
{
    int na, nb, nc;
    scanf("%d %d %d", &na,&nb,&nc);
    sort3(&na, &nb, &nc);
    printf("%d %d %d\n", na,nb,nc);
    return (0);
}




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

using namespace std;
using ll=long long;
int main(){
    ll h,n;
    cin >> h >> n;
    vector<ll> a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum>=h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1024
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j;
	cin>>n;
	ll a[n+1],b[n+1];
	for(i=0;i<n;i++)
		cin>>a[i],b[i]=a[i];
	sort(a,a+n);
	ll cnt=0;
	vi idx;
	for(i=0;i<n;i++){
		if(a[i]!=b[i])
			idx.pb(i);
	}
	if(idx.size()==0){
		cout<<"YES";return 0;
	}
	if(idx.size()==2){
		if(a[idx[0]]==b[idx[1]]&&a[idx[1]]==b[idx[0]])cout<<"YES";else cout<<"NO";
	}else
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin>>N;
	vector<int>dp(N+1);
	int nine[12]={59049,46656,7776,6561,1296,729,216,81,36,9,6,1};
	
	dp[0]=0;
	FOR(i,1,N+1){
		dp[i]=10000000;
		REP(j,12){
			if(i-nine[j]<0){
				continue;
			}
			else{
				dp[i]=min(dp[i],dp[i-nine[j]]+1);
			}
		}
	}
	cout<<dp[N]<<endl;
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

bool check(vint ans){
    int S=accumulate(all(ans),0ll);
    rep(i,ans.size()){
        if(gcd(S-ans[i],ans[i])==1)return false;
    }

    int g=0;
    rep(i,ans.size())g=gcd(g,ans[i]);
    return g==1;
}

vint lis2[2];
vint lis3[3];
vint lis6;


int solve(int N){

        vint ans;
        if(N>15000){
            for(auto x:lis2[1])ans.pb(x);
            for(auto x:lis3[1])ans.pb(x);
            for(auto x:lis3[2])ans.pb(x);
            for(auto x:lis6)ans.pb(x);

            while(ans.size()>N)ans.pop_back();

            rep(i,ans.size()){
                if(i)cout<<" ";
                cout<<ans[i];
            }cout<<endl;
            return 0;
        }

        for(int jj=0;jj<3;jj++){
            for(int kk=0;kk<3;kk++){
            if((jj+kk*2)%3)continue;
            int i=2;
            int j=jj;
            int k=kk;
            int l=0;
            if(j==0&&k==0)j=3;

            if(i+j+k+l>N)continue;

            while(i+j+k+l+2<=N&&i+2<=lis2[1].size())i+=2;
            while(i+j+k+l+3<=N&&j+3<=lis3[1].size())j+=3;
            while(i+j+k+l+3<=N&&k+3<=lis3[2].size())k+=3;
            while(i+j+k+l+1<=N&&l+1<=lis6.size())l++;

            vint ans;
            rep(x,i)ans.pb(lis2[1][x]);
            rep(x,j)ans.pb(lis3[1][x]);
            rep(x,k)ans.pb(lis3[2][x]);
            rep(x,l)ans.pb(lis6[x]);
            rep(x,ans.size()){
                if(x)cout<<" ";
                cout<<ans[x];
            }cout<<endl;
            return 0;
        }
    }
}

signed main(){
    for(int i=1;i<=30000;i++){
        if(i%2&&i%3)continue;
        if(i%2==0&&i%3==0)lis6.pb(i);
        else if(i%2==0)lis3[i%3].pb(i);
        else lis2[i%2].pb(i);
    }

    int N;cin>>N;

    if(N==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }

    solve(N);
    return 0;
}


Measured memory_bytes: 896
n,p = map(int,input().split())
a = list(map(int,input().split()))
even = []
odd = []
for i in range(n):
    if a[i]%2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])

#print(2**len(even)*2**(len(odd)-1)-1)if len(odd) > 0 else print(2**len(even))

if len(odd) > 0:
    print(2**len(even)*2**(len(odd)-1))
else:
    if p == 0:
        print(2**n)
    else:
        print(0)


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<string> name;
	vector<int> time;
	int n;
	cin >> n;
	int q;
	cin >> q;
	string damy1;
	int damy2;
	for (int i = 0; i < n; ++i) {
		cin >> damy1 >> damy2;
		name.push_back(damy1);
		time.push_back(damy2);
	}
	vector<string> nameans;
	vector<int> timeans;
	int max=0;
	int he = 0;
	while (name.begin() + he != name.end()) {
		if (*(time.begin() + he) > q) {
			*(time.begin() + he) -= q;
			max += q;
			name.push_back(*(name.begin() + he));
			time.push_back(*(time.begin() + he));
		}
		else {
			max += *(time.begin() + he);
			nameans.push_back(*(name.begin() + he));
			timeans.push_back(max);
		}
		++he;
	}
	for (int i = 0; nameans.begin() + i != nameans.end(); ++i) {
		cout << *(nameans.begin() + i) << " " << *(timeans.begin() + i) << endl;
	}
	return 0;
}

Measured memory_bytes: 7284