akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int check(int x){
    if(x<0 || x > 9)
        return 0;
    return 1;
}
int main(void){
    int map[10][10]={0};
    int large[13][2]={{0,-2},{-1,-1},{0,-1},{1,-1},{-2,0},{-1,0},{0,0},{1,0},{2,0},{-1,1},{0,1},{1,1},{0,2}};
    int middle[9][2]={{-1,-1},{0,-1},{1,-1},{-1,0},{0,0},{1,0},{-1,1},{0,1},{1,1}};
    int small[5][2]={{0,-1},{-1,0},{0,0},{1,0},{0,1}};
    int x,y,s,place,i,o,max=0,sum=0;
    while(scanf("%d,%d,%d",&x,&y,&s) != EOF){
        if(s == 1){
            for(i=0;i<5;i++){
                    if(check(x+small[i][0]) == 1 && check(y+small[i][1]) == 1){
                        map[y+small[i][1]][x+small[i][0]] ++;
                    }
            }
        }
        if(s == 2){
            for(i=0;i<9;i++){
                    if(check(x+middle[i][0]) == 1 && check(y+middle[i][1]) == 1){
                        map[y+middle[i][1]][x+middle[i][0]] ++;
                    }
            }
        }
        if(s == 3){
            for(i=0;i<13;i++){
                    if(check(x+large[i][0]) == 1 && check(y+large[i][1]) == 1){
                        map[y+large[i][1]][x+large[i][0]] ++;
                    }
            }
        }
    }
    for(i=0;i<10;i++){
        for(o=0;o<10;o++){
            if(map[i][o] == 0)
                sum++;
            if(max < map[i][o])
                max=map[i][o];
        }
    }
    printf("%d\n%d\n",sum,max);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n)
    { i=m*n;
      i-=(m+n);
      i++;
      if(m==0||n==0)i=0;
      cout<<i<<endl;

    }
    return 0;
}


Measured memory_bytes: 3572
// ABC 85 B

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

typedef long long ll;

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; }
const long long INF = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    cin >> d[i];
  }
  sort(d.begin(), d.end(), greater<int>());
  int ans = 0;
  int top = 101;
  rep(i, n) {
    if (d[i] < top) {
      ans++;
      top = d[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

#
# Tips:
# - Use pbcopy command to copy this file to clipboard.
#

################################################################################

import math
from math import *
from math import factorial as fact
import itertools
from functools import reduce
#import numpy
#import scipy, scipy.special

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def gcd_multi(l):
    return reduce(lambda x, y: gcd(x, y), l)

def input_ints(inp = input, sep = ' ', conv = lambda x: int(x)):
    return [conv(x) for x in inp().split(sep = sep)]

################################################################################

N = input_ints()
A = input_ints()

print(gcd_multi(A))


Measured memory_bytes: 14868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  int count = 0;
  for(int i=0; i<N; i++){
    if(i%2 == 0){
      if(a.at(i)%2 != 0){
        count += 1;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    for (i <- 1 to n) {
      if (math.pow(2, i) > n) {
        println(math.pow(2, i - 1).toInt)
        sys.exit(0)
      }
    }
  }
}


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

int main() {
   int N;
   cin >> N;
   int P[N],Q[N],M[N];
   for (int i=0; i<N; i++) {
       cin >> P[i];
   }
   for (int i=0; i<N; i++) {
       cin >> Q[i];
   }
   for (int i=0; i<N; i++) {
       M[i]=i+1;
   }
   int count=0;
   int a=0;
   int b=0;
   do {
       bool A=true,B=true;
       for (int i=0; i<N; i++) {
           if (M[i]!=P[i]) A=false;
           if (M[i]!=Q[i]) B=false;
       }
       if (A) a=count;
       if (B) b=count;
       count++;
   }while (next_permutation(M,M+N));
   cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		char[] a=s.next().toCharArray();

		for(int i=0;i<a.length;++i){
			int t=i%2+a[i];
			if(t=='L'||t=='S'){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
// Traveling

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int n;
int t[100000];
int x[100000];
int y[100000];

int abs(int n) {
    if (n >= 0) {
        return n;
    } else {
        return -n;
    }
}

bool reachable(int cur_t, int cur_x, int cur_y, int dst_t, int dst_x, int dst_y) {
    int dx = abs(cur_x - dst_x);
    int dy = abs(cur_y - dst_y);
    int dt = dst_t - cur_t;
    // 点curと点dstのマンハッタン距離を求める
    if ((dx + dy <= dt) && ((dt - (dx + dy)) % 2 == 0)) {
        return true;
    } else {
        return false;
    }
}

bool walk(int cur_t, int cur_x, int cur_y) {
    for (int i = 0; i < n; i++) {
        if (reachable(cur_t, cur_x, cur_y, t[i], x[i], y[i])) {
            // cout << t[i] - cur_t << "s" << endl;
            // cout << "(" << cur_x << ", " << cur_y << ") -> (" << x[i] << ", " << y[i] << ")" << endl;
            cur_t = t[i];
            cur_x = x[i];
            cur_y = y[i];
            continue;
        } else {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    if (walk(0, 0, 0)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

vector<int> cnt1(N, 0), cnt2(N, 0);
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n - 1; i += 2) {
        cnt1[a[i]]++, cnt2[a[i + 1]]++;
    }

    vector<pii> v1, v2;
    for(int i = 0; i < N; i++) {
        if(cnt1[i] != 0) {
            v1.push_back({cnt1[i], i});
        }
        if(cnt2[i] != 0) {
            v2.push_back({cnt2[i], i});
        }
    }
    sort(v1.rbegin(), v1.rend());
    sort(v2.rbegin(), v2.rend());
    int ans;
    if(v1[0].se != v2[0].se) {
        ans = n - v1[0].fi - v2[0].fi;
    }else {
        ans = INT64_MAX;
        if(sz(v1) > 1) {
            ans = min(ans, n - v1[1].fi - v2[0].fi);
        }
        if(sz(v2) > 1) {
            ans = min(ans, n - v1[0].fi - v2[1].fi);
        }
        if(sz(v1) == sz(v2) && sz(v1) == 1){
            ans = n / 2;
        }
    }
    cout << ans << "\n"; 
}

Measured memory_bytes: 5876
#include<stdio.h>
#include<string.h>

#define YES "Yes"
#define NO "No"

int main()
{
    int id_s_num = 0;
    int id_t_num = 0;
    char id_s[15];
    char id_t[256];

    scanf("%s", id_s);
    scanf("%s", id_t);

    id_s_num = strlen(id_s);
    id_t_num = strlen(id_t);

    if (((id_t_num - id_s_num) == 1)&&(strncmp(id_s, id_t, id_s_num) == 0))
        printf("Yes");
    else
        printf("No");

    return 0;
}

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

int main(){
    vector<int>s(13,0), h(13,0), c(13,0), d(13,0);
    int n;
    cin >> n;
    for(int i=0; i < n; i++){
        char a;
        cin >> a;
        int b;
        cin >> b;
        if(a == 'S')s[b-1] = 1;
        else if(a == 'H')h[b-1] = 1;
        else if(a == 'C')c[b-1] = 1;
        else if(a == 'D')d[b-1] = 1;
    }
    for(int i=0; i < 13; i++)if(s[i]==0)cout << "S " << i+1 << endl;
    for(int i=0; i < 13; i++)if(h[i]==0)cout << "H " << i+1 << endl;
    for(int i=0; i < 13; i++)if(c[i]==0)cout << "C " << i+1 << endl;
    for(int i=0; i < 13; i++)if(d[i]==0)cout << "D " << i+1 << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main() {
   int x,y;
   scanf("%d%d",&x,&y);
   if(x>y) swap(x,y);
   x = (x==1 ? 1 : x-2);
   y = (y==1 ? 1 : y-2);
   printf("%lld",(long long)x*y);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	if(a==5&&b==5&&c==7 || a==5&&b==7&&c==5 || a==7&&b==5&&c==5){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

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

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

  int d = n.length();
  int f = 0;
  for (int i = 0; i < d; i++) {
      string k = n[i] + ""s;
      int m = stoi(k);
      f += m;
  }
  
  if (stoi(n) % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let s: Vec<u32> = buf
        .trim()
        .chars()
        .map(|c| c.to_digit(10).unwrap())
        .collect();

    let mut cnt = 0;
    for i in 0..s.len() {
        if i % 2 == s[i] as usize {
            cnt += 1;
        }
    }
    println!("{}", std::cmp::min(cnt, s.len() - cnt));
}


Measured memory_bytes: 4352
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n;
vector<p> LR;
template <class V, int NV>
struct SegTree
{ //[l,r) rは含まないよ!
    V comp(V &l, V &r) { return min(l, r); };

    vector<V> val;
    SegTree() { val = vector<V>(NV * 2, INF); }
    //xy間の最小値をとる
    V get(int x, int y, int l = 0, int r = NV, int k = 1)
    {
        if (r <= x || y <= l)
            return INF;
        if (x <= l && r <= y)
            return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2);
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v)
    {
        i += NV;
        val[i] = v;
        while (i > 1)
            i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp, temp1;
        cin >> temp >> temp1;
        LR.push_back(make_pair(temp, temp1 + 1));
    }
    sort(ALL(LR));
    ll ans = 0;
    SegTree<ll, 1 << 17> st;
    for (int i = 0; i < n; i++)
    {
        st.update(i, LR[i].second);
    }
    for (int i = 0; i < n - 1; i++)
    {
        ll temp = st.get(0, i + 1) - LR[i].first;
        if (temp < 0)
        {
            temp = 0;
        }
        ll sum = temp;
        temp = st.get(i + 1, n) - LR[n - 1].first;
        if (temp < 0)
        {
            temp = 0;
        }
        sum += temp;
        chmax(ans, sum);
        temp = min(st.get(0, i), st.get(i + 1, n)) - LR[n - 1].first;
        sum = max(ll(0), temp);
        sum += LR[i].second - LR[i].first;
        chmax(ans, sum);
    }
    cout << ans << "\n";
}


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

int main () {
    string S;
    int N;

    cin >> N >> S;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] + N > 'Z') cout << (char)(S[i] + N - 26);
        else cout << (char)(S[i] + N);
    }

    cout << endl;

    return 0;
}

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

using namespace std;

int main(void)
{
    int N, flug = 0, diff = 0;
    vector<int> score(2);
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i)
        cin >> vec[i];
    while (!vec.empty())
    {
        auto tmp = max_element(vec.begin(), vec.end());
        score[flug] += *tmp;
        vec.erase(tmp);
        flug = (flug + 1) % 2;
    }
    diff = score[0] - score[1];

    cout << diff << "\n";
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
for i in range(n-1):
    if a[i]==a[i+1]:
        a[i+1]=0
    else:
        a[i]=0
a.sort()
a.reverse()
print(a[0]*a[1])


Measured memory_bytes: 14252
#include "bits/stdc++.h"

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}

void Main() {
	ll N;
	cin >> N;

	string name;
	ll tempN = N;
	while(tempN > 0) {
		tempN--;
		name += (tempN % 26) + 'a';
		tempN /= 26;
	}
	reverse(name.begin(), name.end());
	cout << name << endl;
}




int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  map<ll, int> maked;
  rep(i, n) {
    ll x; cin >> x;
    ++maked[x];
  }
  int m; cin >> m;
  map<ll, int> nec;
  rep(i, m) {
    ll x; cin >> x;
    ++nec[x];
  }
  for(auto x : nec) {
    if(x.second > maked[x.first]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 28528
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
set < pair < int , int > > s[1 << 20];
map < pair < int , int > , int > D;
priority_queue < pair < int , pii > , vector < pair < int , pii > > , greater < pair < int , pii > > > Q;
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    scanf("%d%d",&n,&m);
    vector < pair < int , int > > Go;
    while (m --)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        s[a].insert({c,b});
        s[b].insert({c,a});
        if (a == 1 && !D.count({a,c}))
            D[{a,c}] = 1,Q.push({1,{a,c}}),Go.push_back({a,c});
        if (b == 1 && !D.count({b,c}))
            D[{b,c}] = 1,Q.push({1,{b,c}}),Go.push_back({b,c});
    }
    function < void(int,int,int) > get_equal = [&](int a,int b,int was)
    {
        do
        {
            auto it = s[a].lower_bound({b,-1});
            if (it != s[a].end() && it->x == b)
                {
                    int X = it->y,Y = it->x;
                    s[a].erase(it);
                    if (!D.count({X,Y}) || D[{X,Y}] > was) D[{X,Y}] = was,Q.push({was,{X,Y}}),get_equal(X,Y,was);
                }
            else break;
        } while (!s[a].empty());
    };
    for (auto it : Go)
        get_equal(it.x,it.y,1);
    int was = 0;
    while (!Q.empty())
    {
        auto node = Q.top().y;
        Q.pop();
        was = D[node];
        while (!s[node.x].empty())
        {
            auto it = *s[node.x].begin();
            swap(it.x,it.y);
            s[node.x].erase(s[node.x].begin());
            if (D.count(it)) continue;
            D[it] = was + 1;
            Q.push({was+1,it});
            get_equal(it.x,it.y,was+1);
        }
    }
    int ans = 1e9;
    for (auto it : D)
        if (it.x.x == n)
            ans = min(ans,it.y);
    if (ans == 1e9) return puts("-1") * 0;
    fo << ans << '\n';

    return 0;
}

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

typedef long long ll;

int main(){
    vector<int> x(4), y(4);
    cin >> x[0] >> y[0];
    cin >> x[1] >> y[1];
    
    int dx, dy;
    dx = x[1]-x[0];
    dy = y[1]-y[0];
    x[2] = x[1] - dy;
    y[2] = y[1] + dx;
    
    x[3] = x[2] - dx;
    y[3] = y[2] - dy;
    
    cout << x[2] <<" " << y[2] << " " << x[3] <<" " << y[3] << endl;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 998244353;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)


template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,s;
  cin >> n >> s;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  vector<vector<mint>> dp(n+1,vector<mint>(s+1,0));
  dp[0][0] = 1;
  REP(i,n){
    REP(j,s+1){
      dp[i+1][j] += dp[i][j] * 2;
      if(j + a[i] <= s)
        dp[i+1][j+a[i]] += dp[i][j];
    }
    
  }
  // REP(i,n+1){
  //   REP(j,s+1){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  ANS(dp[n][s]);
  return 0;
}

Measured memory_bytes: 73592
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
typedef long long ll;

using namespace std;


int main() {
	ll n, k; cin >> n >> k;
	string s; cin >> s;
	ll cut = 1;
	vector<ll> v0;
	vector<ll> v1;
	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			cut++;
		}
		else {
			if (s[i] == '0') v0.emplace_back(cut);
			if (s[i] == '1') v1.emplace_back(cut);
			cut = 1;
		}
	}
	if (s[n-1] == '0') v0.emplace_back(cut);
	if (s[n-1] == '1') v1.emplace_back(cut);
	ll len0 = v0.size();
	ll len1 = v1.size();
	if (len0 <= k) {
		cout << n << endl;
		exit(0);
	}
	ll ans = 0;
	ll pre_ans = 0;
	ll s0 = 0;
	if (s[0] == '1')s0 = 1;
	rep(i, k) {
		pre_ans += v0[i];
		if (i < len1) pre_ans += v1[i];
	}
	if (k < len1 && s0 == 1) pre_ans += v1[k];
	ans = pre_ans;
	rep(i, len0 - k) {
		pre_ans -= v0[i];
		if(0<= i - 1 + s0) pre_ans -= v1[i-1+s0];
		pre_ans += v0[i + k];
		if(i+k+s0<len1) pre_ans += v1[i + k + s0];
		ans = max(ans, pre_ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1404
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
print(N**3)


Measured memory_bytes: 4328
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> hs(n);
	for(auto &h : hs) cin >> h;
	int answer = 0;
	for(int i = 1; i < n; ++i)
	{
		ld current = t - hs[i] * 0.006, last = t - hs[answer] * 0.006;
		if(abs(a - current) < abs(a - last)) answer = i;
	}
	cout << answer + 1 << '\n';
}

Measured memory_bytes: 3612
import heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

N, M = LI()
A = LI()
BC = [LI() for _ in range(M)]
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)
BC = sorted(BC, key=lambda x: x[1])[::-1]
#print(BC)
#print(A)
k = int(0)
ansC = int(0)
ansA = heapq.heappop(A)*(-1)
for i in range(N):
    if k<M and BC[k][0]==0:
        k +=1
    if k<M and BC[k][1]>ansA:
        ansC = BC[k][1]
        BC[k][0] -=1
    else:
        ansC = ansA
        if A!=[]:
            ansA = heapq.heappop(A)*(-1)
    ans.append(ansC)

#print(ans)
print(sum(ans))



Measured memory_bytes: 35344
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans[301][301], d[301][301], oil[301][301];

	REP(i, 301) REP(j, 301){
		ans[i][j] = INF;
		d[i][j] = INF;
		oil[i][j] = INF;
	} 
	int n, m, l, a, b, c;
	cin >> n >> m >> l;
	REP(i, m){
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
		ans[a][b] = 0;
		ans[b][a] = 0;

	}
	REP1(k, n){
		REP1(i, n){
			REP1(j, n){
				if(d[i][j] > d[i][k] + d[k][j]){
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
	REP1(i, n){
		REP1(j, n){
			if(d[i][j] <= l) oil[i][j] = 1; 
		}
	}
	REP1(k, n){
		REP1(i, n){
			REP1(j, n){
				if(oil[i][j] > oil[i][k] + oil[k][j]){
					oil[i][j] = oil[i][k] + oil[k][j];
				}
			}
		}
	}
	int q, s, t;
	cin >> q;
	REP(i, q){
		cin >> s >> t;
		if(oil[s][t] != INF)cout << oil[s][t]-1 << endl;
		else cout << -1 << endl;
	}

    
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n;i++) {
		cin >> p[i];
		p[i]--;
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		
		if (p[i] == i) {
			if ((i <( n - 1) && p[i + 1] ==( i + 1)) || i == 0) {
				swap(p[i], p[i + 1]);
			}
			else {
				swap(p[i], p[i - 1]);
			}

			cnt++;
		}
	}

	cout << cnt << endl;
	
}


Measured memory_bytes: 640
#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 n, m;
    cin >> n >> m;

    vector<int> b;
    rep(i, n) b.push_back(0);
    rep(i, m) b.push_back(1);

    int ans = 0;
    rep(i, b.size()) rep(j, i)
    {
        int sum = b[i] + b[j];
        if (sum % 2 == 0)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n, s;
    cin>>n;
    long long ans = 0;
    for(int i = 1; i < n; i++){
        ans += i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<stdio.h> 
#include<bitset> 
#include<iomanip> 
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
	while (b) {
		ll mod = a % b; a = b; b = mod;
	}
	return a;
}

bool cmp(pair<int, ll> A, pair<int, ll> B) {
	return A.second < B.second;
}
int main() {
	int n;
	double k = 0.5000;
	cin >> n;
	float q = n;
	//cout << q<<" \n";
	if (n & 1) {
		q = (((q - 1) / 2) + 1) / q;
		cout <<setprecision(6) << q;
	}
	else {
		cout << k;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 11451481;
const int MOD = 1000000007;
const double EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator >(const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, int cost)
{
	g[from].push_back(Edge{from, to, cost});
}

/*--------------------template--------------------*/
void dijkstra(Graph &g, vector<Weight> &d, int s)
{
	d.assign(g.size(), INF);
	d[s] = 0;
	typedef pair<Weight, int> P;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		Weight dist = que.top().first;
		int v = que.top().second;
		que.pop();
		if (d[v] < dist) continue;
		REP(i, g[v].size())
		{
			Edge e = g[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int idx(int v, int c, int n) { return n*c + v; }

int main()
{
	int n, m, c, st, go;
	while (cin >> n >> m >> c >> st >> go, n)
	{
		st--; go--;
		vector<Matrix> d(c, Matrix(n, Array(n)));
		REP(i, c)REP(j, n)REP(k, n) d[i][j][k] = (j == k ? 0 : INF);
		REP(i, m)
		{
			int x, y, dist, com;
			cin >> x >> y >> dist >> com;
			x--; y--; com--;
			d[com][x][y] = d[com][y][x] = min(dist, d[com][x][y]);
		}
		REP(l, c)REP(k, n)REP(i, n)REP(j, n) chmin(d[l][i][j], d[l][i][k] + d[l][k][j]);
		Graph g(n*c);
		REP(i, n)
		{
			REP(j, c)REP(k, j)
			{
				add_edge(g, idx(i, j, n), idx(i, k, n), 0);
				add_edge(g, idx(i, k, n), idx(i, j, n), 0);
			}
		}
		vi p(c);
		REP(i, c) cin >> p[i];
		REP(i, c)
		{
			vi q(p[i] - 1), r(p[i]);
			REP(j, p[i] - 1) cin >> q[j];
			REP(j, p[i]) cin >> r[j];
			REP(j, n)REP(k, j)
			{
				int dist = d[i][j][k];
				int cost = 0;
				int res = dist;
				for (int l = 0; l < p[i]-1; l++)
				{
					if (dist < q[l])
					{
						cost += r[l] * res;
						res = 0;
						break;
					}
					else
					{
						int ad = q[l] - (l == 0 ? 0 : q[l - 1]);
						cost += ad*r[l];
						res -= ad;
					}
				}
				if (res > 0) cost += res*r.back();
				add_edge(g, idx(j, i, n), idx(k, i, n), cost);
				add_edge(g, idx(k, i, n), idx(j, i, n), cost);
			}
		}
		Array ans(g.size());
		dijkstra(g, ans, st);
		cout << (ans[go] >= INF ? -1 : ans[go]) << endl;
	}
	return 0;
}

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

int main() {
  int N; cin >>N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >>a.at(i);
  int i=1;
  for(int j=0; j<N; j++){
    i=a.at(i-1);
    if(i==2){
      cout <<j+1<<endl;
      break;
    }
    if(i!=2 && j==N-1) cout <<"-1"<<endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>

typedef struct{
	int t_num;
	int score;
}t_team;

int main(void){
	t_team team[100000];
	int num = 0;
	int q;

	while(1){
		scanf("%d,%d", &(team[num].t_num), &(team[num].score));
		if(team[num].t_num == 0 && team[num].score == 0) break;
		num++;
	}
	for(int i=num-1; i>0; i--){
		for(int j=0; j<i; j++){
			if(team[j].score < team[j+1].score){
				t_team temp = team[j];
				team[j] = team[j+1];
				team[j+1] = temp;
			}
		}
	}

	while(scanf("%d", &q) != EOF){
		int before = -1;
		int rank = 0;
		for(int i=0; i<num; i++){
			if(team[i].score != before){
				rank++;
				before = team[i].score;
			}
			if(team[i].t_num == q){
				printf("%d\n", rank);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, k, start;
  string s;
  cin >> n >> k >> s;
  if (s[0] == '0')
    start = 0;
  else
    start = 1;
  char f = s[0];
  int cnt = 0;
  vector<int> res;
  rep(i, n) {
    if (s[i] == f)
      cnt++;
    else {
      res.push_back(cnt);
      cnt = 1;
      f = s[i];
    }
  }
  res.push_back(cnt);
  // rep(i, res.size()) cout << res[i] << endl;
  int ans = 0;
  if (start == 1) {
    if (res.size() / 2 <= k) {
      rep(i, res.size()) ans += res[i];
      cout << ans << endl;
      return 0;
    }
    for (int i = 0; i < res.size() - 2 * k; i += 2) {
      int tmp = 0;
      for (int j = i; j < i + 2 * k + 1; ++j) tmp += res[j];
      ans = max(ans, tmp);
    }
    int tmp = 0;
    for (int j = res.size() - 1; j >= res.size() - 2 * k; --j) tmp += res[j];
    ans = max(ans, tmp);
  } else {
    if ((res.size() + 1) / 2 <= k) {
      rep(i, res.size()) ans += res[i];
      cout << ans << endl;
      return 0;
    }
    for (int i = 1; i <= res.size() - 1 - 2 * k; i += 2) {
      int tmp = 0;
      for (int j = i; j < (i + 2 * k + 1); ++j) tmp += res[j];
      ans = max(ans, tmp);
    }
    int tmp = 0;
    for (int j = res.size() - 1; j >= res.size() - 2 * k; --j) tmp += res[j];
    ans = max(ans, tmp);
    tmp = 0;
    for (int j = 0; j < 2 * k; ++j) tmp += res[j];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main()
{
	long long n, d,x,y,s=0;
cin >> n >> d;

for (int i=0; i<n; i++){
	cin >> x >> y;
	if (x*x+y*y<=d*d) s++;
}
cout << s;
return 0;
}



Measured memory_bytes: 3632
/*
  AOJ 1193
  Title:Chain Disappearance Puzzle
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

char ban[10][5];
int n;
void show()
{
  int i,j;
  for(i=0;i<n;i++)
    {
      for(j=0;j<5;j++)
	printf("%d|",ban[i][j]);
      printf("\n");
    }
  printf("----------\n");
}

void shrink()
{
  int i,j,k;
  char ban2[10][5];

  for(i=0;i<5;i++)
    {
      for(j=n-1,k=n-1;j>=0;j--)
	if(ban[j][i])
	  {
	    ban2[k][i]=ban[j][i];
	    k--;
	  }
      for(j=k;j>=0;j--)
	ban2[j][i]=0;
    }
  memcpy(ban,ban2,50);
}
int delete3()
{
  int sum,i,j,p,ret;
  char del[5];

  for(i=0,ret=0;i<n;i++)
    {
      p=0;
      memset(del,0,5);
      if(ban[i][0]>0 && ban[i][0]==ban[i][1] && ban[i][1]==ban[i][2])
	{
	  del[0]=del[1]=del[2]=1;
	  p=ban[i][0];
	}
      if(ban[i][1]>0 && ban[i][1]==ban[i][2] && ban[i][2]==ban[i][3])
	{
	  del[1]=del[2]=del[3]=1;
	  p=ban[i][1];
	}
      if(ban[i][2]>0 && ban[i][2]==ban[i][3] && ban[i][3]==ban[i][4])
	{
	  del[2]=del[3]=del[4]=1;
	  p=ban[i][2];
	}
    
      for(j=0;j<5;j++)
	if(del[j])
	  {
	    ban[i][j]=0;
	    ret += p;
	  }
    }
  return(ret);
}
int solve()
{
  int sum,ret;
  sum=0;
  while(ret=delete3())
    {
      //printf("ret=%d\n",ret);
      //show();
      shrink();
      sum += ret;
      //show();
    }
  return(sum);
}
main()
{
  int i,j,ret;
  while(scanf("%d ",&n) && n)
    {
      for(i=0;i<n;i++)
	for(j=0;j<5;j++)
	  {
	    scanf("%c ",&ban[i][j]);
	    ban[i][j] -= '0';
	  }
      //show();
      ret=solve();
      printf("%d\n",ret);
    }
  return(0);
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


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

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

int main() {
  long long quart,half,one,two;
  long long kounyuL;
  long long kekka = 0;
  long long oneL = 0;
  
  cin >> quart >> half >> one >> two;
  cin >> kounyuL;
  
  oneL = min({quart * 4, half * 2, one});
  kekka = min(oneL * kounyuL, two * (kounyuL / 2) + oneL * (kounyuL % 2));
  cout << kekka;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vi p(n), q(n), a(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	rep(i, n) a[i] = i + 1;
	int ps = 0, qs = 0;
	int f = 1;
	rep(i, n) f *= i + 1;
	
	for (int i = 0; i < f; i++) {
		for (int j = 0; j < n; j++) {
			if (a[j] != p[j]) break;
			if (j == n - 1) ps = i + 1;
		}
		for (int j = 0; j < n; j++) {
			if (a[j] != q[j]) break;
			if (j == n - 1) qs = i + 1;
		}
		next_permutation(a.begin(), a.end());
	}
	//cout << "ps:" << ps << " qs:" << qs << endl;
	cout << max(ps - qs, qs - ps) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int f[maxn],a[maxn],h[maxn],go[maxn],nxt[maxn];
int i,j,k,l,t,n,m,tot,top;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x){
	int t=h[x];
	if (!t) return;
	while (t){
		dfs(go[t]);
		t=nxt[t];
	}
	top=0;
	t=h[x];
	while (t){
		a[++top]=f[go[t]];
		t=nxt[t];
	}
	sort(a+1,a+top+1);
	int i;
	fo(i,2,top)
		if (a[i]<=a[i-1]) a[i]=a[i-1]+1;
	f[x]=a[top]+1;
}
int main(){
	scanf("%d",&n);
	fo(i,2,n){
		scanf("%d",&j);
		add(j,i);
	}
	dfs(1);
	printf("%d\n",f[1]);
}

Measured memory_bytes: 4864
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;


int32_t main() {
	// your code goes here
int n,cr=0,cw=0,count=0;
string s;
cin>>n>>s;
int i;
for(i=0;i<n;i++)
{
    if(s[i]=='R')
    cr++;
    else cw++;
}
for(i=0;i<cr;i++)
{
    if(s[i]=='W')
    count++;
}
cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int N;
    cin>>N;
    cout<<N*800-N/15*200<<endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int N;cin>>N;
    for(int i=1;i<=9;i++){
        for(int y=1;y<=9;y++){
            if(i*y==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include "stdio.h"
int main(void){
int a,b;
char op;
do{
scanf("%d %c %d",&a,&op,&b);
if(op=='+'){
printf("%d\n",a+b);
}else if(op=='-'){
printf("%d\n",a-b);
}else if(op=='*'){
printf("%d\n",a*b);
}else if(op=='/'){
printf("%d\n",a/b);
}
}while(op!='?');
return 0;
}

Measured memory_bytes: 600
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
	public int Lx { get; set; }
	public int Ly { get; set; }
	public int rx { get; set; }
	public int ry { get; set; }
}

public class hello
{
	public static char[,] mapL, mapr;
	public static int w, h;
	public static int Lsx, Lsy, rsx, rsy;
	public static int Lgx, Lgy, rgx, rgy;

	public static void Main()
	{
		while (true)
		{
			string[] line = Console.ReadLine().Trim().Split(' ');
			w = int.Parse(line[0]);
			h = int.Parse(line[1]);
			if (w == 0 && h == 0) break;
			mapL = new char[h, w];
			mapr = new char[h, w];
			Lsx = Lsy = rsx = rsy = 0;
			Lgx = Lgy = rgx = rgy = 0;
			for (int i = 0; i < h; i++)
			{
				line = Console.ReadLine().Trim().Split(' ');
				for (int j = 0; j < w; j++)
				{
					mapL[i, j] = line[0][j];
					if (line[0][j] == 'L') { Lsx = i; Lsy = j; mapL[i, j] = '.'; }
					if (line[0][j] == '%') { Lgx = i; Lgy = j; mapL[i, j] = '.'; }
					mapr[i, j] = line[1][j];
					if (line[1][j] == 'R') { rsx = i; rsy = j; mapr[i, j] = '.'; }
					if (line[1][j] == '%') { rgx = i; rgy = j; mapr[i, j] = '.'; }
				}
			}
			var ans = goBfs(Lsx, Lsy, rsx, rsy);
			Console.WriteLine(ans);
		}
	}
	static string goBfs(int Lsx, int Lsy, int rsx, int rsy)
	{
		var used = new bool[h, w, h, w];
		used[Lsx, Lsy, rsx, rsy] = true;
		var dx = new int[] { 0, 1, 0, -1 };
		var dy = new int[] { 1, 0, -1, 0 };
		var q = new Queue<P>();
		q.Enqueue(new P { Lx = Lsx, Ly = Lsy, rx = rsx, ry = rsy });
		while (q.Count() > 0)
		{
			var a = q.Dequeue();
			if (a.Lx == Lgx && a.Ly == Lgy && a.rx == rgx && a.ry == rgy) return "Yes";
			if ((a.Lx == Lgx && a.Ly == Lgy && !(a.rx == rgx && a.ry == rgy))) continue;
			if (!(a.Lx == Lgx && a.Ly == Lgy) && a.rx == rgx && a.ry == rgy) continue;
			for (int i = 0; i < 4; i++)
			{
				var nLx = a.Lx + dx[i];
				var nLy = a.Ly + dy[i];
				var nrx = a.rx + dx[i];
				var nry = a.ry - dy[i];
				if (!(nLx >= 0 && nLx < h && nLy >= 0 && nLy < w)) { nLx = a.Lx; nLy = a.Ly; }
				if (!(nrx >= 0 && nrx < h && nry >= 0 && nry < w)) { nrx = a.rx; nry = a.ry; }
				if (mapL[nLx, nLy] == '#') { nLx = a.Lx; nLy = a.Ly; }
				if (mapr[nrx, nry] == '#') { nrx = a.rx; nry = a.ry; }
				if (!used[nLx, nLy, nrx, nry])
				{
					q.Enqueue(new P { Lx = nLx, Ly = nLy, rx = nrx, ry = nry });
					used[nLx, nLy, nrx, nry] = true;
				}
			}
		}
		return "No";
	}
}



Measured memory_bytes: 44828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int a[N], n, k;
int main(){

  scanf("%d%d", &n, &k);

  for(int i = 0; i<  n; i++){
    int x;
    scanf("%d", &x);
    a[x]++;
  }

  multiset<int>st;

  int ans = 0;
  for(int i = 1; i <= n; i++)if(a[i])st.insert(a[i]);

  while(st.size() > k){
    ans += *st.begin();
    st.erase(st.begin());
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1000000007;

void solve() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    REP(i, k, n + 2) {
        ans = (ans + 1LL * (n - i + 1) * i + 1) % mod;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3600