akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
typedef complex<double> P;
const double eps = 1e-7;
const double pi = acos(-1);
 
 
 
int N;
double R;
vector<P> ps;
 
bool equals(double a, double b) {
  return abs(a-b) < eps;
}
 
namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}
 
P getRotateP(P p, double rad) {
  double x = p.real();
  double y = p.imag();
  return P(x*cos(rad)-y*sin(rad),
           x*sin(rad)+y*cos(rad));
}
 
int main() {
  while(cin >> N >> R) {
    ps.resize(N);
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    double rad = (double)rand()/(double)RAND_MAX * pi * 2;
    for(int i = 0; i < N; ++i) {
      ps[i] = getRotateP(ps[i], rad);
    }
    sort(ps.begin(), ps.end());
    bool vis[N];
    fill(vis, vis+N, false);
    int res = 0;
    for(int i = 0; i < N; ++i) {
      if(vis[i]) continue;
      vis[i] = true;
      ++res;
      for(int j = i+1; j < N && ps[j].real()-ps[i].real() <= R; ++j) {
        double d = abs(ps[i]-ps[j]);
        if(equals(d,R) || d < R) {
          vis[j] = true;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 4436
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (LL i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (LL i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

LL const MOD = 1e9 + 7;
LL const MaxSize = 2000 + 5;
//LL const MOD = 998244353;

/*

 https://atcoder.jp/contests/abc132/tasks/abc132_d
 D - Blue and Red Balls

 */

//NOTE WORKS ONLY WHEN MOD IS PRIME
//test case, either = 1 or all = 1
string S, T;
int m[26];
int cnt[26];

//NOTE WORKS ONLY WHEN MOD IS PRIME

int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> S >> T;
	LP(i, 0, 26)
	{
		m[i] = -1;
		cnt[i] = 0;
	}

	LP(i, 0, S.size())
	{
		int si = S[i] - 'a';
		int ti = T[i] - 'a';

		int from = si;
		int to = ti;
		if (m[from] >= 0 && m[from] != to) {
			cout << "No";
			return 0;
		}
		m[from] = to;
	}

	LP(i, 0, 26)
	{
		if (m[i] >= 0 && cnt[m[i]]) {
			cout << "No";
			return 0;
		}
		cnt[m[i]] += 1;
	}

	cout << "Yes";
	return 0;
}


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

const int Max = 100005;
int A[Max];
void swap(int *x, int *y)
{
    int temp = *x;
    *x = *y;
    *y = temp;
}
int Partition(int A[], int p, int r)
{
    int x = A[r], i=p-1;
    for(int j=p; j<r; j++)
    {
        if(A[j]<=x)
        {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &A[i]);
    int p = Partition(A, 0, n-1);
    for(int i=0; i<n; i++)
    {
        if(i==p)
        {
            printf("[%d] ", A[i]);
            continue;
        }

        if(i==n-1) printf("%d\n", A[i]);
        else
            printf("%d ", A[i]);
    }
    return 0;
}



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

int main(){
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	vector<vector<ll>> dp(n,vector<ll>(n));
	
	for(int i = n-1; i >= 0; i--){
		for(int j = i; j < n; j++){
			if(i==j){
				dp[i][j] = a[i];
			}
			else{
				dp[i][j] = max( a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
			}
		}
	}
	
	cout << dp[0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 70656
using System;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine().Split();
            decimal a = decimal.Parse(s[0]);
            decimal b = decimal.Parse(s[1]);
            
            var ans = Truncate(a * b);
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 17932
import sys
input = sys.stdin.readline

N = int(input())

m = []
l = []

for _ in range(N):
    i = input().split()
    m.append(i[0])
    l.append(int(i[1]))

s = input().strip()
index = 0
for i, x in enumerate(m):
    if x == s:
        index = i + 1
        break

print(sum(l[index:]))


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int h, w;
    int y, x;
    while(1) {
        scanf("%d%d", &h, &w);
        if(h==0 && w==0) break;
        for(y=0; y<h; y++) {
            for(x=0; x<w; x++) {
                if(y==0||x==0||y==h-1||x==w-1) putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

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

const ll MOD = 1e9 + 7;

int mpow(int base, int exp);
typedef  vector<int> vi;
typedef  vector<ll> vll;
typedef  vector<pair<ll,ll>> vpll;
typedef  vector<pair<int, int>> vpii;
typedef  pair<int, int> pii;
typedef  pair<ll, ll> pll;
typedef  unordered_map<ll, ll> umpll;
typedef  unordered_map<int, int> umpii;
typedef  unordered_map<ll, int> umpli;
typedef  unordered_set<int> usi;
typedef  unordered_set<ll> usll;
typedef  set<int> si;
typedef  set<ll> sll;
typedef  set<pair<int, int>> spii;
typedef  set<pair<ll, ll>> spll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fo(i,n) for(i = 0;i < n; i++)
#define Fo(i,k,n) for(i = k;k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", "<< #z << " = " << z << endl

ll randGen(ll lower, ll upper) { return (rand() % (upper - lower + 1)) + lower; }
ll dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// cout << fixed;
// cout.precision(10);
//******************          Function here          *********************//

   void test_case(){
      ll n;
      cin >> n;
      ll ans = 0;
      for(int i = 1; i <= n - 1; i++) {
         ans += (n - 1) / i;
      }
      cout << ans << endl;
   }

//*********************************************************************//

int main()
{
    #ifndef ONLINE_JUDGE
      string inputFile, outputFile;
      inputFile = "input.txt";
      outputFile = "output.txt";
      freopen(inputFile.c_str(), "r", stdin);
      freopen(outputFile.c_str(), "w", stdout);
    #endif

    int t = 1;
    // cin >> t;
    while(t-- > 0){
      test_case();
    }
    return 0;
}



/**********************   Utility Functions  *****************************/
   int mpow(int base, int exp) {
     base %= MOD;
     int result = 1;
     while (exp > 0) {
       if (exp & 1) result = ((ll)result * base) % MOD;
       base = ((ll)base * base) % MOD;
       exp >>= 1;
     }
     return result;
   }
/***********************************************************************/


Measured memory_bytes: 3632
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline

def main():
    w, h, x, y = input_list()
    if w == x*2 and h == y*2:
        print((w*h)/2, 1)
    else:
        print((w*h)/2, 0)

def divide_list(l, args):
    result = []
    pre = 0
    for i, a in enumerate(args):
        if i != 0:
            pre = args[i-1]
        result.append(l[pre:a])
        if i == len(args) - 1:
            result.append(l[a:])
    return result

def divide_two(n):
    c = 0
    while True:
        if c >= 2:
            break
        if n % 2 != 0:
            break
        n //= 2
        c += 1
    return c

def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64748
#include <bits/stdc++.h>
 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


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






	if(    n<=k  )puts("unsafe");


	else puts("safe");


}


Measured memory_bytes: 3868
#include <stdio.h>

int main(void){
    int a, b, c, d;
    
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    while(1){
        if((c -= b) <= 0){
            printf("Yes\n");
            break;
        }
        if((a -= d) <= 0){
            printf("No\n");
            break;
        }
    }

    return 0;
}

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

int main() {
  int N;
  char S;
  string color = "Three";
  cin >> N;
  for ( int i = 0; i < N; i++) {
    cin >> S;
    if ( S == 'Y' ) {
      color = "Four";
      break;
    }
  }
  cout << color << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,need;
int a[15][15];
int cost[20];
int dp[20][1<<15];
int func(int pos,int mask)
{
    if(pos>n)
    {
        int tcost=0;
        for(int i=1; i<=m; i++)
        {
            int sm=0;
            for(int j=1; j<=n; j++)
            {

                if(mask&(1<<(j-1)))
                {
                    sm+=a[j][i];
                    if(i==1)
                    tcost+=cost[j];
                }
            }
            if(sm<need) return INT_MAX;
        }
        return tcost;
    }
    int &r=dp[pos][mask];
    if(r!=-1) return r;

    int x=func(pos+1,mask|(1<<pos));
    int y=func(pos+1,mask);
    r=min(x,y);
    return dp[pos][mask]=r;
}
int main()
{
    cin>>n>>m>>need;
    for(int i=1; i<=n; i++)
    {
        int c;
        cin>>c;
        cost[i]=c;
        for(int j=1; j<=m; j++)
        {
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof dp);
    int ans=func(0,0);
    if(ans==INT_MAX) cout<<-1;
    else cout<<ans<<endl;
}


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

public class Test
{
	public static void Main()
	{
		var c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int a = c[0];
		int b = c[1];
		
		if((a+b)%2==0){
			Console.WriteLine((a+b)/2);
		}else{
			Console.WriteLine("IMPOSSIBLE");
		}
		
	}
}

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC160B
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = RInt;
            int a = X / 500;
            X %= 500;
            int b = X / 5;

            long ans = (long)a * 1000 + b * 5;
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
N=int(input())
ans_list = [0]*4

for i in range(N):
    S = input()
    if(S=="AC"):
        ans_list[0]+=1
    elif(S=="WA"):
        ans_list[1]+=1
    elif(S=="TLE"):
        ans_list[2]+=1
    else:
        ans_list[3]+=1

print("AC x "+str(ans_list[0]))
print("WA x "+str(ans_list[1]))
print("TLE x "+str(ans_list[2]))
print("RE x "+str(ans_list[3]))

Measured memory_bytes: 9216
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    long long a,b,c,ans=1e18;
    scanf("%lld%lld%lld",&a,&b,&c);
    ans=min(ans,(a%2)*b*c);
    ans=min(ans,(b%2)*c*a);
    ans=min(ans,(c%2)*a*b);
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  vector<int> sides(3, 0);
  for (int i = 0; i < 3; i++) cin >> sides.at(i);
  
  sort(sides.begin(), sides.end());
  
  cout << sides.at(0) * sides.at(1) / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#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 < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  ll n, k;
  cin >> n >> k;
  if (n > k) n = n % k;
  ll tmp = LINF;
  while (n < tmp) {
    tmp = n;
    if (abs(n - k) < n) n = abs(n - k);
    // cout << tmp << " => " << n << endl;
  }
  P(n);
  return 0;
}

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



int gcd(int a,int b){
        return b == 0 ? a : gcd(b , a % b);
    }

int main()
{
	int n,s[100005];
	scanf("%d",&n);
	scanf("%d",&s[0]);
	for(int i=1;i<=n;i++)
		scanf("%d",&s[i]);
	sort(s,s+n+1);
	int ant=s[1]-s[0];
	for(int i=2;i<=n;i++)
		ant=gcd(ant,s[i]-s[i-1]);
	printf("%d\n",ant);
	
	return 0;
} 



Measured memory_bytes: 640
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	int n, i;
	inp(n);
	
	int a[n];
	int x[MAX] = {0}, y[MAX] = {0};
	
	rep(i, 0, n) {
		inp(a[i]);
		if(i&1) y[a[i]]++;
		else x[a[i]]++;
	}
	
	pair<int, int> mx1, mx2, my1, my2;
	mx1.X = mx1.Y = mx2.X = mx2.Y = my1.X = my1.Y = my2.X = my2.Y = 0;
	for(i=1;i<MAX;i++) {
		if(x[i] >= mx1.Y) {
			mx2 = mx1;
			mx1.X = i;
			mx1.Y = x[i];
		} else if(x[i] > mx2.Y) {
			mx2.X = i;
			mx2.Y = x[i];
		}
		
		if(y[i] >= my1.Y) {
			my2 = my1;
			my1.X = i;
			my1.Y = y[i];
		} else if(y[i] > my2.Y) {
			my2.X = i;
			my2.Y = y[i];
		}
	}
	
	int ans = n;
	if(mx1.X != my1.X) {
		ans = min(ans, n - mx1.Y - my1.Y);
	} else {
		ans = min(ans, n - mx1.Y - my2.Y);
		ans = min(ans, n - mx2.Y - my1.Y);
	}
	
	cout<<ans<<endl;
    return 0;
}



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

static const int MAX = 100;
static const ll INF = 1LL << 32;
ll dist[MAX][MAX];
int n;

void floyd(){
  rep(k,n){
    rep(i,n){
      if(dist[i][k] == INF) continue;
      rep(j,n){
        if(dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}


int main(){

  int edge, u,v, c;
  cin >> n >> edge;
  rep(i,n){
    rep(j,n){
      dist[i][j] = ((i==j)? 0:INF);
    }
  }
  rep(i,edge){
    cin >> u >> v >> c;
    dist[u][v] = c;
  }

  floyd();

  bool isNegative = false;
  rep(i,n) if(dist[i][i] < 0) isNegative= true;

  if(isNegative){
    cout << "NEGATIVE CYCLE" << endl;
  }else{
    rep(i,n){
      rep(j,n){
        if(j) cout << " ";
        if(dist[i][j] == INF) cout << "INF";
        else cout << dist[i][j];
      }
      cout << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3180
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N: usize,
        Q: usize,
        ab: [(usize1, usize1); N-1],
        px: [(usize1, i64); Q],
    }

    let mut edges = Vec::with_capacity(N);
    let mut de = Vec::with_capacity(N);
    for _ in 0..N {
        edges.push(vec![]);
        de.push(vec![]);
    }
    for i in 0..(N - 1) {
        let (a, b) = ab[i];
        edges[a].push(b);
        edges[b].push(a);
    }
    dfs(&edges, &mut de, 0, 1 << 60);

    let mut pushed = vec![0; N];
    for (n, cnt) in px {
        pushed[n] += cnt;
    }
    let mut counts = vec![0; N];
    dfs2(&mut counts, &de, &pushed, 0, 0);
    println!("{}", counts.into_iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}

fn dfs(edges: &Vec<Vec<usize>>, de: &mut Vec<Vec<usize>>, cur: usize, from: usize) {
    for &to in &edges[cur] {
        if to == from {
            continue;
        }
        de[cur].push(to);
        dfs(edges, de, to, cur);
    }
}

fn dfs2(counts: &mut Vec<i64>, de: &Vec<Vec<usize>>, pushed: &Vec<i64>, cur: usize, acc: i64) {
    let p = pushed[cur] + acc;
    counts[cur] = p;
    for &child in &de[cur] {
        dfs2(counts, de, pushed, child, p);
    }
}


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

int main(){
  int n, x;

  while(1){
    int res = 0;
    cin >> n >> x;
    if(n==0 && x==0){
      break;
    }

    for(int i=3;i<=n;i++){
      for(int j=2;j<i;j++){
        for(int k=1;k<j;k++){
          // cout << i << " " << j << " " << k << endl;
          if(i+j+k==x){
            res +=1;
          }
        }
      }
    }
    cout << res << endl;
  }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
    int a,b;
    cin >> a >> b;
    ll ans = ll(a)*b/__gcd(a,b); 
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
"""
"""

n = int(input())
s = input()

# 左から操走
tmp, cnt = 0, 0

for i in s:
    if i == "(":
        tmp -= 1
    else:
        tmp += 1
    cnt = max(cnt, tmp)

ans = "(" * cnt + s

# 右から操走
tmp, cnt = 0, 0
for i in s[::-1]:
    if i == "(":
        tmp += 1
    else:
        tmp -= 1
    cnt = max(cnt, tmp)

ans += ")" * cnt
print (ans)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    H = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    W = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ

    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if H > W:
        print(math.ceil(N / H))
    else:
        print(math.ceil(N / W))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
7
10"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """14
12
112"""
        output = """8"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2
100
200"""
        output = """2"""
        self.assertIO(input, output)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
    int i,n;
    string s,a;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s;
        if(s=="Y"){
            a="Four";
            break;
        }
        else
        {
            a="Three";
        }

    }

   cout<<a;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
d1, d2 = gets.split.map(&:to_i)
prev2 = d1 == d2
d1, d2 = gets.split.map(&:to_i)
prev1 = d1 == d2
(N - 2).times do
  d1, d2 = gets.split.map(&:to_i)
  current = d1 == d2
  if prev2 && prev1 && current
    puts 'Yes'
    return
  end
  prev2 = prev1
  prev1 = current
end
puts 'No'

Measured memory_bytes: 14308
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (K, X) = read!(usize, usize);

    println!("{}", if 500 * K >= X { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc169/submissions/14595332 を参考に作成
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			int answer = 0;
			for (int i = 2; i <= (int) Math.sqrt(n); i++) {
				int count = 0;
				while (0 == (n % i)) {
					n /= i;
					count++;
				}
				for (int j = 1; count - j >= 0; j++) {
					count -= j;
					answer++;
				}
			}
			if (n > 1) {
				answer++;
			}
			System.out.println(answer);
		}
	}
}


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

int main() {
    int N;
    cin >> N;
    if (N == 0) {
        cout << 2 << endl;
        return 0;
    }
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    int64_t ans1 = 2LL;
    int64_t ans2 = 1LL;
    for (int i = 1; i < N; ++i) {
        int64_t ans = ans1 + ans2;
        ans1 = ans2;
        ans2 = ans;
    }
    cout << ans2 << endl;
}

Measured memory_bytes: 256
s=input()
n=len(s)
ans=[0]*n

rtmp,ltmp=0,0
for i in range(n-1):
    if s[i]=="R":
        rtmp+=1
        if s[i+1]!="R":
            ans[i+1]=rtmp//2
            ans[i]=(rtmp+1)//2
    else:
        rtmp=0

for i in range(n-1,0,-1):

    if s[i]=="L":
        ltmp+=1
        if s[i-1]!="L":
            ans[i-1]+=ltmp//2
            ans[i]+=(ltmp+1)//2
    else:
        ltmp=0
print(*ans)


Measured memory_bytes: 6400
N, K = map(int, input().split())
x = list(map(int, input().split()))
m = float('inf')
for i in range(N+1-K):
  m = min(m, abs(x[i]) + abs(x[i+K-1] - x[i]))
  m = min(m, abs(x[i+K-1]) + abs(x[i+K-1] - x[i]))
print(m)


Measured memory_bytes: 14224
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int min = -1000000, max = 1000000;
		int K = ni(), X = ni();
		for(int i = X - K + 1; i <= X + K - 1; i++) {
			out.print(i+" ");
		}
		out.println();

	}
			    
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int m,d;cin>>m>>d;
	int ans = 0;
	for(int i = 1; i <= m; i++) {
		for(int j = 1; j <= d; j++) {
			int d1 = j / 10;
			int d2 = j % 10;
			if (d1 >= 2 && d2 >= 2 && i == d1 * d2){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool ans = true;
	for(int i = 0; i < a + b + 1; i++) {
		if(i == a && s[i] != '-') ans = false;
		else if(i != a && (s[i] < '0' || s[i] > '9')) ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
num = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    num[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, num[b][f])))
    if b < 3:
        print("#"*20)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0));

  for (i = 1; i <= n;i++){
    for (j = i; j > 0 ;j--){
      dp[i][j] = max(a[i-1] - dp[i - 1][j], a[j-1] - dp[i][j+1]);
      // cout << i << ' ' << j << ' ' << dp[i][j] << endl;
    }
  }

  cout << dp[n][1] << endl;

  return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>

int main(){
  int n,i;
  
  scanf("%d", &n);
  
  int *a = (int*)malloc(sizeof(int)*n);

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

  int work;
  for(i = 0; i < n/2 ; ++i){
    work = a[i];
    a[i] = a[n - 1 - i];
    a[n - 1 - i] = work;
  }

  for(i = 0; i<n; ++i){
    printf("%d",a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");
  
  free(a);
  
  return 0;
}



Measured memory_bytes: 2040
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, vs: [i64; n]);

    let mut acc = vec![0i64; n + 1];
    for i in 0..n {
        acc[i + 1] = acc[i] + vs[i];
    }

    let mut ans = 1_000_000_010_010;
    for i in 1..n {
        let tmp = 2 * acc[i] - acc.last().unwrap();
        ans = min(ans, tmp.abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
def main():
    n = input()
    n_int = int(n)
    n_list = map(int, list(n))
    sn = sum(n_list)

    if n_int % sn == 0:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


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

typedef long long LL;
const LL mod = 1e9+7;
LL x[100003], y[100003];
int main()
{
    int n, m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; ++i)
        scanf("%lld",&x[i]);
    for(int i=0; i<m; ++i)
        scanf("%lld",&y[i]);
    LL W = 0, H = 0;
    for(int l=0, r=n-1; l<r; ++l,--r)
        W = (W + (x[r]-x[l])*(r-l))%mod;
    for(int l=0, r=m-1; l<r; ++l,--r)
        H = (H + (y[r]-y[l])*(r-l))%mod;
    printf("%lld\n",(W*H)%mod);
    return 0;
}


Measured memory_bytes: 1792
#!/user/bin/env pypy3
import collections
import sys


def fast_input():
    return sys.stdin.readline()[:-1]


def solve(c_500: int, c_100: int, c_50: int, amount: int) -> int:
    amount_list = []
    for i_500 in range(c_500 + 1):
        for i_100 in range(c_100 + 1):
            for i_50 in range(c_50 + 1):
                amount_list.append(i_500 * 500 + i_100 * 100 + i_50 * 50)

    return amount_list.count(amount)


def main():
    c_500 = int(fast_input())
    c_100 = int(fast_input())
    c_50 = int(fast_input())
    amount = int(fast_input())
    result = solve(c_500, c_100, c_50, amount)
    print(result)


main()


Measured memory_bytes: 14204
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[105];
int main(){
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]*4*m>=sum){
            cnt++;
        }
    }
    if(cnt>=m){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  double x[n],r[n];
  for(int i=0;i<n;i++) cin>>x[i]>>r[i];
  double L=0,R=1e9;
  for(int i=0;i<200;i++){
    double M=(L+R)/2;
    double lb=0,ub=1e9;
    for(int j=0;j<n;j++){
      if(r[j]<=M){
	//lb=max(lb,x[j]-r[j]);
	//ub=min(ub,x[j]+r[j]);
	lb=ub+1;
	break;
      }else{
	double tmp=sqrt(r[j]*r[j]-M*M);
	//cout<<tmp<<endl;
	lb=max(lb,x[j]-tmp);
	ub=min(ub,x[j]+tmp);
      }
    }
    //cout<<M<<":"<<lb<<" "<<ub<<endl;
    if(lb<=ub) L=M;
    else R=M;
  }
  printf("%.12f\n",R);
  return 0;
}

Measured memory_bytes: 4860
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}

char maze[1005][1005];
int vis[1005][1005];
int c1,c2,d1,d2;
queue<Pii> q[2];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
 
int main(){
    int t=1;
    // read(t);
    while(t--){
        int h,w;
        read(h,w);
        read(c1,c2,d1,d2);
        for(int i=0;i<=h+1;i++){
            for(int j=0;j<=w+1;j++){
                maze[i][j]='#';
            }
        }
        for(int i=1;i<=h;i++){
            scanf("%s",maze[i]+1);
        }
        bool flag=true;
        vis[c1][c2]=1;
        int x=0,ans=0;
        q[x].push(Pii(c1,c2));
        while(1){
            while(!q[x].empty()){
                Pii now=q[x].front();
                q[x^1].push(now);
                q[x].pop();
                for(int i=0;i<4;i++){
                    int tx=now.first+dx[i];
                    int ty=now.second+dy[i];
                    if(!vis[tx][ty]&&maze[tx][ty]=='.'){
                        q[x].push(Pii(tx,ty));
                        q[x^1].push(Pii(tx,ty));
                        vis[tx][ty]=1;
                    }
                }
            }
            if(vis[d1][d2]){
                break;
            }
            x^=1;
            ans++;
            while(q[x].size()){
                Pii now=q[x].front();
                q[x].pop();
                for(int i=-2;i<=2;i++){
                    for(int j=-2;j<=2;j++){
                        int tx=now.first+i;
                        int ty=now.second+j;
                        if(tx<0||tx>h)continue;
                        if(ty<0||ty>w)continue;
                        if(!vis[tx][ty]&&maze[tx][ty]=='.'){
                            q[x^1].push(Pii(tx,ty));
                            vis[tx][ty]=1;
                        }
                    }
                }
            }
            if(vis[d1][d2]){
                break;
            }
            x^=1;
            if(q[x].empty()){
                flag=false;
                break;
            }
        }
        if(!flag){
            puts("-1");
            break;
        }
        printf("%d\n",ans);
    }
    return 0;}

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

struct store {
  long long price;
  long long zaiko;
};


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

  vector<store> stores;
  for(int i=0;i<N;i++){
    long long t_price;
    long long t_zaiko;
    cin >> t_price >> t_zaiko;
    store t_store = {t_price, t_zaiko};
    stores.push_back(t_store);

    //cout << stores[i].price << " " << stores[i].zaiko << "\n";
  }

  sort(stores.begin(), stores.end(), [](const store& x, const store& y) { return x.price < y.price;});

  long long kosu = 0;
  long long ite = 0;
  long long result = 0;
  while (kosu < M) {
    if(ite == N){
      break;
    }

    if(kosu + stores[ite].zaiko < M){
      kosu += stores[ite].zaiko;
      result += stores[ite].price * stores[ite].zaiko;
    }else{
      result += stores[ite].price * (M - kosu);
      kosu = M;
    }
    ite++;

    //cout << result << " " << kosu << "\n";
  }

  cout << result << "\n";

  return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100, M = 10;

int n;
int a[N];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i ++ ) cin >> a[i];
	sort(a, a + n);
	
	LL res = 0x3f3f3f3f;
	for (int mid = 1; mid <= N; mid ++ )
	{
		LL t = 0;
		for (int i = 0; i < n; i ++ )
			t += abs((mid - a[i]) * (mid - a[i]));
		res = min(res, t);
	}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
if(a*b%2==0) {
	System.out.println("Even");
}
else {
	System.out.println("Odd");
}
	}
}


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

using namespace std;
using ll = long long;
const ll mod = 1000000007;

const vector<vector<int>> dir2 = {{0, 1}, {1, 0}};
const vector<vector<int>> dir8 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> mp(h + 2, vector<bool>(w + 2)), seen(h + 2, vector<bool>(w + 2));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char t; cin >> t;
            mp[i][j] = (t == '#');
        }
    }

    queue<pair<int,int>> que;
    que.push({1,1});

    while(que.size()) {
        auto cur = que.front();
        que.pop();
        int cnt = 0;
        mp[cur.first][cur.second] = 0;
        seen[cur.first][cur.second] = 1;
        for(auto i : dir2) {
            if(mp[i[0] + cur.first][i[1] + cur.second]){
                cnt++;
                que.push({i[0] + cur.first, i[1] + cur.second});
            }
            if(cnt == 2) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    for(int i = 0; i <= h + 1; i++){
        for(int j = 0; j <= w + 1; j++){
            if(mp[i][j]){cout << "Impossible" << endl;
            return 0;}
        }
    }

    if(seen[h][w])
    cout << "Possible" << endl;
    else
    assert(0);
}

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

int main() {
  int n,x;
  cin >> n;
  x = 0;
  int a = n;
  while(a>0){
    x += a%10;
    a = a/10;
  }
  
  if(n%x == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  char s[101], t[101];
  cin >> s >> t;
  int cnt = 0, cnt2 = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (i % 2 == 0) {
      cout << s[cnt];
      cnt++;
    } else {
      cout << t[cnt2];
      cnt2++;
    }
  }
	return 0;
}


Measured memory_bytes: 256