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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << ((a * 100 + b * 10 + c) % 4 == 0 ? "YES" : "NO") << endl;
    return (0);
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
  private static char alphabet[]={'a'};
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n=sc.nextInt();
      String s=sc.next();
      StringBuilder sb=new StringBuilder();
      for(int i=0;i<s.length();i++){
        char c=(int)(s.charAt(i)+n)>90?(char)(s.charAt(i)+n-26):(char)(s.charAt(i)+n);
        sb.append(c);
      }
      System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23124
from collections import deque
k = int(input())

queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
    x = queue.popleft()
    if x % 10 != 0:
        queue.append(10 * x + (x % 10) - 1)
    queue.append(10 * x + x % 10)
    if x % 10 != 9:
        queue.append(10 * x + x % 10 + 1)
#print(queue)
print(x)


Measured memory_bytes: 18708
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

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

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

    ll res = 0;
    for(int d = 0; d < 61; ++d){
        ll one_cnt = 0, zero_cnt = 0;
        for(int i = 0; i < n; ++i){
            if((a[i] >> d) & 1) ++one_cnt;
            else    ++zero_cnt;
        }
        ll tmp = mod_pow(2, d);
        ll cnt = one_cnt * zero_cnt % mod;
        tmp = tmp * cnt % mod;
        res = (res + tmp) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr> () -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();

    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i64 = read::<i64>();
    let D: i64 = read::<i64>();

    let mut ans = 0;
    let num = 2*D+1;
    let mut acc = 0;

    loop {
        if acc >= N {
            break;
        }
        else {
            acc += num;
            ans += 1;
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}

// ATCODER DP CONTEST FROG 1
 
int32_t main()
{ 
	inputoutput() ;

	int n,k;
	cin>>n>>k;
	vector<int> ar(n) ;
	for(int i=0 ; i<n ; ++i)
		cin>>ar[i];

	// dp[i] = min possible cost

	int dp[n] ;

	dp[0]=0;

	for(int i=1 ; i<n ; ++i)
	{
		dp[i]=INT_MAX ;
		for(int j=i-1 ,tim=0 ; j>=0 && tim<k; --j,++tim)
		{
			dp[i]=min( dp[j]+abs(ar[i]-ar[j]) , dp[i] );
			// cout<<dp[i]<<" ";
		}

	}


	cout<<dp[n-1]<<"\n";



	return 0;
}


Measured memory_bytes: 3996
/*
    AOJ Volume0 0003

        Is it a Right Triangle?

        Write a program which judges wheather given length of three side form a right triangle.
        Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
        
        Input
            Input consists of several data sets. In the first line, the number of data set, N is given.
            Then, N lines follow, each line corresponds to a data set.
             A data set consists of three integers separated by a single space.

        Constraints
            1 ≤ length of the side ≤ 1,000
            N ≤ 1,000

        Output
            For each data set, print "YES" or "NO".

        Sample Input
            3
            4 3 5
            4 3 6
            8 8 8

        Output for the Sample Input
            YES
            NO
            NO
*/

#include <iostream>


bool is_right_triangle(int edge1, int edge2, int edge3)
{
    int edge[3] = { edge1, edge2, edge3 };
    int longest = 0;
    int other1 = 1, other2 = 2;

    for(int i=1; i<3; ++i)
    {
        if(edge[i] > edge[longest])
        {
            longest = i;
            if(longest == 1){ other1 = 0; other2 = 2; }
            if(longest == 2){ other1 = 0; other2 = 1; }
        }
    }

    int aa = edge[other1] * edge[other1];
    int bb = edge[other2] * edge[other2];
    int cc = edge[longest] * edge[longest];

    return aa + bb == cc;
}


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

    for(int i=0; i<N; i++)
    {
        int e, f, g;
        std::cin >> e >> f >> g;

        bool ans = is_right_triangle(e,f,g);
        std::cout << (ans ? "YES" : "NO") << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3112
using System;
using System.Linq;

class Challenge
{
  static void Main()
  {
    var NAB = Console.ReadLine().Split();
    var N = int.Parse(NAB[0]);
    var A = int.Parse(NAB[1]);
    var B = int.Parse(NAB[2]);
    
    var count = 0;
    for (int i=0; i<=N; i++)
    {
      var n = i.ToString()
        .ToCharArray()
        .Select( x => x.ToString() )
        .Select( int.Parse )
        .ToArray()
        .Sum();
      if ( A <= n & n <= B ) count += i;
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 15440
n=int(input())
l=[0]*(10**5+1)
v=list(map(int,input().split()))
for i in range(n):
  x=v[i]
  if x==0:
    l[0]+=1
    l[1]+=1
  elif x==10**5:
    l[x-1]+=1
    l[x]+=1
  else:
    l[x-1]+=1
    l[x]+=1
    l[x+1]+=1
l.sort()
print(l[-1])

Measured memory_bytes: 15144
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%10 != 7 && (n/10)%10 != 7 && (n/100)%10 != 7 )
        cout << "No" << endl;
    else 
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	s = []
	for i in range(n):
		s.append(input())
	print(len(set(s)))
	


main()

Measured memory_bytes: 36388
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string X;
  cin >> X;

  long tmp = 0;
  long ans = tmp;

  for (char c: X) {
    if (c == 'T') tmp++;
    else tmp--;
    ans = max(ans, tmp);
  }

  cout << ans * 2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

vll p(1<<16, 0);
vll ans(1<<16, -1);

ll f(ll num){
  if(num==0) return 0;
  if(ans[num]!=-1) return ans[num];

  //std::cout << num << '\n';

  ll ret = p[num];
  int sub = num;
  do{
    if(num!=sub&&sub!=0) ret = max(ret, f(sub) + f(num - sub));
    sub = (sub - 1) & num;
  }while(sub != num);

  return ans[num] = ret;
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl a = vv(n, n, 0, ll);
  re(i, n) re(j, n) scanf("%lld", &a[i][j]);
  for(int i=0;i<(1<<n);i++){
    ll num = 0;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        if(!(i>>j&1)||!(i>>k&1)) continue;
        num += a[j][k];
      }
    }
    p[i] = num;
  }
  for(int i=0;i<n;i++) ans[1<<i] = 0;
  std::cout << f((1<<n)-1)/2 << '\n';
  return 0;
}


Measured memory_bytes: 1912
N = int(input())
p = list(map(int, input().split()))
q = list(range(1, N+1))

cnt = 0
for _p, _q in zip(p, q):
    if _p != _q:
        cnt += 1

if cnt in [0, 2]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int lst[Max], ls[Max];
int n;

bool check(int n)
{
	int lst[Max];
	int i = 0;
	while (n > 0)
	{
		lst[++i] = n % 10;
		n /= 10;
	}
	int f = 0;
	for (int j = 1; j <= i / 2; j++)
	{
		if (lst[j] != lst[i - j + 1]) return false;
	}
	return true;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int sum = 0;
	for (int i = a; i <= b; i++)
	{
		if (check(i))
		{
			sum++;
		}
	}
	cout << sum;

}

Measured memory_bytes: 3160
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 100010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}
 
vi g[N];
int dp[N];
void dfs(int u,int fa=-1){
    int cnt=0;
    for(auto &v:g[u]){
        if(v!=fa){
            dfs(v,u);
            dp[u]+=dp[v];
            if(dp[v]==0)cnt++;
        }
    }
    if(cnt)dp[u]+=cnt-1;
    //cerr<<u<<" "<<dp[u]<<"\n";
}
int main(){
    //freopen("atlarge.in","r",stdin);
    //freopen("atlarge.out","w",stdout);
    //cout<<setprecision(9)<<fixed;
    int T,j,i,k,ca=0,K=0,n,m;
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d%d",&j,&k);
        g[j].pb(k);g[k].pb(j);
    }
    int rt=-1;
    rep(i,0,n)if(SZ(g[i])>=3)rt=i;
    if(rt==-1){
        puts("1");return 0;
    }
    //DBG(rt)
    dfs(rt);
    printf("%d\n",dp[rt]);
    //cerr<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
    return 0;
}   

Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<bool, int>> cnt(n);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (!cnt[p].first) {
      if (s == "WA")
        cnt[p].second++;
      else
        cnt[p].first = true;
    }
  }
  int ac = 0, wa = 0;
  rep(i, n) {
    if (cnt[i].first) {
      ac++;
      wa += cnt[i].second;
    }
  }
  cout << ac << ' ' << wa << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  string s; cin >> s;
  string t;
  for(char c : s) {
    if(c == '0') t += c;
    if(c == '1') t += c;
    if(c == 'B' && t.size() > 0) t.erase(t.size()-1);
  }
  cout << t << endl;

}

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

int main()
{
  vector<long> l(87);
  l.at(0) = 2;
  l.at(1) = 1;
  for (int i=2; i<=86; i++)
    l.at(i) = l.at(i-1) + l.at(i-2);
  
  int n;
  cin >> n;
  cout << l.at(n) << endl;
}

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

int N, A, B, C, ans;
vector<int> L;
// 配列の長さは main() で N を入力したあと L.resize(N) で指定

int dfs(int i, int a, int b, int c) {
  if (i == N) {
  // 素材の竹 N 本をすべて使い終わったら(ベースケース)
    if (a == 0 || b == 0 || c == 0) return 1e9;
    // A, B, C それぞれに 1本も素材の竹が割り当てられて無かったら不可
    return abs(A - a) + abs(B - b) + abs(C - c);
    // 伸縮魔法に必要になる 合計MP を返す
  }
  int ans = 1e9;
  // 再帰ステップ
  ans = min(ans, dfs(i + 1, a + L.at(i), b, c) + (a > 0 ? 10 : 0));
  // [選択1] この素材の竹を A に割り当てる。既に A に素材が割り当てられていたら合成費用 +10
  ans = min(ans, dfs(i + 1, a, b + L.at(i), c) + (b > 0 ? 10 : 0));
  // [選択2] この素材の竹を B に割り当てる。既に B に素材が割り当てられていたら合成費用 +10
  ans = min(ans, dfs(i + 1, a, b, c + L.at(i)) + (c > 0 ? 10 : 0));
  // [選択3] この素材の竹を C に割り当てる。既に C に素材が割り当てられていたら合成費用 +10
  ans = min(ans, dfs(i + 1, a, b, c));
  // [選択4] この素材の竹を使わない
  return ans;
}

int main() {
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);

  cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      int a,b;
      cin >> a >> b;
      cout << (a-1)*(b-1) << endl;
      return 0;}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<b){
      for(int i =0;i<b;i++){
        System.out.print(a);
      }
    }else{
      for(int i=0;i<a;i++){
        System.out.print(b);
      }
    }
  }
  

  
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=100004;
int N, M, k;
ll arr[MX];
map<ll, int> m;
ll over(ll a, ll b)
{
    ll c=a*b;
    if(a == 0 || b == 0) return 0;
    if(c/a == b) return 0;
    return 1;
}
ll l[MX];
ll co[MX];
int main()
{
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%lld", &arr[i]);
    for(int i=1; i<=N; i++)
    {
        ll x=arr[i];
        for(ll j=2; j*j*j<=x; j++)
        {
            while(x%(j*j*j) == 0) x/=(j*j*j);
        }
        m[x]++;
        ll comp=1;
        l[i]=x;
        for(ll j=2; j*j*j<=x; j++)
        {
            if(x%j == 0)
            {
                x/=j;
                if(over(comp, j))
                {
                    comp=-1;
                    break;
                }
                comp*=j;
                if(x%j == 0)
                {
                    x/=j;
                }
                else
                {
                    if(over(comp, j))
                    {
                        comp=-1;
                        break;
                    }
                    comp*=j;
                }
            }
        }
        ll sq=sqrt(x);
        if(sq*sq == x)
        {
            if(!over(comp, sq))
                comp*=sq;
            else comp=-1;

        }
        else
        {
            if(!over(x, x) && !over(x*x, comp))
                comp*=(x*x);
            else comp=-1;
        }
        co[i]=comp;
    }
    ll an=0;
    if(m[1]) m[1]=0, an=1;
    for(int i=1; i<=N; i++)
    {
        an+=max(m[l[i]], m[co[i]]);
        m[l[i]]=0;
        m[co[i]]=0;
    }
    cout<<an;
    return 0 ;
}





Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2001;

int n, z, w, dp[N][2];
vector <int> a;

int solve(int idx, int b){
    if(idx == n - 1) return b ? 2e9 : 0;
    int &ret = dp[idx][b];
    if(ret != -1) return ret;
    ret = b ? 2e9 : 0;
    for(int j = idx ; j < n - 1 ; j++){
        if(b) ret = min(ret, max(abs(a.back() - a[j]), solve(j + 1, !b)));
        else ret = max(ret, min(abs(a.back() - a[j]), solve(j + 1, !b)));
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> z >> w;
    a.resize(n);
    for(auto &i : a) cin >> i;
    cout << max(abs(a.back() - w), solve(0, 0)) << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int i,j,H,W,K,r,c,cnt,ans=0;
    char array[6][7];
    scanf("%d %d %d",&H,&W,&K);

    for(i=0;i<H;i++){
        scanf("%s",array[i]);
    }

    for(r=0;r<(1<<H);r++){//横塗り潰し
        for(c=0;c<(1<<W);c++){//縦塗り潰し
            cnt = 0;
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((((r>>i)&1)==0) && (((c>>j)&1)==0) ){//見る行列かチェック
                        if(array[i][j]=='#'){//そこが黒ならインクリメント
                            cnt++;
                        }
                    }    
                }
            }
            if(cnt==K) ans++;
        }
    }

    printf("%d\n",ans);

    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int A, B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e18;
int main()
{
	int n,W;
	cin>>n>>W;
	int w[n],v[n];
	for(int  i=0;i<n;i++)cin>>w[i]>>v[i];
	ll dp[1010*n];
	for(int i=0;i< 1010*n;i++)dp[i]=inf;
	for(int i=0;i<n;i++)
	{
		for(int x= 1000*n;x>=0;x--)
		{
			dp[x]=min(dp[x-v[i]]+w[i], dp[x]);
		}
	}
	ll a=-1;
	for(int i=(1000*n);i>=0;i--)
	{
		if(dp[i]<=W){cout<<i+1;break;}
	}

	
}

Measured memory_bytes: 1024
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

class UFT {
private:
  vi data, rnk;

public:
  UFT(const int &size)
    : data(size), rnk(size) {
    iota(all(data), 0);
  }

  int root(const int &x) {
    return data[x] == x ? x : data[x] = root(data[x]);
  }

  bool same(const int &a, const int &b) {
    return root(a) == root(b);
  }

  void unite(int a, int b) {
    a = root(a), b = root(b);
    if (a == b) return;
    if (rnk[a] < rnk[b]) swap(a, b);
    data[b] = a;
    if (rnk[a] == rnk[b]) rnk[a]++;
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  UFT uf(n + m);
  rep(i, n) {
    int k;
    cin >> k;
    while (k--) {
      int l;
      cin >> l;
      l--;
      uf.unite(i, n + l);
    }
  }
  int c = 0;
  rep(i, n) c += uf.root(i) == i;
  cout << (c == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3328
N, K = gets.split.map(&:to_i)
D = (1..N).map{gets.split.map(&:to_i)}.sort_by{|ar| -ar[1]}

group = Array.new(N)
taste = 0
kind = 0
pool = []
for i in 0...K
  t, d = D[i]
  taste += d 
  if group[t]
    pool << d
  else  
    group[t] = true 
    kind += 1
  end
end

ans = taste + kind ** 2
for i in K...D.size
  t, d = D[i]
  next if group[t]
  break if pool.empty?
  group[t] = true
  taste += d - pool.pop
  kind += 1
  tmp = taste + kind ** 2
  ans = tmp if tmp > ans
end

puts ans


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

int main()
{
    int k, x;

    cin >> k >> x;
    if (k * 500 >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())

q = deque(range(1, 10))
for _ in range(k):
    x = q.popleft()
    if x % 10 != 0:
        q.append(x*10 + x%10 - 1)
    q.append(x*10 + x%10)
    if x % 10 != 9:
        q.append(x*10 + x%10 + 1)

print(x)

Measured memory_bytes: 11908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0032
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var s = Console.ReadLine();

            List<int> arr = new List<int>();

            for (int i = 0; i < s.Split(' ').Length; i++)
            {
                arr.Add(int.Parse(s.Split(' ')[i]));
            }

            int r = 0;

            for (int i = 0; i < arr.Count(); i++)
            {
                r += arr[i] - 1;

            }

            Console.WriteLine(r);

        }
    }
}

Measured memory_bytes: 48676
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

H = lines[0][0]
N = lines[0][1]

total_damage = 0
for i in 1..N do
  total_damage += lines[1][i-1]
end

if total_damage >= H then
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    double ans = 0;
    for (auto &a : A) ans += 1.0 / a;
    ans = 1.0 / ans;
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}

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

int main(){ 
  string s;
  cin >> s;
  string t = "keyence";
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (t == s.substr(0,i+1) + s.substr(j)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  
  return 0;
} 

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

using namespace std;

void chmax(long long* a, long long b){
  if( *a < b ) *a = b;
}

int main(){
  int n, w;
  cin >> n >> w;
  vector<vector<int> > wvi(n, vector<int>(2,0) );
  for(int i=0; i<n; i++){
    cin >> wvi[i][0] >> wvi[i][1];
  }
  vector< vector<long long> > dp(n+1, vector<long long>(w+1, 0) );

  for(int i=0; i<n; i++){
    for(int j=0; j<=w; j++){
      if( j - wvi[i][0] >= 0 ){
        chmax( &dp[i+1][j], dp[i][j - wvi[i][0]] + wvi[i][1]  );
      }
      chmax( &dp[i+1][j], dp[i][j] );
    }
  }

  cout << dp[n][w];
  return 0;
}


Measured memory_bytes: 80256
#include <iostream>

using namespace std ;

int main(void){
    char S[100000];
    int s0=0, s1=0;
    cin >> S;
    
    for ( int i = 0; S[i] != '\0'; ++i ) {
        if(S[i]=='0') s0++;
        if(S[i]=='1') s1++;
    }
    cout << 2 * min(s0, s1) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
vector<int> v[3],dp[3];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<3;++i)  dp[i].resize(n),v[i].resize(n);
    for(int i=0;i<n;++i)
        for(int j=0;j<3;++j)  cin>>v[j][i];
    for(int i=0;i<3;++i)  dp[i][0]=v[i][0];
    for(int i=1;i<n;++i)
        for(int j=0;j<3;++j)
        {
            dp[j][i]=-1;
            for(int k=0;k<3;++k)  if(k!=j)  dp[j][i]=max(dp[k][i-1],dp[j][i]);
            dp[j][i]+=v[j][i];
        }
    int maxn=-1;
    for(int i=0;i<3;++i)  maxn=max(maxn,dp[i][n-1]);
    printf("%d",maxn);
    return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int n,m;
long long x[1005],y[1005],z[1005];
long long pre[1005],cur[1005],ans;
void cal(int a,int b,int c){
	memset(pre,0,sizeof(pre));
	pre[1]=a*x[1]+b*y[1]+c*z[1];
        for(int i=1;i<=n;i++){
                memset(cur,0,sizeof(cur));
                for(int j=1;j<=min(i,m);j++){
			if(j!=i)
                        	cur[j]=max(pre[j],pre[j-1]+a*x[i]+b*y[i]+c*z[i]);
                	else
				cur[i]=pre[i-1]+a*x[i]+b*y[i]+c*z[i];
		}
		for(int j=1;j<=min(i,m);j++)
			pre[j]=cur[j];
        }
	ans=max(ans,pre[m]);
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i]>>z[i];
	for(int i=-1;i<=1;i+=2)
	for(int j=-1;j<=1;j+=2)
	for(int k=-1;k<=1;k+=2)
		cal(i,j,k);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> vec;
    set<string> vset;
    for(int i=0;i<s.size();i++){
        for(int j=1;j<=k;j++){
            string tmp = s.substr(i,j);
            if ((i+j<s.size()+1) && (vset.find(tmp) == vset.end())){
                vec.push_back(tmp);
                vset.insert(tmp);
            }
        }
    }
    sort(all(vec));
    cout << vec[k-1] << endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int N,T,x=1e9,p,cnt;
set<int>st,stt;
int a[111111];
int main(){
    cin>>N>>T;
    for(int i=0;i<N;i++){
       cin>>a[i];
       st.insert(a[i]);
       stt.insert(a[i]);
    }
    for(int i=0;i<N-1;i++){
        x=min(a[i],x);
        st.erase(a[i]);
        p=max(p,*st.rbegin()-x);
    }
    for(int i=0;i<N-1;i++){
        stt.erase(a[i]);
        if(stt.find(a[i]+p)!=stt.end()){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,c;
    ll wa=0;
    bool hantei=false;
    cin >> a >> b >> c;
    rep(i,100){
        wa += a;
        if(wa%b == c) hantei=true;
    }
    if(hantei) cout << "YES"<<endl;
    else cout << "NO" <<endl;
}

Measured memory_bytes: 256
while True:
    n,x = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for s in range(1, n-1):
        for m in range(s+1, n):
            for e in range(m+1,n+1):
                if x == sum([s,m,e]):
                    count += 1

    print(count)

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

int main(){
    int a, b;
    cin >> a >> b;
    int ans;
    if (a < 6){
        ans = 0;
    }
    else if (a < 13){
        ans = b / 2;
    }
    else {
        ans = b;
    }
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int n, h, w, cH=0, cW=0;
	cin >> n >> h >> w;

	cH = n - h + 1;
	cW = n - w + 1;

	cout << cH * cW << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int pow(int a,int b){
  int ret=1;
  if(b<=0) return 1;
  if(b>=1){
    for(int i=1;i<=b;i++){
      ret*=a;
    }
    return ret;
  }
}

int main(){
  char S[11];
  int s[11];
  int d;
  long ans=0;
  scanf("%s",S);
  for(int i=0;i<=11;i++){
    if(S[i]=='\0'){
      d=i;
      break;
    }
    s[i]=S[i]-'0';
  }
  
  for(int i=0;i<=d-1;i++){
    for(int j=1;j<=d-i;j++){
      ans+=pow(2,i)*pow(2,d-i-j-1)*pow(10,j-1)*s[i];
    }
  }
  
  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 128
x_1,y_1,x_2,y_2 = map(int, input().split())

x_4,y_4 = x_1-(y_2-y_1) , y_1+(x_2-x_1)
x_3,y_3 = x_2+x_4-x_1 , y_2+y_4-y_1
print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>

int main() {
	long long N, M;
	scanf("%lld %lld", &N, &M);
	if (abs(N - M) > 1 ) {
		printf("0\n");
	} else {
		long long Nn = 1, Mm = 1;
		for (long long i = 1; i <= N; i++) {
			Nn *= i;
			Nn %= 1000000007;
		}
		for (long long i = 1; i <= M; i++) {
			Mm *= i;
			Mm %= 1000000007;
		}
		if (N == M) {
			long long temp = (Nn * Mm * 2) % 1000000007;
			printf("%lld\n", temp);
		} else {
			long long temp = (Nn * Mm) % 1000000007;
			printf("%lld\n", temp);
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for (int i=0;i<m;i++)b[i]=sc.nextInt();
        int[][] a = new int[n][m];
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++)a[i][j]=sc.nextInt();
        }
        int ans = 0;
        for (int i=0;i<n;i++){
            int data = 0;
            for (int j=0;j<m;j++){
                data+=a[i][j]*b[j];
            }
            data+=c;
            if (data>0)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 37824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int ans = 0,b= 0;
	rep(i, n) {
		if (b >= a[i]) {
			b = a[i];
		}
		else {
			ans += a[i] - b;
			b = a[i];
		}
	}
	cout << ans;

	
	return 0;
}













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

int main() {
	int n;cin>>n;
	string s,s2(n+2,'a');cin>>s;
	string a(n+2,'a');
	for(int i=0;i<n;i++){
		s2[i]=s[i];
	}
	s2[n]=s[0];
	s2[n+1]=s[1];
	int flag=1;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			if(i){
				a[0]='S';
			}else{
				a[0]='W';
			}
			if(j){
				a[1]='S';
			}else{
				a[1]='W';
			}
			for(int k=2;k<n+2;k++){
				int l1,l2,l3;
				if(a[k-2]=='S'){
					l1=1;
				}else{
					l1=0;
				}
				if(a[k-1]=='S'){
					l2=1;
				}else{
					l2=0;
				}
				if(s2[k-1]=='o'){
					l3=1;
				}else{
					l3=0;
				}
				l1+=l2+l3;
				if(l1%2){
					a[k]='S';
				}else{
					a[k]='W';
				}
			}
			flag=0;
			if(a[0]==a[n]){
				if(a[1]==a[n+1]){
					flag=1;
				}
			}
			if(flag)break;
		}
		if(flag)break;
	}
	if(flag){
		for(int i=0;i<n;i++){
			cout<<a[i];
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
using ulong = unsigned long;
using ll = long long;

int main(){
	int n;
	cin >> n;
	vector<int> ls(2 * n);
	for(int i=0;i<2 * n;i++){
		cin >> ls[i];
	}
	sort(ls.begin(), ls.end());
	int ans = 0;
	for(int i=0;i<n;i++){
		ans += ls[i * 2];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
ll n;
ll d;

cin>>n>>d;
d = d*d;
ll ans = 0;

rep(i,n)
{
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=d) ans ++;
}

cout<<ans<<endl;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
#define inf (0x3f3f3f3f)
typedef long long int LL;
using namespace std;


void work() {
    int n;
    int a, b;
    int pre;
    cin >> n >> a >> b;
    cin >> pre;
    LL ans = 0;
    for (int i = 2; i <= n; ++i) {
        LL x;
        cin >> x;
        LL dis = x - pre;
        pre = x;
        ans += min(a * dis, 1LL * b);
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  string C1, C2;
  cin >> C1 >> C2;

  reverse(C2.begin(), C2.end());

  if(C1 == C2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)


Measured memory_bytes: 9196
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

l, r = getList()
if r >= l + 2019:
    r = l + 2018

# 1, 100
ans = 2020
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        tmp= (i * j) % 2019
        if tmp < ans:
            ans = tmp



print(ans)

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

int main(){
    int H, W, i;
    string s = "#";
    string p = ".";
    while (1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        i = 0;
        string oddwide = "";
        string evenwide = "";
        while (i < W){
            if (i % 2 == 0){
                oddwide += s;
                evenwide += p;
            }
            else {
                oddwide += p;
                evenwide += s;
            }
            i++;
        }
        i = 0;
        while (i < H){
            if (i % 2 == 0){
                cout << oddwide << endl;
                i++;
            }
            else {
                cout << evenwide << endl;
                i++;
            }
        }
        cout << "" << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
n = int(input())
a = list(map(int,input().split()))
b = []
if n % 2 == 0:
    for i in range(n//2):
        b.append(a[n-2*i-1])
    for i in range(n//2):
        b.append(a[2*i])
else:
    for i in range((n-1)//2):
        b.append(a[n-2-2*i])
    for i in range((n-1)//2):
        b.append(a[i*2])
    b.append(a[n-1])
    b.reverse()
for i in b:
    print(i,end=" ")

Measured memory_bytes: 26180
from collections import Counter
from math import gcd

class Prime:
    def __init__(self, N):
        smallestPrime = [1] * (N + 1)
        primes = []

        for i in range(2, N + 1):
            if smallestPrime[i] != 1:
                continue
            primes.append(i)
            for p in range(i * 2, N + 1, i):
                if smallestPrime[p] == 1:
                    smallestPrime[p] = i

        self.smallestPrime = smallestPrime
        self.primes = primes

    def isPrime(self, n):
        return n > 1 and self.smallestPrime[n] == 1

    def factorization(self, n):
        ret = Counter()
        while (p := self.smallestPrime[n]) != 1:
            ret[p] += 1
            n //= p
        if n > 1:
            ret[n] += 1
        return ret

N = int(input())
A = list(map(int, input().split()))
factorization = Prime(max(A) + 10).factorization

def isSetwise(A):
    ret = A[0]
    for a in A:
        ret = gcd(ret, a)
    return ret == 1

def isPairwise(A):
    cnt = Counter()
    for a in A:
        for p in factorization(a):
            if cnt[p] >= 1:
                return False
            cnt[p] += 1
    return True

if not isSetwise(A):
    print('not coprime')
elif isPairwise(A):
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 132944
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    map<string,int>cnt;
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        cnt[s]++;
    }
    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;
    return 0;

}





































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

using namespace std;

int main() {
    int n,a,b;
    bool fl = false;
    cin >> n;
    cin >> a >> b;
    for (int i = a; i <=b; i++) {
        if (i % n == 0) {
            cout << "OK";
            fl=true; break;
        }
    }
    if (!fl) cout << "NG";
}

Measured memory_bytes: 3636
N,M = list(map(int, input().split()))
A = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(M):
    a, b = list(map(int, input().split()))
    A[a][b] = 1
    A[b][a] = 1

br = 0
t = True
while(t):
    t = False
    for i in range(N+1):
        c = 0
        k = -1
        for j in range(len(A[i])):
            if (A[i][j] == 1):
                c += 1
                k = j
        if (c == 1):
            t = True
            A[i][k] = 0
            A[k][i] = 0
            br += 1
print(br)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    
    vector<vector<int>> ans(H, vector<int>(W));
    int idx = 0;
    for (int i = 0; i < H*W; ++i) {
        int h = i / W;
        int w = (h % 2 == 0) ? i % W : W - 1 - i % W;
        // print(h, w, idx);
        ans[h][w] = idx + 1;

        a[idx] -= 1;
        if (a[idx] == 0) idx += 1;
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << ans[i][j] << (j < W-1 ? " " : "");
        }
        cout << endl;
    }

    return 0;
}


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

vector<string> name;
vector<int> num;

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

    string tmp;
    cin >> tmp;
    name.push_back(tmp);
    num.push_back(1);

    for(int i=0; i < n-1; i++){
        cin >> tmp;
        int flag = 1;
        for(int j=0; j < (int)name.size(); j++){
            if(name[j] == tmp) {
                num[j] += 1;
                flag = 0;
            }
        }
        if(flag == 1){
            name.push_back(tmp);
            num.push_back(1);
        }
    }
//    cout << "size : " << name.size() << endl;

    cin >> m;
    for(int i=0; i < m; i++){
        tmp = "a";
        cin >> tmp;
        for(int j=0; j < (int)name.size(); j++) if(name[j] == tmp) num[j] -= 1;
    }


    int ans = 0;
    for(int i=0; i < (int)name.size(); i++) ans = max(ans, num[i]);

    cout << ans << endl;


    //debug
    //for(int i=0; i<(int)name.size(); i++) cout << name[i] << " : " << num[i] << endl;

    return 0;
}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, D = rl()
X = []
for i in range(N):
	X.append(rl())

def check(x, y):
	d = 0
	for i in range(D):
		d += (x[i]-y[i])**2
	d = d**0.5
	if d == int(d):
		return True
	return False

ans = 0
for i in range(N):
	for j in range(i+1, N):
		if check(X[i], X[j]):
			ans += 1
print(ans)

Measured memory_bytes: 69152
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int A = 0, W = 0, T = 0, R = 0;
	for(int i=0;i<N;i++){
		string S;
		cin >> S;
		if(S == "AC") A++;
		if(S == "WA") W++;
		if(S == "TLE") T++;
		if(S == "RE") R++;
	}
	cout << "AC x " << A << endl;
	cout << "WA x " << W << endl;
	cout << "TLE x " << T << endl;
	cout << "RE x " << R << endl;
}


Measured memory_bytes: 3624