akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

vector<P> prime_factorize(ll N){
  vector<P> res;
  for (ll a = 2; a * a <= N; ++a){
    if (N % a != 0) continue;
    ll ex = 0; //指数
    while (N % a == 0){
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main(){
  ll N; cin >> N;
  vector<P> prime = prime_factorize(N);
  ll ans = 0;
  for (int i = 0; i < prime.size(); ++i){
    ll tmp = prime[i].second;
    ll minus = 1;
    while (tmp > 0){
      if (tmp - minus < 0) break;
      ans++;
      tmp -= minus;
      minus++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	char str[200100];
	int len;

	scanf("%s", str);
	len = strlen(str);

	int del = 0;
	int count = 0;

	for(int i = 0; i < len; ++i) {

		char c = str[i];

		if(c == 'S') {
			count += 1;
		} else {
			if(count > 0) {
				count -= 1;
				del += 1;
			}
		}
	}

	printf("%d\n", len - del * 2);

	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    x = sorted(list(map(int, input().split())))
    diff = list()

    for i, j in zip(x, x[1:]):
        diff.append(abs(i - j))

    diff = sorted(diff, reverse=True)
    print(sum(diff) - sum(diff[:n - 1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20484
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  vector<ll> ans(n);
  for(ll i = 0; i < n; i++){
    char c;
    cin >> c;
    if(c == 'G') ans[0]++;
    if(c == 'P') ans[1]++;
    if(c == 'W') ans[2]++;
    if(c == 'Y') ans[3]++;
  }

  ll cnt = 0;
  for(auto i : ans){
    if(i > 0) cnt++;
  }
  if(cnt == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W,N;
    cin >> H;
    cin >> W;
    cin >> N;
    if(H>=N||W>=N)cout << 1 << endl;
    else{
        for(int i=2;i<=N;i++){
            if(H>=W){
                if(i*H>=N){
                    cout << i << endl;
                    break;
                }
            }else if(W>H){
                if(i*W>=N){
                    cout << i << endl;
                    break;
                    
                }
            }
        }
    }
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

int main()
{

    string sd, t;
    cin >> sd >> t;

    int ind = -1;

    REP(i, sd.size() - t.size() + 1)
    {
        bool a = true;
        REP(j, t.size())
        {
            if (sd[i + j] != '?' && sd[i + j] != t[j])
            {
                a = false;
                break;
            }
        }
        if (a)
        {
            ind = i;
        }
    }

    if (ind == -1)
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int i = ind; i < ind + t.size(); i++)
        sd[i] = t[i - ind];

    REP(i, sd.size())
    {
        if (sd[i] == '?')
        {
            sd[i] = 'a';
        }
    }

    cout << sd << endl;

    return 0;
}

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

int a[110];

int main () {

int n;
cin>>n;
int mini=1001,maxi=-1;
for (int i=0; i<n; i++) {
cin>>a[i];
if (a[i]>maxi) {maxi=a[i];}
if (a[i]<mini) {mini=a[i];}
}
cout<<(maxi-mini)<<endl;

return 0;
}



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

int main()
{
    int n,i,j,count=0;
    char a[110],b[5]={'W','G','Y','P'};
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%c ",&a[i]);
    for(i=0;b[i]!='\0';i++)
        for(j=0;a[j]!='\0';j++)
        if(b[i]==a[j])
    {
        count+=1;
        break;
    }
    if(count==4)printf("Four\n");
    else printf("Three\n");
    return 0;
}

Measured memory_bytes: 128
def solve():
    s = input()
    genom = ["A", "T", "G", "C"]
    count, ans = 0, 0
    for c in s:
        if c in genom:
            count += 1
            if count > ans:
                ans = count
        else:
            count = 0
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>

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

    std::vector<int> p(n);

    for(int a = 0; a < n; a++){
        std::cin >> p[a];
    }

    int ans = 0;

    for(int a = 1; a < n - 1; a++){
        if(p[a - 1] > p[a] && p[a] > p[a + 1]){
            ans++;
        }else if(p[a + 1] > p[a] && p[a] > p[a - 1]){
            ans++;
        }
    }

    std::cout << ans  << "\n" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int64_t N = 1000000007;
    int64_t n,k;
    cin >> n >> k;
    
    int64_t ans=0;
    for(int64_t i=k; i<=n+1; i++){
        int64_t inf = i*(i-1)/2;
        int64_t sup = (2*n-i+1)*i/2;
        ans = (ans + ((sup-inf)+1))%N;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int ans = (x - z) / (y + z);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[105][MAXn];
ll d[105];
ll sum[MAXn][2];
int main(){
  IOS();
  ll n,k;
  cin >> n >> k;
  REP1 (i,n) cin >> d[i];

  REP (i,d[1]+1) dp[1][i] = 1;
  REP (i,k+1) {
    if (i != 0) sum[i][1] = (dp[1][i] + sum[i-1][1])%MOD;
    else sum[i][1] = dp[1][i]%MOD;
  }
  for (ll i=2;i<=n;i++) {
    for (ll j=0;j<=k;j++) {
      dp[i][j] = sum[j][(i%2)^1]-(j-d[i]-1>=0 ?sum[j-d[i]-1][(i%2)^1]:0LL);
      while (dp[i][j] < 0) dp[i][j] += MOD;
      if (j != 0) sum[j][i%2] = (dp[i][j] + sum[j-1][i%2])%MOD;
      else sum[j][i%2] = dp[i][j];
    }
  }
  cout << dp[n][k] << endl;
}


Measured memory_bytes: 81664
N, K, Q = map(int,input().split())
A = [0]*Q
survive = [0]*N

for i in range (Q):
    A[i] = int(input())

result={}
for i in range (0,len(A)):
    item = A[i]
    if item in result:
        result[item] = result[item]+1
    else:
        result[item] = 1

for i in range (1,N+1):
    item = i
    if item not in result:
        result[item] = 0

result_sort = sorted(result.items())

for i in range (N):
    if Q - result_sort[i][1] >= K:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 64088
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	class Packet{
		int t;
		int from;
		int to;
		Packet(int t,int from,int to){
			this.t=t;
			this.from=from;
			this.to=to;
		}
	}

	public void run() {
		while(true){
			int N=sc.nextInt(),M=sc.nextInt();
			if(N==0)return;
			Packet[] ps=new Packet[M];

			for(int i=0;i<M;i++){
				ps[i]=new Packet(sc.nextInt(),sc.nextInt()-1,sc.nextInt()-1);
			}
			Arrays.sort(ps,new Comparator<Packet>(){
				@Override
				public int compare(Packet o1, Packet o2) {
					return o1.t-o2.t;
				}
			});
			boolean[] infected =new boolean[N];
			infected[0]=true;

			for(int i=0;i<M;i++){
				if(infected[ps[i].from])infected[ps[i].to]=true;
			}

			int res=0;
			for(int i=0;i<N;i++){
				if(infected[i])
					res++;
			}

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

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 171296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << a;
	}
	else {
		cout << a - 1;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int findMax(const std::map<char, char> &mirror,
            const std::string &str, const int &origo,
            int left, int right,
            const int &size, int cnt) {
    if (origo - left < 0  || origo + right > size - 1) { return cnt; }
    if (mirror.at(str[origo - left]) == str[origo + right]) {
        cnt = findMax(mirror, str, origo, left+1, right+1, size, cnt+2);
    }
    else {
        cnt = std::max(findMax(mirror, str, origo, left, right+1, size, cnt),
                       findMax(mirror, str, origo, left+1, right, size, cnt));
    }
    return cnt;
}



int main()
{
    std::map<char, char> mirror;
    mirror.insert(make_pair('w', 'w'));
    mirror.insert(make_pair('i', 'i'));
    mirror.insert(make_pair('{', '}'));
    mirror.insert(make_pair('}', '{'));
    mirror.insert(make_pair('[', ']'));
    mirror.insert(make_pair(']', '['));
    mirror.insert(make_pair('(', ')'));
    mirror.insert(make_pair(')', '('));

    std::string str;
    std::getline(std::cin, str);
    int size = static_cast<int>(str.size());
    int origo;
    int cnt = 0;
    for (int i = 1; i < size; i++) {
        if (str[i-1] == 'i' && str[i] == 'w' && str[i+1] == 'i')
        {
            origo = i;
            cnt = 3;
            break;
        }
    }
    int res = findMax(mirror, str, origo, 2, 2, size, cnt);

    std::cout << res << std::endl;
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 3520
#include <stdio.h>
#define INF 10000
#define BLACK 1
#define WHITE 0
#define NIL -1
#define N 2000

int a[N][N];
int n;

int prim()
{
  int i, u, v, count=0, mincost,pi[N],d[N],color[N];
  for( i=0 ; i<n ; i++ ){
    d[i] = N;
    pi[i]=NIL;
    color[i]=WHITE;
  }
  while(1){
    mincost = INF;
    for( i=0 ; i<n ; i++ ){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost = d[i];
	u=i;
      }
    }
    if(mincost==INF)
      break;

    color[u] = BLACK;
    for( v=0 ; v<n ; v++ ){
      if(color[v]!=BLACK && d[v]>a[u][v] && a[u][v]!=-1){
	pi[v] = u;
	d[v] = a[u][v];
      }
    }
  }
  for( i=0 ; i<n ; i++ )
    count+=a[i][pi[i]];
  
  return count;
}

int main()
{
  int i, j;
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
      scanf("%d",&a[i][j]);
    }
  }
 
  printf("%d\n",prim());

  return 0;
}

Measured memory_bytes: 1040
#include<iostream>
#include<vector>
#include<algorithm>

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

	std::vector<int> v(n);
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}

	int max = 0;
	for (int i = 1; i < n; i++) {
		// i-part?????§??????????????????
		if (n % i != 0) continue;
		int c = 0;
		for (int j = 0; j < n; j++) {
			if (v[j % i] == v[j]) c++;
			else break;
		}
		if (c == n) max = std::max(max, n / i);
	}
	if (max == 0) max = 1;

	std::cout << max << std::endl;
	return 0;
}

Measured memory_bytes: 1800
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	public final int maxn = 0x3f3f3f3f;
	
	public void solve(InputReader in, PrintWriter out) {
		int[] c = new int[26];
		int[] cc = new int[26];
		int n = in.nextInt();
		
		for (int i=0; i<n; ++i) {
			String s = in.next();
			int len = s.length();
			
			Arrays.fill(cc, 0);
			for (int j=0; j<len; ++j) {
				++cc[s.charAt(j) - 'a'];
			}
			
			if (i == 0) {
				for(int j=0; j<26; ++j)
					c[j] = cc[j];
			} else {
				for (int j=0; j<26; ++j)
					c[j] = Math.min(c[j], cc[j]);
			}
		}
		
		StringBuilder sb = new StringBuilder();
		
		for (int i=0; i<26; ++i) {
			char ch = (char) (i+'a');
			for (int j=0; j<c[i]; ++j) {
				sb.append(ch);
			}
		}
		
		out.println(sb.toString());
	}
}

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: 23380
a, b, m = map(int,input().split())

ai = list(map(int,input().split()))
bi = list(map(int,input().split()))

min_b = min(bi)
min_a = min(ai)

price = float('inf')
for i in range(m):
  mi = list(map(int,input().split()))
  if price > ai[mi[0]-1] + bi[mi[1]-1] -mi[2]:
  	price = ai[mi[0]-1] + bi[mi[1]-1] -mi[2]

if price < min_a + min_b:
  print(price)
else:
  print(min_a + min_b)
               
               



Measured memory_bytes: 18688
#include <stdio.h>

int max(int a, int b)
{
  return a > b ? a : b;
}

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  long long total = 0;
  if(k == 0) {
    printf("%lld\n", n*n);
    return 0;
  }
  for(int b = k+1; b <= n; b++) {
    total += (n / b) * (b - k) + max(n % b - k + 1, 0);
  }
  printf("%lld\n", total);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

def crossz(v1,v2):
  return v1[0]*v2[1]-v1[1]*v2[0]

for s in sys.stdin:
  d = map(float,s.split(","))
  xa,ya,xb,yb,xc,yc,xd,yd = d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7]
  vab = [xb-xa,yb-ya]
  vbc = [xc-xb,yc-yb]
  vcd = [xd-xc,yd-yc]
  vda = [xa-xd,ya-yd]
  dotb = crossz(vab,vbc)
  dotc = crossz(vbc,vcd)
  dotd = crossz(vcd,vda)
  dota = crossz(vda,vab)
  if dotb*dotc*dotd*dota > 0:
    print "YES"
  else:
    print "NO"

Measured memory_bytes: 4260
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  char str[64];
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

int A[1000000];
vector<int> G;
int h = 1;
long cnt;

void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[],int n){
    while(h <= n){
        G.push_back(h);
        h = h*3 + 1;
    }
    for(int i = G.size()-1;i>=0;i--){
        insertionSort(A,n,G[i]);
    }
        
}

int main(){
    int n;
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    cnt = 0;
    
    shellSort(A,n);
    
    cout << G.size() << endl;
    
    cout << G[G.size()-1];
    for(int i=G.size()-2;i>=0;i--){
        cout << " " << G[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    for(int i=0;i<n;i++){
        cout << A[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 6956
import collections

alist = []

while(1):
    try:
        a = int(input())
    except:
        break
    alist.append(a)

ac = collections.Counter(alist)

cnt = 0
while(1):
    print(ac.most_common()[cnt][0])
    if cnt == len(alist):
        break

    if ac.most_common()[cnt][1] == ac.most_common()[cnt+1][1]:
        cnt += 1
    else:
        break



Measured memory_bytes: 6004
#a
"""
import math
a, b = map(str, input().split())
j = int(a + b)
if math.sqrt(j).is_integer():
    print("Yes")
else:
    print("No")
"""

#b
ans = ["Positive","Negative"]
a, b = map(int, input().split())
if 0 < a:
    print("Positive")
elif b >= 0:
    print("Zero")
else:
    print(ans[(b-a)%2-1])

Measured memory_bytes: 38256
import sys
input = sys.stdin.readline
def main():
  N,M=map(int,input().split())
  L=list(map(int,input().split()))
  i=1
  R=list()
  p=set()
  for j in range(N+1):
    if j==M-1:
      print(L[i-1])
      exit()
    if L[i-1] in p:
      c=R.index(L[i-1])
      t=len(R)-c
      m=R[c:]#ループ
      break
    R.append(L[i-1])
    p.add(L[i-1])
    i=L[i-1]
  l=(M-c-1)%t
  print(m[l])
if __name__ == '__main__':
    main()

Measured memory_bytes: 32064
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef vector<vector<int> > mat;
int h,w,n;
inline void mat_mul(mat &A, mat &B, int M=1000000009){
  mat ret(w,vector<int>(w));
  for(int i = 0; i < w; ++i){
    for(int j = 0; j < w; ++j){
      ret[i][j] = 0;
      for(int k = 0; k<w; ++k){
        ret[i][j] += A[i][k]*B[k][j];
        ret[i][j] %= M;
      }
    }
  }
  A=ret;
}

inline mat mat_pow(mat &A, int N, int M=1000000009){
  mat ret(A.size(),vector<int>(A.size(),0)), t = A;
  for(int i = 0; i < A.size(); ++i) ret[i][i] = 1;
  int k = 0;
  while(N>0){
    if(N&1){
      mat_mul(ret,t,M);
    }
    mat_mul(t,t,M);
    N>>=1;
  }
  return ret;
}

mat XXX;

void init(){
	mat res(w,vector<int>(w,0));
	for(int i=0;i<w;i++){
		for(int j=0;j<w;j++){
			if(i==j){
				if(i)res[i-1][j]=1;
				res[i][j]=1;
				if(i!=w-1)res[i+1][j]=1;
			}
		}
	}
	XXX=res;
}


inline mat make_mat(vector<int> &V){
	mat res=XXX;
	for(int i=0;i<V.size();i++){
		for(int j=0;j<w;j++){
			res[j][V[i]]=0;
		}
	}
	return res;
}

signed main(){
	init();
	int cnt=0;
	while(cin>>w>>h>>n,w){
		init();
		cout<<"Case "<<(++cnt)<<": ";
		vector<P>v;
		vector<int>v1;
		r(i,n){
			int x,y;
			cin>>x>>y;
			x--;y--;
			if(y==0)v1.push_back(x);
			else v.push_back(P(y,x));
		}
		v.push_back(P(1e18+1,0));
		int y=0;
		sort(v.begin(),v.end());
		mat A(w,vector<int>(w,0));
		A[0][0]=1;
		r(i,v1.size())A[v1[i]][v1[i]]=0;
		for(int i=0;i<v.size();i++){
			int s=v[i].first;
			int c=s-y;
			vector<int>vs,kara;
			vs.push_back(v[i].second);
			while(v[i].first==v[i+1].first){
				vs.push_back(v[i+1].second);
				i++;
			}
			mat B=make_mat(vs);
			mat C=make_mat(kara);
			if(s==1e18+1){
				c=(h-1)-y;
				if(c){
					C=mat_pow(C,c);
					mat_mul(A,C);
				}
				break;
			}
			if(c>1){
				C=mat_pow(C,c-1);
				mat_mul(A,C);
			}
			mat_mul(A,B);
			y=s;
		}
		int ans=0;
		r(i,w)ans=(ans+A[i][w-1])%1000000009;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N)cin >> A[i];
    REP(i,N-K){
        if(A[i]<A[i+K])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

if k == 1:
    print(1)
    exit()

tmp = 7
for i in range(1, 10**7):
    tmp = (10 * tmp) % (9*k)
    if tmp == 7:
        print(i)
        exit()

print(-1)


Measured memory_bytes: 63252
import sys


def solve(m, a, s):
    for i in range(m):
        if a[i] * 4 * m < s:
            return False
    return True


def main():
    input = sys.stdin.buffer.readline
    _, m = map(int, input().split())
    a = sorted(map(int, input().split()), reverse=True)
    s = sum(a)
    print('Yes' if solve(m, a, s) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
n=int(input())
# 数値→アルファベット
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(n).lower())


Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main()
{
	fast();
	int n, k;	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++)	cin >> h[i];

	vector<int> dp(n, 0);
	for (int i = 1; i < n; i++)
	{
		if (i == 1)
			dp[i] = abs(h[i] - h[0]);
		else
		{
			dp[i] = INT_MAX;
			for (int j = 1; j <= k and i - j >= 0; j++)
				dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 4784
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  
  int f = 0;
  int a;
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    f += a - 1;
  }
  
  printf("%d", f);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int R[MAX], n;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1940
#include<stdio.h>

int A[20], N;

bool exhaustiveSearch(int m, int s, int n){
    if(n==N+1) return false;//it's over
    if(s==m) return true;

    if (exhaustiveSearch(m,s,n+1)) {
        return true;
    }else
    {
        return exhaustiveSearch(m,s+A[n],n+1);
    }
}

int main(){
    int i,q;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int m;
        scanf("%d",&m);
        exhaustiveSearch(m,0,0)?printf("yes\n"):printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2688
//https://beta.atcoder.jp/contests/agc004/tasks/agc004_a

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

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

    long long a, b, c;
    cin >> a >> b >> c;

    long long p = a * b * c;
    if(p % 2){
        long long x, y, z;
        x = abs((a - a / 2) * b * c - a / 2 * b * c);
        y = abs((b - b / 2) * c * a - b / 2 * c * a);
        z = abs((c - c / 2) * a * b - c / 2 * a * b);
        cout << min(x, min(y, z)) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut s = s;
    let mut t = t;
    s.sort();
    t.sort_by(|a, b| b.cmp(a));
    println!("{}", if s < t {"Yes"} else {"No"});
}

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

const double INF = 1e9;
const double eps = 1e-5;
using pdi = pair<double, pair<int, int>>;
using tp4 = tuple<double, int, int, int>;

int N, M;

struct edge
{
    int to;
    double cost;
    int lim;
    edge(int t, double d, int l) : to(t), cost(d), lim(l) {}
};
// dist,v,pv,velocity
void dijkstra(int s, vector<vector<vector<double>>> &dist, vector<vector<edge>> &G)
{
    priority_queue<tp4, vector<tp4>, greater<tp4>> que;
    for (auto e : G[s])
    {
        int ns = e.to;
        que.push(make_tuple(e.cost, ns, s, 1));
        dist[ns][s][1] = e.cost;
    }
    while (!que.empty())
    {
        auto p = que.top();
        que.pop();
        double d = get<0>(p);
        int v = get<1>(p);
        int par = get<2>(p);
        int velo = get<3>(p);

        if (dist[v][par][velo] - d < -eps)
            continue;
        for (edge e : G[v])
        {
            if (e.to == par)
                continue;
            for (int nvelo = max(velo - 1, 1); nvelo <= min(velo + 1, e.lim); nvelo++)
            {
                if (dist[e.to][v][nvelo] - dist[v][par][velo] - e.cost / (double)nvelo > eps)
                {
                    dist[e.to][v][nvelo] = dist[v][par][velo] + e.cost / (double)nvelo;
                    que.push(make_tuple(dist[e.to][v][nvelo], e.to, v, nvelo));
                }
            }
        }
    }
}

int main()
{
    while (cin >> N >> M, N | M)
    {
        int s, g;
        cin >> s >> g;
        s--, g--;
        vector<vector<edge>> G(N);
        for (int i = 0; i < M; i++)
        {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            a--, b--;
            G[a].push_back(edge(b, c, d));
            G[b].push_back(edge(a, c, d));
        }
        double res = INF;
        vector<vector<vector<double>>> dist(N, vector<vector<double>>(N, vector<double>(31, INF)));
        dijkstra(s, dist, G);
        for (int v = 0; v < N; v++)
        {
            res = min(res, dist[g][v][1]);
        }

        if (abs(res - INF) < eps)
        {
            cout << "unreachable" << endl;
        }
        else
        {
            cout << fixed << setprecision(10) << res << endl;
        }
        // s+N -> g+N
    }
}


Measured memory_bytes: 3960
package main

import (
        "fmt"
        "math"
)

func main() {
        var r, d float64
        var x, y, rad float64
        rad = math.Pi / 2
        for {
                _, err := fmt.Scanf("%f,%f", &d, &r)
                if err != nil {
                        break
                }
                if r == 0.0 && d == 0.0 {
                        break
                }

                x += d * math.Cos(rad)
                y += d * math.Sin(rad)
                rad -= r * math.Pi / 180
        }

        fmt.Printf("%d\n", int(x))
        fmt.Printf("%d\n", int(y))
}



Measured memory_bytes: 1108
N=int(input())
A= list(map(int, input().split()))
B= list(map(int, input().split()))
C= list(map(int, input().split()))
ans=0
before=10000000
for i in range(N):
    eat=A[i]
    ans+=B[eat-1]
    if before+1==eat:
        ans+=C[before-1]
    before=eat
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, A[112345];

int main() {

	scanf("%lld", &N);
	rep(i, N) scanf("%lld", &A[i]);

	ll a = 0;
	rep(i, N) {
		a += A[i] * (i % 2 ? -1 : 1);
	}

	rep(i, N) {
		printf("%lld ", a);
		a = A[i] * 2 - a;
	}

	return 0;
}


Measured memory_bytes: 2048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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 rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  YesNo((a<c&&c<b)||(a>c&&c>b));
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    ll H, W, N;
    cin>>H>>W>>N;
    
    map<pair<int,int>,ll> field;
    rep(i,N){
        int a,b; scnd2(a,b);
        for(int i=a-2; i<=a; i++){
            for(int j=b-2; j<=b; j++){
                if( i>=1 && i<=H-2 && j>=1 && j<=W-2 ){
                    field[{i,j}]++;
                }
            }
        }
    }
    
    ll nums[15]; mem(nums,0);
    for(auto x:field){
        nums[x.second]++;
    }
    
    nums[0] = (H-2)*(W-2);
    rep1(i,9) nums[0] -= nums[i];
    
    rep(i,10){
        cout1(nums[i]);
    }
}

Measured memory_bytes: 56448
#include <iostream>

int main () {
    int n;
    std::cin >> n;
    int d[n];
    for(int i = 0; i < n; ++i) {
        std::cin >> d[i];
        for(int j = 0; j < i; ++j){
            if(d[j]==d[i]){
                n -= 1;
                --i;
                break;
            }
        }
    }
    std::cout << n << std::endl;
}

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

using ll = long long;
const ll MOD = 1000000007;

int main() {
	int n; cin >> n;
	vector<ll> num(n); for (auto&& x : num)cin >> x;

	ll ans = 0, x = 1;
	for (int i = 0; i < 61; i++) {
		ll c0 = 0, c1 = 0;
		for (int j = 0; j < n; j++) {
			if (num[j] % 2 == 0) c0++;
			else c1++;
			num[j] /= 2;
		}
		c0 = c0 * x % MOD;
		c0 = c0 * c1 % MOD;
		ans += c0; ans %= MOD;
		x = x * 2 % MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    ll N;
    cin >> N;
    ll A[N];
    rep(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }
    
    ll sum_step=0;
    for(ll i = 1;i<N;i++){
        ll b = A[i-1] - A[i];
        if(b > 0){
            A[i] +=b;
            sum_step += b;
        }
    }
    
    cout << sum_step << endl;
    return 0;
}


Measured memory_bytes: 5164
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>

using int64 = long long;

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

    int N;
    std::cin >> N;

    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }

    int ans = 0;

    for (int i = 0; i < N; i++) {
        bool good1 = true,  // 左上が(i, 0)の正方形領域
             good2 = true;  // 左上が(0, i)の正方形領域

        for (int r = 0; r < N; r++) {
            for (int c = 0; c < N; c++) {
               good1 = good1 && (S[(r - i + N) % N][c] == S[(c - i + N) % N][r]); 
               good2 = good2 && (S[r][(c - i + N) % N] == S[c][(r - i + N) % N]);
            }
        }
        if (good1) ans += N - i;
        if (good2) ans += N - i;

        // ダブルカウントしているので修正
        if (i == 0 and good1 and good2) {
            ans -= N;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  string s = "Sunny", c = "Cloudy", r = "Rainy";
  string ans;
  if (S == s)
    ans = c;
  if (S == c)
    ans = r;
  if (S == r)
    ans = s;
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] v = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Abs(v[1] - v[0]);

            for (int i = 2; i < n; i++)
            {
                dp[i] = Min(
                    Abs(v[i - 1] - v[i]) + dp[i - 1],
                    Abs(v[i] - v[i-2]) + dp[i-2]
                    );
            }
            WriteLine(dp[n-1]);
        }
    }
}


Measured memory_bytes: 18016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



int main(){
  ll N,W;
  cin >> N >>W;
  ll w[N],v[N];
  cin >> w[0] >> v[0];
  ll offset=w[0];
  w[0]=0;
  ll t;
  rep1(i,N-1){
    cin >> t >> v[i];
    w[i] = t-offset;    
  }
  //  rep(i,N) cout << w[i] << endl;
  ll dp[4*N+1][N+1][N+1]; //(offsetを除いた)重さi以下の制限の元jこまでのうちkこ使った場合の価値の総和の最大値
  rep(i,4*N+1)rep(j,N+1) rep(k,N+1) dp[i][j][k]=0;
  rep1(j,N){
    rep1(k,j){
      rep(i,4*N+1){
	if(j==k){
	  if(i-w[j-1]>=0){
	    dp[i][j][k]= max(dp[i-w[j-1]][j-1][k-1] + v[j-1] , dp[i][j-1][k-1]);
	  }else{
	    dp[i][j][k] = dp[i][j-1][k];	    
	  }	  
	}
	else if(i-w[j-1]>=0){	  
	  dp[i][j][k] = max(dp[i-w[j-1]][j-1][k-1] + v[j-1] , dp[i][j-1][k]);
	}else{
	  dp[i][j][k] = dp[i][j-1][k];
	}
      }
    }
  }
  ll ans=0;
  //  cout << offset << endl;
  rep(i,4*N+1)rep(k,N+1){
    //    if(k==1)cout <<"w " << k*offset+i << " v "<< dp[i][N][k] << endl;
    if(k*offset+i<=W){
      ans=max(ans,dp[i][N][k]);
    }
  }
  cout << ans << endl;


  
  return 0;

}


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

int main(void) {
  long long  k;
  cin >> k;
  long long amari = 7 % k;

  for (int i = 1; i <= k; i++) {
    if (amari == 0) {
      cout << i << endl;
      return 0;
    }

    amari = (amari*10 + 7) % k;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 ll n ;
 cin >> n;
 vector<ll> A(n) ;
 rep(i,n) cin>> A[i] ;
 sort(A.begin(),A.end()) ;
 ll k=A[n-1] ;
 ll ans=A[0] ;
 ll small=INF ;
 rep(i,n-1) {
  if( small> abs(A[i]*2-k))  
  ans=A[i] ; 
  small =abs(A[i]*2-k) ;
 }
 cout <<k<<endl;
 cout<<ans<<endl ;
 return 0;
}


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

int main(){
	int n;
	cin>>n;
	if(n<=9)cout<<n;
	else if(n<100)cout<<9;
	else if(n<=999)cout<<9+n-100+1;
	else if(n<10000)cout<<909;
	else if(n<=99999)cout<<9+899+1+1+n-10000;
	else cout<<90909;
		
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll x,k,d;
    cin>>x>>k>>d;
    ll ans;
    if(x==0){
        if(k%2==0) ans=0;
        else ans=d;
    }else{
        if(x<0) x*=-1;
        ll n=(x+d-1)/d;
        if(k>=n){
            ll y=k-n;
            if(y%2==0){
                ans=abs(x-n*d);
            }else{
                ans=abs(x-(n-1)*d);
            }
        }else{
            ans=abs(x-k*d);
        }
    }cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3644
n=int(input())
a=list(map(int,input().split()))
a1=[]
for i in range(n-1,-1,-2):
    a1.append(a[i])
a2=[]
for i in range(n-2,-1,-2):
    a2.append(a[i])
a2.reverse()
a1+=a2
print(*a1)

Measured memory_bytes: 26356
//please refer from line no. 207
/////*31022618*/////
//_MONU KUMAR
#include <iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tc ll t=1; cin>>t; while(t--)
#define ll long long int
#define ld long double
#define ull unsigned long long
#define p1(x) cout <<x<<"\n";
#define p2(x,y) cout <<x<<" "<<y<<"\n";
#define p3(x,y,z) cout <<x<<" "<<y<<" "<<z<<"\n";
#define p4(x,y,z,w) cout <<x<<" "<<y<<" "<<z<<" "<<w<<"\n";
#define trace(x) cout<<#x<<": "<<x<<" "<<"\n";
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n";
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n";
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<"\n";
#define nL cout<<"\n";
#define lp(i,l,r) for (long long int i = l; i < r; i++)
#define lpr(i,r,l) for (long long int i = r-1; i >=l ; i--)
#define mem(a,x) memset(a,x,sizeof(a))              //set elements of array to some value
#define pi 3.1415926535897932384626
#define mod 1000000007
#define big 1e18
#define small -big
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define ff first
#define ss second
#define siz 256
#define leadzero(a) __builtin_clz(a)        // count leading zeroes
#define trailzero(a) __builtin_ctz(a)       // count trailing zeroes
#define bitcount(a) __builtin_popcount(a)   // count set bits
#define all(v) v.begin(),v.end()
#define lps(v,x) (lower_bound(all(v),x)-v.begin())
#define ups(v,x) (upper_bound(all(v),x)-v.begin())
//#########################################################################################

int main()
{
  fast
//  clock_t launch=clock();
  // string r = s1.substr(1, 3);
  //while(clock()<CLOCKS_PER_SEC*10)
  //using num = modnum<int(1e9)+7>;
 //num len = s.size();
  ll n,k,ans=0,flag=0,temp=0,f1=0,count=0,f2=0,sum=0,xx=0,minn1=big,minn2=big,maxx1=small,maxx2=small;
  cin>>n>>k;
  if (k>=n) {
    /* code */
    p1("unsafe")
  }
  else
  {
    p1("safe")
  }



  //clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
  return 0;
}
//////////*********************end of program*********************//////////


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair  
#define st first 
#define nd second 
#define all(v)  v.begin(),v.end()
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)
#define ln '\n'
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);cout.tie(nullptr);
	ll x;
	cin >> x;
	int ans = 0;
	for(ll i = 100; i < x;i +=(i/100))++ans;
	cout << ans;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdint>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
int N; cin >> N;
vector<int64_t> a(3*N);
rep(i,3*N){
  cin >> a[i];
}
sort(a.rbegin(),a.rend());
int64_t sum = 0;
for(int i = 0; i < N; i++){
  sum+=a[2*i + 1];
}
cout << sum << endl;
}

Measured memory_bytes: 2560
inf = 1000 * 1000 + 10

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

g = tuple([inf] * n for _ in range(n))
e = set()
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c
    e.add((a, b, c))

for i in range(n):
    g[i][i] = 0

for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j] = min(g[i][j], g[i][k] + g[k][j])

# print(g)

need = set()
for a, b, c in e:
    for s in range(n):
        for t in range(n):
            if g[s][t] == g[s][a] + c + g[b][t]:
                need.add((a, b))
                break
        else:
            continue
        break
# print(need)
print(m - len(need))


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d[i];
    int ans = 0;
    for (int i = 0; i <= N-2; i++){
        for (int j = i+1; j <= N-1; j++) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256