akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
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)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll N,M;cin>>N>>M;
  VL A(M);
  ll sum=0;
  for(ll i=0;i<M;i++){
    cin>>A[i];
    sum+=A[i];
  }
  if(N-sum<0){
    cout<<-1<<endl;
  }else{
    cout<<N-sum<<endl;
  }

}

Measured memory_bytes: 3648
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
A[0] = B[0]
for i in range(1,N-1):
    if B[i-1] < B[i]:
        A[i] = B[i-1]
    else:
        A[i] = B[i]
A[-1] = B[-1]
print(sum(A))

Measured memory_bytes: 3064
_  = gets.to_s.split.map(&:to_i)
a  = gets.to_s.split.map(&:to_i).sort
bcs = $<.read.split.map(&:to_i).each_slice(2).sort_by{|b,c| c}

ans = 0

b, c = bcs.pop
a.each do |k|
  
  if b && k < c
    ans += c
    b -= 1
    b,c = bcs.pop if b == 0
  else
    ans += k
  end
end

puts ans

Measured memory_bytes: 29536
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    int sum = 0;

    for (int h = 1; h <= N; h++)
    {
        int i = h;
        while (i / 10 >= 0)
        {
            sum += i % 10;
            i /= 10;
            
            if (i == 0)
            {
                break;
            }
            
        }
        
        if (sum >= A && sum <= B)
        {
            ans += h;
        }
        //cout << h << " " << ans << endl;
        sum = 0;
        
    }
    
    cout << ans << endl;

}


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

#define MAX 200000

int main(){
  int n,i,j;
  int R[MAX];
  int maxv,minv;

  scanf("%d",&n);
  if( n < 2 || MAX < n ) exit(2);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&R[i]);
    if( R[i] < 1 || 1000000000 < R[i] )
      exit(3);
  }

  maxv=R[1]-R[0];
  minv=R[0];
  for( j = 1 ; j < n ; j++ )
    { 
      if( maxv < R[j]-minv ) maxv = R[j]-minv;
      if( minv > R[j] ) minv = R[j];
  }
  printf("%d\n",maxv);
 
  return 0;
}

Measured memory_bytes: 1376
import java.util.Scanner;

public class Main {

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

		scan.close();
		int check=0;
		for(int i=0;i<=n/4;i++) {
			for(int j=0;j<=n/7;j++) {
				if(n==4*i+7*j) {
					check=1;
					System.out.println("Yes");
					break;
				}
			}
			if(check==1)break;
		}
		if(check==0)System.out.println("No");
	}

}

Measured memory_bytes: 22996
//priority-queueを使ったダイクストラ
#include<bits/stdc++.h>
using namespace std;
vector<int> color;//0はまだ行ってない1は行った
vector<int> dist;
vector<vector<pair<int,int>>> M;
int n;
const int INF = (1<<20);
void dijkstra(int s){
    priority_queue<pair<int,int>> que;//v,重さ
    dist[s] = 0;
    que.push(make_pair(0,0));
    color[s] = 1;
    while(!que.empty()){
        pair<int,int> f = que.top();
        que.pop();
        int u = f.second;
        color[u] = 1;
        if(dist[u]<f.first*(-1)) continue;//最小値を取り出し、それが最短でなければ無視
        for(auto nv:M[u]){
            int v = nv.first;
            if(color[v]==1) continue;
            if(dist[v]>dist[u]+nv.second){
                dist[v]=dist[u]+nv.second;
                que.push(make_pair(dist[v]*(-1),v));
            }
        }
    }
}
int main(){
    cin >> n;
    color.resize(n);
    dist.assign(n,INF);
    M.resize(n);
    for(int i=0;i<n;i++){
        int id,k;cin >> id >> k;
        for(int j = 0;j<k;j++){
            int v,c;cin >> v >> c;
            M[id].push_back(make_pair(v,c));
        }
    }
    dijkstra(0);
    for(int i=0;i<n;i++){
        cout << i << " ";
        cout << dist[i] << endl;
    }
    
}


Measured memory_bytes: 7772
#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>;

int main() {
    string s, t;
    cin >> s >> t;
    string ans = t+s;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int s; readV(s);

  auto b = new bool[](1000001);
  b[s] = true;

  foreach (i; 2..1000002) {
    s = s%2 == 0 ? s/2 : s*3+1;
    if (b[s]) {
      writeln(i);
      return;
    }
    b[s] = true;
  }
}


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

int main()
{
  string S;
  cin >> S;

  int ans = 0;

  for (int i = 0; i < S.size() / 2; i++)
  {
    if (S.at(i) != S.at(S.size() - i - 1))
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
char buf[25000],out[10];
i;
X,Y,Z;
k;
p;
n;
x;
main()
{
	n=read(0,buf,25000);
	while(buf[i++]-' ');
	while(buf[i++]-' ');
	for(;;)
	{
		k=buf[i++];
		if(k<'0')break;
		X=X*10-k+'0';
	}
	--n;--n;
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		X+=x=p*(k-'0');
		Y+=x;
		p*=10;
	}
	p=1;
	for(;;)
	{
		k=buf[n--];
		if(k<'0')break;
		Y-=p*(k-'0');
		p*=10;
	}
	if(X<0)X=-X;
	if(Y<0)Y=-Y;
	if(X<Y)X=Y;
	i=9;
	do{
		out[--i]=X%10+'0';
		X/=10;
	}while(X);
	write(1,out+i,9-i);
}

Measured memory_bytes: 128
N = int(input())
A_n = list(map(int,input().split()))
a = []
for i in range (0,N):
    if A_n[i] % 2 == 0:
        a.append(A_n[i])

flag = 0
for i in range (0,len(a)):
    if a[i] % 3 != 0 and a[i] % 5 != 0:
        flag += 1

if flag == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrD = np.array(input().split(),dtype=np.int64)

AA,BB = np.meshgrid(arrD,arrD)
a = np.dot(AA.flatten(),BB.flatten())
# print(a)
b = sum(arrD**2)
# print(b)

ans = (a-b)//2

print(ans)

Measured memory_bytes: 12508
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a,b;
string str;
void solve(){
  int res = 0;
  for(int  i = 0; i< str.size(); i++){
    if(str[i] == '+'){
      res ++;
    }else{
      res --;
    }
  }
  cout << res << endl;
  return;
}
int main(){
  cin >> str;
  solve();
  return 0;
}


Measured memory_bytes: 256
# ALDS1_2_B.py
def selectionSort(A,N):
    cnt=0
    for i in range(N):
        minj = i
        for j in range(i+1,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            tmp = A[i] 
            A[i] = A[minj]
            A[minj] = tmp
            cnt += 1
    return A,cnt
N = int(input())
A = list(map(int,input().split()))
A,cnt = selectionSort(A,N)
print(*A)
print(cnt)




Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N,K;
	cin >> N >> K;
	int A[N];
	rep(i,N) cin >> A[i];
	int num = A[0], maxi = 0;
	rep(i,N){
		num = __gcd(A[i], num);
		chmax(maxi, A[i]);
	}
	if(maxi >= K && K % num == 0){
		cout << "POSSIBLE" << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;

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

    int x;
    int ans[n + 1] = {0};

    for (int i = 0; i < n - 1; i++)
    {
        cin >> x;

        ans[x]++;
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

Measured memory_bytes: 4416
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    H, W = iim()
    S = [input() for i in range(H)]
    c1 = "#"
    H1, W1 = H-1, W-1

    inf = H*W+1
    dq = [0]*W
    dq0 = [(inf, True)]*W
    dq0[0] = (0, True)

    for y in range(H):
        (co, good0) = dq0[0]

        good = not S[y][0] == c1
        if not good:
            if good0:
                co += 1
        dq1 = dq[0] = (co, good)
        for x in range(1, W):
            (co0, good0) = dq0[x]
            (co1, good1) = dq1
            good = not S[y][x] == c1
            if not good:
                if good0:
                    co0 += 1
                if good1:
                    co1 += 1
            dq1 = dq[x] = (min(co0, co1), good)
        dq, dq0 = dq0, dq
        #print(dq0)
    print(dq0[-1][0])

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
import Foundation
var k = Int(readLine()!)!
var str = readLine()!.components(separatedBy:" ")
var num = [Int]()
for i in str {
  num.append(Int(i)!)
}
var a = num[0]
var b = num[1]
var ans = "NG"
for n in a...b{
  if n%k == 0{
    ans="OK"
    break
  }
}
print(ans)

Measured memory_bytes: 14060
#include <stdio.h>

int main(void){

    int X = 0;
    int Y = 0;
    int Z = 0;
    int tmp = 0;

    scanf("%d %d %d", &X, &Y, &Z);

    tmp = X;
    X = Y;
    Y = tmp;
    tmp = X;
    X = Z;
    Z = tmp;
    printf("%d %d %d", X, Y, Z);

    return 0;
}

Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        // 整数a, bの入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        // 偶数奇数の判定
        if ( ((a * b) % 2) == 0 )
        {
            Console.WriteLine("Even");
        }
        else
        {
            Console.WriteLine("Odd");
        }
    }
}

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> l(N);
  rep(i, 0, N) {
    cin >> l.at(i);
  }

  sort(l.begin(), l.end());

  int Ans = 0;
  rep(i, 0, K) {
    Ans += l.back();
    l.pop_back();
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int W = sc.nextInt();
			int n = sc.nextInt();
			if (W == 0 && n == 0)
				break;
			long[] accum = new long[n + 1];
			int[] x = new int[n];
			for (int i = 0; i < n; ++i) {
				x[i] = sc.nextInt();
			}
			for (int i = 0; i < n; ++i) {
				accum[i + 1] = accum[i] + x[i];
			}
			int lack = 0;
			int gap = 1;
			outer: for (int i = 14; i >= -1; --i) {
				// gap+i???????????????????????????
				int ngap = gap + (i >= 0 ? (1 << i) : 0);
				int[] vis = new int[n + 1];
				vis[0] = 1;
				vis[1] = -1;
				for (int j = 0; j < n; ++j) {
					vis[j] += (j > 0 ? vis[j - 1] : 0);
					if (vis[j] > 0) {
						if (accum[n] - accum[j] + (n - j - 1) <= W) {
							continue outer;
						}
						int left = j;// 0
						int right = n;// 5
						while (right - left > 1) {
							int middle = (right + left) / 2;
							if (accum[middle] - accum[j] + (middle - j - 1) <= W) {
								left = middle;
							} else {
								right = middle;
							}
						}
						int dmax = left;

						left = j;
						right = n;
						while (right - left > 1) {
							int middle = (right + left) / 2;
							if (W <= accum[middle] - accum[j] + (long) ngap * (middle - j - 1)) {
								right = middle;
							} else {
								left = middle;
							}
						}
						int dmin = right;
						
						if (dmin > dmax)
							continue;
						++vis[dmin];
						--vis[dmax + 1];
					}
				}
				++lack;
				gap = ngap;
			}
			if (lack > 0)
				++gap;
			System.out.println(gap);
		}
	}

	
	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

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

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

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

llint f(llint n)
{
    int d = (n + 1) / 2;
    int m;
    if(d % 2) m = 1;
    else      m = 0;
    
    if(n % 2) return m;
	
    return m ^ n;
}

int main()
{
    llint a, b;
    ci >> a >> b;

    co << (f(a - 1) ^ f(b)) << en;
    
    return 0;
}





Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static int N;
    private static int K;
    private static int L;

    public static void main(String[] args) {
	N = Integer.parseInt(scan.next());
	K = Integer.parseInt(scan.next());
	L = Integer.parseInt(scan.next());

	UnionFind k = new UnionFind(N);
	UnionFind l = new UnionFind(N);
	
	for (int i = 0; i < K; i++) {
	    int p = Integer.parseInt(scan.next()) - 1;
	    int q = Integer.parseInt(scan.next()) - 1;
	    k.connect(p, q);
	}
	for (int i = 0; i < L; i++) {
	    int r = Integer.parseInt(scan.next()) - 1;
	    int s = Integer.parseInt(scan.next()) - 1;
	    l.connect(r, s);
	}

	Pair[] pairs = new Pair[N];
	Map<Pair, Integer> map = new HashMap<Pair, Integer>(N);
	for (int i = 0; i < N; i++) {
	    pairs[i] = new Pair(k.root(i), l.root(i));
	    if(map.containsKey(pairs[i])) {
		int count = map.get(pairs[i]).intValue();
		map.put(pairs[i], count+1);
	    } else {
		map.put(pairs[i], 1);
	    }
	}

	for (int i = 0; i < N; i++) {
	    if(i>0) System.out.print(' ');
	    System.out.print(map.get(pairs[i]).intValue());
	}
	System.out.println();
	scan.close();
    }

    private static class UnionFind {
	int[] uni;

	public UnionFind(int N) {
	    uni = new int[N];
	    for (int i = 0; i < N; i++) {
		uni[i] = -1;
	    }
	}

	public int root(int a) {
	    if(uni[a] < 0) return a;
	    else return uni[a] = root(uni[a]);
	}

	public boolean connect(int a, int b) {
	    a = root(a);
	    b = root(b);

	    if(a == b) return false;
	    if(uni[a] > uni[b]) {
		int tmp = a;
		a = b;
		b = tmp;
	    }
	    uni[a] += uni[b];
	    uni[b] = a;
	    return true;
	}
    }

    private static class Pair {
	private final int x;
	private final int y;

	public Pair(int x, int y) {
	    this.x = x;
	    this.y = y;
	}

	@Override
	public boolean equals(Object obj) {
	    if(obj instanceof Pair) {
		Pair p = (Pair)obj;
		return this.x == p.x && this.y == p.y;
	    } else {
		return false;
	    }
	}

	@Override
	public int hashCode() {
	    return Objects.hash(x, y);
	}
    }
}


Measured memory_bytes: 109276
N,X=map(int,input().split())

hlist=[]
blist=[]
plist=[]
for i in range(N+1):
  hlist.append(2**(i+2)-3)
  #blist.append(2**(i+1)-2)
  plist.append(2**(i+1)-1)
  
#print(hlist)
#print(blist)
#print(plist)

num_p=0
while(True):
  #print(N,X,num_p)
  if N==0:
    num_p+=1
    break
  elif X==1:
    break
  elif X==hlist[N]//2+1:
    num_p+=plist[N-1]+1
    break
  elif X==hlist[N]:
    num_p+=plist[N]
    break
  elif X<hlist[N]//2+1:
    X-=1
    N-=1
  else:
    num_p+=plist[N-1]+1
    X-=hlist[N]//2+1
    N-=1
  
print(num_p)

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

ll calc(ll n, ll div, ll a, ll d) {
  ll dec = n / div * (div - 1);
  if (dec > mod) {
    return a;
  }
  return min(dec * d, a);
}

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

  ll t;
  cin >> t;

  rep(i, t) {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    ll ans = -1;

    priority_queue<P, std::vector<P>, greater<P>> que;
    que.emplace(0, n);

    map<ll, ll> mn;

    vector<P> div;
    div.emplace_back(2, a);
    div.emplace_back(3, b);
    div.emplace_back(5, c);

    while (!que.empty()) {
      auto p = que.top();
      que.pop();

      ll co = p.first;
      ll v = p.second;
      if (v == 1) {
        ans = co + d;
        break;
      }

      if (mn.find(v) != mn.end()) {
        continue;
      }
      mn[v] = co;

      for (auto p : div) {
        ll dv = p.first;
        ll dv_co = p.second;

        if (v % dv == 0) {
          que.emplace(co + calc(v, dv, dv_co, d), v / dv);
        } else {
          ll tmp = v % dv;
          que.emplace(co + (dv - tmp) * d + calc(v + tmp, dv, dv_co, d), (v + tmp) / dv);
          que.emplace(co + tmp * d + calc(v + tmp, dv, dv_co, d), (v + tmp) / dv);
        }
      }

      // que.emplace(co + d, v + 1);
      // que.emplace(co + d, v - 1);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l, n;
    cin >> l >> n;
    vector<ll> x(n);
    rep(i, 0, n) cin >> x[i];
    ll ans = 0;
    rep(qq, 0, 2) {
        vector<ll> z = x;
        z.emplace_back(l);
        for (ll e : x) z.emplace_back(e + l);
        vector<ll> s = z;
        rep(i, 1, s.size()) s[i] += s[i - 1];
        vector<ll> t = s;
        rep(i, 1, t.size()) t[i] += t[i - 1];
        debug(s, t);
        rep(i, 1, n + 1) {
            ll tmp = 0;
            int cnt = n - i + 1;
            tmp += 2LL * (s[n + i + cnt / 2 - 1] - s[n + i - 1]);
            if (cnt % 2)
                tmp += z[n + i + cnt / 2];
            else
                tmp -= z[n - cnt / 2];
            tmp -= z[n];
            tmp -= 2LL * (s[n - 1] - s[n - (cnt + 1) / 2]);
            ans = max(ans, tmp);
            debug(tmp);
        }
        reverse(x.begin(), x.end());
        for (ll &xx : x) xx = l - xx;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<string>s;
	for (int i = 0; i < n; i++){
		string st; cin >> st;
		s.push_back(st);
	}
	int num = n*m;
	for (int i = 1; i < n - 1; i++){
		for (int j = i + 1; j < n; j++) {
			int k;
			int p = 0;
			for (k = 0; k < i; k++){
				for (int i = 0; i < m; i++){
					if (s[k][i] != 'W'){
						p++;
					}
				}
			}
			for (k = i; k < j; k++) {
				for (int i = 0; i < m; i++) {
					if (s[k][i] != 'B') {
						p++;
					}
				}
			}
			for (k = j; k  < n; k++){
				for (int i = 0; i < m; i++) {
					if (s[k][i] != 'R') {
						p++;
					}
				}
			}
			num = min(num, p);
		}
	}
	cout << num << endl;
	return 0;
}

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

int main() {
	int h, w, n; std::cin >> h >> w >> n;
	std::cout << (n + std::max(h, w) - 1) / std::max(h, w) << '\n';
}


Measured memory_bytes: 888
#include<stdio.h>
 
int main(){
   int n,max=0,c=0;
   scanf("%d", &n);
   int h[n],cc[n];
   for(int i=0;i<n;i++){
   	scanf("%d ", &h[i]);
   }
   for(int i=0;i<n-1;i++){
     if(h[i]>=h[i+1]){
      c++; 
       //printf("%d\n",c);
     } else {
       if(max < c){
         max = c;
         //printf("sss\n");
       }
       c = 0; 
     }
   }
  if(max<c){ max =c;}
	printf("%d", max);
	return 0;
 
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

struct node_t{
    long long weight;
    node_t *l;
    node_t *r;
    long long sum;

    node_t(long long weight,node_t *l,node_t *r,long long sum = 0){
        this->weight = weight;
        this->l = l;
        this->r = r;
        this->sum = sum;
    }
}*nill,*aint;

void add(node_t *root,long long l,long long r,long long pos){
    if(r < pos || l > pos){
        return ;
    }

    if(l == r){
        root->weight++;
        root->sum += pos;
        return ;
    }

    long long mid = (l + r) / 2;

    if(root->l == nill){
        root->l = new node_t(0,nill,nill);
    }

    if(root->r == nill){
        root->r = new node_t(0,nill,nill);
    }

    add(root->l,l,mid,pos);
    add(root->r,mid + 1,r,pos);

    root->weight = root->l->weight + root->r->weight;
    root->sum = root->l->sum + root->r->sum;
}

long long offset = 0;

pair<long long,long long> get_elem(node_t *root,long long l,long long r,long long pos){
    if(l == r){
        return {l,offset};
    }

    long long mid = (l + r) / 2;

    if(root->l->weight < pos){
        pos -= root->l->weight;
        auto tmp = get_elem(root->r,mid + 1,r,pos);
        tmp.second = tmp.second + 1LL * root->l->weight * tmp.first - root->l->sum;
        return tmp;
    }
    else{
        auto tmp = get_elem(root->l,l,mid,pos);
        tmp.second = tmp.second - 1LL * root->r->weight * tmp.first + root->r->sum;
        return tmp;
    }
}

long long q;

int main(){
    nill = new node_t(0,NULL,NULL);
    aint = new node_t(0,nill,nill);

    scanf("%lld",&q);

    while(q--){
        long long t;
        scanf("%lld",&t);

        if(t == 1){
            long long a,b;
            scanf("%lld %lld",&a,&b);
            offset += b;
           add(aint,1,2e9 + 1,a + 1e9 + 1);
        }
        else{
            pair<long long,long long> tmp = {0,0}; 
            tmp = get_elem(aint,1,2e9 + 1,(1 + aint->weight) / 2);
            tmp.first -= 1;
            tmp.first -= 1e9;
            printf("%lld %lld\n",tmp.first,tmp.second);
        }
    }

    return 0;
}


Measured memory_bytes: 137856
#include <bits/stdc++.h>
#include <ext/rope>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

string str;

void read()
{
	cin >> str;
}

vector<int> st;

void solve()
{
	for(int i = 0; i < str.size(); i++)
	{
		st.push_back(str[i]);
		while(st.size() > 1)
		{
			if(st[st.size() - 1] == 'T' && st[st.size() - 2] == 'S')
				st.pop_back(), st.pop_back();
			else break;
		}
	}

	cout << st.size() << endl;
}

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

	read();
	solve();
	return 0;
}


Measured memory_bytes: 1552
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  ll n,i;
  cin >> n;
  vector<string> s(n);
  map<string,ll> mp;
  for(i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    mp[s[i]]++;
  }
  ll ans=0;
  for(i=0;i<n;i++){
    if(mp[s[i]]<2){
      continue;
    }
    ans+=mp[s[i]]*(mp[s[i]]-1)/2;
    mp[s[i]]=0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14016
#include <stdio.h>


int main()
{
  int a, b;

  scanf("%d %d", &a, &b);
  if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) printf("Possible\n");
  else printf("Impossible\n");

  return 0;
}

Measured memory_bytes: 128
#56 C - Subarray Sum
N,K,S = map(int,input().split())


ans = []
if S == 10**9:
    for i in range(K):
        ans.append(S)
    for j in range(N-K):
        ans.append(1)
else:
    for i in range(K):
        ans.append(S)
    for j in range(N-K):
        ans.append(S+1)
print(*ans)

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

int N;
int cn = 0;
int p[100010];

int main(){
  cin >> N;

  for(int i = 1; i <= N; i++) cin >> p[i];

  /*連続数jとして、(1+j/2が交換数*/
  int i = 1;
  while(i <= N){
    int j = 0;
    while(i+j <= N && p[i+j] == i+j) ++j;
    cn += (1+j) / 2; i += j; ++i;
  }

  cout << cn << endl;
  return 0;
}

  

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	//https://qiita.com/tnoda_/items/b503a72eac82862d30c6

	//1行ずつ読み込む
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s := sc.Text()

	if s[2:3] == s[3:4] && s[4:5] == s[5:6] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

using namespace std;

int main(){
  int n, k;
  cin>>n>>k;
  vector<int> arr(n);
  vector<int> dp(n);
  for(int i=0; i<n; i++){
    cin>>arr[i];
  }
  if(k>=n){
    cout<<abs(arr[n-1] - arr[0])<<endl;
    return 0;
  }
  for(int i=1; i<k; i++){
    dp[i] = abs(arr[i] - arr[0]);
    for(int j=1; j<i; j++){
      dp[i] = min(abs(arr[i] - arr[j]) + dp[j], dp[i]);
    }
  }

  for(int i=k; i<n; i++){
    dp[i] = abs(arr[i] - arr[i-k]) + dp[i-k];
    for(int j=i-k+1; j<i; j++){
      dp[i] = min(abs(arr[i] - arr[j]) + dp[j], dp[i]);
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
from sys import exit
N, M, K  = map(int, input().split())
if K == 0:
    print("Yes")
    exit()
for n in range(N + 1):
    for m in range(M + 1):
        if (N - n) * (M - m) + n * m == K:
            print("Yes")
            exit()
print("No")

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

int main()
{
	int n;
	std::cin >> n;
	n = n % 1000;
	if (n == 0)
		std::cout << 0 << '\n';
	else
		std::cout << 1000 - n << '\n';
	return (0);
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> B(N - 1);
	for (int i = 0; i < N - 1; i++) {
		cin >> B[i];
	}
	int res = B[0] + B[N - 2];
	for (int i = 1; i < N - 1; i++) {
		res += min(B[i - 1], B[i]);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll n, s = 0;
	cin >> n;
	vector<ll>a(n);
	vector<ll>c(9, 0);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= 1 && a[i] <= 399) {
			c[0]++;
		}
		else if (a[i] >= 400 && a[i] <= 799) {
			c[1]++;
		}
		else if (a[i] >= 800 && a[i] <= 1199) {
			c[2]++;
		}
		else if (a[i] >= 1200 && a[i] <= 1599) {
			c[3]++;
		}
		else if (a[i] >= 1600 && a[i] <= 1999) {
			c[4]++;
		}
		else if (a[i] >= 2000 && a[i] <= 2399) {
			c[5]++;
		}
		else if (a[i] >= 2400 && a[i] <= 2799) {
			c[6]++;
		}
		else if (a[i] >= 2800 && a[i] <= 3199) {
			c[7]++;
		}
		else {
			c[8]++;
		}


	}
	for (ll i = 0; i <= 7; i++) {
		if (c[i] > 0) {
			s++;
		}
	}
	if (s==0) {
		cout << 1 << " " << s + c[8] << endl;
	}
	else {
		cout << s << " " << s + c[8] << endl;
		
	}




}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#define mo 1000000007
#define lowbit(x) ((x) & (-x))
using namespace std;
int n, m, tot, tot1, ans;
long long f[(int)2e5+5], g[(int)2e5+5];
long long t[(int)2e5+5];
struct node {
	int ty, val, id;
} c[(int)2e5+5];
struct node2 {
	int lf, rf;
	node2() { lf = rf = 0; }
} a[(int)2e5+5], b[(int)2e5+5];
map <int, int> mp;

const bool cmp (const node t1, const node t2) { return t1.val < t2.val; }
const bool cmp2 (const node2 t1, const node2 t2) { return t1.rf < t2.rf; }
const bool cmp3 (const node2 t1, const node2 t2) { 
	if (t1.lf != t2.lf) return t1.lf > t2.lf;
	return t1.rf < t2.rf;
}

long long ask (int pos) {
	if (!pos) return 0;
	long long ans = 0;
	while (pos <= n) ans += t[pos], ans %= mo, pos += lowbit (pos);
	return ans % mo;
}

void add (int pos, long long Val) {
	while (pos)
		t[pos] += Val, t[pos] %= mo, pos -= lowbit (pos);
}

int main() {
	int i,j,k;
	scanf ("%d%d", &n, &m);
	for (i=1; i<=n; ++i) scanf ("%d", &c[++tot].val), c[tot].ty = 0, c[tot].id = i;
	for (i=1; i<=m; ++i) scanf ("%d", &c[++tot].val), c[tot].ty = 1, c[tot].id = i;
	sort (c+1, c+tot+1, cmp);
	for (i=1, k = 0; i<=tot; ++i) {
		if (c[i].ty == 1) k = c[i].val;
		else if (k) b[c[i].id].lf = c[i].val - k;
	}
	for (i=tot, k = 0; i>=1; --i) {
		if (c[i].ty == 1) k = c[i].val;
		else if (k) b[c[i].id].rf = k - c[i].val;
	}
	for (i=1; i<=n; ++i)
		if (b[i].lf > 0 && b[i].rf > 0) a[++tot1] = b[i];
	sort (b+1, b+n+1, cmp2);
	sort (a+1, a+tot1+1, cmp3);
	for (i=1; i<=n; ++i)
		mp[b[i].rf] = i;
	for (i=1; i<=tot1; ++i) {
		if (a[i].lf == a[i-1].lf && a[i].rf == a[i-1].rf) { f[i] = f[i-1], g[i] = g[i-1]; continue; }
		f[i] = (max (g[i-1] + f[i-1], 1ll)) % mo;
		g[i] = (max (ask (mp[a[i].rf] + 1ll) + 1ll, 1ll)) % mo, add (mp[a[i].rf], g[i]);
	} printf ("%lld", max (g[tot1] + f[tot1], 1ll) % mo);
	return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> q(n), a(n), b(n);
    for (int i = 0; i < n; i++) {
        int p;
        scanf("%d", &p);
        q[p - 1] = i;
    }

    a[0] = 1;
    b[0] = n * n;
    for (int i = 1; i < n; i++) {
        int t = q[i] - q[i - 1];
        a[i] = a[i - 1] + 1 + max(t, 0);
        b[i] = b[i - 1] - 1 + min(t, 0);
    }

    for (int k = 0; k < 2; k++) {
        for (int i = 0; i < n; i++) {
            printf("%d%c", (k == 0 ? a : b)[i], " \n"[i == n - 1]);
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m,k,ans=0,ct=0,fl=0;
	string s,s1="";
	cin>>s>>n;
	for(int i=0;i<n;i++)
	{
		ll u,v;
		string p;
		cin>>u;
		if(u==1)
			ct++;
		else
		{
			cin>>v>>p;
			if(ct%2==0)
			{
				if(v==2)
					s+=p;
				else
					s1+=p;
			}
			else
			{
				if(v==1)
					s+=p;
				else
					s1+=p;
			}
		}
	}
	if(ct%2==0)
	{
		reverse(s1.begin(),s1.end());
		cout<<s1<<s<<endl;
	}
	else
	{
		reverse(s.begin(),s.end());
		cout<<s<<s1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3784
S = input()
f = True
if S[0] != 'A':
  f = False
elif S[2:-1].count('C') != 1:
  f = False
else:
  for s in S[1:]:
    if s not in 'Cabcdefghijklmnopqrstuvwxyz':
      f = False
      break
print('AC' if f else 'WA')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}


int main(){
    int n = in();
    vvector<pii> edges(n);
    rep(i, n){
        int t;
        t = in();
        rep(j, t){
            int a = in()-1;
            int b = in();
            edges[i].emplace_back(a, b);
        }
    }

    int ans = 0;
    
    rep(trueth, bit(n)){
        bool flag = [&](){
            rep(i, n){
                bool a = bit(i) & trueth;
                if(!a)continue;
                foreach(j, edges[i]){
                    bool b = bit(j.first) & trueth;
                    bool c = j.second;
                    if(b!=c){
                        return false;
                    }
                }
            }
            return true;
        }();
        if(!flag)continue;
        chmax(ans, __builtin_popcount(trueth));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M, C = (int(i) for i in input().split())
B = [int(i) for i in input().split()]

cnt = 0
for i in range(N):
    A = [int(j) for j in input().split()]
    mult = [x * y for (x, y) in zip(A, B)]
    if sum(mult) + C > 0:
        cnt += 1

print(cnt)

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

const int mo=int(1e9+7);
int n,k,m,a[2000],f[2000],ans;

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

void work()
{
	scanf("%d %d",&n,&k);
	for (int i=1; i*i<=n; i++)
		if (n%i==0)
			{
				a[++m]=i;
				if (i!=n/i)  a[++m]=n/i;
			}
	sort(a+1,a+m+1);
	for (int i=1; i<=m; i++)
		f[i]=qpow(k,(a[i]+1)/2);
	for (int i=1; i<=m; i++)
		for (int j=i+1; j<=m; j++)
			if (a[j]%a[i]==0)
				f[j]=(f[j]+mo-f[i])%mo;
	for (int i=1; i<=m; i++)
		if (a[i]&1)  ans=(ans+1LL*f[i]*a[i])%mo;
		else  ans=(ans+1LL*f[i]*a[i]/2)%mo;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 256
a,b,c,d,e = [int(input()) for i in range(5)]
count = a + b + c + d + e
l = [a%10,b%10,c%10,d%10,e%10]
s = [a%10,b%10,c%10,d%10,e%10]
m = [a%10,b%10,c%10,d%10,e%10]
for x in range(len(l)):
    if l[x] == 0:
        m.remove(0)
for i in range (len(s)):
    count = count -s[i]
if len(m) == 0:
    ans= count
    print(ans)
else:
    ans = count + 10*len(m) + min(m) -10
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{long int n,a,b;
 cin>>n>>a>>b;
 if(a>b||(a!=b && n==1)){
 cout<<"0"<<endl;
 return 0;
 }
 cout<<abs(b*(n-2)-a*(n-2))+1<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}


int main()
{
    ciosup;
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    vecin(a);
    ll ans = LLONG_MAX;
    vector<ll> b(n, LLONG_MAX);
    REP(i, n)
    {
        ll temp = i * x;
        REP(j,n){
            b[j] = min(b[j], a[j - i >= 0 ? j - i: j - i + n]);
            temp += b[j];
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define inf 1000000007

int main(void){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.length()-1; i++){
        if(s[i]!=s[i+1])
            count++;
    }
    cout << count << endl;
    return 0;
}

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

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

    vector<int> item(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> item[i];
    }

    sort(item.begin(), item.end(), greater<int>());
    int sum = 0;
    sum += (item[0] / 2);
    for (int i = 1; i < N; i++)
    {
        sum += item[i];
    }
    cout << sum << endl;

    return (0);
}

Measured memory_bytes: 256
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
print(s[a-1])

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
flag=True
for i in range(N):
    if A[i]%2==0:
        if A[i]%3!=0 and A[i]%5!=0:
            flag=False
if flag==True:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	FIO;
	ll n,a,b,c,sum=0;cin>>n;
	map<ll,ll> mp;
	f(i,0,n){
		cin>>a;
		sum+=a;
		mp[a]++;
	} 
	ll q;cin>>q;
	while(q--){
		cin>>b>>c;
		if(mp.find(b)!=mp.end()){
			ll cnt = mp[b];
			mp.erase(b);
			sum -= cnt*b;
			sum += cnt*c;
			mp[c] += cnt;
			cout<<sum<<"\n";
		}
		else cout<<sum<<"\n";
	}
}

Measured memory_bytes: 7440
//⣿⣿⣿⣿⣿⣿⠟⠋⠁⣀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿
//⣿⣿⣿⣿⠋⠁⠀⠀⠺⠿⢿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠻⣿
//⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⣤⠀⠀⠀⠀⠀⣤⣦⣄⠀⠀
//⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⠏⣿⣿⣿⣿⣿⣁⠀⠀⠀⠛⠙⠛⠋⠀⠀
//⡿⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⣰⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀
//⡇⠀⠀⠀⠀⠀⠀⠀⠸⠇⣼⣿⣿⣿⣿⣿⣷⣄⠘⢿⣿⣿⣿⣅⠀⠀⠀⠀⠀⠀⠀⠀
//⠁⠀⠀⠀⣴⣿⠀⣐⣣⣸⣿⣿⣿⣿⣿⠟⠛⠛⠀⠌⠻⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣶⣮⣽⣰⣿⡿⢿⣿⣿⣿⣿⣿⡀⢿⣤⠄⢠⣄⢹⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣿⣿⣿⣿⣿⡘⣿⣿⣿⣿⣿⣿⠿⣶⣶⣾⣿⣿⡆⢻⣿⣿⠃⢠⠖⠛⣛⣷⠀
//⠀⠀⢸⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣮⣝⡻⠿⠿⢃⣄⣭⡟⢀⡎⣰⡶⣪⣿⠀
//⠀⠀⠘⣿⣿⣿⠟⣛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿⢁⣾⣿⢿⣿⣿⠏⠀
//⠀⠀⠀⣻⣿⡟⠘⠿⠿⠎⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣵⣿⣿⠧⣷⠟⠁⠀⠀
//⡇⠀⠀⢹⣿⡧⠀⡀⠀⣀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⢰⣿⠀⠀⠀⠀
//⡇⠀⠀⠀⢻⢰⣿⣶⣿⡿⠿⢂⣿⣿⣿⣿⣿⣿⣿⢿⣻⣿⣿⣿⡏⠀⠀⠁⠀⠀⠀⠀
//⣷⠀⠀⠀⠀⠈⠿⠟⣁⣴⣾⣿⣿⠿⠿⣛⣋⣥⣶⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⡀ 
//
//⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣴⢟⣛⡀⠀⠀⣸⢿⣇⠀ 
//⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⢿⣮⣽⡇⠀⢠⡿⠶⣿⡄ 
#include <bits/stdc++.h>
#define DEBUG false
#define debugf if (DEBUG) printf
#define MAXN 150001
#define MAXM 900009
#define MAXLOGN 20
#define ALFA 256
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define PI 3.141592653589793238462643383279502884
#define FOR(x,n) for(int x=0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) for(int x=int(n)-1; (x)>=0; (x)--)
#define REP1(x,n) for(int x=(n); (x)>0; (x)--)
#define pb push_back
#define pf push_front
#define pr printf
#define sc(x) scanf("%d", &x)
#define sc2(x, y) sc(x);sc(y)
#define sc3(x, y, z) sc2(x, y);sc(z)
#define scll(x) scanf("%lld", &x)
#define sc2ll(x, y) scll(x);scll(y)
#define sc3ll(x, y, z) sc2ll(x, y);scll(z)
#define ff first
#define ss second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x,y) memset(&x, (y), sizeof(x))
#define LOWBIT(A) (A & -A)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair <ll, ll> pll;
typedef pair < pll, ll > plll;

int main(){
    int n;sc(n);
    string s;
    cin >> s;
    if(n&1)pr("No\n");
    else{
        int ind = 0;
        int m = n / 2;
        while(m < s.size()){
            if(s[ind] != s[m]){
                pr("No\n");
                return 0;
            }
            ind++;
            m++;
        }
        pr("Yes\n");
    }
	return 0;
}


Measured memory_bytes: 256
# AOJ 2833: Displayed tweets
# Python3 2018.7.12 bal4u

INF = 0x7ffffff

N, K = map(int, input().split())
k, f = [INF]*(N+1), [0]*(N+1)
a = [0]+[int(input()) for i in range(N)]
ans = 0
for i in range(N, 0, -1):
	re = a[i]
	if re:
		if f[i] == 0: v = 0; ans += 1
		else:
			v = k[i]
			if v < K: ans += 1
		v += 1
		if v < K and k[re] > v: k[re] = v
		f[re] = 1;
	else: ans += 1
print(ans)


Measured memory_bytes: 14392
N = input()
N = int(N)
list = []
ans = 0
for i in range(N):
    token = input()
    list.append(int(token))
maxvalue_index = list.index(max(list))
for i in range(N):
    ans += list[i]
ans -= list[maxvalue_index] / 2
print(int(ans))


Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(n*a > b){
            System.out.println(b);
        }else{
            System.out.println(n*a);
        }
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int n;
    int count = 0;
    int ans = 0;
    cin >> n;
    int h[114514] = {0};
    rep(i,n) {
        cin >> h[i];
    }
    for (int i = 1; i < n; i++) {
        if (h[i - 1] >= h[i]) {
            count++;
            
        } else {
            ans = max(ans, count);
            count = 0;
        }
        ans = max(ans, count);
    }
    cae
    r0
}


Measured memory_bytes: 1152
#include<iostream>
#include<map>
#define REP(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

int main(){
  int H,W,N;
  cin>>H>>W>>N;
  lli total = (lli)(H-2)*(W-2);
  map<pii,lli> pmap;
  REP(i,0,N){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    REP(y,-1,2){
      REP(x,-1,2){
	if(y + a >= 1 && y + a < H - 1 && x + b >= 1 && x + b < W - 1 ){
	  pmap[make_pair(x+b,y+a)]++;
	}
      }      
    }
  }
  lli ans[10] ={total};
  for(auto it=pmap.begin(),e=pmap.end();it!=e;it++){
    ans[it->second]++;
  }
  REP(i,1,10){
    ans[0] -= ans[i];
  }
  REP(i,0,10){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
    return 0;
}



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

using namespace std;

int main(){
  string S; cin >> S;
 if( S[0] == S[1] && S[2] == S[3] && S[0] != S[2] ){ cout << "Yes" << endl;}
else if( S[0] == S[2] && S[1] == S[3] && S[0] != S[1] ) { cout << "Yes" << endl;}
  else if( S[0] == S[3] && S[1] == S[2] && S[0] != S[1] ){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
return 0;}
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
const ll mod = 1000000007;
typedef pair<int, int> P;

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

typedef pair<int, P> speP;

int h, w, n;
bool valid(int x, int y) {
	if (x < 0 || y < 0 || x >= h || y >= w)return false;
	return true;
}

void solve() {
	string s;
	cin >> s;
	vector<int> ra(n + 1,0);
	rep(i, n) {
		int nex = 0;
		if (s[i] == 'L') {
			nex = ra[i] - 1;
		}
		else {
			nex = ra[i] + 1;
		}
		if (nex == 4)nex = 0;
		else if (nex < 0)nex = 3;
		ra[i + 1] = nex;
	}
	vector<int> loc[4];
	rep(i, n+1) {
		loc[ra[i]].push_back(i);
	}
	rep(i, 4)loc[i].push_back(mod);
	vector<vector<int>> v(n+1);
	rep(i, n+1) {
		v[i].resize(4);
		rep(j, 4) {
			int id = lower_bound(loc[j].begin(), loc[j].end(), i) - loc[j].begin();
			v[i][j] = loc[j][id];
		}
	}
	vector<vector<char>> mp(h);
	int sx, sy, gx, gy;
	rep(i, h) {
		mp[i].resize(w);
		rep(j, w) {
			cin >> mp[i][j];
			if (mp[i][j] == 'S') {
				sx = i, sy = j;
			}
			else if(mp[i][j]=='G'){
				gx = i, gy = j;
			}
		}
	}
	vector<vector<int>> dist(h);
	rep(i, h) {
		dist[i].resize(w, mod);
	}
	dist[sx][sy] = 0;
	priority_queue<speP, vector<speP>, greater<speP>> q;
	q.push({ 0,{sx,sy} });
	while (!q.empty()) {
		speP p = q.top(); q.pop();
		int x = p.second.first, y = p.second.second;
		int t = p.first;
		if (dist[x][y] < t)continue;
		rep(j, 4) {
			int nd = v[t][j];
			int cx = x, cy = y;
			while (true) {
				cx += dx[j], cy += dy[j];
				if (!valid(cx, cy))break;
				if (mp[cx][cy] == '#')break;
				if (nd < dist[cx][cy]) {
					dist[cx][cy] = nd;
					q.push({ nd,{cx,cy} });
				}
				else break;
			}
		}
	}
	if (dist[gx][gy] == mod) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> h >> w >> n, h | w | n) {
		solve();
	}
	//stop
	return 0;
}


Measured memory_bytes: 8400
#include <bits/stdc++.h>
using namespace std;
long long n,a[101];
int i;
long long f(long long n)
{
    if(a[n])
    return a[n];
    if(n>0)
    a[n]=f(n-1)*2+2;
}
int main()
{
    scanf("%d",&n);
    a[0]=2;
    f(n);
    printf("%lld\n",a[n]);
}

Measured memory_bytes: 256