akhauriyash/Code-Regression huggingface dataset:
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
ll arr[mxn][4];
ll dp[mxn][4],n;
ll solve(int i,int prev)
{
  if(i==n)
    return 0;
  if(dp[i][prev]!=-1)
    return dp[i][prev];
  ll ans=0,j;
  fr(j,1,4)
  {
    if(prev!=j)
      ans=max(ans,solve(i+1,j)+arr[i][j]);
  }
  return dp[i][prev]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      ll i,j;
      cin>>n;
      fr(i,0,n)
      {
        fr(j,1,4)
        cin>>arr[i][j];
      }
      ms(dp,-1);
      ll ans=solve(0,0);
      cout<<ans;
      
       
    }
  return 0;
  }



Measured memory_bytes: 16768
#include<iostream>
#include<stdio.h>   
#include<math.h>
#include<string> 
#include<set>  
using namespace std;    
int main()   
{   
long long n,m;
cin>>n>>m;
if(n<2 && m<2)
cout<<1;
else
if(n<2)
cout<<m-2;
else
if(m<2)
cout<<n-2;
else
{long long a=(n-2)*(m-2);
 cout<<a;}
system("pause");
return 0;  
}

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

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

int n;
cin >> n;
int max_len = 0;
int sum_len = 0;
vector<int> l(n);
for(int i=0;i<n;++i){
    cin >> l[i];
    max_len = max(max_len,l[i]);
    sum_len += l[i];
}
sum_len -= max_len;
if(sum_len>max_len){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}


//////////////////////////////////////////////////////
return 0;}

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

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

	int min_num;

	while (!(a == b && b == c)) {
		min_num = min({ a, b, c });
		if (a == b && a < c && b < c) {
			a++;
			b++;
			cnt++;
		}
		else if (b == c && b < a && c < a) {
			b++;
			c++;
			cnt++;
		}
		else if (c == a && a < b && c < b) {
			c++;
			a++;
			cnt++;
		}
		else if (min_num == a) {
			a += 2;
			cnt++;
		}
		else if (min_num == b) {
			b += 2;
			cnt++;
		}
		else if (min_num == c) {
			c += 2;
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n+1);
	for(int i=1;i<=n;i++) for(int j=i;j<=n;j+=i) a[j]++;
	int t=0;
	for(int i=1;i<=n;i+=2) if(a[i]==8) t++;
	cout<<t<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (100001)
ans = sum(A)
for a in A:
    cnt[a] += 1
Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    ans += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(ans)


Measured memory_bytes: 20980
n, k =map(int, input().split())
l=list(range(1,n+1,1))
for i in range(k):
    d=int(input())
    t=list(map(int, input().split()))
    for q in range(d):
        if (t[q] in l)==1:
            l.remove(t[q])
print(len(l))


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
string S;
 cin >> N;
 cin >> S;
int i;
int count = 0;
for(i=0;i<N-2;i++){
    if(S[i]=='A'){
        if(S[i+1]=='B'){
            if(S[i+2]=='C'){
                count++;
            }
        }
    }
}
cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        int one = -1;

        for (one = 0; one < N; one++)
        {
            if (A[one] == 1)
            {
                break;
            }
        }

        if (one == N)
        {
            Console.WriteLine("-1");
            return;
        }

        int t = 2;
        for (int i = one + 1; i < N; i++)
        {
            if (A[i] == t)
            {
                t++;
            }
        }

        Console.WriteLine(N- (t - 1));
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 33116
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
vector<vector<int> >all;
void rec(vector<int>temp)
{
  if(temp.size()==n)
    all.push_back(temp);
  else
  {
    temp.push_back(0);
    rec(temp);
    temp.pop_back();
    temp.push_back(1);
    rec(temp);
    temp.pop_back();
  }  
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif

  int m,x;
  cin>>n>>m>>x;
  vector<int>temp;
  rec(temp);
  int a[n+1][m+1];
  int cost[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>cost[i-1];
    for(int j=1;j<=m;j++)
      cin>>a[i-1][j-1];
  }
  int mn=1e17;
  for(auto i:all)
  {
    int ans=0;
    int temp[m+1]={0};
    for(int j=0;j<n;j++)
    {
      if(i[j])
      {
        ans+=cost[j];
        for(int k=0;k<m;k++)
          temp[k]+=a[j][k];
      }
    }
    bool flag=true;
    for(int k=0;k<m;k++)
    {
      if(temp[k]<x)
      {
        flag=false;
        break;
      }
    }
    if(flag)
      mn=min(mn,ans);
  }
  if(mn==1e17)
    cout<<-1;
  else
    cout<<mn;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;

int main() {
    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define rep(i,n) for(long long i = n-1;i>=0;i--)
#define repp(i,n,m) for(long long i = n-1; i >= m; i--)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string S,T;
int dp[3001][3001] = {};
vector<char> V;

void solve(int i,int j){
    if(i == 0 || j == 0) return;
    if(dp[i][j] == dp[i-1][j]){
        solve(i-1,j);
        return;
    }
    else if(dp[i][j] == dp[i][j-1]){
        solve(i,j-1);
        return;
    }
    else{
        V.pb(S[i-1]);
        solve(i-1,j-1);
        return;
    }
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> S >> T;
    REPP(i,1,S.size()+1){
        REPP(j,1,T.size()+1){
            if(S[i-1] == T[j-1]){
                dp[i][j] = max({dp[i-1][j-1]+1,dp[i][j-1],dp[i][j-1]});
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    solve(S.size(),T.size());
    rep(i,V.size()){
        cout << V[i];
    }
    cout << endl;
}

Measured memory_bytes: 35456
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 0

diff =  10 ** 5
for index,cell in enumerate(H):
    if abs(T - (0.006*cell) - A) <= abs(diff-A):
        ans = index + 1
        diff = T - (0.006*cell)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <unordered_map>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int x;
	bool p=1;
	int maksi=0;
	for(int i=0; i<n; i++){
		cin >> x;
		if(x<maksi-1){
			p=0;
		}
		maksi=max(x, maksi);
	}
	if(p){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,ans=0,cnt=0;
string s,t;
int main(){
  cin >> a >> b;
  if(a*b==15){
    cout << '*' << endl;
  }else if(a+b==15){
    cout << '+' << endl;
  }else{
    cout << 'x' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(int argc,char* argv[]){
  double x,y;
  double rad;
  int run;
  int shita;
  x = y = 0;
  rad = M_PI / 2;
   
  for(;;){
    scanf("%d,%d",&run,&shita);
    if(run == 0 && shita == 0){
break;
}
     
    x += cos(rad) * run;
    y += sin(rad) * run;
     
    rad -= shita / 180.0 * M_PI;
  }
   
  modf(x, &x);
  modf(y, &y);
  printf("%.0lf\n%.0lf\n",x,y);
   
  return 0;
   
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	int n = s.size();
	int tmp = 0;
	vector<int> sum(n + 1);
	rep(i, n) {
		tmp ^= (1 << (s[i] - 'a'));
		sum[i + 1] = tmp;
	}
	vector<int> ans(n + 1, INF); ans[0] = 0;
	map<int, int> mp;
	rep(i, n) {
		rep(j, 26) {
			if ((sum[i + 1] ^ (1 << j)) == 0 || mp[sum[i + 1] ^ (1 << j)] != 0) {
				chmin(ans[i + 1], mp[sum[i + 1] ^ (1 << j)] + 1);
			}
		}
		if (sum[i + 1] == 0 || mp[sum[i + 1]] != 0) chmin(ans[i + 1], mp[sum[i + 1]] + 1);
		if (sum[i + 1] != 0) {
			if (mp[sum[i + 1]]) chmin(mp[sum[i + 1]], ans[i + 1]);
			else mp[sum[i + 1]] = ans[i + 1];
		}
	}
	cout << ans[n] << endl;
}

Measured memory_bytes: 275348
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        long count = 0;
        for (int i = 0; i < n; i++) {
            String str = sc.next();
            String countStr = mkString(str);
            map.put(countStr, map.getOrDefault(countStr, 0) + 1);
        }
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int num = entry.getValue();
            count += nC2(num);
        }
        System.out.println(count);
    }

    public static String mkString(String str) {
        int[] count = new int[26];
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            count[c - 'a']++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            sb.append(count[i]);
            char c = (char)(i + 'a');
            sb.append(String.valueOf(c));
        }
        return sb.toString();
    }
    public static long nC2(int num) {
        if (num == 0 || num == 1) return 0;
        return (long)num * (num - 1) / 2;
    }
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N%1000==0) cout << 0 << endl;
    else cout << 1000 - N%1000 << endl;

    return 0;
}


Measured memory_bytes: 3640
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

t=int(input())
abcd=[list(map(int,input().split())) for i in range(t)]

for i in range(t):
    a,b,c,d=abcd[i]
    if a<b:
        print("No")
    elif d<b:
        print("No")
    elif c>=b:
        print("Yes")
    elif b-math.gcd(b,d)+(a%math.gcd(b,d))>c:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 74040
program main
 implicit none
 integer A,B
 integer taxA, taxB
 integer i

 read *, A, B

 do i=1,10000
  taxA=i*0.08
  taxB=i*0.1

 if (taxA==A .and. taxB==B ) then
  print '(i0)',i
  goto 100
 end if

 end do

 print '(i0)', -1

100 continue

endprogram main


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	vector<int>a(n);
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j*a[i] + 1 <=d; j++) {
			if (j*a[i] + 1 <= d) {
				count++;
			}
		}

	}
	cout << count+x << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
	int a, b;
	
	cin >> a >> b;

	
	if (a > b) cout << "a > b" << endl;
	else if(a < b) cout << "a < b" << endl;
	else cout << "a == b" << endl;


    return 0;
}



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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    
    def ht(x):
        t=x%10
        string=str(x)
        h=int(string[0])
        return (h,t)
        
    cnt=[[0]*10 for _ in range(10)]
    
    for i in range(1,N+1):
        h,t=ht(i)
        cnt[h][t]+=1
        
    ans=0
    for i in range(10):
        for j in range(10):
            a=cnt[i][j]
            b=cnt[j][i]
            ans+=a*b
            
    print(ans)
        

main()


Measured memory_bytes: 73352
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

def check(t):
    j = n - 1 if t > 0 else 0
    res = 0
    f = 1

    cond = lambda x, t, f:x <= t if f * t > 0 or (t == 0 and f == -1) else x > t
    shift = lambda x, t:x-1 if t > 0 else x+1
    count = lambda x, n, f:n-x if f == 1 else x

    for ai in a:
        if f == 1 and ai > 0:
            f = -1
            j = n - 1 if t > 0 else 0
        if ai:
            while j >= 0 and j < n and cond(ai * a[j], t, f):
                j = shift(j, t)
            if t > 0:
                res += count(j+1, n, f)
            else:
                res += count(j, n, f)
        else:
            if t >= 0:
                res += n
        if ai * ai <= t:
            res -= 1
    return res // 2
            

m = max(max(a)**2, min(a)**2)
l = -m
r = m

while r - l > 1:
    mid = (l + r) // 2
    if check(mid) < k:
        l = mid
    else:
        r = mid

if check(l) == k:
    print(l)
else:
    print(r)


Measured memory_bytes: 91524
//30
#include<iostream>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int k[150],xp[150][10],d[150][10];
    for(int i=0;i<n;i++){
      cin>>k[i];
      for(int j=0;j<k[i];j++){
	cin>>xp[i][j]>>d[i][j];
      }
    }
    int c[150][150][10]={{}};
    fill(c[0][0],c[150][0],1<<29);
    fill(c[0][m],c[0][m+1],0);
    if(m>0){
      fill(c[1][m-1],c[1][m],0);
    }
    int ans=1<<30;
    for(int y=0;y<n;y++){
      for(int j=0;j<=m;j++){
	for(int x=0;x<k[y];x++){
	  for(int dj=0;dj<=!!j;dj++){
	    if(y+1+dj<n){
	      for(int nx=0;nx<k[y+1+dj];nx++){
		c[y+1+dj][j-dj][nx]=min(c[y+1+dj][j-dj][nx],c[y][j][x]+(d[y][x]+d[y+dj+1][nx])*abs(xp[y][x]-xp[y+1+dj][nx]));
	      }
	    }else{
	      ans=min(ans,c[y][j][x]);
	    }
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2060
import java.util.Scanner;

/*
 * ??\?????????
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
 */
public class Main{

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int totalTime = 0;
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        
        int[] A = new int[n];
        Queue queue = new Queue(n);
        
        for(int i=1;i<=n;i++){
            Process process = new Process(scanner.next(),scanner.nextInt());
            queue.enqueue(process);
        }
        while(true){
        	Process p= queue.dequeue();
        	if(p==null){
        		break;
        	}
        	int time =p.getProcessTime();
        	int remainingTime = time-q;
        	if(remainingTime <=0){
        		totalTime += time;
        		System.out.println(p.getProcessName()+" "+totalTime);
        	}else{
        		totalTime += q;
        		p.setProcessTime(time-q);
        		queue.enqueue(p);
        	}
        }
    }
}
class Queue{
	int startIndex;
	int endIndex;
	int size;
    String[] queueName;
    int[] queueTime;
    
	Queue(int n){
    	startIndex =0;
    	endIndex = 0;
    	size = n;
        queueName = new String[n];
        queueTime = new int[n];
	}
	void enqueue(Process process){
		//System.out.println("??¨????????\???"+process.getProcessName()+","+process.getProcessTime());

		queueName[endIndex]=process.getProcessName();
		queueTime[endIndex]=process.getProcessTime();
		endIndex++;
		endIndex %= size;
	}
	Process dequeue(){
		//System.out.println("????????\???"+queueName[startIndex]+","+queueTime[startIndex]);
		if(queueName[startIndex].equals("")){
			return null;
		}
		Process process = new Process(queueName[startIndex],queueTime[startIndex]);
		queueName[startIndex]="";
		startIndex++;
		startIndex %= size;
		return process;
	}
}

class Process{
	private String processName;
	private int processTime;
	Process(String processName,int processTime){
		this.processName = processName;
		this.processTime = processTime;
	}
	String getProcessName(){
		return processName;
	}
	void setProcessName(String processName){
		this.processName = processName;
	}
	public int getProcessTime() {
		return processTime;
	}
	public void setProcessTime(int processTime) {
		this.processTime = processTime;
	}

	
}

Measured memory_bytes: 75584
import math

while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    m = sum(s) / n
    ss = 0
    for i in s:
        ss += pow((i - m), 2)
    bun = ss / n
    print(math.sqrt(bun))


Measured memory_bytes: 5700
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int Max = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i]=='I')x++;
    else x--;
    Max=max(Max, x);
  }
  cout << Max << endl;
  return 0;
}


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

int N;
int arr[100005];
int dp[100005][2];

int calc_dist(int idx){
	// printf("%d %d\n",idx,std::min(dp[idx][0],dp[idx][1]) );
	if( std::min(dp[idx][0],dp[idx][1]) == -1){

		dp[idx][0] = calc_dist(idx-1) + std::abs(arr[idx]-arr[idx-1]);
		dp[idx][1] = calc_dist(idx-2) + std::abs(arr[idx]-arr[idx-2]);

		// printf("idx:%d\n",idx);
		// printf("%d %d\n",calc_dist(idx-1),std::abs(arr[idx]-arr[idx-1]));
		// printf("%d %d\n",calc_dist(idx-2),std::abs(arr[idx]-arr[idx-2]));
		// printf("dp:%d %d\n",dp[idx][0],dp[idx][1]);
	}

	return std::min(dp[idx][0],dp[idx][1]);

}


int main(){

	scanf("%d",&N);
	for (int i = 0; i < N; ++i){
		scanf("%d",&arr[i]);
		dp[i][0] = -1;
		dp[i][1] = -1;
	}
	dp[0][0] = 0;
	dp[0][1] = 0;
	
	dp[1][0] = std::abs(arr[0]-arr[1]);
	dp[1][1] = std::abs(arr[0]-arr[1]);
		
	printf("%d\n",	calc_dist(N-1));	

}

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

int main(){
    int n,k; cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    ll c = 0;
    for(int i = n-1-k; i >= 0; i--){
        c += a[i];
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			for(;;) {
				String integer = br.readLine();
				if (integer.equals("0")) {
					break;
				}
				System.out.println("Case " + caseNumber + ": " + integer);
				caseNumber++;
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static int caseNumber = 1;

}


Measured memory_bytes: 31504
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<pair<ll, ll>> X(N);
    REP(i, 0, N) cin >> X[i].first >> X[i].second;

    sort(ALL(X), greater<pair<int, int>>());

    map<pair<ll, ll>, int> m;
    REP(i, 0, N) {
        REP(j, i + 1, N) {
            ll x = X[i].first - X[j].first;
            ll y = X[i].second - X[j].second;
            m[{x, y}]++;
        }
    }

    pair<ll, ll> max_pair; int max_count = 0;
    for (auto elm : m) {
        if (max_count < elm.second) {
            max_count = elm.second;
            max_pair = elm.first;
        }
    }

    // cout << "max_pair : " << max_pair.first << " " << max_pair.second << endl;

    set<pair<ll, ll>> s;
    REP(i, 0, N) {
        REP(j, i + 1, N) {
            ll x = X[i].first - X[j].first;
            ll y = X[i].second - X[j].second;
            if (max_pair == make_pair(x, y)) {
                s.insert(X[i]);
                s.insert(X[j]);
            }
        }
    }

    int ans = N - s.size();
    for (auto elm : s) {
        // cout << "# " << elm.first << " " << elm.second << endl;
        ans++;
        ll x = elm.first + max_pair.first;
        ll y = elm.second + max_pair.second;
        while (s.count({x, y})) {
            s.erase({x, y});
            x += max_pair.first;
            y += max_pair.second;
        }
        s.erase(elm);
    }

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

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

int main(){
    ios_base::sync_with_stdio(false);
    string n;
    cin>>n;
    ll sum=0;
    for(ll i=0;i<n.size();i++){
        if(n[i]== '0' || n[i] =='9'){
            continue;
        }
        int num = n[i]-48; 
        if(sum<CONSTANT){
            sum+=num;
            continue;  
        }
        else{
            sum=sum%9;
            sum+=num;
        }
        
    }
    if(sum%9==0){
        cout<<"Yes";
        return 0; 
    }
    cout<<"No";
    return 0;
}
                                                                               
                       

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

int main(){
	int A,B,C;
	cin >> A >> B;
	C=A+B;
	if((A%3==0)||(B%3==0)||(C%3==0)){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}

	return 0;
}

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

int main(){
  long long N;
  cin >> N;
  vector<string>S(N);

  for(long long i=0;i<N;i++){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  int count = N;
  for(int i=0;i<N-1;i++){
    if(S.at(i)==S.at(i+1)){
      count--;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 9564
# B
N = gets.to_i
d = []
N.times do
  input = gets.to_i
  d << input unless d.include? input
end

d.sort!
d << -1 # guard
count = 1
d.each_with_index { |e, i| e <= d[i + 1] ? count += 1 : break }
puts count


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a==b&&b==c){
    cout << 1 << endl;
  }
    else if(a==b||b==c||c==a){
      cout << 2 << endl;
    }
    else{cout << 3 << endl;}
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int idx = 0;
  u64 ans = 1;
  while (idx < n) {
    if (s[idx]==t[idx]) {
      if (idx==0) ans*=3;
      else if (s[idx-1]==t[idx-1]) ans*=2;
      idx+=1;
    } else {
      if (idx==0) ans*=6;
      else if (s[idx-1]==t[idx-1]) ans*=2;
      else ans*=3;
      idx+=2;
    }
    ans = ans % 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input=lambda :sys.stdin.readline().rstrip()
from collections import defaultdict

n = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
ans = 0
for j in range(n):
    Dif = j - A[j]
    ans += d[Dif]
    Sum = A[j] + j
    d[Sum] += 1
print(ans)

Measured memory_bytes: 61540
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]

d = defaultdict(lambda: 50+1)

for i in range(N):
    for c in range(ord("a"), ord("z")+1):
        d[chr(c)] = min(d[chr(c)], S[i].count(chr(c)))

ans = ""
for key, value in d.items():
    ans += key * value

print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    vector<int> e(n);
    vector<P> p(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        s[i]=x-y;
        e[i]=x+y;
    }
    rep(i,n){
        p[i].first=e[i];
        p[i].second=s[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    int pr = -pow(10,9)-1;
    rep(i,n){
        if(pr<=p[i].second){
            ++ans;
            pr=p[i].first;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,a,b,c;
    cin >>a>>b>>c;


    if((a+b-c)*(a+c-b)*(c+b-a)==0)cout <<"Yes"<<endl;
    else cout <<"No"<<endl;

    dbg cout <<ans<<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() {
    string s, a[2];
    cin >> s;
    a[0] = s.substr(0,2);
    a[1] = s.substr(2,2);
    int n[2];
    rep(i, 2){
        n[i] = (a[i][0] - '0') * 10 + (a[i][1] - '0');
    }
    if((n[0] == 0 && n[1] > 12) || (n[1] == 0 && n[0] > 12) || (n[0] == 0 && n[1] == 0) || (n[0] > 12 && n[1] > 12)){
        cout << "NA" << endl;
    }else if((n[0] > 12 || n[0] == 0) && n[1] <= 12){
        cout << "YYMM" << endl;
    }else if(n[0] <= 12 && (n[1] > 12 || n[1] == 0)){
        cout << "MMYY" << endl;
    }else if(n[0] <= 12 && n[1] <= 12){
        cout << "AMBIGUOUS" << endl;
    }
    return 0;
}


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll h, w, k, cnt = 1;
    cin >> h >> w >> k;
    vector<string> s(h);
    vector<vector<ll>> ans(h,vector<ll>(w));
    for(ll i = 0;i < h;i++){
        cin >> s[i];
    }

    for(ll i = 0;i < h;i++){
        bool f = true;
        for(ll j = 0;j < w;j++){
            if('#' == s[i][j]){
                f = false;
            }
        }
        if(!f){
            bool f2 = false;
            for(ll j = 0;j < w;j++){
                ans[i][j] = cnt;
                if(!f2 && s[i][j] == '#'){
                    f2 = true;
                }
                else if(s[i][j] == '#'){
                    cnt++;
                    ans[i][j] = cnt;
                }
            }
            cnt++;
        }
        else if(i != 0){
            for(ll j = 0;j < w;j++){
                ans[i][j] = ans[i - 1][j];
            }
        }
    }

    for(ll i = h - 2;i >= 0;i--){
        if(ans[i][0] == 0){
            for(ll j = 0;j < w;j++){
                ans[i][j] = ans[i + 1][j];
            }
        }
    }

    for(ll i = 0;i < h;i++){
        for(ll j = 0;j < w;j++){
            cout <<ans[i][j]<<" ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

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

using namespace std;

typedef long long unsigned int ll;

void println(string const str)
{
    printf("%s\n", str.c_str());
}

void print(string const str)
{
    printf("%s", str.c_str());
}

int main()
{
    long int A, B;
    int K;
    cin >> A >> B >> K;
    while (true)
    {

        A = A / 2;
        B += A;
        K--;
        if (K == 0)
        {
            printf("%ld %ld\n", A, B);
            return 0;
        }

        B = B / 2;
        A += B;
        K--;
        if (K == 0)
        {
            printf("%ld %ld\n", A, B);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    int N;
    cin >> N;

    string s, t;
    cin >> s >> t;

    RNREP(l, N) {
        bool match = true;

        REP(i, l) {
            if (s[N - l + i] == t[i]) {
                continue;
            } else {
                match = false;
                break;
                ;
            }
        }

        if (match) {
            cout << N * 2 - l << endl;
            return 0;
        }
    }
    cout << N * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
void File(){
	freopen("ARC94E.in","r",stdin);
	freopen("ARC94E.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define ll long long
int n;
ll ans,c=0x3f3f3f3f;
bool flag=1;
int main(){
	//File();
	scanf("%d",&n);
	REP(i,1,n){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		ans+=a;
		if(a>b && b<c)c=b;
		if(a!=b)flag=0;
	}
	if(flag){
		cout<<0<<endl;
		return 0;
	}
	cout<<ans-c<<endl;
	return 0;
}


Measured memory_bytes: 256
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
n = int(input())
li_num=[int(input()) for i in range(n)]
 
li_card = [li_a, li_b, li_c]
 
ans = False
 
#print(li_card)
#print(li_b)
#print(li_c)
#print(n)
#print(li_num)
 
for m in li_num:
    for i in range(3):
        for j in range(3):
          if li_card[i][j] == m:
              li_card[i][j] = 0
 
for i in range(3):
    if li_card[i][0] == li_card[i][1] == li_card[i][2]:
        ans = True
        break
    elif li_card[0][i] == li_card[1][i] == li_card[2][i]:
        ans = True
        break
 
if not ans:
  if li_card[0][0] == li_card[1][1] == li_card[2][2]:
      ans = True
  elif li_card[0][2] == li_card[1][1] == li_card[2][0]:
      ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll dp[105][100005];
ll weight[105], value[105];
int n,w;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> w;
    rep(i,n) cin >> weight[i] >> value[i];

    rep(i,n) {
        rep(j,w+1) {
            if(weight[i]<=j) chmax(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;

    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        
        int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = nk[0];
        int k = nk[1];
        int[] x = new int[n];
        for (int i = 0; i < k; i++)
        {
            int d = int.Parse(Console.ReadLine());
            int[] candy = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            for (int j = 0; j < d; j++)
            {
                x[candy[j] - 1] += 1;
            }
        }
        Console.WriteLine(x.Count(w => w == 0));
    }
}

Measured memory_bytes: 28436
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vv(10, vector<int>(10));

  ll ans=0;
  REP(i,10)REP(j,10){
    vv[i][j]=0;
  }

  // REP(i,10)REP(j,10){
  //   cout << i << " : " << j << " " << vv[i][j] << endl;
  // }

  FOR(i,1,N+1){
    int t = i % 10;
    int s = i;
    int u = 0;
    while(s >= 10){
       s = s / 10;
       u += 1;
    }
    vv[s][t]++;
  }
  // REP(i,10)REP(j,10){
  //    cout << i << " : " << j << " " << vv[i][j] << endl;
  // }

  REP(i,10)REP(j,10){
    ans += vv[i][j]*vv[j][i];
  }
  cout << ans << endl;

}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var K = input[2];

            var A1 = Math.Max(A - K, 0);
            var B1 = K <= A ? B : Math.Max(0, B - (K - A));

            Console.WriteLine(A1 + " " + B1);
        }
    }
}

Measured memory_bytes: 13396
n=int(input())
a=list(map(int,input().split()))

s=set()
f=1
for x in a:
	if f==0:
		break
	if x>1:
		r=int(x**0.5+1e-8)+1
		for i in range(2,r):
			if x%i==0:
				while x%i==0:
					x//=i
				if i in s:
					f=0
					break
				else:
					s.add(i)
		if x>1:
			if x in s:
				f=0
				break
			else:
				s.add(x)

if f:
	print("pairwise coprime")
	exit()
p=a[0]
from math import gcd
for x in a:
	p=gcd(p,x)
if p==1:
	print("setwise coprime")
else:
	print("not coprime")



Measured memory_bytes: 197900
def main():
    N, M = map(int, input().split())
    yakusuu_list = []

    for i in range(1, int(M ** 0.5) + 1):
        if M % i == 0:
            yakusuu_list.append(i)
            yakusuu_list.append(M // i)
    yakusuu_list.sort(reverse=True)

    for num in yakusuu_list:
        if num * N <= M:
            print(num)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int i;
	int k[4]={0};
	int w[4]={0};
	int n,s;
	int temp;

	for(i=0;i<10;i++){
		scanf("%d",&k[0]);
		s=0;
		while(k[s] >k[s+1]){
			if(k[s] >k[s+1]){
				temp=k[s];
				k[s]=k[s+1];
				k[s+1]=temp;
			}
			s++;
			if(s+1 == 4)
				break;
		}
	}
	for(i=0;i<10;i++){
		scanf("%d",&w[0]);
		s=0;
		while(w[s] >w[s+1]){
			if(w[s] >w[s+1]){
				temp=w[s];
				w[s]=w[s+1];
				w[s+1]=temp;
			}
			s++;
			if(s+1 == 4)
				break;
		}
	}
	printf("%d %d\n",k[1]+k[2]+k[3],w[1]+w[2]+w[3]);
	return 0;
}

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


int main(){
    int t;
    scanf("%d",&t);
    /*while(t--){}*/
    if(t>=400&&t<=599){
    	t=8;
    }
    else if(t>=600&&t<=799){
    	t=7;
    }
    else if(t>=800&&t<=999){
    	t=6;
    }
    else if(t>=1000&&t<=1199){
    	t=5;
    }else if(t>=1200&&t<=1399){
    	t=4;
    }
    else if(t>=1400&&t<=1599){
    	t=3;
    }
    else if(t>=1600&&t<=1799){
    	t=2;
    }
    else if(t>=1800&&t<=1999){
    	t=1;
    }

    
    printf("%d",t);

    return 0;
}


Measured memory_bytes: 3820
def main():
    mod = 998244353
    N, K = map(int, input().split())
    LR = []
    for _ in range(K):
        l, r = map(int, input().split())
        LR.append((l, r))
    LR.sort()
    dp = [0] * N
    dp[0] = 1
    z = 0
    for i in range(1, N):
        for l, r in LR:
            if i - l >= 0:
                z += dp[i - l]
            if i - r - 1 >= 0:
                z -= dp[i - r - 1]
        z %= mod
        dp[i] = z

    return dp[-1]

print(main())


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

Measured memory_bytes: 61700
#include<stdio.h>
#include<stdlib.h>

struct node{
	int key,priority;
	struct node *left,*right;
};
typedef struct node* Node;

Node NIL,root;

Node rightRotate(Node);
Node leftRotate(Node);
Node insert(Node,int,int);
Node delete(Node,int);
Node _delete(Node,int);
void inOrder(Node);
void preOrder(Node);
Node find(int);

int main(){
	root=NIL;
	int i,n,k,p;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d%d",&k,&p);
			insert(root,k,p);

		}else if(com[0]=='p'){
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else if(com[0]=='f'){
			scanf("%d",&k);
			if(find(k)!=NIL)printf("yes\n");
			else printf("no\n");
		}else{
			scanf("%d",&k);
			delete(root,k);
		}
		//printf("\n");
	}

	return 0;
}

Node rightRotate(Node t){
	//printf(" rR\n");
	Node s = t->left;
	if(t==root)root=s;
	t->left = s->right;
	s->right = t;

	return s; // root of the subtree
}
Node leftRotate(Node t){
	//printf(" lR\n");
	Node s = t->right;
	if(t==root)root=s;
	t->right = s->left;
	s->left = t;
	return s; // root of the subtree
}
Node insert(Node t, int k, int p){
	//printf("i ");
	Node x;
	if (t == NIL){
		x=(Node)malloc(sizeof(struct node));
		x->key=k;	x->priority=p;
		x->left=x->right=NIL;

		if(root==NIL)root=x;

		return x;
	}
	if (k == t->key)
		return t;                            // 重複したkeyは無視

	if (k < t->key){                               // 左の子へ移動
		t->left = insert(t->left, k, p);   // 左の子へのポインタを更新
		if (t->priority < t->left->priority)          // 左の子の方が優先度が高い場合右回転
			t = rightRotate(t);
	}else{                                         // 右の子へ移動
		t->right = insert(t->right, k, p); // 右の子へのポインタを更新
		if (t->priority < t->right->priority)         // 右の子の方が優先度が高い場合左回転
			t = leftRotate(t);
	}

	return t;
}

Node delete(Node t, int key){
	if (t == NIL)return NIL;

	if (key < t->key)                                // 削除対象を検索
		t->left = delete(t->left, key);
	else if (key > t->key)
		t->right = delete(t->right, key);
	else
		return _delete(t, key);
	return t;
}

Node _delete(Node t, int key){ // 削除対象の節点の場合
	if (t->left == NIL && t->right == NIL)           // 葉の場合
		return NIL;
	else if (t->left == NIL)                        // 右の子のみを持つ場合左回転
		t = leftRotate(t);
	else if (t->right == NIL)                       // 左の子のみを持つ場合右回転
		t = rightRotate(t);
	else{                                         // 左の子と右の子を両方持つ場合
		if (t->left->priority > t->right->priority)    // 優先度が高い方を持ち上げる
			t = rightRotate(t);
		else
			t = leftRotate(t);
	}
	return delete(t, key);

}void inOrder(Node x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}
Node find(int k){
	Node p=root;

	while(p!=NIL){
		if(p->key==k){
			return p;
		}

		if(k < p->key)p=p->left;
		else p=p->right;
	}

	return NIL;
}




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




int main(){

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

  sort(d.begin(),d.end());
  int s=d[n/2]-d[n/2-1];
  cout<<s<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
 
int main() {
  int L;
  cin >> L;
 double x = L/3.0000000000000000000000000;
  
 long double volume = x*x*x;
  cout << std::setprecision(10) << volume;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s,t;
  cin>>s>>t;
  int n=s.length();
  for(int i=0;i<n;i++){
  if(s[i]!=t[i]){
  cout<<"No";
    return 0;
  }
  }
  cout<<"Yes";
}

Measured memory_bytes: 3564