akhauriyash/Code-Regression huggingface dataset:
#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  unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    ll a;
    cin>>a;
    string s;
    cin>>s;
   int b =  (s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
 
 
 
    ll ans = a*b;
 
    
 
    cout<<ans/100<<endl;
 
 
 
}

Measured memory_bytes: 3156
def factorial(n):
    x = n
    r = 1
    while x != 1:
        r *= x
        r %= d
        x -= 1
    return r

d = (10**9) + 7
n, m = map(int, raw_input().split())
if not(n-1 <= m <= n+1):
    print 0
    exit()
if n == m:
    c = factorial(n)**2 * 2 % d
else:
    c = factorial(n) * factorial(m) % d
print c


Measured memory_bytes: 2568
#include<iostream>

using namespace std;

int gcd(int,int);
int lcm(int,int);

main(){

  int a, b;

  
  while(cin >> a >> b){

    cout << gcd(a,b) << " "<<lcm(a,b) << endl;

    

  }

}


int gcd( int m, int n )
{
	// [NbhÌû@
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd


// Å¬ö{iLeast Common MultiplejðÔ·B// øÉOª éêÍOðÔ·B

int lcm( int m, int n )
{	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define F first
#define S second
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;
vector<vi> tree;
vi dp;
int solve(vi &arr, int n) {
	if (n == 1) {
		return dp[n] = 0;
	}
	if (n == 2) {
		return dp[n] = abs(arr[n] - arr[n - 1]);
	}
	int n_1;
	if (dp[n - 1] != -1) {
		n_1 = dp[n - 1];
	}
	else {
		n_1 = solve(arr, n - 1);
	}
	int n_2;
	if (dp[n - 2] != -1) {
		n_2 = dp[n - 2];
	}
	else {
		n_2 = solve(arr, n - 2);
	}
	return dp[n] = min(abs(arr[n] - arr[n - 1]) + n_1,
	                   abs(arr[n] - arr[n - 2]) + n_2);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	dp.assign(n + 1, -1);
	vi arr(n + 1); repF(i, 1, n) cin >> arr[i];
	//dp[n] = min(abs(arr[n]-arr[n-1])+dp[n-1], abs(arr[n]-arr[n-2])+dp[n-2]);
	cout << solve(arr, n) << endl;
	return 0;
}



Measured memory_bytes: 8696
#include<bits/stdc++.h>
using namespace std;
int a[55],b[55],c[55],d[55];
int ans[12];
int n,m,q;
int res=0;
void cal(){
	int ress=0;
	for(int i=1;i<=q;i++){
		if(ans[b[i]]-ans[a[i]]==c[i]) ress+=d[i];
	}
	res=max(res,ress);
}
void dfs(int id,int now){
	ans[id]=now;
	if(id==n){
		cal();
		return;
	}
	for(int i=now;i<=m;i++){
		dfs(id+1,i);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	dfs(0,1);
	printf("%d\n",res);
}

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

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

 int main() {
   int N, M;
   cin >> N >> M;
   vector<int> L(M), R(M);

   rep(i, M) cin >> L.at(i) >> R.at(i);

   int l = L.at(0), r = R.at(0);

   for (int i = 1; i < M; i++) {
     l = max(l, L.at(i));
     r = min(r, R.at(i));
   }

   cout << max(r - l + 1, 0) << endl;
 }


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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 int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n, 0);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }
    REP(i, n) cin >> b[i];
    REP(i, n - 1) cin >> c[i];
    int t = 0;
    int p = n - 1;
    REP(i, n) {
        t += b[a[i]];
        if (p + 1 == a[i]) t += c[p];
        p = a[i];
    }
    cout << t << endl;
}


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

unsigned int digit(unsigned long long u)
{
    unsigned int ret = 0;
    while(u > 0)
    {
        u = u / 10;
        ++ret;
    }
    return ret;

}

int main()
{
    unsigned int n;
    cin >> n;
    vector<unsigned long long> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    unsigned long long ans = 1;
    unsigned long long lim = 1e18;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] <= lim / ans)
        {
            ans *= a[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
       cin>>n;
        for(int i=1;i<=n;++i)
             cin>>a[i];//scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int n;
	int a[21],v[101];
	int i;
	int max=0,m;

	while(scanf("%d",&n)!=EOF){
		for(i=0;i<n;i++){
			scanf("%d %d",&a[i],&v[i]);
			if(max<v[i]){
				max=v[i];
				m=a[i];
			}
			if(max==v[i] && m>a[i]){
				m=a[i];
			}
		}
		printf("%d %d\n",m,max);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int dp[1401][1401];
	int h,w,tp,max_a=0;
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&tp);
			if(tp==1)
			dp[i][j]=0;
			else
			dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
			max_a=max(max_a,dp[i][j]);
		}
	}
	printf("%d\n",max_a*max_a);
}


Measured memory_bytes: 10856
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

Measured memory_bytes: 1096
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#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 = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	string s;
	scans(s);
	printyn(s.substr(0, 4) == "YAKI");
	
	Please AC;
}


Measured memory_bytes: 256
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let list = [for i in [1..5] -> readInt()] 
let k = readInt()

if (list.[list.Length - 1] - list.[0]) <= k then "Yay!" else ":("
|> printfn "%s"

Measured memory_bytes: 14160
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int main()
{
	int n, num, sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		sum = 0;
		
		REP(n / 4)
		{
			cin >> num;
			sum += num;
		}
		
		cout << sum << endl;
	}
	
	return 0;
}

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

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, (c1, c2) -> {
			if ( c1[1] != c2[1] ) return c1[1] - c2[1];	// 1.prefでソート
			else return c1[2] - c2[2];					// 2.yearでソート
		});

		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		for ( int i = 1; i <= m; i++ ) {
			city[i][3] = (city[i][1] == city[i - 1][1] ? city[i - 1][3] + 1 : 1);
			result[city[i][0] - 1] = df.format(city[i][1]) + df.format(city[i][3]);
		}

		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {
			sb.append(s).append("\n");
		}
		System.out.println(sb.toString());
		in.close();
	}
}

Measured memory_bytes: 101872
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto s = readln.chomp;

  auto isValid(bool[] sw)
  {
    foreach (i; 2..n)
      sw[i] = sw[i-1] ^ (s[i-1] != 'o') ^ sw[i-2];

    return ((sw[$-1] ^ (s[$-1] != 'o') ^ sw[$-2]) == sw[0] &&
            (sw[0]   ^ (s[0]   != 'o') ^ sw[$-1]) == sw[1]);
  }

  foreach (sw1; [false, true])
    foreach (sw2; [false, true]) {
      auto sw = new bool[](n);
      sw[0] = sw1;
      sw[1] = sw2;
      if (isValid(sw)) {
        foreach (swi; sw) write(swi ? 'W' : 'S');
        writeln;
        return;
      }
    }

  writeln(-1);
}


Measured memory_bytes: 2684
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<set>

using namespace std;

int main(){
	int n;
	cin>>n;
	set<int> anko;
	for(int i=0;i<n;++i){
		int x;
		cin >> x;
		anko.insert(x);
	}
	cout << anko.size() << endl;
	return 0;		
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, x;
  while (cin >> n >> x) {
    if (n == 0 && x == 0)
      break;

    int ans = 0;
    rep(i, 1, n + 1) {
      rep(j, i + 1, n + 1) {
        rep(k, j + 1, n + 1) {
          if (i + j + k == x)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3092
#include<queue>
#include<iostream>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;


int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<pair<ll, ll>> q;
	rep(i,n) {
		int a;
		cin >> a;
		q.push(make_pair(a, 1));
	}
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		q.push(make_pair(b, a));
	}
	int num = 0;
	ll ans = 0;
	while (true) {
		if (num >= n) break;
		auto p = q.top();
		q.pop();
		ans += p.first * min((ll)n - num, p.second);
		num += p.second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7460
package main
import "fmt"
var (a, b int
     c string)
func main() {
 	 
  fmt.Scan(&a,&c, &b)
  switch c[0]{
    case '+':
    fmt.Println(a+b)
    case '-':
    fmt.Println(a-b)
    case '*':
    fmt.Println(a*b)
    case '/':
    fmt.Println(a/b)
    
  }
  
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

long long gcd(long long x, long long y) {
	if (x > y)swap(x, y);
	if (x == 0)return y;
	if (y%x == 0)return x;
	return gcd(y%x, x);
}

long long pomod(long long x, long long p) {
  x=x%MOD;
	long long re = 1;
	while (p > 0) {
		if (p % 2 == 1)re = (re*x) % MOD;
		p = p / 2;
		x = (x*x) % MOD;
	}
	return re;
}

int main() {
	long long  h, w, t;
	long long x, y, z, g;
	long long xx,s, ans;
	scanf("%lld %lld %lld", &h, &w, &t);
	x = gcd(h, t);
	y = gcd(w, t);
	z = x * y;
	x = h / x;
	y = w / y;
  g=gcd(x,y);
	s = pomod((long long)2, x);
	xx = pomod((long long)2, y);
	s = (s + xx) % MOD;
	xx = pomod((long long)2, g);
	s = (s + xx) % MOD;
	s = (s + MOD - 3) % MOD;
	ans = pomod(s, z);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	Hi := make([]int, N)
	for i := range Hi {
		fmt.Scan(&Hi[i])
	}
	if N <= K {
		fmt.Println(0)
	} else {
		sort.Sort(sort.Reverse(sort.IntSlice(Hi)))
		sum := 0
		for _, val := range Hi[K:] {
			sum += val
		}
		fmt.Println(sum)
	}
}

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

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

long long a[100010][3];
long long dp[100010][3];

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) continue;
        chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  long long res = 0;
  for (int i = 0; i < 3; i++) {
    chmax(res, dp[N][i]);
  }

  cout << res << endl;
}


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

int main(){
	int n,c;
	int r=0;
	while(cin >> n && n){
		c = 0;
		vector<int> one(n);
		vector<int> two(n);
		for(int i=0;i<n;i++){
			cin >> one[i];
		}
		while(one != two){
			for(int k=0;k<one.size();k++){
				r=0;
				for(int i=0;i<one.size();i++)
					if(one[k]==one[i])r++;
				two[k]=r;
			}
			c++;
			swap(one,two);
		}
		cout << c-1 << endl;
		for(int i=0;i<n;i++){
			if(i)cout << " ";
			cout << one[i];
		}
		cout << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  ll ans = 0;
  rep(i, n) {
    cin >> a[i];
    if (i == 0) continue;

    if (a[i] < a[i-1]) {
      int diff = a[i-1] - a[i];
      a[i] = a[i] + diff;

      ans += diff;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int a;cin >> a;
  string s;cin >>s;
  if(a>=3200){
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  ll pre = 0;
  ll ans = 0;
  for (int i = 0; i < A.size(); i++){
    if (pre > 0){
      if (A[i] > 0){
        A[i]--;
        ans++;
      }
    }
    ans += A[i] / 2;
    A[i] %= 2;
    pre = A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
n, m = map(int,input().split())
coords = sorted(list(map(int,input().split())))

diff = []
for i in range(1,len(coords)):
	diff.append((coords[i]-coords[i-1], i))

diff.sort()

indexes = [x[1] for x in diff[-1:-min(n,m):-1]]

final_index = [0]
for i in indexes:
	final_index.append(i)
	final_index.append(i-1)

final_index.append(len(coords)-1)
final_index.sort()

total = 0
for i in range(1,len(final_index),2):
	total += coords[final_index[i]]-coords[final_index[i-1]]

print(total)

Measured memory_bytes: 24512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e18;
const ll inf=1e18;
const long double eps=1e-8;
const double pi=acos(-1);
unordered_map<string,int> mp;
int n;
int dfs(int ch,int zh,string s){
    if(ch==n){
        cout<<s<<'\n';
        return 0;
    }
    for(int i=0;i<zh+1;i++){
        char k='a'+i;
        string ss=s+k;
        dfs(ch+1,max(i+1,zh),ss);
    }
    return 0;
}
int main(){
    //TB
    cin>>n;
    dfs(1,1,"a");

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}


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

	ll ans = 0;
	vector<bool> S;
	char c; cin >> c;

	bool prev = (c == 'R');
	S.pb(prev);
	rep(i, N-1) {
		cin >> c;
		bool next = (c == 'R');
		if (prev == next) {
			ans++;
		}
		else {
			S.pb(next);
			prev = next;
		}
	}

	ll size = S.size();
	if (size == 1) {
		cout << ans << endl;
		return 0;
	}

	if (K < size / 2) {
		ans += K * 2;
	}
	else {
		ans += size - 1;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  bool f[40][40];
  int e,g;
  for(int i=0;i<40;i++){
    for(int j=0;j<40;j++){
      f[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    cin >> e;
    for(int j=0;j<e;j++){
      cin >> g;
      f[i][g-1]=1;
    }
  }
  int ans=m;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(f[j][i]==0){
        ans--;
        break;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
import sys
def mips():
    return map(int,input().split())
def ii():
    return int(input())
#AOJ_maximum sum
def procedure():
    N,K = mips()
    if N == 0:
        sys.exit(0)
    A = []
    res = -(10**100)
    for _ in range(N):
        a = ii()
        A.append(a)
    S = [0]
    for i in range(N):
        s = S[i] + A[i]
        S.append(s)
    for i in range(N-K):
        res = max(res,S[i+K]-S[i])
    print(res)
while True:
    procedure()


Measured memory_bytes: 13316
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;

void trace(int A[], int N) {//配列の要素の順番に出力
	for (int i = 0; i < N; ++i) {
		if (i > 0) cout << ' ';
		cout << A[i];
	}
	cout << endl;
}

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



int main() {
	int N, i;
	int A[100];

	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}

	trace(A, N);
	insertionSort(A, N);

	return 0;
}


Measured memory_bytes: 3096
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    x, n = _ia()
    p = {i: 1 for i in _ia()}

    for i in range(101):
        if p.get(x-i) is None:
            return x-i
        if p.get(x+i) is None:
            return x+i


if __name__ == "__main__":
    print(main())


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

int main(){
    char t[8] = "ACTGAC";
    char b;
    cin >> b;
    for(int i=0;i<4;i++){
        if(b==t[i]){
            cout << t[i+2];
            return 0;
        }
    }
    cout << "error";
    return 0;
}

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <stdio.h>
#include <cmath>
#include <map>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int lnko(int a, int b){
    int temp;
    while(b>0){
        temp = b;
        b = a%b;
        a = temp;
    }
    return a;
}

int main() {
	int n,k;
	cin >> n >> k;
	vi arr(n);
	int gcd = 0;
	int biggercount = 0;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		gcd = lnko(arr[i],gcd);
		if(arr[i] == k) {
			cout << "POSSIBLE";
			return 0;
		}
		if(arr[i] > k) {
			biggercount++;
		}
	}
	if(k%gcd == 0 && biggercount > 0) {
		cout << "POSSIBLE";
	} else {
		cout << "IMPOSSIBLE";
	}
	return 0;
}



Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vi p(n);
    vvi p_(n);
    rep(i, n-1) {
        cin >> p[i+1];
        --p[i+1];
        p_[p[i+1]].push_back(i+1);
    }
    vi x(n);
    rep(i, n) {
        cin >> x[i];
    } 

    stack<int> topo;
    queue<int> q;
    topo.push(0);
    q.push(0);
    while(!q.empty()) {
        int now = q.front();
        q.pop();
        for(int x:p_[now]) {
            q.push(x);
            topo.push(x);
        }
    }


    bool ok = true;

    vector<vector<P> > dp(n);
    rep(i, n) {
        int now = topo.top();
        topo.pop();


        if(p_[now].empty()) {
            dp[p[now]].push_back(P(0, x[now]));
        } else {
            int num = dp[now].size();
            vi data(num);
            int sum = 0;
            int sum_ = 0;
            rep(j, num) {
                data[j] = dp[now][j].second - dp[now][j].first;
                sum += dp[now][j].first;
                sum_ += dp[now][j].second;
            }
            if(sum > x[now]) {
                ok = false;
                break;
            } else if(sum == x[now]) {
                if(now == n-1) break;
                dp[p[now]].push_back(P(sum, sum_));
                continue;
            } else {
                if(now == n-1) break;
                vi dp_(x[now]-sum+1, -1);
                dp_[0] = 0;
                rep(j, num) {
                    rep(k_, x[now]-sum+1-data[j]) {
                        int k = x[now]-sum-k_;
                        if(dp_[k-data[j]] != -1) {
                            dp_[k] = 0;
                        }
                    }
                }
                int ma = 0;
                rep(j, x[now]-sum+1) {
                    if(!dp_[j]) ma = j;
                }
                sum = x[now];
                sum_ -= ma;
                if(sum > sum_) swap(sum, sum_);
                dp[p[now]].push_back(P(sum, sum_));

                //cout << sum << ' ' << sum_ << endl;
            }
            
        }
    }

    cout << (ok ? "POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

const int CMax = 120002;
const int CVMax = 31;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, k;
int A[CMax], P[CVMax];
int res;

long long gcd(long long a, long long b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}



int main()
{
    scanf("%d", &n);
    printf("%d\n", n * n * n);

    return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :axp
Created Time  :2016/9/24 20:07:59
TASK		  :B.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
int n,m;
int T;
int ar[N];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		ar[i]=x;
		if(ar[x]==i)
			ans++;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main (void) {
  int i, j;
  
  char S[256];
  scanf ("%s", S);
  
  for (i = 0; S[i]!='\0'; ++i);
  
  for (j = 0; j < i; j++){
    printf ("x");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

constexpr int Nmax = 100000;
int N, M, S[2];
int U[Nmax], V[Nmax];
vector<int> to[100000];
lint C[2][Nmax], d[2][Nmax];

int main()
{
    scanf("%d%d%d%d", &N, &M, &S[0], &S[1]);
    S[0]--;
    S[1]--;
    REP(e, M)
    {
        int u, v, a, b;
        scanf("%d%d%d%d", &u, &v, &a, &b);
        U[e] = u - 1;
        V[e] = v - 1;
        C[0][e] = a;
        C[1][e] = b;
        to[u - 1].push_back(e);
        to[v - 1].push_back(e);
    }

    REP(i, 2)
    {
        REP(j, N) d[i][j] = 1E15;
        d[i][S[i]] = 0;
        priority_queue<plint, vector<plint>, greater<plint>> pq;
        for (auto e : to[S[i]]) pq.push(plint(C[i][e], U[e] + V[e] - S[i]));

        while (!pq.empty())
        {
            auto pa = pq.top();
            pq.pop();
            int now = pa.second;
            if (d[i][now] > pa.first)
            {
                d[i][now] = pa.first;
                for (auto e : to[now])
                {
                    int nxt = U[e] + V[e] - now;
                    if (d[i][nxt] > d[i][now] + C[i][e]) pq.push(plint(d[i][now] + C[i][e], nxt));
                }
            }
        }
    }

    lint ans[Nmax];
    lint tmp_cost = 1E15;
    IREP(i, N)
    {
        tmp_cost = min(tmp_cost, d[0][i] + d[1][i]);
        ans[i] = tmp_cost;
    }
    REP(i, N) printf("%lld\n", (lint)1E15 - ans[i]);
}


Measured memory_bytes: 12148
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
b = Hash.new(0)
n.times do |i|
  b[a[i]] += 1
end
m = 0
for i in a[0]..a[-1]
  m = [m,b[i-1]+b[i]+b[i+1]].max
end
p m

Measured memory_bytes: 16112
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>

using namespace std;

int main(){
	int n;
	cin>>n;
	long long arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	long long sum;
	for(int i=0;i<n-1;i=i+2)
		sum += arr[i] - arr[i+1];
	sum += arr[n-1];
	long long ans[n] = {0};
	ans[0]= sum;
	for(int i=1;i<n;i++){
		ans[i] = 2*arr[i-1] - ans[i-1];
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 2816
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;

    if(n<1000)
        cout<<"ABC"<<endl;
    else
        cout<<"ABD"<<endl;
        
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  string c,d;
  cin>>a>>b;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=b;j++){
      cin>>c;
      if(c=="snuke"){
        d=64+j;
        cout<<d<<i<<"\n";
      }
    }
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	text := []byte(scanner.Text())

	for i := 0; i < len(text)-1; i++ {
		if text[i] == 0x41 && text[i+1] == 0x43 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

using i64 = long long int;

int main(){
    i64 n, m, d;
    cin >> n >> m >> d;
    printf("%.10Lf\n",(d==0?1.0:2.0)*(n-d)*(m-1)/(long double)(n*n));

    return 0;
}


Measured memory_bytes: 256
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "is_unsearched", "is_unreachable", "dist"]

    def __init__(
        self, height: int, width: int, grid: List[bytes], road: str = ".",
    ) -> None:
        self.height = height + 4
        self.width = width + 4
        self.is_unsearched = 1 << 30
        self.is_unreachable = -1
        self.dist = self._convert_grid_to_dist(grid, road)

    def _convert_grid_to_dist(self, grid: List[bytes], road: str) -> List[int]:
        """Convert a 2D grid to a 1D dist."""
        dist = [self.is_unreachable] * self.height * self.width
        i = self.width * 2 + 1
        for row in grid:
            for c in row.decode():
                i += 1
                if c == road:
                    dist[i] = self.is_unsearched
            i += 4
        return dist

    def _flatten_coordinate(self, x: int, y: int) -> int:
        """Flatten 2D coordinate values.
        Values of a coordinate must be 1-origin.
        """
        return self.width * (x + 1) + y + 1

    def bfs(self, start_2d: Tuple[int, int], goal_2d: Tuple[int, int]) -> int:
        """BFS to compute the distance from start to goal.
        Values of start_2d and goal_2d must be 1-origin.
        """
        start = self._flatten_coordinate(*start_2d)
        goal = self._flatten_coordinate(*goal_2d)

        w = self.width
        walk_to_warp = {
            -w: (-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -w - 1),
            w: (w + 1, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2),
            -1: (-w - 2, -2, w - 2, w - 1, 2 * w - 2),
            1: (-w + 1, -2 * w + 2, -w + 2, 2, w + 2),
        }

        dist = self.dist[:]
        dist[start] = 0
        queue = deque([start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]
            if x == goal:
                break

            for walk, warp in walk_to_warp.items():
                nx = x + walk
                if dist[nx] > cur_dist:
                    dist[nx] = cur_dist
                    queue.appendleft(nx)
                    continue
                if dist[nx] >= 0:
                    continue

                for dx in warp:
                    nx = x + dx
                    if dist[nx] > cur_dist + 1:
                        dist[nx] = cur_dist + 1
                        queue.append(nx)

        return dist[goal] if dist[goal] != self.is_unsearched else self.is_unreachable


def main():
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline

    H, W = map(int, readline().split())
    (*start,) = map(int, readline().split())
    (*goal,) = map(int, readline().split())
    (*S,) = read().split()

    maze = WarpableMaze(H, W, S)
    print(maze.bfs(start, goal))


if __name__ == "__main__":
    main()


Measured memory_bytes: 96832
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
bool dpX[2][16001];
bool dpY[2][16001];
int main() {
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	int pos = 0;
	while (pos < s.size() && s[pos] == 'F') x--, pos++;
	vector<int> vx, vy;
	bool dir = 0;
	int d = 0;
	while (pos < s.size()) {
		if (s[pos] == 'T') {
			if (dir) vy.push_back(d);
			else vx.push_back(d);
			d = 0;
			dir ^= 1;
		}
		else {
			d++;
		}
		pos++;
	}
	if (dir) vy.push_back(d);
	else vx.push_back(d);
	dpX[0][8000] = 1;
	for (int i = 0; i < vx.size(); i++) {
		for (int j = 0; j <= 16000; j++) dpX[(i + 1) % 2][j] = 0;
		for (int j = 0; j <= 16000; j++) {
			if (j + vx[i] <= 16000) dpX[(i + 1) % 2][j + vx[i]] |= dpX[i % 2][j];
			if (j - vx[i] >= 0) dpX[(i + 1) % 2][j - vx[i]] |= dpX[i % 2][j];
		}
	}
	dpY[0][8000] = 1;
	for (int i = 0; i < vy.size(); i++) {
		for (int j = 0; j <= 16000; j++) dpY[(i + 1) % 2][j] = 0;
		for (int j = 0; j <= 16000; j++) {
			if (j + vy[i] <= 16000) dpY[(i + 1) % 2][j + vy[i]] |= dpY[i % 2][j];
			if (j - vy[i] >= 0) dpY[(i + 1) % 2][j - vy[i]] |= dpY[i % 2][j];
		}
	}
	if (dpX[vx.size() % 2][x + 8000] && dpY[vy.size() % 2][y + 8000]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
while True:
    x,y = map(int,input().split())
    if x == 0 and y == 0:
        break

    for i in range(x):
        for j in range(y):
            if i == 0 or i == x-1 or j == 0 or j == y-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
package main

import "fmt"

func main() {
	var n, k int
	var a []int

	fmt.Scan(&n, &k)
	var tmp int
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		a = append(a, tmp)
	}

	ans := 0
	for _, v := range a {
		if v >= k {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define all(x) (x).begin(),(x).End()
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define pb(x) push_back(x)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
using std::bitset;
typedef long long ll;
const ll maxn=1e6+5;
const ll mod=998244353;
const ll INF=0x3f3f3f3f3f3f3f3f;
const long double PI=acos(-1.0);
const long double eps=1e-5;
inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

bool a[100010];
int b[100010];

int main()
{
   int n,m;
   cin>>n>>m;
   mem(a); mem(b);
   int numac=0,numfa=0;
   int x;
   string s;
   for(int i=0;i<m;i++)
   {
       cin>>x>>s;
       if(s=="AC")
       {
           if(a[x]==0)
           {
               numac++;
               a[x]=1;
               numfa+=b[x];
           }
       }
       else
       {
           if(a[x]==1)
            continue;
           else
            b[x]++;
       }
   }
   cout<<numac<<" "<<numfa;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int	main(void)
{
  	int	N;
  	int	A[21];
  	int	B[21];
  	int	C[21];
	int	num;
  	int	i;
  	int	sum;
  	int pre;
  
  	num = scanf("%d\n", &N);
  	if (num != 1)
      	return (0);
  
    A[0] = 0;
  	for (i=1; i<=N; i++)
    {
      	num = scanf("%d", &A[i]);
      	if (num != 1)
          	return (0);
    }
  	
  	B[0] = 0;
    for (i=1; i<=N; i++)
    {
      	num = scanf("%d", &B[i]);
      	if (num != 1)
          	return (0);
    }
  	
  	C[0] = 0;
  	for (i=1; i<=N-1; i++)
    {
      	num = scanf("%d", &C[i]);
      	if (num != 1)
          	return (0);
    }
  	
  	pre = 0;
  	sum = 0;
  	for (i=1; i<=N; i++)
    {
      	sum += B[A[i]];
      	if (pre == A[i] - 1)
          	sum += C[A[i] - 1];
        pre = A[i];
    }
  	
  	printf("%d", sum);
  	return (0);
}

Measured memory_bytes: 128
K=int(input())

X=[0]*K
m=0
p=7
for i in range(K):
  m=(m+p)%K
  if m==0:
    print(i+1)
    break
  elif X[m]==1:
    print(-1)
    break
  else:
    X[m]=1
  p=(p*10)%K

Measured memory_bytes: 16476
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

void shit() {
    int n; cin >> n;
    string ans = "";
    if(!n) {
        cout << "0\n";
        return;
    }
    for(int rem;n;rem < 0 ? rem += 2, ++n: rem += 0) {
        rem = n%(-2);
        n /= -2;
        ans += to_string(abs(rem));
    }
    reverse(all(ans));
    cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;


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

    ll n;
    cin>>n;
    ll ar[n];
    for(ll i=0;i<n;++i){cin>>ar[i];}
    ll dp[n];
    dp[0]=0;
    for(ll i=1;i<n;++i)
    {
        if(i==1){
            dp[i]=dp[i-1]+abs(ar[i]-ar[i-1]);
        }
        else
        {
            dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i-2]-ar[i]));
        }
    }
    cout<<dp[n-1]<<endl;

    return (0);
}


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

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

int main(){
	int nex[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
	while(1){
		string s;
		cin>>s;
		if(s=="#")break;
		
		int loc=0;
		rep(i,s.size()){
			loc=nex[loc][s[i]-48];
			if(loc==-1)break;
		}
		if(loc==5)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	int ans = INT_MAX;
	for (int i = 0; i < N - K + 1; i++) {
		int L, R;
		L = v.at(i);
		R = v.at(i + K - 1);

		int dist = 0;
		if ((L < 0) && (R > 0)) {
			dist = min(abs(L), abs(R)) * 2 + max(abs(L), abs(R));
		}
		else {
			if (R < 0) dist = abs(L);
			else dist = abs(R);
		}

		ans = min(ans, dist);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int k; cin>>k;
    int a,b; cin>>a>>b;
    for (int i = a; i <= b; ++i) {
        if (i%k==0) {
            cout << "OK" << '\n';
            return 0;
        }
    }
    cout << "NG" << '\n';
    return 0;
}

Measured memory_bytes: 3588