akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c , d = MAP()
print(max(a * c, a * d, b * c,  b * d))

Measured memory_bytes: 10616
import numpy as np
n = int(input())
v=list(map(int, input().split()))  #リスト入力
c=list(map(int, input().split()))  #リスト入力

v = np.array(v)
c = np.array(c)


venefit = v - c

venefit= venefit.tolist()
l_minus = [i for i in venefit if i > 0]

n = sum(l_minus)  # 真偽値リストを作って True の数を合計する方法
print(n)

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

int main(){
 int a=0, b=0;
 cin >> a >> b;
 string stra= "", strb="";

  
  for(int i=0; i<b; i++){
   stra = stra+to_string(a); 
  }
  
  for(int i=0; i<a; i++){
   strb = strb+to_string(b); 
  }
  if(strb < stra){
   cout << strb; 
  }else
    cout << stra;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,a,b,c;
string s,t;

int main() {
  cin >> a >> b >> c >> n;
  int ans=0;
  rep(i,n+1)rep(j,n+1){
    int d=n-a*i-b*j;
    if(d>=0 && d%c==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int a,b;
cin >> a>> b;
int e = min(a,b);
if(e==a&&a!=1&&a!=b){
    cout << "Bob" << endl;
}else if(e==b&&b!=1&&a!=b){
    cout << "Alice" << endl;
}else if(a==b){
    cout << "Draw" << endl;
}else if(e==a&&a==1&&a!=b){
    cout << "Alice" <<endl;
}else if(e==b&&b==1&&a!=b){
    cout << "Bob" << endl;
}
return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
x = sorted(list(map(int,input().split())))
if N == 1:
    print(x[-1]-x[0])
elif (M == 1) or (N >= M):
    print(0)
else:
    it = [0] * (M-1)
    for i in range(M-1):
        it[i] = x[i+1] - x[i]
    print(sum(sorted(it)[:1-N]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ieps (int) 1e6
#define eps (int) 1e9
#define pii pair<int, int>
int pai[ieps] , peso[ieps];

struct edge{
	int x , y , w;
};

int fd(int x){
	return pai[x] == x ? x : pai[x] = fd(pai[x]);
}

void join(int u , int v){
	u = fd(u) , v = fd(v);
	if(peso[u] < peso[v]) swap(u , v);
	pai[v] = u , peso[u]++;
}

bool cmp(edge a , edge b){
	return a.w < b.w;
}


int32_t main(){
	int n;
	cin>>n;
	vector<pair<pii , int> > v(n) , v3(n);
	for(int i = 0;i<n;i++){
		cin>>v[i].F.F>>v[i].F.S;
		v[i].S = i;
		v3[i].F.F = v[i].F.S;
		v3[i].F.S = v[i].F.F;
		v3[i].S  = i;
		pai[i] = i , peso[i] = 0;
	}
	sort(v.begin() , v.end());
	sort(v3.begin() , v3.end());
	int resp = 0;
	vector<edge> vet;
	set<pii> builded;
	for(int i = 0;i<n-1;i++){
		int v1 = abs(v[i+1].F.F - v[i].F.F) , v2 = abs(v[i+1].F.S - v[i].F.S);
		vet.pb({v[i].S , v[i+1].S , min(v1, v2)});
		v1 = abs(v3[i+1].F.F - v3[i].F.F) , v2 = abs(v3[i+1].F.S - v3[i].F.S);
		vet.pb({v3[i].S , v3[i+1].S , min(v1 , v2)});
	}
	sort(vet.begin(), vet.end() , cmp);
	for(int i = 0;i<vet.size();i++){
		if(fd(vet[i].x) != fd(vet[i].y)){
			join(vet[i].x , vet[i].y);
			resp+=vet[i].w;
		}
	}
	cout<<resp;
}

Measured memory_bytes: 18160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef pair <int, pii> piii;
#define fr first
#define sc second
#define pb push_back
#define ppb pop_back()
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define mpr make_pair
string s;
int cnt['z' + 1];
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	ll ans = (1ll * sz(s) * (sz(s) - 1)) / 2 + 1;
	for(auto to : s)++cnt[to];
	for(char i = 'a';i <= 'z'; ++ i){
		ans -= (1ll * cnt[i] * (cnt[i] - 1)) / 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();

		if(b == 1){
			System.out.println(0);
			return;
		}

//		for(int i = 1; i < 20; i++){
//			System.out.println(Math.floor((double)a*i/b) - a*Math.floor(i/b));
//		}

		long tmpA = a;
		long tmpB = b;

		long gcd = gcd(tmpA, tmpB);

//		long tmpX = b/gcd;
		long tmpX = b;

		if(n >= tmpX - 1){
			System.out.println((long)(Math.floor((double)a*(tmpX - 1)/b) - a*Math.floor(((double)tmpX - 1)/b)));
		}
		else {
			System.out.println((long)(Math.floor((double)a*n/b) - a*Math.floor(n/b)));
		}
	}

	static long gcd(long a, long b){
    	long tmp;

    	while (a % b != 0)
    	{
    		tmp = b;
    		b = a % b;
    		a = tmp;
    	}
    	return b;
    }
}


Measured memory_bytes: 27104
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        if (a[i] == b[i] && b[i] == c[i]) {

        } else if (a[i] == b[i]) {
            ans++;
        } else if (a[i] == c[i]) {
            ans++;
        } else if (b[i] == c[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int n, T, H, L;
int t[128], h[128];

int solve() {
    int cur = 0;
    for (int i = 0;; i = (i+1)%n) {
        if (t[i] == 0 && h[i] == 0) return i;
        if (t[i] > 0) t[i]--, T++, cur+=10;
        else h[i]--, H++, cur+=100;
        if (T > L) return i;
        if (cur >= 90) {
            int ex = cur - 90;
            while (ex%100 != 0) {
                if (T == 0) return i;
                T--, t[i]++, ex-=10;
            }
            while (ex != 0) {
                if (T >= 10) T-=10, t[i]+=10, ex-=100;
                else if (H > 0) H--, h[i]++, ex-=100;
                else return i;
            }
            cur = 0;
        }
    }
}

int main() {
    scanf("%d%d%d%d", &n, &T, &H, &L);
    rep (i, n) scanf("%d%d", t+i, h+i);
    printf("%d\n", solve()+1);
    return 0;
}

Measured memory_bytes: 1028
using System;

namespace abc087A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int Ans = (X - A) % B;
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 13140
from collections import deque


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)
    ans = 0
    q = deque([(0, set([0]))])
    while len(q):
        cur, visited = q.popleft()
        if len(visited) == N:
            ans += 1
            continue
        for nxt in adj[cur]:
            if nxt not in visited:
                nxtvst = set(visited)
                nxtvst.add(nxt)
                q.append((nxt, nxtvst))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44528
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)



  
int main()
{
    
    int a;
    scf(a);
    
    int v=a+a*a+a*a*a;
    
    prin(v);

     
}

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

int main(){
    int n,ans=0;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        a ++;
        if(mp.size()==0 || a<=mp.begin()->first) mp[a] ++;
        else{
            auto ite = mp.lower_bound(a);
            if(ite==mp.end()){
                mp.rbegin()->second --;
                if(mp.rbegin()->second==0) mp.erase(mp.rbegin()->first);
                mp[a] ++;
            }else{
                ite --;
                ite->second --;
                if(ite->second==0) mp.erase(ite->first);
                mp[a] ++;
            }
        }
    }
    for(auto ite = mp.begin();ite != mp.end();++ite){
        ans += ite->second;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp11
{
    class Class31
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            List<char> I = new List<char>();
            List<char> K = new List<char>();
            int count = 0, countif = 0;
            for(int a = 1; a < S.Length-1; a++)
            {
                for (int i=0;i<a;i++)
                {
                    if (!I.Contains(S[i]))
                        I.Add(S[i]);

                }
                for(int k = a; k < S.Length; k++)
                {
                    if (!K.Contains(S[k]))
                        K.Add(S[k]);
                }
                for (int b = 0; b < K.Count(); b++)
                countif += I.Contains(K[b]) ? 1 : 0;
                count = Math.Max(count, countif);
                I.Clear();K.Clear();countif = 0;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13152
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

X=lines[0][0]
N=lines[0][1]

unless N==0
  line=lines[1]
  k=0
  loop do 
  unless line.include? (X-k)
    p X-k
    break
  end
  unless line.include? (X+k)
    p X+k
    break
  end
    k+=1
end
else print X
end


Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
int n;
int dp[50][500][500];
int ai,bi,ci;
int ma,mb;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>ma>>mb;
	memset(dp,63,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		cin>>ai>>bi>>ci;
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++){
				dp[i+1][j+ai][k+bi]=min(dp[i+1][j+ai][k+bi],dp[i][j][k]+ci);
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
			}
		}
	}
	int res=1e9;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=400;j++){
			for(int k=1;k<=400;k++){
				if(j*mb==k*ma){
					res=min(res,dp[i][j][k]);
				}
			}
		}
	}
	if(res==1e9)
		res=-1;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 49660
m=0
f=0
r=0
m,f,r=map(int,input().split())
while m!=-1 or f!=-1 or r!=-1:
    if m!=-1 and f!=-1:
        if m+f>=80:
            print("A")
        elif m+f>=65:
            print("B")
        elif m+f>=50:
            print("C")
        elif m+f>=30:
            if r>=50:
                print("C")
            else:
                print("D")
        else :
            print("F")
    else:
        print("F")
    m,f,r=map(int,input().split())



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int a;
    set<int> s;
    fr(i,3) in>>a,s.insert(a);
    puts(s.size()==2?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>

using namespace std;

struct dice{
  int surface[6];
  void (*func)(struct dice *, char c);
};

void numReplace(int num[6], int n0, int n1, int n2, int n3, int n4, int n5){
  num[0] = n0;
  num[1] = n1;
  num[2] = n2;
  num[3] = n3;
  num[4] = n4;
  num[5] = n5;
}

void rotation(struct dice *self, char c){
  int num[6];
  for(int i = 0; i < 6; i++){
    num[i] = self->surface[i];
  }

  if(c == 'N'){
    numReplace(self->surface, num[1], num[5], num[2], num[3], num[0], num[4]);
  }
  else if(c == 'E'){
    numReplace(self->surface, num[3], num[1], num[0], num[5], num[4], num[2]);
  }
  else if(c == 'S'){
    numReplace(self->surface, num[4], num[0], num[2], num[3], num[5], num[1]);
  }
  else if(c == 'W'){
    numReplace(self->surface, num[2], num[1], num[5], num[0], num[4], num[3]);
  }
  /*
  if(c == 'N'){
    numReplace(num, num[1], num[5], num[2], num[3], num[0], num[4]);
  }
  else if(c == 'E'){
    numReplace(num, num[3], num[1], num[0], num[5], num[4], num[2]);
  }
  else if(c == 'S'){
    numReplace(num, num[4], num[0], num[2], num[3], num[5], num[1]);
  }
  else if(c == 'W'){
    numReplace(num, num[2], num[1], num[5], num[0], num[4], num[3]);
  }

  for(int i = 0; i < 6; i++){
    self->surface[i] = num[i];
  }
  */
}

int main(){
  struct dice d1{{0}, rotation};
  string order;

  for(int i = 0; i < 6; i++){
    cin >> d1.surface[i];
  }
  cin >> order;

  for(int i = 0; i < order.size(); i++){
    d1.func(&d1, order[i]);
  }

  cout << d1.surface[0] << endl;

  return 0;
}



Measured memory_bytes: 3200
import math
N = int(input())
z = []
s = 0
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)

for i in range(N):
    x, y = map(int, input().split())
    z.append([x, y])

for i in range(N):
    for j in range(i, N):
        d = (math.sqrt((z[i][0] - z[j][0])**2 + (z[i][1] - z[j][1])**2))
        s += d

f = factorial(N)

print(s * (f*2//N) / f)





Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long
using namespace std;
int main()
{
    long long n;
    cin>>n;
    stack<char> s;
    char a[]="zabcdefghijklmnopqrstuvwxy";
    while(n>0)
    {
        s.push(a[n%26]);
        if(n%26==0)
            n--;

        n/=26;
    }
    while(!s.empty())
    {
        cout<<s.top();
        s.pop();
    }
    return 0;
}


Measured memory_bytes: 3628
import math
#数値ひとつ
I = int(input())
#数値欲しいとき
#N, M = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#listA = list(N)
#受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
list = [input() for i in range(I)]
print(len(set(list)))


Measured memory_bytes: 35588
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

string s;
ll ans,cnt;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    int n=s.sz;
    for (int i = n-1; i >= 0; --i)
        if (s[i]=='B') ++cnt, ans+=n-cnt-i;
    cout << ans;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT:

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

    def bisearch_left(self, l, r, x):
        """ 区間[l,r]で左からx番目の値がある位置 """
        l_sm = self.sum(l-1)
        ok = r + 1
        ng = l - 1
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if self.sum(mid) - l_sm >= x:
                ok = mid
            else:
                ng = mid
        if ok != r + 1:
            return ok
        else:
            return -1

    def bisearch_right(self, l, r, x):
        """ 区間[l,r]で右からx番目の値がある位置 """
        r_sm = self.sum(r)
        ok = l - 1
        ng = r + 1
        while ok+1 < ng:
            mid = (ok+ng) // 2
            if r_sm - self.sum(mid-1) >= x:
                ok = mid
            else:
                ng = mid
        if ok != l - 1:
            return ok
        else:
            return -1

N = INT()
A = LIST()
# aの昇順に処理できるようにindexで並べておく
idxs = [0] * (N+1)
for i, a in enumerate(A):
    idxs[a] = i

bit = BIT(N)
ans = [0] * (N+1)
# 大きいaから見ていく
for a in range(N, 0, -1):
    # a(N~1)が格納されているindex
    idx = idxs[a]
    # 自分より小さいindexで2回目に自分より大きい値がある直前の場所
    res = bit.bisearch_right(0, idx, 2)
    p = res + 1 if res != -1 else 0
    # 自分より小さいindexで最初に自分より大きい値がある直前の場所
    res = bit.bisearch_right(0, idx, 1)
    q = res + 1 if res != -1 else 0
    # 自分より大きいindexで最初に自分より大きい値がある直前の場所
    res = bit.bisearch_left(idx, N-1, 1)
    r = res - 1 if res != -1 else N - 1
    # 自分より大きいindexで2回目に自分より大きい値がある直前の場所
    res = bit.bisearch_left(idx, N-1, 2)
    s = res - 1 if res != -1 else N - 1
    # aを使う回数 * a = (左に自分より大きい値がある時の通り数 + 右に自分より大きい値がある時の通り数) * a
    ans[a] = ((q-p)*(r-idx+1) + (idx-q+1)*(s-r)) * a
    # aを出現済とする
    bit.add(idx, 1)
# 全てのaについての合計
print(sum(ans))


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

int main() {
  int r;
  cin>>r;
  if (r < 1200) {
    cout<<"ABC"<<endl;
  } else if (r < 2800) {
    cout<<"ARC"<<endl;
  } else {
    cout<<"AGC"<<endl;
  }
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

xdir = "R" if dx >= 0 else "L"
xdir_r = "L" if dx >= 0 else "R"
ydir = "U" if dy >= 0 else "D"
ydir_r = "D" if dy >= 0 else "U"

ans = ans_r = ""
ans_2 = ans_2_r = ""
ans += xdir * abs(dx) + ydir * abs(dy)
ans_r += xdir_r * abs(dx) + ydir_r * abs(dy)

ans_2 += ydir_r + xdir * (abs(dx) + 1) + ydir * (abs(dy) + 1) + xdir_r
ans_2_r += ydir + xdir_r * (abs(dx) + 1) + ydir_r * (abs(dy) + 1) + xdir
print(ans + ans_r + ans_2 + ans_2_r)

Measured memory_bytes: 9040
# https://atcoder.jp/contests/abc131/tasks/abc131_d

n=int(input())
ab=sorted([tuple(map(int,input().split())) for _ in range(n)],key=lambda x: x[1])

time=0
for a,b in ab:
    if time+a>b:
        print('No')
        exit()
    time+=a
else:
    print('Yes')

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

using namespace std;

int n;

void solve(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    long long ans = 60*(h2-h1)+m2-m1-k;
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 3620
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (r, g, b, n) = get!(usize, usize, usize, usize);
    let mut ans = 0;
    for i in 0..n / r + 1 {
        for j in 0..n / g + 1 {
            //eprintln!("i: {}, j: {}", i, j);
            let nr = i * r;
            let ng = j * g;
            //eprintln!("nr: {}, ng: {}", nr, ng);
            if n < nr + ng {
                continue;
            }
            if (n - nr - ng) % b == 0 {
                ans += 1;
            }
            //if nr + ng + nb == n {
            //    ans += 1;
            //}
        }
    }
    println!("{}", ans);
}


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

using namespace std;

int main(){
    string S;
    int p=-1;
    cin>>S;

    for(int i=0; i<S.size() ;++i){
        if(i%2){
            if(S[i]=='R'){
                p=0;
                break;
            }}
        else
            if(S[i]=='L'){
                p=0;
                break;
            }

    }

    if(p==0)
        cout<<"No";
    else
        cout<<"Yes";




    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int a, b, k;
void solve() {
    cin >> k >> a >> b;
    loop(i, a, b + 1) {
        if (i % k == 0) {
            cout << "OK" << '\n';
            return;
        }
    }
    cout << "NG" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
typedef vector<pp> VPP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<(int)p.real()<<' '<<(int)p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

bool Comp(C p,C q){
	if(eq(p.imag(),q.imag())) return p.real()<q.real();
	return p.imag()<q.imag();
}

VP Convex_Hull(VP p){
	sort(p.begin(),p.end(),Comp);
	int v=0,n=p.size();
	VP q(n*2);
	for(int i=0;i<n;i++){
		while(v>1&&Det(q[v-1]-q[v-2],p[i]-q[v-2])<-eps) v--;
		q[v++]=p[i];
	}
	for(int i=n-2,t=v;i>=0;i--){
		while(v>t&&Det(q[v-1]-q[v-2],p[i]-q[v-2])<-eps) v--;
		q[v++]=p[i];
	}
	q.resize(v-1);
	return q;
}

int n;
VP a;

int main(){
	cin>>n;
	a=VP(n);
	for(auto &i:a) In(i);
	a=Convex_Hull(a);
	n=a.size();
	cout<<n<<endl;
	for(auto i:a) Out(i);
}


Measured memory_bytes: 9276
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N, x;
    cin >> N >> x;
    int a[N];
    rep(i, N){
        cin >> a[i];
    }

    ll ans = 0;
    ll tmp = 0;
    rep(i, N){
        if (a[i] + tmp > x) {
            ans += a[i] + tmp - x;
            a[i] = x - tmp;
        }
        tmp = a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// var w, h int
	for scanner.Scan() {
		// fmt.Scanf("%d %d", &w, &h)

		input := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(input[0])
		h, _ := strconv.Atoi(input[1])

		if w == 0 && h == 0 {
			return
		}

		isArrive := make([][]bool, w)
		tiles := make([][]string, w)

		for i := 0; i < w; i++ {
			rowArrive := make([]bool, h)
			rowTiles := make([]string, h)
			scanner.Scan()
			row := scanner.Text()
			for j := 0; j < h; j++ {
				rowTiles[j] = string(row[j])
			}
			tiles[i] = rowTiles
			isArrive[i] = rowArrive
		}

		var i, j int
		isEnd := false
		for {
			if isArrive[i][j] == true {
				fmt.Println("LOOP")
				break
			}
			isArrive[i][j] = true

			switch tiles[i][j] {
			case ">":
				j++
			case "^":
				i--
			case "v":
				i++
			case "<":
				j--
			case ".":
				isEnd = true
			}

			if isEnd == true {
				fmt.Println(j, i)
				break
			}
		}
	}
}



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

int main() {
    string a, b;
    cin >> a >> b;
    reverse(b.begin(), b.end());
    cout << (a==b?"YES":"NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    int len = s.length();
    rep(i,len){
        if(s[i] == 'U' || s[i] == 'D') continue;
        if(i%2 == 0 && s[i] == 'L'){
            cout << "No" << endl;
            return 0;
        }
        if(i%2 == 1 && s[i] == 'R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3728
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**6
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M = LI()
    root = [[] for _ in range(N)]
    node = [[INF,INF,INF] for _ in range(N)]
    for _ in range(M):
        a,b = LI()
        root[a-1].append(b-1)
    S,T = LI()
    S -= 1; T -= 1
    q = collections.deque()
    q.append((S,0,0))
    node[S][0] = 0
    while q:
        v,n,d = q.popleft()
        t = (n+1) % 3
        for u in root[v]:
            if node[u][t] > d+1:
                node[u][t] = d+1
                q.append((u,t,d+1))
    if node[T][0] < INF:
        print(node[T][0]//3)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68524
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;

int main() {
    char s[8001];
    int x, y;

    scanf("%s", &s);
    cin >> x >> y;

    int p = 0;
    while (s[p] == 'F') p++;

    vector<int> yoko, tate;
    int d = 1, cont = 0;
    for (int i=p; s[i] != '\0'; i++) {
        if (s[i] == 'F') cont++;
        else if (i == 0 || s[i-1] == 'F') {
            if (d == 1) yoko.push_back(cont);
            else        tate.push_back(cont);
            cont = 0;
            d *= -1;
        }
        else d *= -1;
    }
    if (d == 1) yoko.push_back(cont);
    else        tate.push_back(cont);
    
    map<int, bool> prev, curr;
    vector<int>::iterator it_v;
    map<int, bool>::iterator it_m;
    
    prev[p] = true;
    for (it_v = yoko.begin(); it_v != yoko.end(); it_v++) {
        for (it_m = prev.begin(); it_m != prev.end(); it_m++) {
            curr[it_m->first + *it_v] = true;
            curr[it_m->first - *it_v] = true;
        }
        prev = curr;
        curr.clear();
    }

    if (prev.find(x) == prev.end()) {
        cout << "No" << endl;
        return 0;
    }

    prev.clear();
    prev[0] = true;
    for (it_v = tate.begin(); it_v != tate.end(); it_v++) {
        for (it_m = prev.begin(); it_m != prev.end(); it_m++) {
            curr[it_m->first + *it_v] = true;
            curr[it_m->first - *it_v] = true;
        }
        prev = curr;
        curr.clear();
    }

    if (prev.find(y) == prev.end()) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, c; cin >> n >> m >> c;
  V<> b(m); for (auto&& e : b) cin >> e;
  int res = 0;
  while (n--) {
    V<> a(m); for (auto&& e : a) cin >> e;
    int sum = c;
    for (int i = 0; i < m; ++i) {
      sum += a[i] * b[i];
    }
    res += sum > 0;
  }
  cout << res << '\n';
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n,a,b;

ll calc(ll num){
	ll res = 0;
	while(num > 0){
		res += num % 10;
		num /= 10;
	}
	return res;
}

int main(){
	cin >> n >> a >> b;
	ll ans = 0;
	rep(i,n){
		ll num = calc(i+1);
		if(a <= num && num <= b)ans += (i+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAX = 300010;

int n;
char in[MAX];

int main(){
  scanf("%d", &n);
  scanf("%s", in);

  int el = 0, wl = 0;
  int er = count(in + 1, in + n, 'E'),
      wr = count(in + 1, in + n, 'W');

  int best = er;
  for(int i = 1;i < n;++i){
    if(in[i - 1] == 'E') ++el;
    if(in[i - 1] == 'W') ++wl;

    if(in[i] == 'E') --er;
    if(in[i] == 'W') --wr;

    relaxMin(best, wl + er);
  }

  printf("%d\n", best);

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <bitset>
#include <utility> 
using namespace std;

int main() {
    int N,K; cin >> N >> K;
    vector<int> A(N,0);
    for(int i=0;i<N;i++) {
        int a; cin >> a;
        A[a-1]++;
    }
    sort(A.begin(),A.end(),greater<int>());
    int res=0;
    for (int i=0;i<K;i++){
        res+=A[i];
    }
    cout << N-res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n,l,s;
    while (~scanf("%d %d", &n,&l)) {
        int r = l+n-1;
        s = (l + r) * n / 2;

        if (l<=0 && 0<=r) s-=0;
        else if (l>0) s-=l;
        else s-=r;
        printf("%d\n", s);

    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int N;
string S;
int main(int argc, const char * argv[]) {
  cin >> N >> S;

  int v = 0;
  int maxv = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') {
      v++;
    } else {
      v--;
    }
    maxv = max(maxv, v);
  }
  
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 256
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i+1, f + s[i+1]) + dfs(i+1, f + "+" + s[i+1])

s = input()
n = len(s)
print(dfs(0, s[0]))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>

typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  vector<pair<ll,ll> > v;
  for(i=0;i<n;i++){
    cin >> j >> k;
    v.push_back(make_pair(j,k));
  }
  sort(v.begin(),v.end());
  ll ret = 0;
  i=0;
  while(m>0){
    ret+=v[i].first*(min(v[i].second,m));
    m-=v[i].second;
    i++;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    //cin >> t;
    for(int T = 0; T < t ; T++){
        ll n, h;
        cin >> h >> n;
        vector<pair <ll ,ll>>  p(n);
        for(int i = 0 ; i < n ; i++){
            cin >> p[i].first >> p[i].second;
        }
        sort(p.begin(), p.end());
        ll ans[h + 1];
        for(int i = 0; i <= h; i++)
            ans[i] = 1e9;
        ans[0] = 0;
        for(int i = 1; i <= h; i++){
            for(int j = 0; j < n; j++){
                ans[i] = min(ans[i], ans[max(i - p[j].first,0LL)] + p[j].second);   
            }
            if(ans[i] == 1e9){
                ans[i] = p[0].second;
            }
        }
        cout << ans[h] << endl;
    }
    return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;
	string comp;
	if (a < b) {
		comp = "a < b";
	}
	else if (a==b) {
		comp = "a == b";
	}
	else {
		comp = "a > b";
	}
	cout << comp.c_str() << std::endl;
    return 0;
}

Measured memory_bytes: 1192
import itertools
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson

N,M,R = map(int, input().split())
r_list = np.array(list(map(int, input().split()))) -1 

nodes = np.full((N,N), np.inf) 
for i in range(M):
    a,b,c = map(int, input().split())
    nodes[a-1,b-1] = nodes[b-1,a-1] = c
min_ds = shortest_path(nodes)
res = 10**9
for cmb in itertools.permutations(r_list):
    prev = cmb[0]
    tmpres = 0
    for to in cmb[1:]:
        tmpres += min_ds[prev,to]
        prev = to
    res = min(res, tmpres)

print(int(res))

Measured memory_bytes: 40512
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

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

int main() {
	int A, B;

	cin >> A >> B;
  
  vector<vector<int>> X(A);
  
  for (auto& i : X) {
    i.resize(B);
    for (auto& j : i)
      cin >> j;
  }
  
  int r = 0;
  for (int i = 0; i < X.size(); i++) {
    for (int j = i + 1; j < X.size(); j++) {
  	  long long now = 0;
      for (int k = 0; k < B; k++)
      	now += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      
      auto sq = sqrt(now);
      if (sq == (double)((int)sq))
        r++;
    }
  }

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = scan!(usize, usize);
    let mut ans = k;
    for _ in 1..n {
        ans *= k - 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys

input = sys.stdin.readline


# Editorial AC
def main():
    M, K = map(int, input().split())

    if K >= 2 ** M:
        print(-1)
        exit()

    if M == 1:
        if K == 0:
            print(0, 0, 1, 1)
        else:
            print(-1)
        exit()

    A = list(range(2 ** M))
    B = list(reversed(range(2 ** M)))
    A.remove(K)
    B.remove(K)

    ans = A + [K] + B + [K]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 41472
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<int> > T(n);
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    stack<int> S;
    vector<bool> odw(n, false);
    vector<int> oj(n);
    oj[0] = -1;
    S.push(0);
    odw[0] = true;
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < T[akt].size(); ++i)
        {
            if (!odw[T[akt][i]])
            {
                S.push(T[akt][i]);
                odw[T[akt][i]] = true;
                oj[T[akt][i]] = akt;
            }
        }
    }
    vector<int> sc;
    int akt = n - 1;
    while (akt != -1)
    {
        sc.push_back(akt);
        akt = oj[akt];
    }
    reverse(sc.begin(), sc.end());
    int ilp;
    if (((int) sc.size()) % 2 == 0)
        ilp = ((int) sc.size()) / 2;
    else
        ilp = ((int) sc.size()) / 2 + 1;
    vector<int> kto(n, 1);
    kto[sc[ilp]] = 0;
    for (int i = 0; i < n; ++i)
        odw[i] = false;
    S.push(sc[ilp]);
    odw[sc[ilp]] = true;
    while (!S.empty())
    {
        int akt = S.top();
        S.pop();
        for (int i = 0; i < T[akt].size(); ++i)
        {
            if (!odw[T[akt][i]] && T[akt][i] != oj[sc[ilp]])
            {
                odw[T[akt][i]] = true;
                S.push(T[akt][i]);
                kto[T[akt][i]] = 0;
            }
        }
    }
    int p = 0, d = 0;
    for (int i = 0; i < n; ++i)
    {
        if (kto[i] == 1)
            ++p;
        else
            ++d;
    }
    if (p > d)
        cout << "Fennec";
    else
        cout << "Snuke";
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string S; cin >> S;
  if(S[0] < 'a'){
    cout << "A" << endl;
  }
  else{
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3632
def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 114356
#7_C
r, c = map(int, input().split())
mat = [[0 for i in range(c+1)] for j in range(r+1)]

for i in range(r):
    row = list(map(int, input().split()))
    row_sum = sum(row)
    mat[i][c] = row_sum
    for j in range(c):
        mat[i][j] = row[j]

for j in range(c+1):
    col_sum = 0
    for i in range(r):
        col_sum += mat[i][j]
    mat[r][j] = col_sum

for i in range(r+1):
    row = str(mat[i][0])
    for j in range(c):
        j = j + 1
        row += " " + str(mat[i][j])
    print(row)


Measured memory_bytes: 5696