akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int p;

ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % p : y; x = x * x % p; } return y; }

struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i)
            fact[i + 1] = fact[i] * (i + 1) % p;
        for (int i = 0; i <= n; ++i)
            ifact[i] = mpow(fact[i], p - 2);
    }
    ll operator ()(int n, int k) { return /*k < 0 || k > n ? 0 :*/ fact[n] * ifact[n - k] * ifact[k] % p; }
};

vector<int> a;
vector<ll> b;

int main() {
    cin >> p;
    a.resize(p);
    rep(i, p) cin >> a[i];

    Combination C(3072);

    b.resize(p);
    rep(i, 0, p) {
        if (a[i]) {
            b[0] += 1 + ((p - 1) % 2 ? 1 : -1) * mpow(i, p - 1) + p;
        }
    }

    rep(j, 1, p) {
        rep(i, 0, p) {
            if (a[i]) {
                b[j] += ((p - 1 - j) % 2 ? 1 : -1) * C(p - 1, j) * mpow(i, p - 1 - j) + p * p;
            }
        }
    }

    rep(i, p) {
        cout << (b[i] % p) << (i == p - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 384
/*
                                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include <bits/stdc++.h>
 
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
 
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
string ch[1][50000];
int i=0;
int permutations(string str)
{	string ch=str;
	sort(str.begin(), str.end());
	i=0;
	while(1)
	{	if(ch==str)
		return i;
		if (!next_permutation(str.begin(), str.end()))
			break;
		i++;
	}
	return 0;
}
signed main()
{   jaldi
	int n,x,sum=0,hj=0;
	cin>>n;
	for(int j=0;j<n;j++)
	{	cin>>x;
		sum=(sum*10)+x;
	}
	int u;
	for(int j=0;j<n;j++)
	{	cin>>u;
		hj=(hj*10)+u;
	}
	int g=0,f=0;
	string a=to_string(sum);
	g=permutations(a);
	string b=to_string(hj);
	f=permutations(b);
	cout<<abs(f-g);
}

Measured memory_bytes: 640
#include <stdio.h>

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

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;

int main() {
char ch;
while(1){
scanf("%c",&ch);
		if (isalpha(ch)) {
			if (islower(ch)) {
				printf("%c", toupper(ch));
			} else {
				printf("%c", tolower(ch));
			}
		} else {
			printf("%c", ch);
		}
		if(ch=='\n')break;
	}
}

Measured memory_bytes: 3084
<?php

fscanf(STDIN, "%d %d", $n, $k);
$a_arr = [];
for ($i = 0; $i < $k; ++$i) {
    fscanf(STDIN, "%d", $tmp_d);
    $a_arr[] = explode(' ', trim(fgets(STDIN)));
}

$res = array_fill(0, $n, false);

for ($i = 0; $i < $k; ++$i) {
    $tmp = $a_arr[$i];
    foreach ($tmp as $val) {
        $res[$val - 1] = true;
    }
}

$cnt = 0;
foreach ($res as $sn) {
    if (!$sn) {
        ++$cnt;
    }
}

echo $cnt;


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

import sys
import os
import math
import re
import random

tableA = {
    "A": "00000",
    "B": "00001",
    "C": "00010",
    "D": "00011",
    "E": "00100",
    "F": "00101",
    "G": "00110",
    "H": "00111",
    "I": "01000",
    "J": "01001",
    "K": "01010",
    "L": "01011",
    "M": "01100",
    "N": "01101",
    "O": "01110",
    "P": "01111",
    "Q": "10000",
    "R": "10001",
    "S": "10010",
    "T": "10011",
    "U": "10100",
    "V": "10101",
    "W": "10110",
    "X": "10111",
    "Y": "11000",
    "Z": "11001",
    " ": "11010",
    ".": "11011",
    ",": "11100",
    "-": "11101",
    "'": "11110",
    "?": "11111"}

tableB = {
    "101": " ",
    "000000": "'",
    "000011": ",",
    "10010001": "-",
    "010001": ".",
    "000001": "?",
    "100101": "A",
    "10011010": "B",
    "0101": "C",
    "0001": "D",
    "110": "E",
    "01001": "F",
    "10011011": "G",
    "010000": "H",
    "0111": "I",
    "10011000": "J",
    "0110": "K",
    "00100": "L",
    "10011001": "M",
    "10011110": "N",
    "00101": "O",
    "111": "P",
    "10011111": "Q",
    "1000": "R",
    "00110": "S",
    "00111": "T",
    "10011100": "U",
    "10011101": "V",
    "000010": "W",
    "10010010": "X",
    "10010011": "Y",
    "10010000": "Z"}

def my_solve(s):
    s = s.strip('\n')
    lst = []
    for c in s:
        lst.append(tableA[c])
    s = ''.join(lst)

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    return ans

while True:
    try:
        s = input()
    except:
        break

    print(my_solve(s))

Measured memory_bytes: 11708
#include<bits/stdc++.h>
using namespace std;
vector<pair<long long,long long> > v;
long long we[4];
int main()
{
    //we[0]=0.25;
   // we[1]=0.5;
    we[2]=1;
    we[3]=2;
    long long ans=0,n,i,yo;
    double x;
    for(i=0;i<4;++i)
    {
        cin>>x;
        if(i==0)
        v.push_back({x*8,0});
        else if(i==1)
        v.push_back({x*4,-1});
        else if(i==2) v.push_back({x*2,1});
        else if(i==3) v.push_back({x,2});
       // cout<<x/we[i];
    }
    cin>>n;
    sort(v.begin(),v.end());
   // cout<<v[0].second<<endl;
    if(v[0].second==2)
    {
        yo=n/2;
       // cout<<n<<' '<<yo<<endl;
        ans+=yo*(v[0].first);
        yo=n%2;
        
        ans+=yo*(v[1].first/2);
        cout<<ans<<endl;
    }
    else
    {
        ans+=n*(v[0].first/2);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(x>=a and a+b>=x) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a[5], k;
	for (int i = 0; i < 5; i++) scanf("%d", &a[i]);
	scanf("%d", &k);
	printf("%s\n", a[4] - a[0] > k ? ":(" : "Yay!");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.seq", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		double a0;
		stringstream ss(str);
		ss >> a0;
		double res = 211.*a0/27.;
		printf ("%.9f\n", res );
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){

  int in[3], out[3];

  while(cin >> in[0] >> in[1] >> in[2] >> out[0] >> out[1] >> out[2]){

    int intime, outtime;

    intime = in[0]*3600+in[1]*60+in[2];
    outtime = out[0]*3600+out[1]*60+out[2];
    outtime -= intime;

    int h = 0, m = 0, s = 0;

    while(outtime >= 3600){
      h++;
      outtime-=3600;
    }
    while(outtime >= 60){
      m++;
      outtime-=60;
    }
    s = outtime;

    cout << h<<" " << m << " " << s<<endl;

  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
      if(a[i]%2==1){
        cout<<"first"<<endl;
        return 0;
      }
    }
    cout<<"second"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>

int max_index(std::vector<int> &c1){
    std::vector<int>::iterator iter1 = std::max_element(c1.begin(), c1.end());
    int index1 = std::distance(c1.begin(), iter1);
    return index1;
}

int second_max_index(std::vector<int> c1, const int firstIndex){
	c1[firstIndex] = 0;
    std::vector<int>::iterator iter1 = std::max_element(c1.begin(), c1.end());
    int index1 = std::distance(c1.begin(), iter1);
    return index1;
}

int main(){
	int n;
	std::cin >> n;
	std::vector<int> v(n);
	std::vector<int> c1( 100000, 0 );  //0,2,
	std::vector<int> c2( 100000, 0 );	//1,3,
	for (int i=0; i < n; i++){
		std::cin >> v[i];
		if(i%2==0) c1[v[i]]++;
		else	   c2[v[i]]++;
	}
	int index1 = max_index(c1);
	int index2 = max_index(c2);
    if(index1==index2){
    	int index1second = second_max_index(c1, index1);
    	int index2second = second_max_index(c2, index2);
    	if(c1[index1] + c2[index2second] >= c1[index1second] + c2[index2]){
    		index2 = index2second;
    	}else{
    		index1 = index1second;
    	}
    }
    int replaceNum = n - (c1[index1] + c2[index2]);
    std::cout << replaceNum << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<int> A(N-1);
  rep(i,N-1) cin>>A[i];

  vector<int> ans(N,0);
  rep(i,N-1){
    A[i]--;
    ans[A[i]]++;
  }

  for(int i=0;i<N;i++) cout<<ans[i]<<"\n";

  return 0;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
 
const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll cnt[60] = {};
    for (int i = 0 ; i < n ; i++) {
        ll add;
        cin >> add;
        for (int j = 0 ; j < 60 ; j++) {
            if (add & (1LL<<j)) {
                cnt[j]++;
            }
        }
    }
    ll ans = 0;
    for (int i = 0 ; i < 60 ; i++) {
        ans += (1LL<<i) % mod * (n - cnt[i]) % mod * cnt[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

int main(){
  
  vector<int> N(4);
  
  for(int i = 0;i < 4;++i){
    cin >> N[i];
  }
  
  sort(N.begin(),N.end());
  
  if(N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
 
}


Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     double l;cin>>l;
     l = l/3;;
     //cout<<l<<endl;
     printf("%0.10lf",l*l*l);
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int  main(void)
{
	int n,a[100],max,min;
	
	max=-1;
	min=1000000000;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%d",&(a[i]));
		if(a[i]<min){
			min=a[i];
		}
		if(a[i]>max){
			max=a[i];
		}
	}
	
	printf("%d\n",max-min);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
#include <set>

#define key first
#define val second

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vx;
typedef set<i64> sx;
typedef map<i64, int> mxi;

vi prime_sieve(int n) {
    vi primes(n);
    int i, j;
    for (i=2; i<n; i++)
        primes[i] = i;

    for (i=2; i*i<n; i++)
        if (primes[i])
            for (j=i*i; j<n; j+=i)
                primes[j] = 0;

    return primes;
}

i64 norm(i64 x, vx &pcubes) {
    for (i64 c: pcubes) {
        if (c > x) break;
        while (x%c==0) x/=c;
    }
    return x;
}

const i64 INF=1e12;
i64 mul(i64 m, i64 n) {
    return INF/n<m? INF:m*n;
}

i64 anti(i64 x, vx &primes) {
    i64 y=1;
    for (i64 p: primes) {
        if (1LL*p*p > x) break;
        if (x%p==0) {
            if ((x/p) % p) {
                y = mul(y, mul(p, p));
                x /= p;
            } else {
                y = mul(y, p);
                x /= p * p;
            }
        }
    }
    if (x != 1) y = mul(y, mul(x, x));
    return y;
}

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

    vi ps=prime_sieve(2154);
    vx primes, pcubes;
    int i;
    for (i=0; i<2154; i++) {
        if (ps[i]) {
            primes.push_back(i);
            pcubes.push_back(1LL*i*i*i);
        }
    }

    vx a(n);
    mxi count_;
    for (i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        i64 n_=norm(a[i], pcubes);
        count_[n_]++;
    }

    int res=0;
    sx used;
    for (auto item: count_) {
        i64 x=item.key;
        int c=item.val;

        i64 y=anti(x, primes);
        if (used.count(x)) continue;
        if (x==y && x==1) {
            res++;
        } else {
            used.insert(x);
            if (count_.count(y)) {
                res += max(c, count_[y]);
                used.insert(y);
            } else {
                res += c;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 12032
//自称高知能系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 MODA 1000000007 

int main() {
    int ans = 0;
	int H, h, W, w;
	cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
}

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

using namespace std;

int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<a[K-1]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.substring(i, i + 1).equals("0")) {
				count++;
			}
		}

		System.out.println(Math.min(2 * count, 2 * (s.length() - count)));
		sc.close();
	}
}

Measured memory_bytes: 30648
// Jai Mata Di
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
void solveTest(){
  string s;
  cin>>s;
  int sum = 0;
  for(char c: s){
    sum += (c-'0');
    sum = sum%9;
  }
  if(sum==0){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t=1, i=1;
  //cin>>t;//Comment if only one test case
  while(i<=t){
    //cout<<"Case #"<<i<<": ";
    solveTest();
    i++;
  }
  return 0;
}


Measured memory_bytes: 3776
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

// OrderedSet
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template < typename T > using ordered_set = tree < T, null_type, greater < T >, rb_tree_tag, tree_order_statistics_node_update >;

//typedef uint64_t hash_t;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int HASH_COUNT = 2;
//const hash_t HASH_P = (uint32_t)-13337;
//uniform_int_distribution<hash_t> MULT_DIST(0.25 * HASH_P, 0.75 * HASH_P);
//const hash_t HASH_MULT[HASH_COUNT] = {MULT_DIST(rng), MULT_DIST(rng)};

int n;

int dist[505][505];
int out[505][505];
int grid[505][505];

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

queue < pii > Q;

bool isValid(int r, int c){
  if(r < 1 || c < 1) return 0;
  if(r > n || c > n) return 0;
  return 1;
}

void SPFA(){
  while(!Q.empty()){
    pii u = Q.front();
    Q.pop();
    for(int i = 0; i < 4; i++){
      int x = u.fs + dx[i];
      int y = u.se + dy[i];
      if(isValid(x, y) && dist[x][y] > dist[u.fs][u.se] + !out[x][y]){
        dist[x][y] = dist[u.fs][u.se] + !out[x][y];
        Q.push(mp(x, y));
      }
    }
  }
}

int main(){
  int ans = 0;
  fastScan(n);
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      dist[i][j] = n * n;
    }
  }
  for(int i = 1; i <= n; i++){
    dist[1][i] = dist[i][1] = dist[n][i] = dist[i][n] = 0;
    grid[1][i] = grid[i][1] = grid[n][i] = grid[i][n] = 1;
    Q.push(mp(1, i)); Q.push(mp(i, 1));
    Q.push(mp(n, i)); Q.push(mp(i, n));
  }
  SPFA();
  for(int i = 1; i <= n * n; i++){
    int who, x, y;
    fastScan(who);
    x = (who - 1) / n + 1;
    y = (who - 1) % n + 1;
    ans += dist[x][y];
    dist[x][y]--;
    out[x][y] = 1;
    Q.push(mp(x, y));
    SPFA();
  }
  printf("%d\n", ans);
  return 0;
}


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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    vector<vector<int>> A(3, vector<int>(3, 0));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    for (int n = 0; n < N; n++) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (A[i][j] == b) {
                    A[i][j] = -1;
                }
            }
        }
    }
    vector<int> sum(8);
    sum[0] = A[0][0] + A[0][1] + A[0][2];
    sum[1] = A[1][0] + A[1][1] + A[1][2];
    sum[2] = A[2][0] + A[2][1] + A[2][2];

    sum[3] = A[0][0] + A[1][0] + A[2][0];
    sum[4] = A[0][1] + A[1][1] + A[2][1];
    sum[5] = A[0][2] + A[1][2] + A[2][2];

    sum[6] = A[0][0] + A[1][1] + A[2][2];
    sum[7] = A[0][2] + A[1][1] + A[2][0];

    for (int i = 0; i < 8; i++) {
        if (sum[i] == -3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x = sorted(x)
y = sorted(y)
ok = False
for i in range(X+1,Y+1):
    if x[n-1] < i and y[0] >= i:
        ok = True
        break
if ok == 1: print("No War")
else: print("War")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
// AOJ 0568
// Title:Pasta
// @kankichi573
int N,K,A,B;
char plan[101];

struct memo_st
{
        char first;
        char second;
        char str[101];
        char len;
        int  size;
} memo[10000];

int memoindex;


void register_memo(char first,char second,char * ptr,char len,int size)
{
        memoindex++;

        memo[memoindex].first   = first;
        memo[memoindex].second  = second;
        strncpy(memo[memoindex].str,ptr,len);
        memo[memoindex].len  = len;
        memo[memoindex].size = size;
}
struct memo_st * assoc(char first,char second,char * ptr,char len)
{
        int i;
        struct memo_st * p;

        for(i=0;i<memoindex;i++)
        {
                p=&memo[i];
                if(p->first==first && p->second==second &&
                   len==p->len && 0==strncmp(p->str,ptr,len))
                        return(p);
        }
        return(NULL);
} 

int solve(char first,char second,char *rest,char len)
{
        struct memo_st *p;
        int ans;
        //printf("%s\n",rest);
        if(len==0)
                return(1);
        if(first!='D' && first == second && first == rest[0])
                return(0);
        if(rest[0] != 'D')
                return(solve(second,rest[0],rest+1,len-1));
        if(p=assoc(first,second,rest,len))
                return(p->size);
        
        ans=0;
        if(!(first==second && first=='A'))
                ans += solve(second,'A',rest+1,len-1);
        if(!(first==second && first=='B'))
                ans += solve(second,'B',rest+1,len-1);
        if(!(first==second && first=='C'))
                ans += solve(second,'C',rest+1,len-1);
        ans %= 10000;
        register_memo(first,second,rest,len,ans);
        return(ans);
}



int main()
{
        int i,ret;
        
 
        scanf("%d %d",&N,&K);
        memoindex=0;
        for(i=0;i<N;i++)
                plan[i]='D';
        for(i=0;i<K;i++)
        {
                scanf("%d %d",&A,&B);
                plan[A-1]=(B-1)+'A';
        }
        //printf("%s\n",plan);
        ret=solve('D','D',plan,N);
        printf("%d\n",ret);

        return(0);
}

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

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine();

            Console.WriteLine(input1.Select((x, i) => (x, i)).LongCount(x => !x.x.Equals(input2[x.i])));
        }
    }
}


Measured memory_bytes: 27924
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
int main()
{
    fastio();
   
    int n;
    cin>>n;
    ll ans=0;
    for(int a=1;a<=n;a++)
    {
        for(int b=1;b<=n;b++)
        {
            int g = gcd(a,b);
            for(int c=1;c<=n;c++)
            {
                int s = gcd(g,c);
                ans=ans+s;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int S, W;
    cin >> S >> W;
    if (S <= W) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3608
N = int(input())
A = list(map(int,input().split()))
a = 0
b = 0
A.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        a = a + A[i]
    if i%2 == 1:
        b = b + A[i]
print(a-b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define T int t;cin>>t;while(t--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<x = <<x<<n;
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}	
	int c = 0;
	for(int i=1;i<n-1;i++){
		if((v[i]<v[i+1] && v[i]>v[i-1])||(v[i]>v[i+1] && v[i]<v[i-1])) c++;
	}
	cout<<c;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 int main()
 {
   int n,m;
   while(cin>>n>>m&&(n||m))
   {
     list<int> mm;
     list<int>::iterator iter;
     list<int>::iterator iter2;
     for(int i=1;i<=n;i++) mm.push_back(i);
     while(mm.size()>1)
     {
       for(int i=1;i<=m-1;i++)
       {
         mm.push_back(mm.front());
         mm.pop_front();
       }   
       mm.pop_front(); 
       //cout<<mm.front()<<endl;            
     }
     iter=mm.begin();
     cout<<(*iter)<<endl;                
   }
   //while(1);
   return 0; 
 }

 

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

int main() {
  
 	

    int a,b;
    cin>>a>>b;
    int c=a+b;
    int d=a-b;
    int e=a*b;
    int f= max(c,d);
    int g= max(f,e);
    cout<<g;
    

    return 0;
}

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

using namespace std;

const int NMAX = 21;
const int PMAX = 1 << NMAX;
const int mod = 1e9 + 7;

int N;
int a[NMAX + 5][NMAX + 5];
int bts[PMAX + 5];
int dp[PMAX + 5];

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

    dp[0] = 1;
    for(int msk = 1; msk < (1 << N); msk++)
    {
        bts[msk] = bts[msk >> 1] + (msk & 1);
        int i = bts[msk] - 1;
        for(int j = 0; j < N; j++)
            if( (msk >> j) & 1 )
            {
                if(a[i][j] == 1)
                    dp[msk] = (dp[msk] + dp[msk ^ (1 << j)]) % mod;
            }
    }

    cout << dp[(1 << N) - 1] << '\n';
    exit(0);
}

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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  bool frag=true;
  rep(i, n) {
    if (a[i]%2==0) {
      if ((a[i]%5==0)||(a[i]%3==0)) continue;
      frag=false;
    }
  }
  if (frag) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


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

int get_gcd(int a, int b) {
  int r;
  while (r = a % b) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a, b;
  while (cin >> a >> b) {
    int gcd = get_gcd(a, b);
    int lcm = a / gcd * b;
    cout << gcd << " " << lcm << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N; cin >> N;
  LL vmin = 1e18;
  for (LL i = 1; i * i <= N; ++i) {
    if (N % i  == 0) {
      LL j = N / i;
      vmin = min(vmin, (i + j - 2));
    }
  }
  cout << vmin << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define RI register int
#define RC register char
#define ed puts("")
#define space putchar(' ')
#define Pair pair<int,int> 
using namespace std;

template <typename tp> inline void read(tp &x)
{
	x=0;
	RI f=1;
	RC c=getchar();
	while(c<'0' || c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}	
	x*=f;
}

template <typename tp> inline void print(tp x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) print(x/10);	
	putchar(x%10+'0');	
} 

const int maxn=2333;
int n,m,a,b,tmpb,tmpa,flag;
int mp[maxn][maxn];
int col[maxn];

int main()
{
	read(n),read(m),read(a),read(b);
	tmpb=b,tmpa=a;
	begin:
	for(RI i=1; i<=n; ++i)
	{
		RI tot=0;
		for(RI j=1; j<=m; ++j)
		{
			if(col[j] < b) mp[i][j]=1,++tot,++col[j];
			if(tot==a) break; 
		}
		if(tot!=a && tot!=m-a)
		{
			++flag;
			break;
		}
		if(i==n)
		{
			bool flagggg=true;
			for(RI j=1; j<=m; ++j)
			{
				if(col[j]!=b && col[j]!=n-b)
				{
					flagggg=false;
					++flag;
					break;
				}
			}
			if(flagggg) 
				flag=0;
		}
	}
	if(flag)
	{
		if(flag==1) b=n-tmpb,a=tmpa;
		if(flag==2) b=tmpb,a=m-tmpa;
		if(flag==3) b=n-tmpb,a=m-tmpa;
		if(flag==4)
		{
			print(-1);
			return 0;
		}
		for(RI i=1; i<=n; ++i)
		{
			for(RI j=1; j<=m; ++j)
			{
				col[j]=0;
				mp[i][j]=0;
			}
		}
		goto begin;
	}
	for(RI i=1; i<=n; ++i)
	{
		for(RI j=1; j<=m; ++j)
		{
			print(mp[i][j]);
		}
		ed;
	}
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N;
	cin >> N;
	string s;
	map<string, ll>S;
	for (int i = 0;i < N;i++) {
		cin >> s;
		S[s]++;
	}
	int max = 0;
	for (auto x : S) {
		int v = x.second;
		if (v > max) max = v;
	}
	for (auto itr = S.begin();itr != S.end();itr++) {
		if (itr->second == max) {
			cout << itr->first << endl;
		}
	}
}

Measured memory_bytes: 25216
import sys
input = sys.stdin.readline
import heapq

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
BC = []
changeable = N
broke = False
for i in range(M):
    B,C = (int(x) for x in input().split())
    BC.append((C*(-1),B))
heapq.heapify(A)
heapq.heapify(BC)
for i in range(M):
    t1 = heapq.heappop(BC)
    if t1[1] < changeable:
        for j in range(t1[1]):
            t2 = heapq.heappop(A)
            if t2 < t1[0] * (-1):
                heapq.heappush(A,t1[0]*(-1))
            else:
                heapq.heappush(A,t2)
                broke = True
                break
        else:
            changeable -= t1[1]
    else:
        for j in range(changeable):
            t2 = heapq.heappop(A)
            if t2 < t1[0] * (-1):
                heapq.heappush(A,t1[0]*(-1))
            else:
                heapq.heappush(A,t2)
                break
        break
    if broke:
        break
print(sum(A))

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

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

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        if((i%3 != 0)&&(i%5 != 0)) ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int A, B, C; std::cin >> A >> B >> C;
  if      ( A == 5 && B == 5 && C == 7 ) std::cout << "YES" << std::endl;
  else if ( A == 5 && B == 7 && C == 5 ) std::cout << "YES" << std::endl;
  else if ( A == 7 && B == 5 && C == 5 ) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	vector<int> ans(n + 1, 0);
	for(int x = 1; x <= 100; x++)
	{
		for(int y = 1; y <= 100; y++)
		{
			for(int z = 1; z <= 100; z++)
			{
				int cur = x * x + y * y + z * z + x * y + y * z + z * x;
				if(cur <= n)
					ans[cur]++;
			}
		}
	}
	for(int i = 1; i <= n; i++)
		cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3664
def warshall_floyd(V):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

                
from collections import Counter

INF = float('inf') 
H, W = map(int, input().split())
d =[[int(i) for i in input().split()] for _ in range(10)]  #; print(d)
a = []
for _ in range(H):
    a.extend([int(i) for i in input().split() if i != '-1'])
dic = Counter(a)     #; print(a); print(dic) 

warshall_floyd(10)   #; print(d)

ans = 0
for key, val in dic.items():
    ans += d[key][1] * val   #; print(key, d[key][1], val)

print(ans)


Measured memory_bytes: 9756
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	string s, str;
	cin >> str >> n;
	int sum = 0;
	for (int i = 0; i < n; i++){
		cin >> s;
		s += s;
		if ((int)s.find(str) != -1)
			sum++;
	}
	cout <<sum<< endl;
	return 0;
}

Measured memory_bytes: 3212
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

INF = float("inf")
dp = [INF] * (N + 1)
dp[1] = 0
for l, r, c in sorted(X):
    for i in range(r, l, -1):
        if dp[i] > dp[l] + c:
            dp[i] = dp[l] + c
        else:
            break
            
print(dp[-1] if dp[-1] < INF else -1)



Measured memory_bytes: 93016
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        for(int i =0; i<s.length(); i++){
            if(Character.isUpperCase(s.charAt(i))){
                cnt++;
            }
        }
        if(s.charAt(0)=='A'){
            for(int i =2; i<=s.length()-2;i++){
                if(s.charAt(i)=='C'){
                    if(cnt==2){
                        System.out.println("AC");
                        return;
                    }
                }    
            }
        }
        System.out.println("WA");
    }
}


Measured memory_bytes: 21844
import std.stdio;

void main(){
	long n, x, y, h, w, size, sum;
	while (readf("%d\n", &n), n) {
		sum = 0;
		foreach (i; 0..n) {
			readf("%d %d %d %d\n", &x, &y, &h, &w);
			size = x + y + h;
			if (size <= 60 && w <= 2) sum += 600;
			else if (size <= 80 && w <= 5) sum += 800;
			else if (size <= 100 && w <= 10) sum += 1000;
			else if (size <= 120 && w <= 15) sum += 1200;
			else if (size <= 140 && w <= 20) sum += 1400;
			else if (size <= 160 && w <= 25) sum += 1600;
		}
		writeln(sum);
	}
}

Measured memory_bytes: 980
# 挿入ソート

N = int(input())
A = list(map(int, input().split()))


def insertionSort(A, N):
    print(' '.join([str(i) for i in A]))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join([str(i) for i in A]))


insertionSort(A, N)



Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>

#define rep(i,n)    for(int i=0;i<n;i++)
#define rep1(i,n)   for(int i=1;i<=n;i++)
#define INF         ( 1<<20 )

using namespace std;

int costs[21][21];

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

	rep1(i,N)rep1(j,N)costs[i][j] = INF;
	rep1(i,N)costs[i][i] = 0;

	char comma;
	int a, b, c, d;
	rep(i,M)
	{
		cin>>a>>comma>>b>>comma>>c>>comma>>d;
		costs[a][b] = c;
		costs[b][a] = d;
	}

	int S, G, money, hashira;
	cin>>S>>comma>>G>>comma>>money>>comma>>hashira;

	rep1(k,N)rep1(i,N)rep1(j,N)
	{
		costs[i][j] = min(costs[i][j], costs[i][k] + costs[k][j]);
	}
	cout << (money - hashira - (costs[S][G] + costs[G][S])) << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define abs(n) (n < 0) ? n*-1 : n

int main(void){

  //変数の準備
  int N, T, A;
  
  //入力
  cin >> N >> T >> A;
  
  //配列
  int H[N];
  float a[N];	//Aとの差分
  float min = INF;	//差分が一番小さいやつ
  rep(i, N){
    cin >> H[i];
    a[i] = abs( (A - (T - H[i]*0.006)) );//差分を入れる
    if(a[i] < min) min = a[i];	//差分が一番小さいやつを入れる
  }
  
  //一番小さいやつの番号探す
  int ans = 1;
  while(a[ans - 1] != min){
    ans++;
  }
  
  //出力
  cout << ans << endl;

  return 0;
}

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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    vector<int> d(N);
    rep(i, N) {
        if (i == N - 1) {
            d[N - 1] = A[0] + (K - A[N - 1]);
            break;
        }
        d[i] = A[i + 1] - A[i];
    }
    int max = 0;
    rep(i, N) {
        if (max < d[i]) max = d[i];
    }
    cout << K - max << endl;
}

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

int main(){
    int N,K;cin >> N >> K;
    vector<long long> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    
    long long ans = 1;
    for(int i = 0; i < K;i++) ans *= A[i];
    
    vector<long long> calc(N-K+1);
    calc[0] = ans;
    for(int i = 1; i < N-K+1; i++){
        // cout << A[i + K - 1] << endl;
        // cout << A[i - 1] << endl;
        if(A[i-1]<A[i+K-1])cout <<"Yes" <<endl;
        else cout << "No" << endl;
        //calc[i] = calc[i-1];
        //calc[i] *= A[i+K-1];
        //calc[i] /= A[i-1];
    }
    
    //for(int i = 0; i < N - K+1 ; i++)cout << calc[i] << endl;
    
    // for(int i = 0; i < N-K; i++){

    //     if(calc[i] < calc[i+1])cout <<"Yes"<<endl;
    //     else cout << "No" << endl;
    // }
    
}






Measured memory_bytes: 6356
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
    a, b, c = LI()
    if i:
        dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
        dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
        dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
    else:
        dp[0] = a, b, c

print(max(dp[-1]))

Measured memory_bytes: 99308
import Control.Applicative

main = do
  _ <- getLine
  dat <- map (map read . words) . lines <$> getContents :: IO [[Int]]
  print $ solve (reverse dat) 0

  where
    solve [] i = i
    solve ([a,b]:xs) i = solve xs (i + if x == 0 then 0 else b - x)
      where
        x = (a+i) `mod` b
        


Measured memory_bytes: 100604
import math

p = 0

n,d  = input().split()
n = int(n)
d = int(d)

for i in range(n):
    x,y  = input().split()
    x = int(x)
    y = int(y)

    a = math.sqrt(x*x + y*y)
    
    if a <= d:
        p = p + 1

print(p) 


Measured memory_bytes: 9180
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    mod = 10**9+7
    # a_sum = sum(A)
    a_cum = [0] * (n+1)
    for i in range(n):
        a_cum[i + 1] = a_cum[i] + A[i]
    ans = 0
    for i in range(len(A)-1):
        ans += A[i] * (a_cum[n] - a_cum[i+1])
    ans %= mod
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    if (a.front() == 0) {
        cout << 0 << '\n';
        return;
    }

    ll res = 1;
    for (ll x : a) {
        if (LINF / res < x) {
            cout << -1 << '\n';
            return;
        }
        res *= x;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3988
#pragma GCC optimize("Ofast,fast-math,unroll-loops,inline,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,avx,avx2,abm,mmx,popcnt")

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;
#define pb push_back
#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string t;
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t;

}

Measured memory_bytes: 3776
def Main(A, B, C):
    if A == B and A != C:
        return 'Yes'
    elif B == C and A != B:
        return 'Yes'
    elif A == C and A != B:
        return 'Yes'
    else:
        return 'No'

def main():
    A, B, C = list(map(int, input().split()))
    print(Main(A, B, C))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int pita();

int main(){
	int num,length[2],longest,i,temp,unko;
	scanf("%d",&num);
	for (;num>0;num--){
		longest=0;
		for(i=0;i<3;i++){
			scanf("%d",&temp);	
			if (temp>longest){
				if (longest>0) length[i-1]=longest;
				longest=temp;
			}else{
				length[i-1]=temp;
			}
		}
			
		unko=pita((double)length[0],(double)length[1],(double)longest);
		
		if (unko){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
		
	}
	return 0;
}

int pita(double a,double b,double c){
	return (c*c==a*a+b*b);
}

Measured memory_bytes: 0