akhauriyash/Code-Regression huggingface dataset:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

def solve(n,k,a):
	for j in range(int(min(42,k))):
		b = [0]*n
		for i in range(n):
			l = max(0, i-a[i])
			r = min(n-1, i+a[i])
			b[l]+=1
			if r+1<n: b[r+1]-=1
		for i in range(1,n):
			b[i]+=b[i-1]
		a = b[:]

	for i in range(len(b)):
		print(b[i],end=" ")

def main():
	n,k = readInts()
	a = readInts()
	solve(n,k,a)

if __name__=='__main__':
	main()

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

VLL C(12, 0);
vector<VLL> A;

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

    REP(i, N) {
        cin >> C[i];
        LL tmp;
        VLL tmp2;

        REP(j, M) {
            cin >> tmp;
            tmp2.PB(tmp);
        }

        A.PB(tmp2);
    }

    LL ans = INFL;
    REP(i, (1LL<<N)) {
        VLL sum_a(12, 0);
        LL sum_cost = 0;
        REP(j, N) {
            if(i & (1LL<<j)) {
                sum_cost += C[j];
                REP(k, M) {
                    sum_a[k] += A[j][k];                    
                }
            }
        }

        bool flag = true;
        REP(j, M) {
            flag &= (sum_a[j] >= X);
        }

        if(flag) {
            ans = min(ans, sum_cost);
        }
    }

    cout << (ans == INFL ? -1 : ans) << endl;
}


Measured memory_bytes: 3628
def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string




H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='#':
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1


i=0
while(i<W):
    same_flag = True

    for s in range(len(lines)):
        #print(lines)
        if(lines[s][i]=='#'):
                same_flag=False
                break


    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)

        i-=1
        W-=1
            #print(lines[s])
        #print('deleted')

    i+=1


for i in range(len(lines)):
    print(lines[i])



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

vector <int> e1[55],e2[55],e3[55];
int d1[55],d2[55];

int p1[55],p2[55];

void dfs1(int x) {
  for(int i=0;i<e2[x].size();i++)
    if (e2[x][i]!=p1[x]) {
    	int u=e2[x][i];
    	p1[u]=x;
    	dfs1(u);
	}
}

void dfs2(int x) {
  for(int i=0;i<e3[x].size();i++)
    if (e3[x][i]!=p2[x]) {
    	int u=e3[x][i];
    	p2[u]=x;
    	dfs2(u);
	}
}

vector <int> ee[55];
int deg[55];
queue <int> q;

int solve(int n,int rt) {
  p1[rt]=p2[rt]=0;
  dfs1(rt);
  dfs2(rt);
  int s=0;
  for(int i=1;i<=n;i++) ee[i].clear();
  memset(deg,0,sizeof(deg));
  for(int i=1;i<=n;i++)
    if (p1[i]==p2[i]&&p1[p1[i]]!=p2[p1[i]]) return inf;
  for(int i=1;i<=n;i++)
    if (p1[i]!=p2[i]) {
    	s++;
    	for(int j=0;j<e2[i].size();j++)
    	  if (e2[i][j]!=p1[i]) {
		    ee[e2[i][j]].push_back(i);
		    deg[i]++;
		  }
		for(int j=0;j<e3[i].size();j++)
		  if (e3[i][j]!=p2[i]) {
		    ee[i].push_back(e3[i][j]); 
		    deg[e3[i][j]]++;
		  }
	}
  for(int i=1;i<=n;i++)
    if (!deg[i]) q.push(i);
  while (!q.empty()) {
  	int x=q.front();q.pop();
  	for(int i=0;i<ee[x].size();i++) {
  		int u=ee[x][i];
  		deg[u]--;
  		if (!deg[u]) q.push(u);
	  }
  }
  for(int i=1;i<=n;i++)
    if (deg[i]) return inf;
  return s;
}

int main() {
  int cases;
  scanf("%d",&cases);
  for(;cases;cases--) {
  	memset(d1,0,sizeof(d1));
  	memset(d2,0,sizeof(d2));
  	int n;
  	scanf("%d",&n);
  	for(int i=1;i<=n;i++) {
  		e1[i].clear();
  		e2[i].clear();
	  }
	for(int i=1;i<n;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		e2[x].push_back(y);
		e2[y].push_back(x);
		d1[x]++;d1[y]++;
	}
	for(int i=1;i<n;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		e1[x].push_back(y);
		e1[y].push_back(x);
		d2[x]++;d2[y]++;
	}
	for(int i=1;i<=n;i++) e3[i]=e1[i];
	int ans=inf;
	for(int i=1;i<=n;i++)
	  ans=min(ans,solve(n,i));
	if (ans==inf) {
		for(int i=1;i<=n;i++)
		  if (d2[i]==1) {
		  	for(int j=1;j<=n;j++)
		  	  if (j!=i) {
		  	  	  for(int k=1;k<=n;k++) 
					if (k!=i) {
		  	  	  	    e3[k].clear();
		  	  	  	    for(int l=0;l<e1[k].size();l++)
		  	  	  	      if (e1[k][l]!=i) e3[k].push_back(e1[k][l]);
					  }
				  e3[j].push_back(i);
				  e3[i].clear();
				  e3[i].push_back(j);
				  ans=min(ans,solve(n,i)+1);
				}
		  }
	}
	printf("%d\n",(ans<inf)?ans:-1);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
	ios::sync_with_stdio(0);
  	cin.tie(0);
  	int n;
  	cin>>n;
  	vector<int>L(n+1),R(n+1);
  	for(int i=0;i<n;i++)
  		cin>>L[i]>>R[i];
  	sort(L.rbegin(),L.rend());
  	sort(R.begin(),R.end());
  	LL ans=0;
  	for(int i=0;i<=n;i++){
  		//cout<<L[i]<<" "<<R[i]<<endl;
	  	ans+=max(0,L[i]-R[i]);
	}
	cout<<ans*2<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
int n,m;
using namespace std;
void toposort(int s,vector<int> graph[],vector<bool> &visited,vector<int> &o)
{
    visited[s]=1;
    for(int v:graph[s])  
    {
        if(!visited[v])
        {
            toposort(v,graph,visited,o);
        }
    }
    o.push_back(s);
}
int main()
{
    cin>>n>>m;
    vector<int> graph[n+1];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        graph[a].push_back(b);
    }
    vector<int> o;
    vector<bool> visited(n+1,false);
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            toposort(i,graph,visited,o);
        }
    }
    // for(int x:o)
    // cout<<x<<" "; 
    int best=0;
    vector<int> dp(n+1);
    for(int i=0;i<o.size();i++)
    {   
        for(int j=0;j<graph[o[i]].size();j++)
        {
            dp[o[i]]=max(dp[o[i]],dp[graph[o[i]][j]]+1);
            best=max(dp[o[i]],best);
        }
    }
    cout<<best;
}

Measured memory_bytes: 11924
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int cnt =0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int h=0;h<n;h++){
                cnt++;
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int r,g;
  cin >> r >> g;
  cout << g * 2 - r << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = sorted([list(map(int, input().split())) for _ in range(m)])

ans = ["*"] * (n)
for s, c in sc:
    if ans[s-1] != "*" and ans[s-1] != str(c):
        print(-1)
        exit()
    else:
        ans[s-1] = str(c)

for i in range(n):
    if ans[i] == "*":
        if i == 0 and i != n-1:
            ans[i] = "1"
        else:
            ans[i] = "0"
            
ans = "".join(ans)

if ans == str(int(ans)):
    print(int(ans))
else:
    print(-1)

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::array<int64_t, 2> rets{};
  std::array<int64_t, 2> sums{};
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    std::array<int64_t, 2> moves{};
    for (int j = 0; j < 2; j++) {
      sums[j] += a;
      if (i % 2 == j) {
        if (sums[j] >= 0) {
          moves[j] = -sums[j] - 1;
        }
      } else {
        if (sums[j] <= 0) {
          moves[j] = -sums[j] + 1;
        }
      }
      sums[j] += moves[j];
      rets[j] += abs(moves[j]);
    }
  }
  std::cout << std::min(rets[0], rets[1]) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

ll junken(char t){
  if(t=='r')return 0;
  if(t=='s')return 1;
  if(t=='p')return 2;
}

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

  ll n,k;
  std::cin>>n>>k;

  ll point[3];
  rep(i,0,3)std::cin>>point[i];

  std::vector<std::vector<ll>> hand(k);
  std::string t;
  std::cin>>t;

  rep(i,0,n){
    hand[i%k].push_back(junken(t[i]));
  }

  ll ans=0;

  rep(i,0,k){
    ll len=hand[i].size();
    std::vector<std::vector<ll>> dp(len+1,std::vector<ll>(3,0));

    rep(j,0,len){
      rep(temp,0,3){
        rep(jh,0,3){
          if(temp!=jh){
            chmax(dp[j+1][temp],dp[j][jh]);
          }
        }
        if(temp==(hand[i][j]+2)%3)dp[j+1][temp]+=point[(hand[i][j]+2)%3];
      }
    }
    ll max=0;
    rep(temp,0,3)chmax(max,dp[len][temp]);
    ans+=max;
  }

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 6596
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
        }
        int sight = 1;
        label: for (int i = 1; i < h.length; i++) {
            for (int j = 0; j < i; j++) {
                if (h[j] > h[i] ) {
                    continue label;
                }
            }
            sight++;
        }
        System.out.println(sight);
        sc.close();
    }
}

Measured memory_bytes: 21204
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  long long A;
  long long B;
  long long C;
  long long K;
  long long res = 0;
  long long t;
  rd(A);
  rd(B);
  rd(C);
  rd(K);
  t =min_L(A, K);
  res += t;
  K -= t;
  t =min_L(B, K);
  K -= t;
  res -= K;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   ll A, B, C, K, res = 0, t;
//   rd(A,B,C,K);
//   t = min(A,K);
//   res += t;
//   K -= t;
//   t = min(B,K);
//   K -= t;
//   res -= K;
//   wt(res);
// }


Measured memory_bytes: 3640
N=int(input())
from collections import defaultdict
city=set()
data=defaultdict(list)
for i in range(N):
    S,P=input().split()
    P=int(P)
    city|={S}
    data[S].append((P,i+1))
city=list(city)
city.sort()
for c in city:
    x=data[c]
    x.sort(key=lambda x:x[0],reverse=True)
    for p,k in x:
        print(k)

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

using namespace std;

typedef long long ll;

#define db(m)  cout<<#m<<" = "<<m<<"\n"

#define MAX 200005

const ll mod = 1000000007;

void bang(){
    ll n; cin>>n;
    vector<ll>v(n);
    ll sum = 0;
    for(auto& i : v){
        cin>>i;
        sum += i;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        sum -= v[i];
        ans += (sum % mod * v[i] % mod) % mod;
    }
    cout<<ans%mod<<"\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // int q; cin>>q;
    // while(q--)
        bang();

    return 0;
}

Measured memory_bytes: 4780
S = list(input())

for i in range(2, len(S)):
    miniS = S[0:-i]
    if len(miniS) % 2 == 0:
        front = ''.join(miniS[0:len(miniS)//2])
        back = ''.join(miniS[len(miniS)//2:len(miniS)])
        if front == back:
            print(len(miniS))
            exit()

Measured memory_bytes: 9004
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) throws IOException {

	final Scanner stdin = new Scanner( System.in );
	final int n = Integer.parseInt( stdin.nextLine() );
	for ( int i = 0; i < n; i++ ) {
	    final String input = stdin.nextLine();
	    final StreamTokenizer tokenizer = new StreamTokenizer( new StringReader( input.substring( 0, input.length() - 1 ) ) );
	    tokenizer.parseNumbers();
	    tokenizer.ordinaryChar( '+' );
	    tokenizer.ordinaryChar( '-' );
	    tokenizer.ordinaryChar( '/' );
	    tokenizer.ordinaryChar( '*' );
	    tokenizer.ordinaryChar( ')' );
	    tokenizer.ordinaryChar( '(' );
	    tokenizer.nextToken();
	    System.out.println( pm( tokenizer ) );
	}
    }

    static int pm( StreamTokenizer tokenizer ) throws IOException {
	int ans = md( tokenizer );

	while ( tokenizer.ttype != StreamTokenizer.TT_EOF &&
		( tokenizer.ttype == '+' || tokenizer.ttype == '-' ) ) {
	    
	    boolean add = ( tokenizer.ttype == '+' );
	    tokenizer.nextToken();
	    final int val = md( tokenizer );
	    if ( add ) {
		ans += val;
	    } else {
		ans -= val;
	    }
	}
	return ans;
    }

    static int md( StreamTokenizer tokenizer ) throws IOException {
	int ans = term( tokenizer );
	while ( tokenizer.ttype != StreamTokenizer.TT_EOF &&
		( tokenizer.ttype == '*' || tokenizer.ttype == '/' ) ){
	    
	    boolean mul = ( tokenizer.ttype == '*' );
	    tokenizer.nextToken();
	    final int val = term( tokenizer );
	    if ( mul ) {
		ans *= val;
	    } else {
		ans /= val;
	    }
	}
	return ans;
    }

    static int term( StreamTokenizer tokenizer ) throws IOException {
	if ( tokenizer.ttype == StreamTokenizer.TT_NUMBER ) {
	    final int val = ( int )tokenizer.nval;
	    tokenizer.nextToken();
	    return val;
	} else { 
	    tokenizer.nextToken(); //(
	    final int val = pm( tokenizer );
	    tokenizer.nextToken(); //)
	    return val;
	}
    }
}

Measured memory_bytes: 17184
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
d = {}

for i in range(6,-1,-1):
    d[a[i]] = 7-i
kkk = input()

print(d[kkk])



Measured memory_bytes: 38484
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
 
 
 
int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int Ans[N] = {0};
    for (int i = 0; i < Q; i++)
    {
        int A; cin >> A;
        Ans[A-1]++;
    }
    
    for (int i = 0; i < N; i++)
    {
        if(Ans[i] > Q-K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n==0 && m==0) break;
			
			int[][] cost = new int[m+1][m+1];
			int[][] time = new int[m+1][m+1];
			for(int i=0;i<=m;i++){
				for(int j=0;j<=m;j++){
					cost[i][j] = Integer.MAX_VALUE;
					time[i][j] = Integer.MAX_VALUE;
				}
			}
			int a, b, c, d;
			for(int i=0;i<n;i++){
				a = sc.nextInt();
				b = sc.nextInt();
				c = sc.nextInt();
				d = sc.nextInt();
				cost[a][b] = c;
				cost[b][a] = c;
				time[a][b] = d;
				time[b][a] = d;
			}
			for(int i=0;i<=m;i++){
				cost[i][i] = 0;
				time[i][i] = 0;
			}
			
			for(int i=0;i<=m;i++){
				for(int j=0;j<=m;j++){
					for(int k=0;k<=m;k++){
						if(cost[j][i]!=Integer.MAX_VALUE && cost[i][k]!=Integer.MAX_VALUE){
							cost[j][k] = Math.min(cost[j][k], cost[j][i]+cost[i][k]);
						}
						if(time[j][i]!=Integer.MAX_VALUE && time[i][k]!=Integer.MAX_VALUE){
							time[j][k] = Math.min(time[j][k], time[j][i]+time[i][k]);
						}
					}
				}
			}
			
			int q = sc.nextInt();
			for(int i=0;i<q;i++){
				a = sc.nextInt();
				b = sc.nextInt();
				c = sc.nextInt();
				if(c==0) System.out.println(cost[a][b]);
				else System.out.println(time[a][b]);
			}
		}
	}	
}

Measured memory_bytes: 94896
def main():
    a, b, c, x, y = map(int, input().split())
    minimum = 0

    if a + b >= 2 * c:
        number = min(x, y)
        x -= number
        y -= number
        minimum += 2 * c * number

        if x == 0:
            minimum += min(b, 2 * c) * y
            y = 0
        else:
            minimum += min(a, 2 * c) * x
            x = 0

    else:
        minimum += a * x
        minimum += b * y

    print(minimum)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
def time_shift(s):
    time={}
    time["hour"]=(s//3600)
    time["munite"]=((s%3600)//60)
    time["second"]=((s%3600)%60)
    return time
def Watch():
    S=int(input())
    time=time_shift(S)
    print("{}:{}:{}".format(time["hour"],time["munite"],time["second"]))

if __name__ == "__main__":
    Watch()

"""
C:\programs\program_training\AizuOnlineJudge>python ITP1_1_D.py
46979
13:2:59

"""


Measured memory_bytes: 5620
from collections import Counter

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

if N == 1:
    print(1)
    exit()

pos.sort(reverse = True)

cnt = Counter()

for i in range(N):
    a,b = pos[i]
    for j in range(i+1,N):
        c,d = pos[j]
        t = (a - c, b - d)
        cnt[t] += 1

ans = N - cnt.most_common()[0][1]
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

#define INF 0x7fffffff

using namespace std;

typedef pair<int, pair<int,int> > PP;

struct edge{
	int to, D, E;
	edge(int t, int d, int e): to(t), D(d), E(e) {}
};


int main(){
	int N, M, L, A, B, D, E;

	while( cin>>N>>M>>L, N|M|L ){
		priority_queue<PP,vector<PP>,greater<PP> > que;
		vector<edge> v[105];
		int dh[105][105];
		for(int i=0; i<M; i++){
			cin >> A >> B >> D >> E;
			v[A].push_back( edge(B, D, E) );
			v[B].push_back( edge(A, D, E) );
		}
		fill(dh[0], dh[0]+105*105, INF);
		
		que.push( make_pair(0, make_pair(1,L)) );
		while( !que.empty() ){
			PP p = que.top(); que.pop();
			int psf = p.second.first, pss = p.second.second;
			if( pss >= 0 && p.first < dh[psf][pss] ){
				dh[psf][pss] = p.first;
				for(int i=0; i<v[psf].size(); i++){
					edge e = v[psf][i];
					que.push( make_pair(p.first + e.E, make_pair(e.to, pss)) );
					que.push( make_pair(p.first, make_pair(e.to, pss-e.D)) );
				}
			}
		}

		int ans = INF;
		for(int i=0; i<=L; i++)
			ans = min(ans, dh[N][i] );

		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  string A, B;
  cin >> A >> B;
  string ans="EQUAL";
  if (A.size()>B.size()) {ans="GREATER";}
  else if (A.size()<B.size()) {ans="LESS";}
  else {
    for (int i=0; i<A.size(); i++) {
      if (A[i]-B[i]>0) {
        ans = "GREATER";
        break;
      }
      else if (A[i]-B[i]<0) {
        ans = "LESS";
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define INF ((1<<31)-1)

class SegmentTree{
private:
  int *stree;
  int n;
public:
  SegmentTree(int N);
  ~SegmentTree();
  void update(int i, int x);
  int find(int s, int t);
  int query(int s, int t, int k, int l, int r);
};

SegmentTree::SegmentTree(int N){
  int leading_zero = __builtin_clz(N);

  /* find nearest power of 2 for given N */
  if(__builtin_popcount(N) == 1) n = 1<<(sizeof(int)*8-leading_zero-1);
  else n = 1<<(sizeof(int)*8-leading_zero);

  /* initializing nodes as INF */
  stree = new int[2*n-1];
  for(int i=0;i<2*n-1;i++){
    stree[i] = INF;
  }

}

SegmentTree::~SegmentTree(){
  delete [] stree;
}

void SegmentTree::update(int i, int x){
  int j;

  /* deepest number of nodes */
  j = i + n - 1;
  stree[j] = x;

  while(j>0){
    /* number of upper node */
    j = (j-1)/2;
    stree[j] = min(stree[2*j+1], stree[2*j+2]);
  }
}

int SegmentTree::find(int s, int t){
  return query(s, t+1, 0, 0, n);
}

int SegmentTree::query(int s, int t, int k, int l, int r){
  if(r <= s || t <= l) return INF;
  if(s <= l && r <= t) return stree[k];
  else{
    int vl = query(s, t, 2*k+1, l, (l+r)/2);
    int vr = query(s, t, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
}

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

  SegmentTree seg(n);

  for(int i=0;i<q;i++){
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0) seg.update(x, y);
    if(com == 1) cout << seg.find(x, y) << endl;
  }

  return 0;
}

Measured memory_bytes: 2060
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	n := 26
	f := make([]bool, n)
	for i := 0; i < n; i++ {
		f[i] = true
	}

	for _, c := range s {
		f[c - 'a'] = false
	}

	none := true
	for i, t := range f {
		if t {
			fmt.Printf("%c\n", 'a' + i)
			none = false
			break
		}
	}

	if none {
		fmt.Println("None")
	}
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B,C;
	scan(A>>B>>C);
	if((C-A)*(C-B)<0) prin("Yes");
	else prin("No");
	return 0;
}


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

int main() {
	string a, b, c;

	cin >> a >> b >> c;

	if (a.back() != b[0]) {
		cout << "NO" << endl;
	}
	else if (b.back() != c[0]) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int m, n;
int sum[10000 + 5];
int p[10000 + 5], c[505], e[505];
int dp[505][10000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> m >> n;
    rep(i, m) cin >> p[i];
    sort(p, p + m);
    reverse(p, p + m);
    rep(i, m) {
        sum[i + 1] = sum[i] + p[i];
    }
    rep(i, n) cin >> c[i] >> e[i];
    rep(i, n + 1)rep(j, m + 1) dp[i][j] = -INF;
    rep(i, n + 1) dp[i][0] = 0;
    rep(i, n)rep(j, m + 1) {
        dp[i + 1][j] = dp[i][j];
        if (j - c[i] >= 0) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - c[i]] - e[i] + sum[j] - sum[j - c[i]]);
        }
        else {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][0] - e[i] + sum[j]);
        }
    }
    int ans = 0;
    rep(j, m + 1) ans = max(ans, dp[n][j]);
    cout << ans << endl;
}

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

int main(void) {
  string A, B, C;
  cin >> A >> B >> C;
  cout << (A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0] ? "YES"
                                                                  : "NO")
       << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, K;
    cin >> N >> K;
    deque<ll> V(N);
    rep(i, N) cin >> V[i];
    ll ans = 0;
    rep(i, K + 1) {
        ll remain = K - i;
        rep(j, remain + 1) {
            auto X = V;
            vector<ll> S;
            if (i + j > N) continue;
            rep(x, i) {
                S.push_back(X.front());
                X.pop_front();
            }
            rep(x, j) {
                S.push_back(X.back());
                X.pop_back();
            }
            ll s = accumulate(S.begin(), S.end(), 0LL);
            sort(S.begin(), S.end());
            ll r = K - i - j;
            rep(k, min(r, (ll) S.size())) {
                if (S[k] < 0) s -= S[k];
            }
            ans = max(ans, s);
        }
    }
    cout << ans << '\n';
}

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


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    string g;
    int y, m, d;
    while (cin >> g >> y >> m >> d, g != "#")
    {
        if(y<=30){
            cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
        }
        else if(y==31 && m<=4){
            cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
        }
        else{
            cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
        }
    }
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int arr[50];
int main(void) {
	int n, k, MAX = 0, tmp;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n, greater<int>());
	for (int i = 0; i < k; i++)
		MAX += arr[i];
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int m = (int)(n / 1.08)-1;
	int flag = 0;
	for (int i = m; i * 1.08 < n + 1; i++)
	{
		if ((int)(i * 1.08) == n) {
			printf("%d\n", i);
			flag = 1;
			break;
		}
	}
	if (!flag) printf(":(\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define INF 0x3f3f3f3f3f
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 20;

int n;
pii a[1 << N];

pii merge(pii A, pii B) {
    if(A.fi < B.fi) swap(A, B);
    pii ans = A;
    if(B.fi > ans.se) ans.se = B.fi;
    return ans;
}

void run() {
    for(int i = 0; i < 1 << n; i++) {
        int x; cin >> x;
        a[i] = MP(x, -INF);
    }
    for(int j = 0; j < n; j++) {
        for(int i = 0; i < 1 << n; i++) {
            if(i >> j & 1) a[i] = merge(a[i], a[i ^ (1 << j)]);
        }
    }
    int ans = 0;
    for(int i = 1; i < 1 << n; i++) {
        ans = max(ans, a[i].fi + a[i].se);
        cout << ans << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../put/a.input", "r", stdin);
    freopen("../put/a.output", "w", stdout);
#endif
    while(cin >> n) run();
    return 0;
}

Measured memory_bytes: 5600
def next(x):
    return chr(ord(x)+1)

import sys

A=set([chr(ord("a")+k) for k in range(26)])
S=input()

if len(S)!=26:
    u=min(A-set(S))
    print(S+u)
    exit()

p=-1

for i in range(25):
    if S[i]<S[i+1]:
        p=i

if p==-1:
    print(-1)
else:
    T=S[:p]
    a=next(S[p])

    while a in T:
        a=next(a)
    print(T+a)


Measured memory_bytes: 61984
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int k;
	cin >> k;

	if (k % 2 == 0) {
		cout << (k / 2) * (k / 2) << endl;
	}
	else {
		cout << (k / 2) * (k / 2 + 1) << endl;
	}
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a, b, c;
int main() {
  cin >> n;
  read_n(a, n); read_n(b, n); read_n(c, n);
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  sort(begin(c), end(c));

  lli ans = 0;
  for (lli i=0; i<n; ++i) {
    lli x = b[i];
    auto ai = lower_bound(begin(a), end(a), x);
    auto ci = lower_bound(begin(c), end(c), x+1);
    lli aj = ai - begin(a),
        cj = end(c) - ci;
    ans += aj * cj;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  int64_t k[n+1];
  int64_t w[n];
  rep(i,n+1){
    cin >> k[i];
  }
  rep(i,n){
    cin >> w[i];
  }
  int64_t ans=0;
  rep(i,n){
    int64_t y=n-1-i;
    if(k[y+1]>=w[y]){
      ans+=w[y];
      k[y+1]-=w[y];
      w[y]=0;
    }
    else{
      ans+=k[y+1];
      w[y]-=k[y+1];
      k[y+1]=0;
      if(k[y]>=w[y]){
        ans+=w[y];
        k[y]-=w[y];
        w[y]=0;
      }
      else{
        ans+=k[y];
        w[y]-=k[y];
        k[y]=0;
        
      }
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int r = scanner.nextInt();
        
        System.out.println(3*r*r);
                
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

bool mp[123][123];
int main(){ 
	int n;
	cin >>  n;
	int m = n / 2 * 2;
	for(int i = 1; i <= m; i ++) {
		for(int j = 1; j <= m; j ++) {
			if(i == j || i + j == m + 1) continue;
			mp[i][j] = 1;
		}	
	}
	if(n != m) {
		for(int i = 1; i <= n; i ++) 
			mp[i][n] = mp[n][i] = 1;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
	for(int j = i +1; j <= n; j ++) 
		ans += mp[i][j];
	cout << ans << endl;
	for(int i = 1; i <= n; i ++) 
	for(int  j = i + 1; j <= n; j ++)
	if(mp[i][j]) printf("%d %d\n", i, j);
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s;
    cin >> s;

    if(s[0]==s[1] &&s[1]==s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cstring>
#include <cstdio>
# include <string>
# include <vector>
# include <cmath>
# include <sstream>
# include <algorithm>
# include <bitset>
# include <sstream>
# include <typeinfo>
using namespace std;

int main(){
	string str;
	stringstream ss;
	cin >> str;
	long long sum = 0;
	long long n=0;
	for(long int i=0;i<str.size()-1;i++){
		n |= 1<<i;
	}
	for(unsigned long i=0;i<=n;i++){
		string a;
		for(long j=0;j<str.size();j++){
			if(i & 1<<j || j==str.size()-1){
				a += str[j];
				long long  val;
				ss << a;
				ss >> val;
				sum += val;
				ss.clear();
				a.clear();
			}else {
				a += str[j];
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 384
/*
Problem:Simple Knapsack(Atcoder2556) 
Algorithm:DP
Status:
DP formula:
	dp[i][cnt][j]=max(dp[i-1][cnt][j],dp[i-1][cnt-1][j-w[i]+w[0]]+v[i])
*/

//Simple?????!!!!

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

const int INF=1e9+7;

int n,W;
int v[105],w[105];
int dp[105][105][305];

int main()
{
	#ifndef ZZZYT
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
	#endif
	scanf("%d%d",&n,&W);
	for(int i=0;i<n;i++){
		scanf("%d%d",w+i,v+i);
	}
	
	for(int i=0;i<n;i++){
		for(int cnt=0;cnt<=i;cnt++){
			for(int j=0;j<=3*cnt;j++){
				dp[i+1][cnt][j]=max(dp[i+1][cnt][j],dp[i][cnt][j]);
				dp[i+1][cnt+1][j+(w[i]-w[0])]=max(dp[i+1][cnt+1][j+(w[i]-w[0])],dp[i][cnt][j]+v[i]);
				//cout<<dp[i][cnt][j]<<' ';
			}
			//cout<<endl;
		}
		//cout<<endl;
	}
	
	int ans=-INF;
	for(int cnt=0;cnt<=n;cnt++){
		for(int j=0;j<=cnt*3;j++){
			long long tmp=(long long)cnt*(long long)w[0]+j;
			if(tmp>W)continue;
			ans=max(ans,dp[n][cnt][j]);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


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

class Queen{
    static const int N = 8;
    vector<bool> horizontal, vertical;
    vector<bool> right_angled, left_angled;
    vector<pair<int, int>> position;
public:
    Queen() : horizontal(N), vertical(N), right_angled(2*N-1), left_angled(2*N-1) {}

    void queen_set(int x, int y) {
        horizontal[y] = vertical[x] = right_angled[x + y] = left_angled[x - y + N - 1] = true;
        position.emplace_back(x, y);
    }

    void queen_unset(int x, int y) {
        horizontal[y] = vertical[x] = right_angled[x + y] = left_angled[x - y + N - 1] = false;
        position.pop_back();
    }

    bool is_used(int x, int y) {
        return (horizontal[y] || vertical[x] || right_angled[x + y] || left_angled[x - y + N - 1]);
    }

    void print() {
        vector<vector<bool>> placement(N, vector<bool>(N));

        for(auto p : position){
            placement[p.second][p.first] = true;
        }

        for (int y = 0; y < N; y++) {
            for (int x = 0; x < N; x++){
                cout << (placement[y][x] ? 'Q' : '.');
            }
            cout << endl;
        }
    }

    void dfs(int y){
        if(y >= N){
            print();
            return;
        }

        if(horizontal[y]){
            dfs(y + 1);
        }
        else{
            for (int x = 0; x < N; x++){
                if (!is_used(x, y)) {
                    queen_set(x, y);
                    dfs(y + 1);
                    queen_unset(x, y);
                }
            }
        }
    }

};

int main(){

    int k;
    cin >> k;

    Queen queen;
    for(int i = 0; i < k; ++i){
        int r, c;
        cin >> r >> c;
        queen.queen_set(c, r);
    }

    queen.dfs(0);

    return 0;
} 


Measured memory_bytes: 3104
import sys
input = sys.stdin.readline
from collections import *

def bfs(s):
    q = deque([s])
    dist = [-1]*N
    dist[s] = 0
    leaf = set()
    
    while q:
        v = q.popleft()
        flag = True
        
        for nv in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+1
                q.append(nv)
                flag = False
                
        if flag:
            leaf.add(v)
    
    return dist, leaf

N, u, v = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(N-1):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

d1, _ = bfs(u-1)
d2, leaf = bfs(v-1)
ans = 0

for i in range(N):
    if i not in leaf and d1[i]<=d2[i]:
        ans = max(ans, d2[i])

print(ans)

Measured memory_bytes: 68128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,x,y,h,m;cin>>N;
  ll X[N],Y[N],H[N],D[N];
  REP(i,N)cin>>X[i]>>Y[i]>>H[i];
  REP(x,101){
    REP(y,101){
      h=-1;m=10000100000;
      REP(i,N)D[i]=abs(X[i]-x)+abs(Y[i]-y);
      REP(i,N){
        if(H[i]==0)m=min(m,D[i]);
        else if(h==-1)h=H[i]+D[i];
        else if(h!=H[i]+D[i]){h=m+1;break;}
      }
      if(h<=m)break;
    }
    if(y<101)break;
  }
  cout<<x<<" "<<y<<" "<<h<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
    ll ans;
	cin >> n;
    ll a[10][10];
    fr(i,10){
    	fr(j,10){
        	a[i][j]=0;
        }
    }
    for(int i=1;i<n+1;i++){
    	int j=i;
        if(i<10)a[j][j]++;
        else if(i<100)a[j/10][j%10]++;
        else if(i<1000)a[j/100][j%10]++;
        else if(i<10000)a[j/1000][j%10]++;
        else if(i<100000)a[j/10000][j%10]++;
        else if(i<1000000)a[j/100000][j%10]++;
    }
    fr(i,10){
    	fr(j,10){
        	ans+=a[i][j]*a[j][i];
        }
    }
      cout << ans << endl;
}


Measured memory_bytes: 256