akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int H,N;
    cin>>H>>N;
    long long int val = 0;
    long long int sum = 0;
    for(int i = 0;i<N;i++){
        cin>>val;
        sum+=val;
    }
    if(sum<H){
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main(){
        ll n; scanf("%lld", &n);
        ll zero[64], one[64];
        for(ll i=0; i<64; i++) zero[i]=0, one[i]=0;
        for(ll i=0; i<n; i++){
                ll a; scanf("%lld", &a);
                for(ll j=0; j<64; j++){
                        if((a>>j)&1) one[j]++;
                        else zero[j]++;
                }
        }

        ll ans = 0, wei = 1;
        for(ll i=0; i<64; i++){
                ll tmp = (zero[i]*one[i])%MOD;
                ans += (tmp*wei)%MOD; ans %= MOD;
                wei *= 2; wei %= MOD;
        }
        printf("%lld\n", ans%MOD);

        return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 100000000;
    for(int i=0;i<=n;i++){
        int tmp = 1;
        for(int j=1;j<=i;j++){
            tmp *=2;
        }
        for(int j=1;j<=n-i;j++){
            tmp += k;
        }
        if(ans > tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  double a,b,C;
  cin >> a >> b >> C;
  C*=3.14159265;
  C/=180;
  double c=a*a+b*b-2*a*b*cos(C);
  c=sqrt(c);
  double L=a+b+c;
  double S=a*b*sin(C)*0.5;
  double h=b*sin(C);
  cout << fixed << setprecision(5);
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
}


Measured memory_bytes: 3476
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
chomp $n;

my @c;
{
    my $in = <STDIN>;
    @c = split(" ", $in);
}
@c = sort { $a <=> $b } @c;

for (my $i=0; $i<$n-1; $i++)
{
    if ($c[$i]==$c[$i+1])
    {
        print "NO\n";
        exit;
    }
}

print "YES\n";

Measured memory_bytes: 37156
x, y = map(int, input().split())
grp1 = [1,3,5,7,8,10,12]
grp2 = [4,6,9,11]
grp3 = [2]

if x in grp1 and y in grp1:
    print('Yes')
elif x in grp2 and y in grp2:
    print('Yes')
elif x in grp3 and y in grp3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
X, K ,D = map(int,input().split())
ans = 0
X = abs(X)
M = X // D 
if M > K:
    ans = X - K * D
else :
    if (K - M) % 2 == 1:
        ans = X - D * (M + 1)
    else:
        ans = X - D * M
print(abs(ans))


Measured memory_bytes: 9176
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Map<Character, List<Integer>> posMap = new HashMap<>();
        for(int i = 0; i < s.length(); i++) {
        	char c = s.charAt(i);
        	if(!posMap.containsKey(c))
        		posMap.put(c, new ArrayList<>());
        	posMap.get(c).add(i);
        }

        int min = s.length();
        for(List<Integer> list : posMap.values()) {
        	int maxDist = 0;
        	int prev = -1;
        	for(int i = 0; i < list.size(); i++) {
        	    int dist = Math.abs(list.get(i) - prev - 1);
        		maxDist = Math.max(maxDist, dist);
        		prev = list.get(i);
        	}
        	maxDist = Math.max(maxDist, Math.abs(s.length() - prev - 1));

        	min = Math.min(min, maxDist);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b;
	string s;
	cin >> a >> b >> s;
	for(int i = 0; i < a; ++i){
		if(!('0' <= s[i] && s[i] <= '9')){
			cout << "No" << endl;
			return 0;
		}
	}
	if(s[a] != '-'){
		cout << "No" << endl;
		return 0;

	}
	for(int i = a+1; i < a+b; ++i){
		if(!('0' <= s[i] && s[i] <= '9')){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
N, Y = [int(n) for n in input().split()]

for i in range((Y // 10000) + 1):
    for j in range((Y // 5000) + 1):
        k = N - i - j
        if k >= 0:
            #p = 10000 * i + 5000 * j + 1000 * k 
            if 10000 * i + 5000 * j + 1000 * k == Y:
                print(' '.join(map(str, [i, j, k])))
                break
    else:
        continue
    break
else:
    print('-1 -1 -1')

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

long n, m;
vector<pair<long,long>> hitobito[100002];
vector<bool> visited(100002);
vector<long> number(100002);

bool dfs(long t, long cnt) {
    visited[t] = true;
    number[t] = cnt;
    bool rslt = true;
    for (auto p : hitobito[t]) {
        if (!visited[p.first])
            rslt &= dfs(p.first, cnt+p.second);
        else if (number[p.first] != cnt+p.second)
            rslt = false;
    }
    return rslt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (long i=0; i<m; i++) {
        long l, r, d;
        cin >> l >> r >> d;
        hitobito[l].push_back(make_pair(r, d));
        hitobito[r].push_back(make_pair(l, -d));
    }
    for (long i=1; i<=n; i++)
        if (!visited[i] && !dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    cout << "Yes" << endl;
}

Measured memory_bytes: 16512
import sys
input = sys.stdin.readline
s = input()[: -1]
t = s.split("T")
x, y = map(int, input().split())
x -= t[0].count("F")
xm = t[: : 2]
ym = t[1: : 2]
xl = 0
yl = 0
if "F" in t[0]: xm = xm[1: ]
for i in range(len(xm)): xl += len(xm[i])
for i in range(len(ym)): yl += len(ym[i])
if xl < abs(x) or (yl < abs(y)):
  print("No")
  exit(0)
#print(xm, ym)
dp = [[0] * (xl * 2 + 1) for _ in range(len(xm) + 1)]
dp[0][xl] = 1
for i in range(len(xm)):
  for j in range(xl * 2 + 1):
    z = len(xm[i])
    if (j + z) in range(xl * 2 + 1):
      dp[i + 1][j + z] |= dp[i][j]
    if (j - z) in range(xl * 2 + 1):
      dp[i + 1][j - z] |= dp[i][j]
if dp[-1][xl + x] == 0:
  print("No")
  exit(0)
dp = [[0] * (yl * 2 + 1) for _ in range(len(ym) + 1)]
dp[0][yl] = 1
for i in range(len(ym)):
  for j in range(yl * 2 + 1):
    z = len(ym[i])
    if (j + z) in range(yl * 2 + 1):
      dp[i + 1][j + z] |= dp[i][j]
    if (j - z) in range(yl * 2 + 1):
      dp[i + 1][j - z] |= dp[i][j]
if dp[-1][yl + y] == 0:
  print("No")
  exit(0)
print("Yes")

Measured memory_bytes: 167772
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    if(N%10 in (2,4,5,7,9)):
        print("hon")
    elif(N%10 in (0,1,6,8)):
        print("pon")
    else:
        print("bon")
if __name__ == '__main__':
    main()

Measured memory_bytes: 78064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define ms map<string,ll>
#define itr ::iterator
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define db(i) cout<<i<<"  "
#define M 1000000007

ll power(ll x, ll y)
{ ll res = 1;
  x=x%M;
  while (y > 0)
    {if (y & 1)
      res = (res*x)%M;
     y = y>>1;
     x = (x*x)%M;
    }
    return res;
}

ll check(ll n)
{ if(n==1)
   return 1;
return 2*check(n/2)+1;
}

int main()
{ ll t=1;
  //cin>>t;
  while(t--)
  { ll h=0,n=0,k=0,i=0;
    cin>>h;
    cout<<check(h);
  }
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

typedef struct{
	char name[11];
	int time;
}Process;

class ProcessQueue{
public:
	ProcessQueue(int size):
		m_size(size),
		m_head(0),
		m_tail(0),
		number(0)
	{
		m_process = new Process[m_size];
	};

	~ProcessQueue(){
		delete[] m_process;
	};

	void enQueue(Process process){
		//strcpy(m_process[m_tail].name,process.name);
		//m_process[m_tail].time = process.time;

		m_process[m_tail] = process;	//=??§??£??\????

		number++;

		if(m_tail < m_size-1){
			m_tail++;
		}else{	//?????°?????????
			m_tail = 0;
		}
	};

	Process deQueue(){
		number--;
		if(m_head < m_size-1){
			m_head++;
			return m_process[m_head-1];
		}else{	//?????°?????????
			m_head = 0;
			return m_process[m_size-1];
		}
	};

	int getNumber(){
		return number;
	}

private:
	int m_head;
	int m_tail;
	int m_size;
	int number;
	Process* m_process;

};

int main(){

	int n,q,totaltime=0;
	scanf("%d%d",&n,&q);

	ProcessQueue queue(n);

	Process tmp;
	for(int i = 0; i < n; i++){
		scanf("%s%d",&tmp.name,&tmp.time);
		queue.enQueue(tmp);
	}

	while(queue.getNumber() != 0){
		tmp = queue.deQueue();
		if(tmp.time - q > 0){
			totaltime += q;
			tmp.time -= q;
			queue.enQueue(tmp);
		}else{
			totaltime += tmp.time;
			printf("%s %d\n",tmp.name,totaltime);
		}
	}

}



Measured memory_bytes: 3588
import numpy as np
import math as m

def main(**kwargs):
    if c - a - b < 0:
        res = "No"
    elif 4 * a * b < (c - a - b) ** 2:
        res = "Yes"
    else:
        res = "No"

    return res

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    a, b, c, *_ = cin

    cout = main(a=a, b=b, c=c)
    print(cout)

Measured memory_bytes: 21644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}, dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int odd = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2) odd++;
	}
	if (odd % 2)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  int average;
  average = (a + b + 1) / 2;

  cout << average;
    
  return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  d = 0;
    
  while (c > 0){
    if (a >= b){
      c -= a;
      d += 1;
    }
    else {
      c -= b;
      d += 1;
    }
  }
  cout << d;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
const int mod=1000000007;
long long div(long long pow){//x^1000000005
    long long x=1;
    for(int i=mod-2;i>0;i/=2){
        if(i%2){
            x*=pow;
            x%=mod;
        }
        pow*=pow;
        pow%=mod;
    }
    return x;
}
int main(){
    int n;
    cin>>n;
    int a[n];
    int m=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        m=max(m,a[i]);
    }
    vector<int>furui(m+1);//エラトステネスの篩 0=prime_number
    vector<int>prm(m+1);//素数iは何番目の素数？
    vector<int>prm2;
    int p=0;//m以下の素数の数
    for(int i=2;i<=sqrt(m);i++){
        if(furui[i]==0){
            for(int j=i*2;j<=m;j+=i)furui[j]=1;
        }
    }
    for(int i=2;i<=m;i++){
        if(furui[i]==0){
            prm[i]=p;
            prm2.push_back(i);
            p++;
        }
    }
    int lcm[p]={};
    for(int i=0;i<n;i++){
        int A=a[i];
        for(int j=2;j<=sqrt(A);j++){
            int soinsu=0;
            while(A%j==0){
                soinsu++;
                A/=j;
            }
            lcm[prm[j]]=max(soinsu,lcm[prm[j]]);
        }
        if(A>1)lcm[prm[A]]=max(1,lcm[prm[A]]);
    }
    long long l=1;
    for(int i=0;i<p;i++){
        for(int j=0;j<lcm[i];j++){
            l*=prm2[i];
            l%=mod;
        }
    }
    long long x=0;
    for(int i=0;i<n;i++){
        x+=l*div(a[i]);
        x%=mod;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 8824
N, M, R = map(int, input().split())
r = list(map(int, input().split()))

adj = [[] for i in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    adj[-A].append((B, C))
    adj[-B].append((A, C))

import heapq

def Dijkstra(N, v_st, v_go):
    cost = [float('inf') for i in range(N)]

    pq = []
    heapq.heappush(pq, (0, v_st))

    while pq:
        c, v_now = heapq.heappop(pq)

        if v_now == v_go:
            return c

        if cost[-v_now] < c:
            continue

        cost[-v_now] = c

        for v, c2 in adj[-v_now]:
            if cost[-v_now] + c2 < cost[-v]:
                cost[-v] = cost[-v_now] + c2
                heapq.heappush(pq, (cost[-v], v))

cost_min = [[float('inf') for i in range(R)] for j in range(R)]

for i in range(R):
    for j in range(i, R):
        cost_min[i][j] = Dijkstra(N, r[i], r[j])
        cost_min[j][i] = cost_min[i][j]

import itertools
p = list(itertools.permutations(range(R)))

ans = float('inf')
for pp in p:
    c = 0
    for i in range(R - 1):
        c += cost_min[pp[i]][pp[i + 1]]

    ans = min(ans, c)
    
print(ans)


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

int main()
{
	int n,d;
	cin>>n;
	ll h[n];
	vector<ll > v;
	map<ll,ll> mp;
	for(ll i=0;i<n;i++)
	{
		cin>>h[i];
		mp[h[i]+i+1]++;
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ans+=mp[i+1-h[i]];
	}
	cout<<ans<<endl;
}


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

int main() {
  string S;
  cin >> S;

  int count = 0;
  if (S == "SSS") {
    count = 0;
  }
  else if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") {
    count = 1;
  }
  else if (S == "RRS" || S == "SRR") {
    count = 2;
  }
  else if (S == "RRR") {
    count = 3;
  }
  cout << count << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007



int main()
{
    string s;
    cin >> s;
    int d;
    cin >> d;
    vector<vector<int> > dp(d, vector<int>(2));
    
    dp[0][0] = 1;
    for(int i=0; i<s.size();i++)
    {
        vector<vector<int> > tmp_dp(d, vector<int>(2));
        int cur = s[i]-'0';
        for(int remainder=0; remainder<d; remainder++)
        {
            bool ar[2];
            ar[0] = false;
            ar[1] = true;
            for(bool small:ar) 
                for(int j=0;j<10;j++)
                {
                    if(j > cur && !small)
                    {
                        break;
                    }
                    tmp_dp[(remainder+j)%d][small || j<cur] = (tmp_dp[(remainder+j)%d][small || j<cur]
                                            + dp[remainder][small])%mod ;
                }
        }
        dp = tmp_dp;
    }

    int ans = (dp[0][true] + dp[0][false])%mod;
    ans--;
    if(ans<0)
        ans = mod-1;
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
     int n;
     cin >> n;
     int d[n];
     int sum = 0;
     int ans = 0;
     rep(i,n){
          cin >> d[i];
          sum += d[i];
     }
     sum -= d[0];
     for(int i = 0; i<n-1; i++){
          ans += d[i] * sum;
          sum -= d[i+1];
     }
     cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        string s;
        int N;
        cin >> s;
        N=s.size();
        ll ans = 0;
        //2^(N-1)のbit全探索
        rep(i,1 << (N - 1)) {
                //初期化
                ll sum = 0;
                //文字列を整数型に変換
                ll a = s[0] - '0';
                //文字列を探索
                rep(j,N-1) {
                        //bitが立っていたら+を挿入したと考える
                        if (i & (1 << j)) {
                                sum += a;
                                a = 0;
                        }
                        //bitが立っていなかったら次の文字に行く準備
                        a = a * 10 + s[j + 1] - '0';
                }
                //探索の結果をansに加算して次のループへ
                sum += a;
                ans += sum;
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
const int M=1e5+5;
const int inf=INT_MAX;
int a[N][N],b[N][N],vi[N][N],vis[N][N];
int n,m,s,now,w[M],v[M],cr[N],dis[N],nex[M],head[N];
void addedges(int x,int y,int z){
	nex[++now]=head[x],w[now]=z;
	head[x]=now,v[now]=y;
}
queue<int>que;
void add(int x,int y){
	addedges(x,y,1);
	addedges(y,x,0);
}
bool bfs(){
	for(int i=0;i<=s;i++)	cr[i]=head[i],dis[i]=0;
	que.push(s),dis[s]=1;
	while(!que.empty()){
		int x=que.front();	que.pop();
		for(int i=head[x];i;i=nex[i])
			if(w[i]&&!dis[v[i]]){
				dis[v[i]]=dis[x]+1;
				que.push(v[i]);
			}
	}
	return dis[0];
}
int dfs(int x,int f){
	int ans=0;
	if(!x||!f)	return f;
	for(int &i=cr[x];i;i=nex[i])
		if(w[i]&&dis[v[i]]==dis[x]+1){
			int d=dfs(v[i],min(f,w[i]));
			if(!d)	continue;
			ans+=d,w[i]-=d;
			w[i^1]+=d,f-=d;
			if(!f)	break;
		}
	if(!ans)	dis[x]=-1;
	return ans;
}
int main(){
	scanf("%d%d",&n,&m),s=n+n+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)	scanf("%d",&a[i][j]);
	for(int i=1;i<=m;i++){
		now=1;
		for(int j=0;j<=s;j++)	head[j]=0;
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++)	vis[j][k]=0;
			for(int k=1;k<=m;k++){
				int d=(a[j][k]+m-1)/m;
				if(!vis[j][d]&&!vi[j][k])
					vis[j][d]=k,add(j,n+d);
			}
			add(s,j);
		}
		for(int j=1;j<=n;j++)	add(j+n,0);
		while(bfs())
		while(dfs(s,inf));
		for(int j=1;j<=n;j++)
			for(int k=head[j];k;k=nex[k])
				if(!w[k]){
					int x=v[k]-n,y=vis[j][x];
					b[j][i]=a[j][y],vi[j][y]=1;
				}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			printf("%d ",b[i][j]);
			a[(b[i][j]+m-1)/m][j]=b[i][j];
		}
		putchar('\n');
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			printf("%d ",a[i][j]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 7168
from sys import stdin
n = stdin.readline().rstrip()
if n == "hi":
    print('Yes')
elif n == "hihi":
    print('Yes')
elif n == "hihihi":
    print('Yes')
elif n == "hihihihi":
    print('Yes')
elif n == "hihihihihi":
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  long long max = 0;
  long long min = 1000000000;
  REP(i,n){
    long long a;
    cin >> a;
    if(a<min) min = a;
    if(a>max) max = a;
  }
  cout << max-min << endl;
  return 0;
}


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

using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) {
        par.resize(n);
        for(int i=0;i<n;i++) par[i] = -1;
    }

    int root(int x) {
        if( par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(par[x] > par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
    }

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

    int size(int x) {
        return -par[root(x)];
    }
};

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

    UnionFind uf(N);

    vector<set<int>> frds(N);
    
    for(int i=0;i<M;i++) {
        int a,b; cin >> a >> b;
        a--; b--;
        frds[a].insert(b);
        frds[b].insert(a);
        uf.merge(a,b);
    }

    for(int i=0;i<K;i++) {
        int a,b; cin >> a >> b;
        a--; b--;
        if(!uf.issame(a,b)) continue;
        frds[a].insert(b);
        frds[b].insert(a);
    }

    for(int i=0;i<N;i++) {
        int num = uf.size(i) - 1 - frds[i].size();
        cout << num << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> s(n,0);
    rep(i, n) scanf("%d", &s[i]);
    int q;
    scanf("%d", &q);
    vector<int> t(q,0);
    rep(i, q) scanf("%d", &t[i]);

    int count = 0;
    rep(i, q) {
        rep(j, n) {
            if (t[i] == s[j]) {
                count++;
                break;
            }
        }
    }
    printf("%d\n", count);
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	ll n ; cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	rep(i,n) cin >> a[i] >> b[i];

	ll ans = 0 ;
	for(int i = n - 1; i >= 0; i--){
		if((ans + a[i]) % b[i] == 0 ) continue;
		ans += b[i] - ((ans + a[i]) % b[i]) ;
	}
	cout << ans << endl;

}


Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
import itertools
import copy

def main():
    N, A, B, C = [int(x) for x in input().split()]
    l = []
    for _ in range(N):
        l.append(int(input()))

    memo = 0
    ans = float("inf")

    for a, b, c in list(itertools.permutations([A, B, C], 3)):
        Ncopy = N
        a_cost = float("inf")
        b_cost = float("inf")
        c_cost = float("inf")

        lcopy = copy.deepcopy(l)

        for i in range(1, 2 ** Ncopy):
            tmp = -10
            a_len = 0
            for j in range(Ncopy):
                if i >> j & 1:
                    tmp += 10
                    a_len += lcopy[j]
            tmp += abs(a_len - a)
            a_cost = min(a_cost, tmp)
            if a_cost == tmp:
                memo = i

        for j in range(Ncopy - 1, -1, -1):
            if memo >> j & 1:
                lcopy.pop(j)
                Ncopy -= 1

        for i in range(1, 2 ** Ncopy):
            tmp = -10
            b_len = 0
            for j in range(Ncopy):
                if i >> j & 1:
                    tmp += 10
                    b_len += lcopy[j]
            tmp += abs(b_len - b)
            b_cost = min(b_cost, tmp)
            if b_cost == tmp:
                memo = i

        for j in range(Ncopy - 1, -1, -1):
            if memo >> j & 1:
                lcopy.pop(j)
                Ncopy -= 1


        if len(lcopy) == 0:
            continue


        for i in range(1, 2 ** Ncopy):
            tmp = -10
            c_len = 0
            for j in range(Ncopy):
                if i >> j & 1:
                    tmp += 10
                    c_len += lcopy[j]
            tmp += abs(c_len - c)
            c_cost = min(c_cost, tmp)
            if c_cost == tmp:
                memo = i
        for j in range(Ncopy - 1, -1, -1):
            if memo >> j & 1:
                lcopy.pop(j)
                Ncopy -= 1

        ans = min(ans, a_cost + b_cost + c_cost)


    print(ans)









    

if __name__ == '__main__':
    main()




Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string S;
	
	cin>>S;
	
	if(count(S.begin(), S.end(), 'A') == 0 ||count(S.begin(), S.end(), 'B') == 0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	
	return 0;
}

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

std::vector<int> move (std::vector<int> dice, std::string dir) {
    std::vector<int> new_dice(6,0);
    int deflt_data[] = {1, 2, 3, 4, 5, 6};
    std::vector<int> deflt(deflt_data, deflt_data + 6);
    int east_data[] = {4, 2, 1, 6, 5, 3};
    std::vector<int> east(east_data, east_data + 6);
    int west_data[] = {3, 2, 6, 1, 5, 4};
    std::vector<int> west(west_data, west_data + 6);
    int south_data[] = {5, 1, 3, 4, 6, 2};
    std::vector<int> south(south_data, south_data + 6);
    int north_data[] = {2, 6, 3, 4, 1, 5};
    std::vector<int> north(north_data, north_data + 6);
    if (dir == "E") {
        for (int loop = 0; loop < 6; loop++) {
            new_dice[deflt[loop] - 1] = dice[east[loop] - 1];
        }
    } else if (dir == "W") {
        for (int loop = 0; loop < 6; loop++) {
            new_dice[deflt[loop] - 1] = dice[west[loop] - 1];
        }
    } else if (dir == "S") {
        for (int loop = 0; loop < 6; loop++) {
            new_dice[deflt[loop] - 1] = dice[south[loop] - 1];
        }
    } else if (dir == "N") {
        for (int loop = 0; loop < 6; loop++) {
            new_dice[deflt[loop] - 1] = dice[north[loop] - 1];
        }
    }
    return new_dice;
}

void printDice (std::vector<int> dice); 

int main(void) {
    std::vector<int> dice(6,0);
    for (int surface = 0; surface < dice.size(); surface++) {
        std::cin >> dice[surface];
    }
    std::string dir_list;
    std::cin >> dir_list;
    std::string dir;
    for (int loop = 0; loop < dir_list.size(); loop++) {
        dir = dir_list[loop]; 
        dice = move(dice, dir);
    }
    std::cout << dice[0] << std::endl;
    return EXIT_SUCCESS;
}

void printDice (std::vector<int> dice) {
    for (int surface = 0; surface < dice.size(); surface++) {
        std::cout << dice[surface] << " ";
    }
    std::cout << std::endl;
    return;
}

Measured memory_bytes: 3220
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a)

now=A[0]
can=1

for i in range(2*n):
    if now==2:
        print(i+1)
        can=0
        break

    now=A[now-1]

if can:
    print(-1)

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

using namespace std;

static const int MAX = 200000;

int main(int argc, char** argv) {
	
	int n;
	int r[MAX];
	int i;
	int maxv, minv;
	
	maxv = -2000000000;
	
	cin >> n;
	
	for (i = 0; i < n; i++)
		cin >> r[i];
		
	minv = r[0];
		
	for (i = 1; i < n; i++) {
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<tuple<ll, ll, ll> > YP(M);
  vector<ll> count(N+1);
  vector<tuple<ll, string> > id(M);
  for (int j=0; j < M; ++j) {
    ll P, Y;
    cin >> P >> Y;
    YP[j] = make_tuple(Y, P, j);
  }
  sort(YP.begin(), YP.end());
  for (int j=0; j < M; ++j) {
    ll P, Y, i;
    tie(Y, P, i) = YP[j];
    ostringstream s;
    s << setfill('0') << setw(6) << P << setfill('0') << setw(6) << count[P]+1;
    id[j] = make_tuple(i, s.str());
    count[P] += 1;
  }
  sort(id.begin(), id.end());
  for (int j=0; j < M; ++j) {
    ll i;
    string s;
    tie(i, s) = id[j];
    cout << s << endl;
  }
}


Measured memory_bytes: 10880
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ar = new int[n];
        double res = 0;
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
            res += (1/(double)ar[i]);
        }
        System.out.println(1/res);
    }
}

class io{

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include <math.h>
using namespace std;

int main() {
	string s;
	long long int ans =0;
	long long int a[10];
	cin >> s;
	int array_length = s.length();
	for(int i=0;i<array_length;i++){
		a[i] = s[i]-'0';
	}
	int n=1;
	int nn=1;
	int nnn=1;
	int temp;
	int b = array_length;
	for(int i=0;i<array_length;i++){
		temp = array_length-nnn;
		for(int k=0;k<b;k++){
			ans += a[i] * n * pow(10,temp);
			if(k !=0){
				n=n+n;
			}
			temp=temp-1;
				
		}
		nn=nn*2;
		n=nn;
		nnn++;
		b--;
	}

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

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

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

    ll a[n];
    map<ll, int> map;

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

    ll max = -1;
    ll max_second = -1;
    int max_cou = -1;
    for(auto itr = map.begin(); itr != map.end(); ++ itr){
        ll key = itr -> first;
        int cou = itr -> second;

        if(cou >= 2){
            if(max <= key){
                if(max == -1){
                    max = key;
                }else{
                    max_second = max;
                    max = key;
                }
                max_cou = cou;
            }else if(max_second <= key){
                max_second = key;
            }
        }
    }

    if(max == -1){
        cout << 0 << endl;
    }else{
        if(max_cou >= 4){
            cout << max * max << endl;
        }else{
            if(max_second == -1){
                cout << 0 << endl;
            }else{
                cout << max * max_second << endl;
            }
        }
    }
}

Measured memory_bytes: 7296
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

	vector<vector<vector<vector<ll>>>> dp(N + 1, vector<vector<vector<ll>>>(4, vector<vector<ll>>(4,vector<ll>(4))));
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				if (j == 0 && k == 1 && l == 2)continue;
				if (j == 0 && k == 2 && l == 1)continue;
				if (j == 1 && k == 0 && l == 2)continue;
				dp[3][j][k][l] = 1;
			}
		}
	}

	for (int i = 3; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					for (int s = 0; s < 4; s++) {
						if (j == 0 && k == 1 && s == 2)continue;
						if (j == 0 && l == 1 && s == 2)continue;
						if (k == 0 && l == 1 && s == 2)continue;
						if (k == 0 && l == 2 && s == 1)continue;
						if (k == 1 && l == 0 && s == 2)continue;
						dp[i + 1][k][l][s] += dp[i][j][k][l];
						dp[i + 1][k][l][s] %= DIV;
					}
				}
			}
		}

	}
	
	/*
	//for (int i = 2; i <= N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					printf("dp[4][%d][%d][%d]=", j, k,l);
					cout << dp[4][j][k][l] << " ";
					cout << endl;
				}
			}
		}

	//}
	*/
	ll ans = 0;
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
			for(int l=0;l<4;l++)
			ans += dp[N][j][k][l];
			ans %= DIV;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k, cnt = 0;
	cin>>a>>b>>c>>k;
	cnt += min(a, k);
	D(cnt);
	k -= a;
	if (k > 0) k -= b;
	D(cnt);
	if (k > 0) cnt -= k;
	D(cnt);
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3648
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s;cin>>s;
  if(s=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
 //  system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define MAX 305
using namespace std;

int C[MAX],V[MAX],D[MAX],L[MAX];
int n,cost;
int dp[MAX][MAX];


int recv(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  if(j < C[i])return recv(i+1,j);
  else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*V[i]+recv(i+1,j-k*C[i]));
    }
    }
  
  return dp[i][j]=res;
}
int recd(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  if(j < C[i])return recd(i+1,j);
  else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*D[i]+recd(i+1,j-k*C[i]));
    }
    }
  
  return dp[i][j]=res;
}
int recl(int i,int j){
  if(dp[i][j] != -1) return dp[i][j]; 
  if(i == n )return 0;
  int res =0;
  if(j < C[i])return recl(i+1,j);
  else{
    for(int k=0;k*C[i]<=j;k++){
      res = max(res,k*L[i]+recl(i+1,j-k*C[i]));
    }
    }
  
  return dp[i][j]=res;
}



int main(){

  int iori,chihaya=0,makoto=0,miki=0;


  while( cin >> n >> cost ){

    for(int i=0;i<n;i++){
      char ch = getchar();
      while((ch=getchar())!='\n');
      cin >> C[i] >> V[i] >> D[i] >> L[i];
    }

    memset(dp,-1,sizeof(dp));
    chihaya = (chihaya,recv(0,cost));
    //cout << "DEBUG V = " << chihaya << endl;
    /*
    for(int i=0;i < 10;i++){
      for(int j=0;j<10;j++)cout << dp[i][j] << " " ;
      cout << endl; 
    }
    */
    memset(dp,-1,sizeof(dp));
    makoto = recd(0,cost);
    //cout << "DEBUG D = " << makoto << endl;
    memset(dp,-1,sizeof(dp));
    miki = recl(0,cost);
    //  cout << "DEBUG L = " << miki << endl;

    iori=max(chihaya,max(makoto,miki));

    cout << iori << endl;

  }
  return 0;
}

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

class city {
	public:
		city* route_zero;
		city* route_one;
		char city_name;

		city(city* a, city* b, char c) {
			route_zero = a;
			route_one = b;
			city_name = c;
		}

		city() {
			route_zero = NULL;
			route_one = NULL;
			city_name = '0';
		}
};

city a, b, w, x, y, z;
string route;

void init() {
	route.clear();
}
bool input() {
	cin >> route;
	if(route[0] == '#')
		return false;
	return true;
}
bool solve() {
	city* cur = &a;
	
	for(int i = 0; i < route.size(); i++) {
		if(route[i] == '1') {
			cur = cur->route_one;
		}
		else if(route[i] == '0') {
			cur = cur->route_zero;
		}

		if(cur == NULL)
			return false;
	}

	if(cur->city_name != 'B')
		return false;

	return true;
}

int main() {
	// make map
	a = city(&x, &y, 'A');
	b = city(&y, &x, 'B');
	w = city(&b, &y, 'W');
	x = city(NULL, &z, 'X');
	y = city(&x, NULL, 'Y');
	z = city(&w, &b, 'Z');

	while(init(), input()) {
		if(solve())
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
    int a, b, cnt=0, icopy;
    cin >> a >> b;

    for(int i=a;i<=b;i++){
        if(i/10000 == i%10){
            icopy = i;
            icopy = (icopy/10)%1000;
            // cout << icopy << endl;
            if(icopy/100 == icopy%10){
                cnt++;
                // for debug
                // cout << i << endl;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ll a;
  while( 1 ){
    cin >> a;
    if( !a ) break;
    ll ret = 0;
    ll scale = 1;
    while( a > 0 ){
      ll d = a & 7;
      a = a >> 3;
      if( d >= 4 ) d++;
      if( d >= 6 ) d++;
      ret += d * scale;
      scale *= 10;
    }
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
int a;
int main()
{
	scanf("%d",&a);
	int ans=0;
	int n=a;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	if(a%ans==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <list>
#include <string>
#define TEAM_MAX 51
#define PROB_MAX 11
#define PENA_TIME 1200

using namespace std;

struct status{
  int teamNum;
  int ac, wa[ PROB_MAX ];
  int pena;
};

int main(){
  while( 1 ){
    struct status ts[ TEAM_MAX ];
    int t, p, r;
    list< struct status > ranking;
    cin >> t >> p >> r;
    if( !( t || p || r ) ){ return 0; } 
    for( int i = 1; i <= t; i++ ){
      ts[ i ].ac = 0;
      for( int j = 1; j <= p; j++ ){
        ts[ i ].wa[ j ] = 0;
      }
      ts[ i ].pena = 0;
      ts[ i ].teamNum = i;
    }
    for( int i = 0; i < r; i++ ){
      int team, problem, time;
      string message;
      cin >> team >> problem >> time >> message;
      if( message[ 0 ] == 'C' ){ // AC
        ts[ team ].ac++;
        ts[ team ].pena += ( ts[ team ].wa[ problem ] * PENA_TIME + time );
      }else{ // WA
        ts[ team ].wa[ problem ]++;
      }
    }
    for( int i = 1; i <= t; i++ ){
      if( i == 1 ){
        ranking.push_back( ts[ 1 ] );
        continue;
      }
      int counter = 0;
      for(
        list< struct status >::iterator it = ranking.begin();
        it != ranking.end(); it++
      ){
        counter++;
        if( ts[ i ].ac > it -> ac  ){
          ranking.insert( it, ts[ i ] );
          break;
        }else if( ts[ i ].ac == it -> ac ){
          if( ts[ i ].pena < it -> pena ){
            ranking.insert( it, ts[ i ] );
            break;
          }else if( ts[ i ].pena == it -> pena ){
            if( ts[ i ].teamNum < it -> teamNum ){
              ranking.insert( it, ts[ i ] );
              break;
            }
          }
        }
        if( counter == ranking.size() ){
          ranking.push_back( ts[ i ] );
          break;
        }
      }
    }
    for(
        list< struct status >::iterator it = ranking.begin();
        it != ranking.end(); it++
      ){
        cout << it -> teamNum << ' ' <<
        it -> ac << ' ' <<
        it -> pena << endl;
      }
  }
}

Measured memory_bytes: 936
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,num=0;
    cin>>n;
    while(n>0) {
        num+=n%10;
        n/=10;
    }
    cout<<num<<endl;
    return 0;
}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

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

    string s;
    cin >> s;

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

bool isPrime(int n){
  if(n == 1) return false;
  if(n == 2) return true;
  if(n % 2 == 0) return false;
  for(int i = 3; i <= sqrt(n); i += 2){
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X; cin >> X;
  while(true){
    if(X != 2 && X % 2 == 0) X++;
    if(isPrime(X)){
      cout << X << endl;
      return 0;
    }
    X += 2;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "algorithm"
using namespace std;
int main(){
	int a, i;
	vector<int> v;
	for (i = 0; i < 3; ++i){
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	cout << v[0] << " " << v[1] << " " << v[2] << endl;
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

char arr[1020][1020];
int dist[1020][1020];
int x[] = {-2,-1,0,1,2}, y[] = {-2,-1,0,1,2};
priority_queue<pair<int,pii>, vector<pair<int,pii> >, greater<pair<int,pii> > > pq;
int main() {
	int H,W, CH, CW, DH, DW;
	scanf("%d %d",&H,&W);
	scanf("%d %d",&CH,&CW);
	scanf("%d %d",&DH,&DW);
	for(int i=0; i<H; i++) {
		scanf("%s",arr[i+1]+1);
	}
	for(int i=0; i<=1010; i++) {
		for(int j=0; j<=1010; j++) {
			dist[i][j] = -1;
		}
	}
	pq.push({0,{CH,CW}});
	while(!pq.empty()) {
		pii point = pq.top().second;
		int curr = pq.top().first;
		
		if(dist[point.first][point.second]>=0) {
			pq.pop();
			continue;
		}
		else {
			//printf("%d %d %d\n",point.first, point.second, curr);
			pq.pop();
			dist[point.first][point.second] = curr;
			for(int i=0; i<5; i++) {
				for(int j=0; j<5; j++) {
					if(i==2 && j==2) {
						continue;
					}
					int xp = point.first + x[i], yp = point.second + y[j];
					//printf("%d %d %c\n",xp,yp, arr[xp][yp]);
					if(xp<1 || xp > H || yp<1 || yp > W) {
						continue;
					}
					int a = abs(x[i])+abs(y[j]);
					if(a==1) {
						if(arr[xp][yp]=='.')
							pq.push({curr,{xp, yp}});
					}
					else {
						if(arr[xp][yp]=='.')
							pq.push({curr+1,{xp,yp}});
					}
				}
			}
		}
	}
	printf("%d",dist[DH][DW]);
}	



Measured memory_bytes: 9848
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Vec[] arr = new Vec[n];
		for (int i = 0; i < n; i++) {
			Vec v = new Vec();
			v.x = sc.nextInt();
			v.y = sc.nextInt();
			v.atan = Math.atan2(v.y, v.x);
			arr[i] = v;
		}
		sc.close();

		Arrays.sort(arr, (a, b) -> Double.compare(a.atan, b.atan));

		double ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i; j < i + n; j++) {
				int x = 0;
				int y = 0;
				for (int k = i; k <= j; k++) {
					x += arr[k % n].x;
					y += arr[k % n].y;
				}
				ans = Math.max(ans, Math.hypot(x, y));
			}
		}
		System.out.println(ans);
	}

	static class Vec {
		int x, y;
		double atan;
	}
}


Measured memory_bytes: 28884
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var map = new char[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++) map[i, j] = s[j];
        }
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (map[i, j] == '#' && !check(map, i, j)) { Console.WriteLine("No"); goto end; }
        Console.WriteLine("Yes");
        end:;
    }
    public static bool check(char[,] map, int x, int y)
    {
        var h = map.GetLength(0);
        var w = map.GetLength(1);
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        for (int i = 0; i < 4; i++)
        {
            var nx = x + dx[i];
            var ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == '#') return true;
        }
        return false;
    }
}


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

int main(){
    string S;
    cin >> S;
  if (S[0]!=S[1] && S[1]!=S[2] && S[2]!=S[0]) {cout << "Yes" << endl;
                                              }
  else {cout << "No" << endl;
       }
}
  


Measured memory_bytes: 256