akhauriyash/Code-Regression huggingface dataset:
class Dice
	def initialize()
		# top bottom N E S W
		@number = gets.split.map(&:to_i)

		@dice_number = [1, 6, 5, 3, 2, 4]
	end

	def rotate(command)
		swap_number = []

		case command
		when 'N'
			swap_number = [2, 1, 4]
			swap(swap_number)
		when 'E'
			swap_number = [3, 1, 5]
			swap(swap_number)
		when 'S'
			swap_number = [4, 1, 2]
			swap(swap_number)
		when 'W'
			swap_number = [5, 1, 3]
			swap(swap_number)
		end
	end

	def rotate_horizontal
		tmp = @dice_number[2]
		(2..4).each {|i| @dice_number[i] = @dice_number[i+1]}
		@dice_number[5] = tmp
	end

	def swap(number)
		number.map do |n|
			@dice_number[0], @dice_number[n] = @dice_number[n], @dice_number[0]
		end
	end

	def number
		number_return = []
		(0..5).each do |e|
			number_return << @number[@dice_number[e]-1]
		end
		
		number_return
	end
end

def rotateToTop(dice, position)
	case position
	when 0 then
	when 1 then
		dice.rotate('N')
	when 2 then
		dice.rotate('W')
	when 3 then
		dice.rotate('E')
	when 4 then
		dice.rotate('S')
	when 5 then
		2.times { dice.rotate('S') }
	end
end

dice1 = Dice.new
dice2_source = Dice.new

match_flag = false
(0..5).each do |e|
	dice2 = Marshal.load(Marshal.dump(dice2_source.clone))

	rotateToTop(dice2, e)

	num_of_rotation = 0
	while (num_of_rotation+=1) <= 4 do
		if dice1.number == dice2.number then
			match_flag = true
			break
		end
		
		dice2.rotate_horizontal
	end
	
	break if match_flag
end

if match_flag then
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 6152
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
ll helper(vector<vector<char>>& v, int h, int w){
  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;
  for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w; j++){
      if(i == 0 && j == 0)
        continue;
      if(v[i][j] == '.'){
        ll x = 0, y = 0;
        if(i > 0)
          x = dp[i-1][j];
        if(j > 0)
          y = dp[i][j-1];
        dp[i][j] = ((x % mod) + (y % mod)) % mod;
      }
    }
  }
  /*for(int i = 0 ; i < h ; i++){
    for(int j = 0 ; j < w ; j++)
      cout << dp[i][j] << " ";
  	cout << endl;
  }*/
    return dp[h-1][w-1];
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<char>> v(h, vector<char>(w));
  for(int i = 0 ; i < h ; i++)
    for(int j = 0 ; j < w ; j++)
      cin >> v[i][j];
  cout << helper(v, h, w) << endl;
}

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

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = a[0];
    for (int j = 1; j < n; j++)
    {
        ans *= a[j];
        if (ans < 0)
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    if (0 < ans && ans <= 1000000000000000000)
    {
        cout << ans << endl;
    }
    else
        cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M,j=0;
  cin>>N>>M;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    j+=i;
  }
  sort(A.begin(),A.end());
  if(A[N-M]*4*M<j)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
The secret of getting ahead is getting started.
It is hard to beat a person who never gives up.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.*/
// #include<bits\stdc++.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#include<sstream>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first > b.first;
//  }

int a[2 * N];
void solve()
{
    int n;
    cin>>n;
    rep(i,n)
    {
        cin >> a[i];
    }
    ll ans = 0;
    ll m = 0;
    rep(i,n)
    {
        if(a[i]<m)
        {
            ans += (m - a[i]);
        }
        else if(a[i]>m)
        {
            m = a[i];
        }
    }
    cout << ans << lin;
}





int main()
{
    // auto start = clock();
    fast_io;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    // int c = 1;
    while (t--)
    {
        // cout << "Case " << c << ":"
        // << lin;
        solve();
        // if(t)
        // {
        //     cout << lin;
        // }
        // c++;
    }
    // auto stop = clock();
    // cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}

Measured memory_bytes: 4432
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        PrintWriter out = new PrintWriter(System.out);
        if (N < 1000) {
            out.println(1000 - N);
            sc.close();
            out.flush();
            return;
        }

        int x = 0;
        x = (int) Math.ceil((double) N / 1000);

        out.println(1000 * x - N);
        sc.close();
        out.flush();
    }
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string c1 = Console.ReadLine();
            string c2 = Console.ReadLine();
            Console.WriteLine(c1[1] == c2[1] && c1[0]==c2[2] && c2[0]==c1[2]?"YES":"NO");
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = nint();
        int T = nint();
        int[] t = nints(N);
        
        long ans = 0;
        for (int i = 0; i < N-1; i++) {
            ans += Math.min(T, t[i+1] - t[i]);
        }
        ans += T;
        
        System.out.println(ans);
    }
    
    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}

Measured memory_bytes: 64524
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

vector<string> v;
int N;

void rec(int n, string s) {
    if (n == 0) {
         if(atoi(s.c_str()) <= N) v.push_back(s);
        return;
    }
    rec(n-1, s+'3');   
    rec(n-1, s+'5');   
    rec(n-1, s+'7');   
}

void solve() {
    cin >> N;
    string s = to_string(N);

    for (int i = 3; i <= s.size(); i++) rec(i, "");

    int ans = 0;

    for (auto e : v) {
        int state = 0;
        for (int i = 0; i < e.size(); i++) {
            if (e[i] == '3') state |= 1;
            if (e[i] == '5') state |= 1<<1;
            if (e[i] == '7') state |= 1<<2;
        }
        if (state == 7) ans++;
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4296
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

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

	std::vector<int> hs(n);
	for (auto&& e : hs)
		std::cin >> e;

	std::sort(hs.begin(), hs.end());

	std::cout << std::accumulate(hs.begin(), hs.begin() + std::max(n - k, 0), 0ll) << std::endl;
}

Measured memory_bytes: 1024
N = int(input())
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))
ZW = []
for i in range(N):
    ZW.append([XY[i][0]-XY[i][1],XY[i][0]+XY[i][1]])

out = []
ZW.sort(key=lambda x:x[0])
out.append(abs(ZW[0][0]-ZW[N-1][0]))
ZW.sort(key=lambda x:x[1])
out.append(abs(ZW[0][1]-ZW[N-1][1]))
print(max(out))


Measured memory_bytes: 140316
s = int(input())
ans = [0]*1000001
for i in range(1,1000001):
    if i == 1:
        a = s
        ans[a] +=1
    else:
        if a%2 == 0:
            a = a//2
            ans[a] += 1
        else:
            a = 3*a+1
            ans[a] +=1
        if ans[a] ==2:
            print(i)
            break


Measured memory_bytes: 16700
N = int(input())

V = list(input().split())
V = [int(V[i]) for i in range(N)]

C = list(input().split())
C = [int(C[i]) for i in range(N)]

Ans = 0

for i in range(N):
    if V[i] - C[i] >= 0:
        Ans += V[i] - C[i]
        
print(Ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

vector <ll> v[100005];
multiset <ll> s;

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,m,x,y;
  cin>>n>>m;
  forn(i,0,n){
    cin>>x>>y;
    if(x>m) continue;
    v[x].pb(y);
  }
  ll ans=0;
  for(ll i=1;i<=m;i++){
    for(auto it:v[i])
      s.insert(it);
    if(sz(s)!=0){
      ans+=(*s.rbegin());
      auto it1=s.end();
      --it1;
      s.erase(it1);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8320
height, width = gets.split.map &:to_i
g = Array.new(height)
dp = Array.new(height).map { Array.new(width) }
max = 0

(0...height).each do |i|
  g[i] = gets.split.map &:to_i
end

(0...height).each do |i|
  if g[i][0] == 0
    dp[i][0] = 1
    max = 1
  else
    dp[i][0] = 0
  end
end

(0...width).each do |i|
  if g[0][i] == 0
    dp[0][i] = 1
    max = 1
  else
    dp[0][i] = 0
  end
end

(1...height).each do |i|
  (1...width).each do |j|
    if g[i][j] == 1
      dp[i][j] = 0
    else
      dp[i][j] = [dp[i-1][j-1], dp[i][j-1], dp[i-1][j]].min + 1
      max = max > dp[i][j] ? max : dp[i][j]
    end
  end
end

puts max**2

Measured memory_bytes: 40424
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

bool p[52];
vector<vector<pair<int,int>>> G(51);

bool conn(int from, int to) {
	if (from == to)return 1;
	for (auto i : G[from]) {
		if (p[i.second])continue;
		if (conn(i.first, to))return 1;
	}
	return 0;
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N), B(N);

	for (int i = 1;i < 51;i++) {
		for (int j = i;j < 51;j++) {
			if (j%i == j)continue;
			G[j%i].push_back({ j,i });
		}
	}
	ll a = 1, ans = 0;
	for (int i = 0;i < N;i++)cin >> A[i];
	for (int i = 0;i < N;i++)cin >> B[i];
	for (int i = 0;i < 52;i++)p[i] = 0;
	for (int i = 0;i < 51;i++)a *= 2;

	for (int i = 51;i > 0;i--) {
		p[i] = 1;
		for (int j = 0;j < N;j++) {
			if (!conn(B[j], A[j]))p[i] = 0;
		}
		if (!p[i])ans += a;
		if (!p[i] && i == 51) { ans = -1;break; }
		//cout << a << endl;
		a >>= 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  int A[5]={};
  cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
  int map[5] = {};
  for(int i = 0; i < 5; i++){
    if(A[i]%10 == 0){
      map[i] = 0;
    }else{
      map[i] = 10- A[i]%10;
    }
  }
  vector<pair<int,int>> pairs(5);
  for(int i = 0; i < 5; i++){
    pairs[i] = make_pair(map[i],A[i]);
  }
  sort(pairs.begin(),pairs.end());
  cout << (pairs[0].first + pairs[0].second + pairs[1].first + pairs[1].second + pairs[2].first + pairs[2].second + pairs[3].first + pairs[3].second + pairs[4].second) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll     long long int
#define pb     push_back
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std ;
int main()
{
     fast;
     int t=1;
    // cin>>t;
     while(t--)
     {
       ll n,i,j,k,a,b,c=0,d,sum=0,x,y,result,ans=0;
      string s;
      cin>>s;
      if(s=="ABC")
        cout<<"ARC"<<endl;
      else cout<<"ABC"<<endl;


     }
     return 0;
}


Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var t = N / 2;
            double ans = 1.0 - (double)(t / (double)N);
            WriteLine(ans);
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  vi a(n), ans(n);
  rep(i, n){
    cin >> a[i];
    ans[a[i]-1]=i+1;
  }

  rep(i, n)cout << ans[i] << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };

ll a[200005];
ll ps[200005];
int main()
{
	SYNC;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	ll ans = 0;
	ll res = 1;
	for (int i = 1; i <= n; i++) {
		ps[i] = (ps[i - 1] + a[i]) % MOD;
	}
	for (int i = 1; i <= n; i++) {
		ans = (ans + a[i] * (ps[n] - ps[i]) % MOD) % MOD;
		if (ans < 0)
			ans += MOD;
		ans %= MOD;
	}
	//모든 곱
	if (ans < 0)
		ans += MOD;
	ans %= MOD;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6800
n = gets.to_i

count = {}
n.times do
    s = gets.chomp
    if count[s]
        count[s] += 1
    else
        count[s] = 1
    end
end

max = count.values.max
puts count.to_a.select { |a| a[1]==max }.map { |a| a[0] }.sort.join("\n")


Measured memory_bytes: 46696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

ll A,B,K;

int main(){
  cin >> A >> B >> K;
  rep(i , K) {
    if(i % 2 == 0){
      if(A % 2 != 0) A -= 1;
      B += A / 2; A -= A / 2;
    }
    else {
      if(B % 2 != 0) B -= 1;
      A += B / 2; B -= B / 2;
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	int mx,my;
	scanf("%d%d",&mx,&my);
	for(int i=0;i<mx;i++)
	{
		for(int j=0;j<my;j++)
		{
			string s;
			cin>>s;
			if(s=="snuke")
			{
				printf("%c%d\n",'A'+j,i+1);
				return 0;
			}
		}
	}
}

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

int main(){
  int n,m; cin>>n>>m;
  int l=0, r=n;

  for(int i=0; i<m; ++i){
    int x,y; cin>>x>>y;
    l=max(l,x);
    r=min(r,y);
  }

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


Measured memory_bytes: 256
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2017;

string s, t;
int ans = oo;
PII a[N];

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> s >> t;
	int n = sz(s);

    bool ok = 0;
    forn(i, 0, n - 1) if (t[i] == '1') ok = 1;
    if (!ok) {
        forn(i, 0, n - 1) if (s[i] == '1') ok = 1;
        if (!ok) cout << "0\n";
        else cout << "-1\n";
        return 0;
    }

	forn(i, 0, n - 1) {
        int val1 = 0;
        forn(j, 0, n - 1) if (s[j] != t[(j + (n - i)) % n]) {
            ++val1;
        }
        int cur = 1, last = -1;
        forn(j, 0, n - 1) if (t[j] == '1') last = j;
        forn(j, 0, n - 1) {
            if (t[j] == '1') last = j;
            if (s[j] == '1' && t[(j + (n - i)) % n] == '0') {
                a[cur].F = (last > j ? j + (n - last) : j - last);
                ++cur;
            }
        }
        int sz = cur - 1;
        for1(j, n - 1, 0) if (t[j] == '1') last = j;
        for1(j, n - 1, 0) {
            if (t[j] == '1') last = j;
            if (s[j] == '1' && t[(j + (n - i)) % n] == '0') {
                --cur;
                a[cur].S = (last < j ? last + (n - j) : last - j);
            }
        }
        sort(a + 1, a + sz + 1);
        int val2 = oo;
        if (sz == 0) val2 = min(i, n - i);
        int mx = 0, pos = 0;
        for1(j, sz, 1) {
            pos = (i + mx) % n;
            val2 = min(val2, min(pos, n - pos) + mx + a[j].F * 2);
            mx = max(mx, a[j].S);
        }
        pos = (i - a[sz].F + n) % n;
        val2 = min(val2, min(pos, n - pos) + a[sz].F);
        forn(j, 1, sz) swap(a[j].F, a[j].S);
        sort(a + 1, a + sz + 1);
        mx = 0;
        for1(j, sz, 1) {
            pos = (i - mx + n) % n;
            val2 = min(val2, min(pos, n - pos) + mx + a[j].F * 2);
            mx = max(mx, a[j].S);
        }
        pos = (i + a[sz].F) % n;
        val2 = min(val2, min(pos, n - pos) + a[sz].F);

        ans = min(ans, val1 + val2);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1; 
        for(int i = 2; i < x ; i++){
            if(x == 1){
                break;
            }
            for(int j = 2; Math.pow(i,j) <= x; j++){
                if(Math.pow(i,j) > ans){
                    ans = Math.pow(i,j);
                }    
            }
        }
        System.out.println((int)ans);
    }
}


Measured memory_bytes: 21712
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define REP(i,m,n) for(int i = (int)(m) ;i < (int)(n) ;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int a, b;
int main(){

	cin >> a >> b;
	cout << a * b - a - b + 1 << endl;






	return 0;
}

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

int main(){
	int A,B;cin >> A >> B;

	if(A == 1){
		if(B == 2){
			cout << 3 << endl;
		}else if(B == 3){
			cout << 2 << endl;
		}
	}else if(A == 2){
		if(B == 1){
			cout << 3 << endl;
		}else if(B == 3){
			cout << 1 << endl;
		}
	}else{
		if(B == 1){
			cout << 2 << endl;
		}else if(B == 2){
			cout << 1 << endl;
		}
	}
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    vector<int>a(5);
    for(int i=0;i<5;i++)cin >> a[i];
    int mxdif=0;
    int mndif=1e9;
    int mxidx=-1;
    int ans=0;
    for(int i=0;i<5;i++){
		if(a[i]%10==0) ans+=a[i];
		else ans+=((10-(a[i]%10))+a[i]);
 
		if(10-a[i]%10>mxdif && a[i]%10!=0){
			mxdif=10-a[i]%10;
			mxidx=i;
		}
	}
    if(mxidx!=-1){
		ans-=(10-(a[mxidx]%10))+a[mxidx];
		ans+=a[mxidx];
 
	}
	cout << ans << endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())

l = 0
r = N - 1

p = 0
print(p, flush=True)
first = sys.stdin.readline().strip()
if first == "Vacant":
    sys.exit()
if first == "Male":
    second = "Female"
else:
    second = "Male"

while True:
    p = (l + r) // 2
    print(p, flush=True)
    sex = sys.stdin.readline().strip()
    if sex == "Vacant":
        # print("end!")
        sys.exit()
    if p % 2 == 0:
        # pまでの間に空席がない場合は性別が同じ
        if sex == first:
            l = p + 1
        # ずれているので、そこまでに空席がある
        else:
            r = p
    else:
        if sex == second:
            l = p + 1
        else:
            r = p

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
string S,T;

int dp[3010][3010] = {0};

int main() {
    cin >> S >> T;
    // 初期化 (最小問題なので INF に初期化)

    // 初期条件

    // ループ
    for (int i = 0; i < S.size(); ++i) {
        for (int j=0;j<T.size();j++) {
            if (S[i] == T[j]) {
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string ans = "";
    int i = S.size();
    int j = T.size();

    while(i > 0 && j > 0) {
        if (dp[i][j] == dp[i][j-1]) {
            j--;
        }
        else if (dp[i][j] == dp[i-1][j]) {
            i--;
        }
        else {
            ans = S[i-1] + ans ;
            i--;
            j--;
        }
    }
    // 答え
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

#define FOR(i,n) for(ll i=0;i<n;i++) 
#define RFOR(i,n) for(ll i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl

#define MAX_N 100ll //"long long","int"かを変えること!!!!

string A = "ABC" ;

string B = "ARC";

//入力
int x ;

int main() {

	cin >> x;

	if(1200<= x) COUT(B);

	else COUT(A);

	return 0;
}


Measured memory_bytes: 256
main=print.solve=<<readLn
solve k=as!!(k-1)
as=[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]

Measured memory_bytes: 3940
a, b = input().split(" ")
x = int(a)
y = int(b)
amt = 0
if x == 3:
    amt += 100000
elif x == 2:
    amt += 200000
elif x == 1: 
    amt += 300000

if y == 3:
    amt += 100000
elif y == 2:
    amt += 200000
elif y == 1: 
    amt += 300000

if x == 1 and y == 1:
    amt += 400000

print (amt)

Measured memory_bytes: 3064
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: chars
    );
    let ans = if n.contains(&'7') {"Yes"} else {"No"};
    println!("{}", ans);
}


Measured memory_bytes: 2112
import java.util.*;
class Main {
	public static void main(String args[]) {
    	Scanner s = new Scanner(System.in);
      	int a = s.nextInt();
      	int b = s.nextInt();
      	System.out.println((a % 2 == 0 || b % 2 == 0) ? "No" : "Yes");
    }
}

Measured memory_bytes: 21844
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    if (s.size() > 5 && s[2] == s[3] && s[5] == s[4])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S,T;
    cin >> S;
    cin >> T;
    cout << T+S << endl;

    

}

Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
  
public class Main {
	private MyIntStack st = new MyIntStack();

    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
    
    public void exec() throws IOException {
    	SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        out.println(calc(in.readStrArray(" ")));
        out.flush();
    }

    private int calc(String[] exp) {
    	int ret=0;
    	for(String s: exp) {
    		switch(s.charAt(0)){
	    		case '+':{
	    			int b = st.pop();
	    			int a = st.pop();
	    			ret = st.push(a + b);
	    			break;
	    		}
	    		case '-':{
	    			int b = st.pop();
	    			int a = st.pop();
	    			ret = st.push(a - b);
	    			break;
	    		}
	    		case '*':{
	    			int b = st.pop();
	    			int a = st.pop();
	    			ret = st.push(a * b);
	    			break;
	    		}
	    		default:{
	    			st.push(Integer.parseInt(s));
	    		}
    		}
    	}
    	return ret;
    }

}

class MyIntStack {
	private static final int CAPACITY = 100;
	private int[] stack = new int[CAPACITY];
    private int head = 0;
    
    public boolean isEmpty(){return head == 0;}
    public boolean isFull(){return head == CAPACITY;}
    
    public int pop() {
    	if(isEmpty()) throw new IllegalStateException();
    	return stack[--head];
    }
   
    public int push(int value) {
    	if(isFull()) throw new IllegalStateException();
    	return stack[head++] = value;
    }
}

class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
}

Measured memory_bytes: 24336
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,k,c,sw,ans;
  sw=0;
  
  cin >> a >> b >> k;
  c=gcd(a,b);
  ans=c;
  while(sw<k)
  {
  if(c%ans==0) sw++;
  ans--;
  }
  cout << ans+1;
return 0;}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<queue>
using namespace std;
const int maxn=505;
const int INF=(int)(1e9)+100;
int a[maxn][maxn];
int c[maxn],d[maxn],inq[maxn];
char s[maxn][maxn];
queue<int> Q;
int n;
void SPFA()
{
    for(int i=1;i<=n;i++) 
	if(!d[i])Q.push(i),inq[i]=1;
    while(!Q.empty()) 
	{
        int x=Q.front();Q.pop();
        inq[x]=0;
        for(int i=1;i<=n;i++) 
		if(d[i]>d[x]+1) 
		{
            d[i]=d[x]+1;
            if(!inq[i]) 
			{
                Q.push(i);
                inq[i]=1;
            }
        }
    }
}
int main() 
{
   	scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    int mx=0;
    for(int i=1;i<=n;i++) 
	for(int j=1;j<=n;j++) 
	{
        a[i][j]=(s[i][j]=='#');
        c[i]+=a[i][j];mx=max(mx,c[i]);
    }
    if(!mx) 
	{
        printf("-1\n");return 0;
	}
    for(int i=1;i<=n;i++)d[i]=INF;
    for(int i=1;i<=n;i++) 
	for(int j=1;j<=n;j++) 
	if(a[i][j]) d[j]=0;
    SPFA();
    int tmp=INF,id=0;
    for(int i=1;i<=n;i++) 
	{
        if(d[i]!=INF && n-c[i]<tmp) 
		{
            tmp=min(tmp,n-c[i]+d[i]);id=i;
        }
    }
    for(int j=1;j<=n;j++)
	for(int i=1;i<=n;i++) 
	if(!a[i][j]) 
	{
        tmp++;
		break;
    }
    printf("%d\n",tmp);
    return 0;
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int a, b;
    cin >> a >> b;
    if (a <= 5)
        cout << 0;
    else if (a <= 12)
        cout << b / 2;
    else
        cout << b;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3512
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int A[1000000];

int main()
{
    int K, N, i, minimum;

    scanf("%d%d", &K, &N);
    for(i = 0; i < N; ++i)
        scanf("%d", &A[i]);

    minimum = A[N - 1] - A[0];
    for(i = 0; i < N - 1; ++i)
        minimum = min(minimum, A[i] + K - A[i + 1]);
    printf("%d", minimum);

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  int count1=0;
  
  cin>>s;
  if(s[0]=='1')count1++;
  if(s[1]=='1')count1++;
  if(s[2]=='1')count1++;
  cout<<count1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int par[100010],unionfind_rank[100010];

void init(int n){
  FOR(i,n){
    par[i+1]=i+1;
    unionfind_rank[i+1]=0;
  }
}

int root(int x){
  return par[x] == x ? x : par[x] = root(par[x]);
}

bool same(int x,int y){
  return root(x) == root(y);
}

void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  if(unionfind_rank[x]<unionfind_rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(unionfind_rank[x]==unionfind_rank[y])unionfind_rank[x]++;
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  int p[100010],v[100010];
  FOR(i,n){
    cin >> p[i];
    v[p[i]]=i+1;
  }
  int x[100010],y[100010];
  init(n);
  FOR(i,m){
    cin >> x[i] >> y[i];
    unite(x[i],y[i]);
  }
  int ans=0;
  FOR(i,n){
    if(same(v[i+1],i+1))ans++;
  }

  cout << ans << endl;
  
}

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

const int N=1e4+5,zqm=1e9+7;
int f[N][100],n,d;
char num[N];

int dp(int x,int y,bool ub) {
	int lim=(ub ? num[x] : 9);
	if(x==n) return lim/d+1-(lim/d*d+y>lim);
	if(!ub&&f[x][y]!=-1) return f[x][y];
	int ret=0;
	for(int i=lim;i>=0;--i) {
		(ret+=dp(x+1,(y-i+d)%d,ub&&i==num[x]))%=zqm;
	}
	if(!ub) f[x][y]=ret;
	//cerr<<x<<' '<<y<<' '<<ub<<' '<<ret<<endl;
	return ret;
}

int main() {
	//freopen("1.in","r",stdin);
	//freopen("1.ans","w",stdout);
	
	scanf("%s%d",num+1,&d);
	n=strlen(num+1);
	for(int i=1;i<=n;++i) num[i]-=48;
	memset(f,255,sizeof(f));
	printf("%d\n",(dp(1,0,1)+zqm-1)%zqm);
	
	return 0;
}


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

int n,q;
int A[20];

bool solve(int i,int target){
    //sumというのを用意しないで、引いていくのが頭いいね。変数が少なくて済む。
    if(target==0)return true;
    else if(i>=n)return false;
    else{
        bool rec= solve(i+1,target) || solve(i+1,target-A[i]);
        return rec;
    }
}

int main(){
    cin>>n;for(int i=0;i<n;i++)cin>>A[i];
    cin>>q;
    for(int j=0;j<q;j++){
        int target;cin>>target;
        if(solve(0,target))cout<<"yes"<<endl;
        else{cout<<"no"<<endl;}
    }
    return 0;
}


Measured memory_bytes: 3128
# https://atcoder.jp/contests/abc079/tasks/abc079_d

# cost[i][j] = 数字 i から数字 j に変えた時の最小コスト
# per[i][j] = 最小コストを実現した際の数字 i を数字 j に変えるのにかかるコスト
# num[i][j] = 最小コストを実現した際の新たに追加された数字 j の個数

from collections import Counter
from copy import copy

import sys
input = sys.stdin.readline

H, W = map(int, input().split())

cost = [list(map(int, input().split())) for _ in range(10)]

A = [list(map(int, input().split())) for _ in range(H)]
A = sum(A,[])

cnt = Counter(A)

for k in range(10):
    for i in range(10):
        for j in range(10):
            if cost[i][j] > cost[i][k] + cost[k][j]:
                cost[i][j] = cost[i][k] + cost[k][j]

res = 0
for i in range(10):
    res += cnt[i]*cost[i][1]


print(res)

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

int main()
{
  int n;
  cin >> n;
  valarray<int> a(n);
  for (auto&& e : a) cin >> e;
  a ^= reduce(begin(a), end(a), 0, [](auto x, auto y){return x ^ y;});
  for_each(begin(a), end(a), [](auto e){cout << e << endl;});
}


Measured memory_bytes: 4056
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    vector<ll> a(n);

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

    ll fx = 0;

    for(int i = 0; i < n; i++){
        if(i&1){
            fx -= a[i];
        }else{
            fx += a[i];
        }
    }

    vector<ll> ans;
    ans.push_back(fx);

    for(int i = 1; i < n; i++){
        ans.push_back(2*(a[i-1]-ans.back()/2));
    }

    for(auto &x:ans){
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3060
# input
N = int(input())
X = list(map(int, input().split()))

# check
ans = 0
for i in range(1, 101, 1):
    sub_life = sum([(j - i) ** 2 for j in X])

    if i == 1 or ans > sub_life:
        ans = sub_life

print(ans)

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

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

	vector<pair<long long, long long>> p;
	for( long long i = 2; i * i <= N; i++ ) {
		if( N % i == 0 ) {
			p.push_back( make_pair( i, N / i ) );
		}
	}
	p.push_back( make_pair( 1, N ) );

	long long ans = INT64_MAX;
	for( auto it = p.begin(); it < p.end(); it++ ) {
		ans = min( ans, it->first + it->second - 2 );
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    long long b[10];
    long long mb=0;
    long long ma=0;
    for(long long i=1;i<10;i++){
    cin>>b[i];}
    if(((b[1]+b[5]+b[9])==(b[2]+b[6]+b[7])&&(b[2]+b[6]+b[7])==(b[3]+b[4]+b[8]))&&((b[1]+b[6]+b[8])==(b[3]+b[5]+b[7])&&(b[3]+b[5]+b[7])==(b[2]+b[4]+b[9]))){
    cout<<"Yes"<<endl;}
    else
    cout<<"No"<<endl;}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
   int N;
   cin>>N;
   if(N<=111){
       cout<<111<<endl;
   }
   else if(N<=222){
       cout<<222<<endl;
   }   
   else if(N<=333){
       cout<<333<<endl;
   }   
   else if(N<=444){
       cout<<444<<endl;
   }   
   else if(N<=555){
       cout<<555<<endl;
   }  
   else if(N<=666){
       cout<<666<<endl;
   }   
   else if(N<=777){
       cout<<777<<endl;
   }   
   else if(N<=888){
       cout<<888<<endl;
   }   
   else{
       cout<<999<<endl;
   }   
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[2][200];
int d[2][200];

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define int long long
using namespace std;
int n;
bool b[12345];
vector<int>v[12345];
int a[12345], ans[12345], ans1;
queue<int>q; int ap;
void f(int p) {
	ans[p] = a[ap--]; if (p != 1)ans1 += ans[p];
	b[p] = 1;
	for (int i = 0; i < v[p].size(); i++)if (!b[v[p][i]])q.push(v[p][i]);
	return;
}
signed main() {
	cin >> n; ap = n - 1;
	for (int i = 0; i < n - 1; i++) {
		int p, q; cin >> p >> q;
		v[p].push_back(q);
		v[q].push_back(p);
	}
	for (int i = 0; i < n; i++)cin >> a[i]; sort(a, a + n);
	q.push(1);
	while (q.size()) {
		if (!b[q.front()]) {
			f(q.front());
		}
		q.pop();
	}
	cout << ans1 << endl << ans[1];
	for (int i = 2; i <= n; i++)cout << ' ' << ans[i];
	cout << endl;
	cin >> n;
}

Measured memory_bytes: 1280
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    ans = -100
    for i in range(-1,102):
        if i not in p and abs(i-x) < abs(ans-x):
            ans = i
    print(ans)
    
    return

if __name__ == '__main__':
    main()

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

int n, m;

vector <int> g[100100];

vector <int> topol;
bool used[100100];
int dp[100100];

void dfs(int v){
    used[v] = 1;
    for (int to : g[v]){
        if (!used[to])
            dfs(to);
    }
    topol.push_back(v);
}

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

    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    for (int i = 1; i <= n; i++){
        if (!used[i])
            dfs(i);
    }
    reverse(topol.begin(), topol.end());
    int ans = 0;
    for (int v : topol){
        ans = max(ans, dp[v]);
        for (int to : g[v])
            dp[to] = max(dp[to], dp[v] + 1);
    }
    cout << ans;

}


Measured memory_bytes: 8824
#include <stdio.h>

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

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

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <map>

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<array<ll, 3>> lrc(m);
    vector<vector<ll>> starts(n);
    vector<vector<ll>> ends(n);
    REP(i, m){
        ll li, ri, ci;
        cin >> li >> ri >> ci;
        li--;
        ri--;
        lrc[i] = {li, ri, ci};
        starts[li].push_back(i);
        ends[ri].push_back(i);
    }
    map<ll, ll> x;
    vector<ll> dist(n, numeric_limits<ll>::max());
    dist[0] = 0;
    REP(i, n){
        if(i > 0){
            if(x.size() == 0){
                cout << -1 << endl;
                return 0;
            }else{
                dist[i] = min(dist[i], x.begin()->first);
            }
        }
        for(ll j : starts[i]){
            x[dist[i] + lrc[j][2]]++;
        }
        for(ll j : ends[i]){
            x[dist[lrc[j][0]] + lrc[j][2]]--;
            if(x[dist[lrc[j][0]] + lrc[j][2]] <= 0){
                x.erase(dist[lrc[j][0]] + lrc[j][2]);
            }
        }
    }
    if(dist[n - 1] == numeric_limits<ll>::max()){
        cout << -1 << endl;
    }else{
        cout << dist[n - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 14592