akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

// Copy from Uwi-san's Python
int main() {
    int N; cin >> N;
    vector T(N,0);
    rep(i,N) cin >> T.at(i);
    vector V(N,0);
    rep(i,N) cin >> V.at(i);
    vector bound(N+1, 0);
    for (int i = 0; i < N-1; i++) {
        bound[i+1] = min({V[i], V[i+1], bound[i] + T[i]});
    }
    for (int i = N-1; i > 0; i--) {
        bound[i] = min({bound[i], V[i], V[i-1], bound[i+1] + T[i]});
    }

    double ans = 0;
    rep(i, N) {
        double L = bound[i];   // Left side velocity limit
        double R = bound[i+1]; // Right side velocity limit
        // When need to break while accelerating ignoring the limit
        double x = (R - L + T[i]) / 2; // L + x = R + (T[i] - x) 
        if (L + x <= V[i]) { // breaking before (or just) touching to the limit
            // Two Trapezoid
            ans += (L + (L + x)) * x / 2 + (L + x + R) * (T[i] - x) / 2;
        } else { // Including constant speed (rectangle)
            // Two Trapezoid (both side of the area /－\) 
            // One of, or both of them can be zero (totally constant speed)
            ans += (V[i] + L) * (V[i] - L) / 2 + (V[i] + R) * (V[i] - R) / 2;
            // Rectangle (constant speed area)
            ans += (T[i] - (V[i] - L) - (V[i] - R)) * V[i];
        }
    }
    printf("%.15f\n", ans);
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int l,r;cin>>l>>r;
    int d;cin>>d;
    int ans=0;
    rep(i,l,r+1)if(i%d==0)ans++;
    cout<<ans<<endl;
}


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

int main(){
	
	int n;
	cin>>n;
	map<ll,ll>mp1,mp2;
	while(n--){
		ll x,y;
		cin>>x>>y;
		mp1[x+y]++;
		mp2[x-y]++;
	}
	ll res=abs(mp1.rbegin()->first-mp1.begin()->first);
	res=max(res,mp2.rbegin()->first-mp2.begin()->first);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 28624
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

int n,p;
ll res;
const int maxn=2*1e5+5;
char s[maxn];
unordered_map<int,int> ma;

int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&p);
    scanf("%s",s);
    int len=strlen(s);
    ma[0]=1;int t=1,x=0;
    if(p==2||p==5){  //以该数结尾都可以被除
        for(int i=0;i<len;i++){
            if((s[i]-'0')%p==0) res+=i+1;
        }
    }else{
        for(int i=len-1;i>=0;i--){
            x=(x+(s[i]-'0')*t)%p;
            res+=ma[x];
            ma[x]++;
            t=t*10%p;
        }
    }
    printf("%lld\n",res);
    return 0;

}



Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int a[3];
    for (int i=0; i<3; i++) {
        cin>>a[i];
    }
    sort(a, a+3);
    int min=0;
    for (int i=0; i<2; i++) {
        min+=a[i+1]-a[i];
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n ;
    cin >> n ;
    ll ans = 0 ;
    ll a, b ;
    REP(i,n){
        cin >> a ;
        if(i==0){
            ans += a/2 ;
            b = a%2 ;
            continue ;
        }
        if(a==0){
            b = 0 ;
            continue ;
        }
        ans += b ;
        a -= b ;
        ans += a/2 ;
        b = a%2 ;
    }
    cout << ans << endl ;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for k in range(len(Y)-K+1):
            H = Y[k+K-1] - Y[k]
            ans = min(ans, W*H)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(){
    const int MEM=214514;
    int N,Q;
    int A[MEM],B[MEM];
    int p[MEM],x[MEM];
    vector<int> G[MEM];
    cin >> N >> Q;
    REP(i,N-1){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    REP(i,Q){
        cin >> p[i] >> x[i];
        p[i]--;
    }
    
    queue<int> P;
    P.push(0);
    int d[214514]={};
    bool visit[214514]={};
    REP(i,Q){
        d[p[i]]+=x[i];
    }
    while(!P.empty()){
        int T=P.front();
        P.pop();
        visit[T]=true;
        REP(i,G[T].size()){
            if(!visit[G[T][i]]){
                P.push(G[T][i]);
                d[G[T][i]]+=d[T];
            }
        }
    }
    REP(i,N){
        if(i!=0)cout << " ";
        cout << d[i];
    }
    cout << endl;
    return 0;
}   


Measured memory_bytes: 25328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int bestTime = 99999;
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int n = 5;
	vector <int > time = {a, b, c, d, e};
	vector <int > nextTime(n);
	for (int i = 0; i < n; i++) {
		if (time[i] % 10 == 0) {
			nextTime[i] = time[i];
		}
		else {
			nextTime[i] = time[i] - time[i] % 10 + 10;
		}
	}
	
	for (int i = 0; i < n; i++) {
		int sumTime = 0;
		for (int j = 0; j < n; j++) {
			if (i == j)
				sumTime += time[j];
			else
				sumTime += nextTime[j];
		}
		bestTime = min(bestTime, sumTime);
	}
	cout << bestTime;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n,ac=0,tle=0,wa=0,re=0;
  string s;
  cin>>n;
  while(n--)
  {
    cin>>s;
    if(s=="AC")
      ac++;
    else
      if(s=="RE")
      re++;
    else
      if(s=="WA")
      wa++;
    else
      tle++;
      
  }
  cout<<"AC x "<<ac<<endl;
   cout<<"WA x "<<wa<<endl;
   cout<<"TLE x "<<tle<<endl;
   cout<<"RE x "<<re<<endl;
  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n;
signed main(){
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	rep(i,0,n)
		rep(j,0,n)
			if(i*4+j*7==n){
				cout<<"Yes";
				re 0;
			}
	cout<<"No";
	re 0;
}

Measured memory_bytes: 3640
D = int(input())
C = list(map(int, input().split()))
#  S = [[1st day], [2nd day],  ..., [D-th day]]
S = []
for i in range(D):
    Si = list(map(int, input().split()))
    S.append(Si)
I = 26

last = [0]*I

for day in range(D):
    score = [last[i]*S[day][i] for i in range(I)]
    contest = score.index(max(score))

    last = [x+1 for x in last]
    last[contest] = 0

    print(contest + 1)

Measured memory_bytes: 9392
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int x=-1, y=-1,tmp;
	while (1){
		cin >> x;
		cin >> y;
		if (x == 0 && y == 0){ break; }
		if (x <= y){
			tmp = y;
			y = x;
			x = tmp;
		}
		cout << y << " " << x << endl; 
	}

	
	return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	int s = 0;
	for (int i = 0; i < n; i++){
		cin >> w[i];
		s += w[i];
	}
	int s1 = 0;
	int ans = s;
	for (int i = 0; i < n; i++){
		s1 += w[i];
		s -= w[i];
		ans = min(ans, abs(s1-s));
	}
	cout << ans << '\n';
}


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

int main() {
  int k, a, b; cin >> k >> a >> b;
  for(int i = 1; i < 1000; i++){
    if(a <= k * i){
      if(b >= k * i){
        cout << "OK";
        return 0;
      }
    }
  }
  cout << "NG";
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		double m = 0;
		for(int i = 0 ;i < n;i++) {
			 m+=1/scn.nextDouble();
		}
		System.out.println(1/m);
		scn.close();
	}
}

Measured memory_bytes: 25172
import Data.List

toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y

ret :: [Int] -> Int -> Int -> Int
ret hs n k
    | n <= k = 0
    | otherwise = sum (drop k (reverse $ Data.List.sort hs))

main = do
    ns <- getInts
    let n = head ns
    let k = last ns
    hs <- getInts
    let r = ret hs n k
    putStrLn $ show r


Measured memory_bytes: 104828
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

ll L, R;
const ll mod = 2019;

int main(void)
{
  cin >> L >> R;

  R = min(R, L + 4096);
  map<ll, int> n, m;
  ll ans = INT_MAX;
  for (int i = L; i < R; i++) {
    for (int j = i + 1; j <= R; j++) {
      ll a = i * j % mod;
      ans = min(ans, a);
      if (ans == 0) {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

/**
 * 根付き木の表現
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=en">ALDS1_7_A</a>
 */
public class Main {
	private static int d[] = new int[100005];
	private static Node t[] = new Node[100005];

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

		for (int i = 0; i < n; i++) {
			t[i] = new Node();
		}

		int l = 0;
		for (int i = 0; i < n; i++) {
			int id = sc.nextInt();
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int c = sc.nextInt();
				if (j == 0) {
					t[id].left = c;
				} else {
					t[l].right = c;
				}
				l = c;
				t[c].parent = id;
			}
		}

		int r = 0;
		for (int i = 0; i < n; i++) {
			if (t[i].parent == -1) r = i;
		}

		for (int i = 0; i < n; i++) {
			d[i] = getDepth(i);
		}

//		rec(r, 0);

		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < n; i++) {
			ans.append("node ").append(Integer.toString(i)).append(": parent = ").append(Integer.toString(t[i].parent))
			.append( ", depth = ").append(Integer.toString(d[i])).append(", ");
			if (d[i] == 0) {
				ans.append("root, ");
			} else if (t[i].left == -1) {
				ans.append("leaf, ");
			} else {
				ans.append("internal node, ");
			}

			ans.append("[");
			int c = t[i].left;
			while (c != -1) {
				if (c != t[i].left) {
					ans.append(", ");
				}
				ans.append(Integer.toString(c));
				c = t[c].right;
			}
			ans.append("]\n");
		}

		System.out.print(ans.toString());

		sc.close();
	}

	private static int getDepth(int i) {
		int d = 0;
		while (t[i].parent != -1) {
			i = t[i].parent;
			d++;
		}
		return d;
}

// スタックオーバーフローするようだ
//	private static void rec(int i, int p) {
//		d[i] = p;
//		if (t[i].left != -1) rec(t[i].left, p + 1);
//		if (t[i].right != -1) rec(t[i].right, p);
//	}

}

class Node {
	int parent;
	int left;
	int right;

	Node() {
		this.parent = -1;
		this.left = -1;
		this.right = -1;
	}
}


Measured memory_bytes: 127564
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int[] dp = new int[n];
            dp[0] = 0;
            for (int i = 1; i < n; i++) {
                int min = Integer.MAX_VALUE;
                for (int j = Math.max(0, i - k); j < i; j++) {
                    min = Math.min(min, dp[j] + Math.abs(arr[j] - arr[i]));
                }
                dp[i] = min;
            }

            out.println(dp[n - 1]);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 38232
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel";
		return 0;
	}
	cout << "consonant";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
temp = [i for i in p]
for i in range(N):
    if temp[i] != i + 1:
        temp[temp[i]-1], temp[i] = temp[i], temp[temp[i]-1]
        break
p.sort()
if temp == p:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] temp = scanner.nextLine().split(" ");
		int k = Integer.parseInt(temp[0]);
		int n = Integer.parseInt(temp[1]);

		for(int i = n - k + 1; i < k + n; i ++) {

			System.out.println(i);

		}


	}

}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

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

vector <int> adj[100010];
int mx[100010], n, m;

void dfs(int u){
	if(mx[u]) return; 
	mx[u] = 1;
	rep(i, 0, adj[u].size()) dfs(adj[u][i]);
	mx[u] = 0;
	rep(i, 0, adj[u].size()) mx[u] = max(mx[u], mx[adj[u][i]]);
	mx[u]++;
}

int main(){
	
	scanf("%d %d", &n, &m);
	int u, v;
	rep(i, 0, m){
		scanf("%d %d", &u, &v);
		adj[u].pb(v);
	}
	
	rep(i, 1, n+1) dfs(i);
	
	int ans = 0;
	rep(i, 1, n+1) ans = max(ans, mx[i]);
	
	cout << ans-1 << '\n';
	
	
	return 0;
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  int cnt = 0;
  vi sieve(a.back() + 1);
  for (int i : a) {
    for (int j = i; j <= a.back(); j += i) {
      sieve[j]++;
    }
  }

  for (int i : a) if (sieve[i] == 1) cnt++;

  cout << cnt;

  return 0;
}


Measured memory_bytes: 7876
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i = (a); i <= (n); i++)
#define repb(i, a, n) for (int i = (a); i >= (n); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
/******* Variable ***************************************************/
const int maxn = 1e6 * 50;
const double inf = 0x3f3f3f3f3f;
int N;
vector<int> A, G;
ll cnt = 0;
/******* Function ***************************************************/
void OneLineOut(const vector<int> &X, int n) {
    rep(i, 0, n - 2) {
        cosp(X[i]);
    }
    cout << X.back() << endl;
}
void InsertionSort(int g) {
    rep(i, g, N - 1) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}
void SellSort(const vector<int> &G) {
    repb(i, G.size() - 1, 0) {
        InsertionSort(G[i]);
    }
}

/******* Main *****************************************************/
int main() {
    cin >> N;
    A.resize(N);
    rep(i, 0, N - 1) {
        cin >> A[i];
    }
    int calc = 1;
    while (calc <= N) {
        G.push_back(calc);
        calc = calc * 3 + 1;
    }
    SellSort(G);
    co(G.size());
    reverse(all(G));
    OneLineOut(G, G.size());
    co(cnt);
    rep(i, 0, N - 1) {
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6712
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
struct elem{
	vector<pair<int,int> > val;
	void merge(pair<int,int> x){
		int pos = find(val.begin(),val.end(),x) - val.begin();
		if(pos != val.size())
			return;
		val.pb(x);
		sort(val.begin(),val.end(),greater<pair<int,int> >());
		if(val.size()>2)
			val.resize(2);
	}
};
int main()
{
    fastread;
    int n;
    cin>>n;
    vector<int> arr(1<<n);
    for(int i=0;i<(1<<n);i++){
    	cin>>arr[i];
    }
    vector<elem> mask(1<<n);
    for(int i=0;i<(1<<n);i++)
    	mask[i].merge({arr[i],i});
    for(int i=1;i<(1<<n);i++){
    	for(int j=0;j<n;j++){
    		if(i & (1<<j)){
    			for(int k=0;k<(mask[i^(1<<j)].val.size());k++)
    				mask[i].merge(mask[i^(1<<j)].val[k]);
    		}
    	}
    }
    int ans[(1<<n)];
    for(int i=0;i<(1<<n);i++){
    	ans[i] = mask[i].val[0].fx + mask[i].val[1].fx;
    }
    for(int i=2;i<(1<<n);i++)
    	ans[i] = max(ans[i],ans[i-1]);
    for(int i=1;i<(1<<n);i++)
    	cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 23680
import sys
sys.setrecursionlimit(2**20)

class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right

def get_depth(T, u): # T : ノードの情報が入っているdict, u :Node
    d = 0
    while T[u].parent != None:   # TはNodeクラスで作る
        u = T[u].parent     # 親がNIL（つまり根）になるまで親を辿っていく
        d += 1
    return d

D = {}

def get_all_depth(T, u, p):  # p : 深さ
    D[u] = p
    if T[u].right != None:
        get_all_depth(T, T[u].right, p)
    if T[u].left != None:
        get_all_depth(T, T[u].left, p+1)
        
def get_children(T, u):
    children = []
    c = T[u].left
    while c != None:
        children.append(c)
        c = T[c].right
    return children


# 入力
n = int(input()) # Node（節点）の数
T = {i : Node(None, None, None) for i in range(n)} # 情報を入れるdictをNodeクラスで作成

for _ in range(n):   # 変数名を「 _ 」にすることによって、「その変数を使っていない」ことを表現している（Pythonの習慣）
    tmp = list(map(int, input().split())) # Nodeの情報を格納[節点の番号, 次数, 1番目の子の節点番号, ..., k番目の子の節点番号]
    if tmp[1] == 0:  # 子Nodeがなければ次へ 
        continue
    T[tmp[0]].left = tmp[2] # 今見ているNode（tmp[0]）のleftアトリビュートに左子Nodeを入れる
    T[tmp[2]].parent = tmp[0]  # 当然tmp[2]の親はtmp[0]
    prev_sibling = tmp[2]  # 兄弟の一番左のNode番号を保存しておく
    for sib in tmp[3:]:  # 残りの兄弟について
        T[prev_sibling].right = sib  # 一つ右の兄弟 
        T[sib].parent = tmp[0]  # 親は同じくtmp[0]（当然）
        prev_sibling = sib
        
# 出力
def print_for_a_node(T, node, D):
    if T[node].left == None:
        node_type = "leaf"
    else:
        node_type = "internal node"
    
    if T[node].parent == None:
        parent = -1
        node_type = "root"
    else:
        parent = T[node].parent
    
    children = get_children(T, node)

        
    #print(f"node {node} : parent = {parent}, depth = {D[node]}, {node_type}, {children}")
    print("node {}: parent = {}, depth = {}, {}, {}".format(node, parent, D[node], node_type, children))

for node in range(n):
    if T[node].parent == None:
        get_all_depth(T, node, 0)  # rootを入れる
        # Dに深さが入る
        break
        
for node in range(n):
    print_for_a_node(T, node, D)



Measured memory_bytes: 141940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    int dp[n];
    dp[0] = 0;
    int cnt = 0;
    rep2(i, 1, n)
    {
        cnt = abs(a[i] - a[i-1])+dp[i-1];
        if(cnt>abs(a[i]-a[i-2])+dp[i-2]&&i>1)
            cnt=abs(a[i]-a[i-2])+dp[i-2];
        dp[i] = cnt;
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AABCxxx {
public:
	void solve(istream& in, ostream& out) {
        int n; in >> n;
        out << "ABC" << n << endl;
	}
};

int main() {
	AABCxxx solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

signed main() {
  int N; cin >> N;
  vector<int> a(N), s(N), l(N+1);
  l[0] = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    s[i] = a[i];
  }
  sort(s.begin(), s.end());
  int right = N-1;
  int left = 0;
  while(right != left) {
    int j = (right + left + 1) / 2;
    int num = s[j];
    for(int i = 0; i < N; ++i) {
      if(a[i] >= num) {
        l[i+1] = 1;
      } else {
        l[i+1] = -1;
      }
    }
    for(int i = 1; i <= N; ++i) l[i] += l[i-1];


    int count, t = 0;
    vector<int> bit(2*N+2, 0);
    for(int i = 0; i < N + 1; ++i) {
      int first = l[i] + N + 1;
      for(int x = first; x <= 2 * N + 1; x += x&-x) {
        bit[x]++;
      }
      int sum = 0;
      for(int x = first; x >= 1; x-=x&-x) sum += bit[x];
      t += i+1-sum;
    }
    count = N * (N + 1) / 2 - t;
    if(count >= (N * (N+1)/2+1)/2) {
      left = j;
    } else {
      right = j - 1;
    }
  }
  cout << s[left] << endl;

  return 0;
}


Measured memory_bytes: 4200
import sys
while 1:
    n=int(input())
    if n==0:
        sys.exit()
    ma=0
    mi=1000
    s=0
    for i in range(n):
        l=int(input())
        s+=l
        if l>ma:
            ma=l
        if l<mi:
            mi=l
        
    print ((s-ma-mi)//(n-2))

Measured memory_bytes: 7580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vector<ll> p(n);
  for (int i=0; i<n; i++){
    cin >> p[i];
  }
  sort(p.begin(),p.end());
  ll ans = 0;
  rep(i, k) {
    ans += p[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  priority_queue<int> que;
  int N, M;
  cin >> N >> M;
  REP(i, N) {
    int l;
    cin >> l;
    que.push(l);
  }
  while(M>0){
    M--;
    int tmp = que.top();
    que.pop();
    que.push(tmp / 2);
  }
  ll ans = 0;
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}

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


int main(){
    int n; cin >> n;
    int ans=-1;
    for(double i=1;i<=n;i++){
        int x=i*1.08;
        if(x==n){ans=i;break;} 
    }
    if(ans==-1){cout << ":("<< endl;}
    else{cout << ans << endl;}
}

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

int main() {
	
 int a,b,c;
 int s=0;
 int count=1;
 cin>>a>>b;
 while(a-->0){
 	
 cin>>c;
 s=s+c;
 if(s<=b){
 	
 	count++;
 }
 }
 cout<<count<<endl;
 return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).rbegin(),(a).rend()
const int MOD = 1000000007;
ll l,x,y,s = 0,d,n,m;
int main() {
    cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, n) {
        cin >> x;
        pq.push(x);
    }
    rep(i, m) {
        y = pq.top(); pq.pop();
        pq.push(y / 2);
    }
    while (!pq.empty()) {
        s += pq.top(); pq.pop();
    }
    cout << s << endl;
}

Measured memory_bytes: 1400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc094_c {
public:
    void solve(istream& in, ostream& out) {
        int A, B, C;
        in >> A >> B >> C;
        int ans = 0;
        while (A != B || B != C) {
            ++ans;
            if (A < min(B, C)) {
                A += 2;
            } else if (B < min(A, C)) {
                B += 2;
            } else if (C < min(A, B)) {
                C += 2;
            } else if (A == B) {
                ++A;
                ++B;
            } else if (B == C) {
                ++B;
                ++C;
            } else {
                assert(A == C);
                ++A;
                ++C;
            }
        }
        out << ans << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc094_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int l = s.size();
    while(l > 0){
        if(l >= 5 && s.substr(l - 5, 5) == "dream"){
            l = l - 5;
        }
        else if(l >= 7 && s.substr(l - 7, 7) == "dreamer"){
            l = l - 7;
        }
        else if(l >= 5 && s.substr(l - 5, 5) == "erase"){
            l = l - 5;
        }
        else if(l >= 6 && s.substr(l - 6, 6) == "eraser"){
            l = l - 6;
        }
        else break;
    }
    if(l == 0) puts("YES");
    else puts("NO");
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vll a(n), b(n);
  REP(i, n) cin >> a[i] >> b[i];
  vector<pair<ll, int>> su(n);
  REP(i, n) {
    su[i].fi = a[i] + b[i];
    su[i].se = i;
  }

  sort(ALL(su));
  reverse(ALL(su));

  ll taka = 0, ao = 0;
  
  
  REP(i, n) {
    if(i % 2 == 0) {
      taka += a[su[i].se];
    } else {
      ao += b[su[i].se];
    }
  }

  cout << taka - ao << endl;
  

}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void){

	int n;
	scanf("%d",&n);
	char s[n];
	scanf("%s",s);
	int r=0,b=0;
	rep(i,n) {
		if(s[i] == 'R') r++;
		else b++;
	}
	if(r>b) printf("Yes\n");
	else printf("No\n");
	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
bool cs(P a,P b){
  if(a.second==b.second)return a.first>b.first;
  else return a.second>b.second;
}
signed main(){
  int n,K;cin>>n>>K;
  vector<P> p(n);
  int res=INT64_MAX;
  rep(i,n){
    cin>>p[i].first>>p[i].second;
  }
  //cout<<res<<"\n";
  sort(p.begin(),p.end(),cs);
  rep(i,n){
    //printf("%lld %lld\n",p[i].first,p[i].second);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        for(int l=0;l<n;l++){
          vector<P> buf(4);
          buf[0]=p[i];
          buf[1]=p[j];
          buf[2]=p[k];
          buf[3]=p[l];
          sort(buf.begin(),buf.end());
          int left=buf[0].first;
          int right=buf[3].first;
          sort(buf.begin(),buf.end(),cs);
          int up=buf[0].second;
          int down=buf[3].second;
          int tmp=0;
          rep(i,n){
            if(p[i].first<=right&&p[i].first>=left){
              if(p[i].second<=up&&p[i].second>=down){
                tmp++;
              }
            }
          }
          if(tmp>=K){
           int s=max((int)1,(up-down))*max((int)1,(right-left));
           if(res>s){
             res=s;
             //cout<<tmp<<" k="<<k<<"\n";
             //printf("s=%lld\nleft=%lld\nright=%lld\nup=%lld\ndown=%lld\n",s,left,right,up,down);
          }
          }
        }
      }
    }
  }
  cout<<res<<"\n";
  return 0;
}


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

int N;
int dist[2010] = {},s[2010] = {},dp_max[2010] = {},dp_min[2010] = {};
string S;
vector<vector<int>> v(2010);

void dfs(int n,int m){
    for(auto x:v[n]){
        if(x==m) continue;
        dist[x] = dist[n]+1;
        dfs(x,n);
        s[n] += s[x];
    }
    if(S[n]=='1') s[n]++;
}

void dfs2(int n,int m){
    int sum = 0;
    for(auto x:v[n]){
        if(x==m) continue;
        dfs2(x,n);
        sum += dp_max[x]+s[x];
        dp_max[n] += dp_max[x]+s[x];
    }
    for(auto x:v[n]){
        if(x==m) continue;
        dp_min[n] = max(dp_min[n],dp_min[x]+s[x]-(sum-dp_max[x]-s[x]));
    }
    if(dp_min[n]<0) dp_min[n] = (dp_min[n]%2==0? 0:1);
}

int main(){
    cin >> N >> S;
    int a,b;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int inf = 1e9,ans = inf;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dist[j] = 0;
            s[j] = 0;
            dp_max[j] = 0;
            dp_min[j] = 0;
        }
        dfs(i,-1);
        int sum = 0;
        for(int j=0;j<N;j++) if(S[j]=='1') sum += dist[j];
        if(sum%2==1) continue;
        dfs2(i,-1);
        if(dp_min[i]==0) ans = min(ans,sum/2);
    }
    cout << (ans!=inf? ans:-1) << endl;
}

Measured memory_bytes: 512
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

struct Elem {
    int x, y, z, val;
};

signed main() {
    int P, Q;
    while(cin >> P >> Q, P) {
        vector<string> train(P+1), pat(Q+1);
        rep(i,0,P) cin >> train[i];
        rep(i,0,Q) cin >> pat[i];

        vector<Elem> info, cand;
        rep(i,0,P) {
            int cnt_r = 0, cnt_c = 0, cnt_s = 0;
            repq(j,0,i) for(auto x : train[j]) {
                if(x == '(') cnt_r++;
                if(x == ')') cnt_r--;
                if(x == '{') cnt_c++;
                if(x == '}') cnt_c--;
                if(x == '[') cnt_s++;
                if(x == ']') cnt_s--;
            }
            int val = 0;
            while(train[i+1][val] == '.') val++;
            info.push_back(Elem{cnt_r, cnt_c, cnt_s, val});
        }

        repq(R,1,20) repq(C,1,20) repq(S,1,20) {
            bool ok = true;
            for(auto e : info) {
                int val = R*e.x + C*e.y + S*e.z - e.val;
                if(val != 0) ok = false;
            }
            if(ok) cand.push_back(Elem{R, C, S, 0});
        }

        vector<int> ans(Q);
        rep(i,0,Q-1) {
            int cnt_r = 0, cnt_c = 0, cnt_s = 0;
            repq(j,0,i) for(auto x : pat[j]) {
                if(x == '(') cnt_r++;
                if(x == ')') cnt_r--;
                if(x == '{') cnt_c++;
                if(x == '}') cnt_c--;
                if(x == '[') cnt_s++;
                if(x == ']') cnt_s--;
            }

            set<int> S;
            for(auto e : cand) {
                int val = cnt_r * e.x + cnt_c * e.y + cnt_s * e.z;
                S.insert(val);
            }

            if(S.size() != 1) ans[i+1] = -1;
            else ans[i+1] = *(S.begin());
        }

        rep(i,0,Q) {
            if(i != 0) printf(" ");
            printf("%lld", ans[i]);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3500
import Control.Applicative
import qualified Data.HashMap.Strict as Map

main = do
    [_,capa] <- map (read :: String -> Int) . words <$> getLine
    goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
    print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)

resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] 0
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v      = next'
      | n > (capa - w)                      = capaMap
      | capaMap Map.! (n+w) >= v + oldValue = next
      | otherwise                           = next'
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n+1)
        next'    = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n+1)

Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)


int main(){
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	vector<vector<int>> dp(H,vector<int> (W,0));//dp[i][j] 上からi,左からjマス目に至る経路数
	dp[0][0]=1;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(S[i][j]=='#')continue;
			if(i!=0)dp[i][j]=mod(dp[i][j]+dp[i-1][j]);
			if(j!=0)dp[i][j]=mod(dp[i][j]+dp[i][j-1]);
		}
	}
	
	cout<<dp[H-1][W-1]<<endl;
	
	
	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main () {
     char s;
	cin >> s;
	if(s == 'A'){
		cout << 'T';
	}
	 if(s=='C')
	{
		cout << 'G';
	}
	 if(s == 'T'){
		cout << 'A';
	}
	 if(s == 'G'){
		cout<<'C';
	}
}

Measured memory_bytes: 256
N = int(input())
a = input().split()

flg = False
old = a[0]

cnt = 0
for i in range(1,N):
    if a[i] == old and not flg:
        cnt += 1
        flg = True
    else:
        flg = False
    old = a[i]

print(int(cnt))

Measured memory_bytes: 3060
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const size_t SIZE = 3e4 + 10;
ll dp[SIZE];
const ll inf = 5e15;

int main() {
    fill(dp, dp + SIZE, inf);
    dp[0] = 0;
    ll H, N;
    cin >> H >> N;
    V<PLL> AB(N);
    for (auto &&e : AB) {
        ll a, b;
        cin >> a >> b;
        e = PLL(a, b);
    }

    for (ll h = 0; h <= H; h++) {
        for (auto &&e : AB) {
            ll a, b;
            tie(a, b) = e;
            chmin(dp[h + a], dp[h] + b);
        }
    }

    cout << *min_element(dp + H, dp + SIZE) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }

void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int m, d, M, D; cin >> m >> d >> M >> D;
    cout << (d + 1 != D ? 1 : 0);
}


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

int main(){
	int n,m; cin >> n >> m;
  	int ans;
  	for(int i=1;i<100000;i++){
      if(m % i == 0 && m/i >= n) ans = ans < i ? i : ans;
      if(m % i == 0 && i >= n) ans = ans < m/i ? m/i : ans;
    }
	cout << ans << endl;
  	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<long long> v(n);
  
  for (int i = 0; i < n; i++) 
    cin >> v.at(i);
  
  long long sum = 0;
  long long mod = 1000000007;
  
  for (int i = 0; i < n; i++)
    sum += v.at(i) % mod;
  
  sum %= mod;
  
  long long ans = 0;
  
  for (int i = 0; i < n; i++) {
    sum -= v.at(i) % mod;
    if (sum < 0) sum += mod;
    ans += (sum * v.at(i)) % mod;
  }
  
  cout << ans % mod<< endl;
}

Measured memory_bytes: 4780