akhauriyash/Code-Regression huggingface dataset:
/* Bismillahirrahmanirrahim
   Semoga Dapet AC ya Allah
   Amin.................. :)
   Ps. SelfRemainder #1: Variabel gak otomatis nilainya 0
					 #2: Output harus sama persis formatnya sama di contoh
					 #3: Jangan lama2 mikirin 1 soal. Kalo dah gabisa, stop
					 #4: Kalau for bersarang, variabelnya jangan sama
*/
#include<bits/stdc++.h>
#define forA for(int i=0; i<a; i++)
#define Fora for(int i=1; i<=a; i++)
#define ll long long
#define F first
#define S second
using namespace std;

int main(){
	int a, sum=0, cek1, cek2;
	cin >> a;
	int arr[a+1]; int bar[a+1]; int car[a+1];
	forA{
		cin >> arr[i];
	}
	forA{
		cin >> bar[i];
	}
	forA{
		cin >> car[i];
	}
	for(int i=0; i<a; i++){
		cek1=arr[i];
		sum+=bar[cek1-1];
		if((i>0)&&(cek1-cek2==1))sum+=car[cek2-1];
		cek2=arr[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a < b){
    if(a+t*v >= b+t*w)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }else{
    if(a-t*v <= b-t*w)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3640
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


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


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')


def main():
	n=II()
	s=input()
	
	A=[]
	if s[0]==")":
		A.append(0)
	s+="0"
	cnt=1
	for i in range(n):
		if s[i]==s[i+1]:
			cnt+=1
		else:
			A.append(cnt)
			cnt=1
	#print(A)
	
	l=0
	r=0
	now=0
	for i in range(len(A)):
		#print(r)
		if i%2:
			r+=2*min(A[i],now)
			l+=max(A[i]-now,0)
			now=max(now-A[i],0)
		else:
			now+=A[i]
	#print(l,n-l-r)
	
	ans="("*l+s[:-1]+")"*(n-l-r)
	print(ans)
	
	
	
	
	
	

if __name__=="__main__":
	main()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define int long long
using namespace std;

int N, A[100005], B[100005];

signed main(){
  
  cin>>N;

  for(int i=0;i<N;i++) scanf("%lld %lld", &A[i], &B[i]);
  
  int ans=0;
  
  for(int i=N-1;i>=0;i--){
    A[i]+=ans;
    if(A[i]%B[i]!=0) ans+=(B[i]-A[i]%B[i]);
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
l,r=map(int,input().split())
an=(l*(l+1))%2019

for i in range(l,r):
    for j in range(i+1,r+1):
        if (i*j)%2019 < an:
            an=(i*j)%2019
        if an==0:
            print("0")
            exit()

print(an)

Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

typedef struct calc {
    int* top;
    int* data;
} calc_t;

calc_t* init(int size) {
    calc_t* calc = (calc_t*)malloc(sizeof(calc_t));
    calc->top = calc->data = (int*)malloc(sizeof(int) * size);
    return calc;
}

int pop(calc_t* stack) {
    if (stack->top == stack->data) {
        return -1;
    }
    int v = *(stack->data);
    stack->data--;
    return v;
}

int* push(calc_t* stack, int val) {
    int v = val;
    stack->data++;
    *(stack->data) = v;
    return stack->data;
}

int main() {
    calc_t* stack = init(200);
    string line;
    getline(cin, line);
    string buf;
    stringstream ss(line);
    while (ss >> buf) {
        if (buf == "+") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v1 + v2);
        } else if (buf == "-") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v2 - v1);
        } else if (buf == "*") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v1 * v2);
        } else {
            push(stack, stoi(buf));
        }
    }

    printf("%d\n", pop(stack));
    return 0;
}

Measured memory_bytes: 3324
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

typedef vector <vector<int>> Graph;

// 強連結成分分解ライブラリ
class StronglyConnectedComponent {
public:
  Graph G;
  Graph rG;
  Graph cG;
  vector<int> vs;
  vector<bool> used;
  vector<int> componentId;
  int componentCount;
  int V;

  StronglyConnectedComponent(Graph G) {
    V = G.size();
    used = vector<bool>(V);
    componentId = vector<int>(V);
    this->G = G;
    componentCount = 0;
    rG = Graph(V);

    initReverseGraph();
    scc();
  }

private:
  void initReverseGraph() {
    for (int v = 0; v < V; ++v) {
      for (int i = 0; i < G[v].size(); ++i) {
        int u = G[v][i];

        rG[u].push_back(v);
      }
    }
  }

  void scc() {
    fill(used.begin(), used.end(), false);
    vs.clear();

    for (int v = 0; v < V; ++v) {
      if (used[v]) continue;

      dfs(v);
    }

    fill(used.begin(), used.end(), false);

    for (int i = vs.size() - 1; i >= 0; --i) {
      int v = vs[i];
      if (used[v]) continue;

      cG.push_back(vector<int>());
      rdfs(v, componentCount++);
    }
  }

  void dfs(int v) {
    used[v] = true;

    for (int i = 0; i < G[v].size(); ++i) {
      int u = G[v][i];

      if (used[u]) continue;

      dfs(u);
    }

    vs.push_back(v);
  }

  void rdfs(int v, int k) {
    used[v] = true;
    componentId[v] = k;
    cG[k].push_back(v);

    for (int i = 0; i < rG[v].size(); ++i) {
      int u = rG[v][i];

      if (used[u]) continue;

      rdfs(u, k);
    }
  }
};

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

  Graph G(N);
  int from, to;
  for (int i = 0; i < M; ++i) {
    cin >> from >> to;
    G[from].push_back(to);
  }

  StronglyConnectedComponent scc(G);

  int cnt = scc.componentCount;

  cout << cnt << endl;
  for (int i = 0; i < cnt; ++i) {
    vector<int> T = scc.cG[i];
    cout << T.size() << " ";

    for (int j = 0; j < T.size(); ++j) {
      cout << T[j];

      if (j != T.size() - 1) {
        cout << " ";
      } else {
        cout << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 121092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			double a = scanner.nextDouble();
			double b = scanner.nextDouble();
			int c = slove(a);
			int d = slove2(b);
			int max = Math.max(c, d);
			System.out.println(slove3(max));
		}
	}

	private static String slove3(int max) {
		switch (max) {
		case 1:
			return"AAA";
		case 2:
			return "AA";
		case 3:
			return "A";
		case 4:
			return "B";
		case 5:
			return "C";
		case 6:
			return "D";
		case 7:
			return "E";
		default:
			return "NA";
		}
	}

	private static int slove2(double b) {
		if (b < 71)
			return 1;
		else if (b < 77)
			return 2;
		else if (b < 83)
			return 3;
		else if (b < 89)
			return 4;
		else if (b < 105)
			return 5;
		else if (b < 116)
			return 6;
		else if (b < 148)
			return 7;
		else
			return 8;
	}

	private static int slove(double a) {
		if (a < 35.5)
			return 1;
		else if (a < 37.5)
			return 2;
		else if (a < 40.0)
			return 3;
		else if (a < 43.0)
			return 4;
		else if (a < 50)
			return 5;
		else if (a < 55)
			return 6;
		else if (a < 70)
			return 7;
		else
			return 8;
	}
}

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

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

    long long ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long min = long.MaxValue;
		for(int i=0;i<N;i++){
			for(int j=i;j<N;j++){
				for(int k=j;k<N;k++){
					for(int l=k;l<N;l++){
					
						long w0 = new long[]{X[i],X[j],X[k],X[l]}.Min();
						long w1 = new long[]{X[i],X[j],X[k],X[l]}.Max();
						long h0 = new long[]{Y[i],Y[j],Y[k],Y[l]}.Min();
						long h1 = new long[]{Y[i],Y[j],Y[k],Y[l]}.Max();
						
						long ar = (w1 - w0) * (h1 - h0);
						if(ar == 0) continue; // 無いはず
						
						int cnt = 0;
						for(int m=0;m<N;m++){
							if(InRange(X[m], w0, w1) && InRange(Y[m], h0, h1)) cnt++;
						}
						if(cnt >= K){
							min = Math.Min(min, ar);
						}
						
					}
				}
			}
		}
			
		Console.WriteLine(min);
		
		
		
		
		
	}
	
	bool InRange(long t, long l, long r){
		return l <= t && t <= r; // inclusive;
	}
	int N,K;
	long[] X,Y;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			d = ria();
			X[i] = d[0];
			Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17384
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,1,n){
        if(i%3 != 0 && i%5 != 0)ans += i;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long s[] = new long[n + 1];
		s[0] = a[0];

		for (int i = 0; i < n - 1; i++) {
			s[i + 1] = s[i] + a[i + 1];
		}

		long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			ans += (a[i] % 1000000007 * ((s[n - 1] - s[i]) % 1000000007)) % 1000000007;
		}

		System.out.println(ans % 1000000007);
	}
}


Measured memory_bytes: 62472
A, B, K = map(int, input().split())
K2=B-A+1
K3=K2-K*2
if K3 > 0:
    for i in range (K):
        print ('%d'%(A+i))
    for i in range (K):
        print ('%d'%(B-K+i+1))
if K3 <= 0:
    for i in range (B-A+1):
        print ('%d'%(A+i))

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

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

  string s;
  cin >> s;

  if (s.size() <= k) {
    cout << s << endl;
  }
  else {
    cout << s.erase(k)  << "..." << endl;
  }
}




Measured memory_bytes: 3640
use proconio::input;
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        k: usize,
    }
    
    let mut h: HashSet<u32> = HashSet::new();
    for i in 0..k {
        input!{
            d: usize,
            a: [u32; d],
        }
        for j in a {
            h.insert(j);
        }
    }
    println!("{}", n - h.len());
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int x, n;
	cin >> x >> n;
	v1 p(n);
	rep(i, n){
		cin >> p.at(i);
	}
	bool judge = true;
	int i = 0;
	int ans;
	int ans1 = 100000;
	int ans2 = 100000;
	while(judge){
		int xp = x+i;
		int xm = x-i;
		i++;
		
		if(find(p.begin(), p.end(), xp) == p.end()){
			ans1 = xp;
			judge = false;
		}
		if(find(p.begin(), p.end(), xm) == p.end()){
			ans2 = xm;
			judge = false;
		}
		ans = min(ans1, ans2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
# from ../../myProgConLib/unionfind import UnionFind

class UnionFind:
    def __init__(self, n):
        # par = Parent Number or NoV
        self.par = [-1] * (n+1)
        # rank = Tree Height
        self.rank = [0] * (n+1)
    
    # 自分が所属する集合の数を返す
    def size(self, x):
        return -1*self.par[self.find(x)]

    # 根なら番号を返す
    def find(self, x):
        
        if(self.par[x] < 1):
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    # 親が同じか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # もう繋がれている
        if(x == y):
            return False

        # つなぎ替える
        if(self.size(x) < self.size(y)):
            x,y = y,x
        
        # xのサイズを更新
        self.par[x] += self.par[y]
        # yのサイズ(おやばんごう)をxに
        self.par[y] = x

        return True 
 

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = UnionFind(N)
    ans = [0] * M 
    ans[M-1] = int(N*(N-1)/2)

    for i in reversed(range(1, M)):
        # A[i] -= 1
        # B[i] -= 1

        ans[i-1] = ans[i]

        if(uf.find(A[i]) != uf.find(B[i])):
            # print('SoP', uf.size(A[i]), uf.size(B[i]))
            ans[i-1] -= uf.size(A[i]) * uf.size(B[i])
            uf.union(A[i], B[i])
        # print(i, uf.par)

    for i in ans:
        print(i)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17712
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 
#define pll pair<ll,ll>



void solve()
{
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}

int main()
{
   ll t;
   t=1;
   // cin>>t; 
   while (t--)
   {
       solve();
   }  
}

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

using namespace std;

int main () {
	string a, b, c;
	cin >> a >> b >> c;
	int lena = a.length();
	int lenb = b.length();
	int lenc = c.length();
	if (a[lena - 1] == b[0] && b[lenb - 1] == c[0])
		puts("YES");
	else puts("NO");	
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
#define print(a) printf("%d",a)
#define sc1(a) scanf("%d",&a)
using namespace std;
 
typedef unsigned long  ull;
typedef long long int lli;
 
int main()
{
 	int n,m;
 	
 	cin>>n>>m;
 	int arr[n+1];
 	int sum=0;
 	for(int i=0;i<n;++i)
 	{
 		cin>>arr[i];
 		sum+=arr[i];
	}
 		
 	int cnt=0;
 	sort(arr,arr+n,greater<int>());
	double chk=(1/(float)(4*m))*sum;
	for(int i=0;i<n;++i)
	{
		if (chk<=arr[i]) cnt++;
		else
			break;
	}
	if (cnt>=m) cout<<"Yes\n";
	else cout<<"No\n";
 
 
 return 0;
 }


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

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

  if (b - a <= 0) {
    cout << "delicious" << endl;
  } else if (x >= b - a && b - a > 0) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    
    vector<int> a(N);
    long long ans = 0;
    for(int i= 0;i<N;i++)
    {
        if((i+1) %3 == 0 || (i+1) %5 == 0)
        {
            a[i] = 0;
        }
        else
        {
            a[i] = i+1;
            ans += i+1;
        }
    }
    cout << ans << endl;
    
    return 0;
    /*
    vector<int> a(N);
    for(int i= 0;i<N;i++)
    {
        cin >> a[i];
    }
    */
    
}

Measured memory_bytes: 7048
N,M = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(M)]

for e in l:
  L,R = e[0],e[1]
  if e == l[0]:
    _L,_R = L,R
  else:
    if _L < L:
      _L = L
    if _R > R:
      _R = R
if _R - _L >= 0:
  print(_R - _L + 1)
else:
  print(0)


Measured memory_bytes: 27464
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cerrno>
#include <cfenv>
#include <cstring>
#include <bitset>
#include <queue>
#include <iomanip>

using namespace std;
int A,B;
int ans = -1;

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

	for (int i = 0; i < 1260; i++)
	{
		if (floor(i*0.08) == A && floor(i*0.10) == B)
		{
			ans = i;
			break;
		}
	}

	cout << ans;
}


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

int main(){
  int x, y; cin >> x >> y;
  int a, b, c; cin >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  for(int i = 0; i < a; i++) cin >> p[i];
  for(int i = 0; i < b; i++) cin >> q[i];
  for(int i = 0; i < c; i++) cin >> r[i];
  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  priority_queue<ll> que;
  for(int i = 0; i < x; i++) que.push(p[i]);
  for(int i = 0; i < y; i++) que.push(q[i]);
  for(int i = 0; i < c; i++) que.push(r[i]);
  ll ans = 0;
  for(int i = 0; i < x+y; i++){
    ll app = que.top(); que.pop();
    ans += app;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 9732
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <stdio.h>
using namespace std;
ostringstream oss ;

int main(){
    int n ;
    string ss ;
    cin >> n >> ss;
    int ans = 0;
    vector<int> s(n);
    for (size_t i = 0; i < n; i++)
    {
        if (ss.at(i) == '0')
        {
            s.at(i) = 0 ;
        }else if (ss.at(i) == '1')
        {
            s.at(i) = 1 ;
        }else if (ss.at(i) == '2')
        {
            s.at(i) = 2 ;
        }else if (ss.at(i) == '3')
        {
            s.at(i) = 3 ;
        }else if (ss.at(i) == '4')
        {
            s.at(i) = 4 ;
        }else if (ss.at(i) == '5')
        {
            s.at(i) = 5 ;
        }else if (ss.at(i) == '6')
        {
            s.at(i) = 6 ;
        }else if (ss.at(i) == '7')
        {
            s.at(i) = 7 ;
        }else if (ss.at(i) == '8')
        {
            s.at(i) = 8 ;
        }else if (ss.at(i) == '9')
        {
            s.at(i) = 9 ;
        }
    }
    
    for (size_t i = 0; i < 1000; i++)
    {
        bool stop = false ;
        int p = 0 ;
        int temp = i / 100 ;
        int now = temp ;
        while(p < s.size()){

            if (s.at(p) == now)
            {
                p++ ;
                int temp = (i / 10) % 10  ;
                oss << temp ;
                now = temp ;
                while (p < s.size() )
                {
                    if (s.at(p) == now)
                    {
                        p++ ;
                        int temp = i % 10 ;
                        oss << temp ;
                        now = temp ;
                        while (p<s.size())
                        {
                            if (s.at(p) == now)
                            {
                                ans ++ ;
                                stop = true ;
                                break ;
                            }
                            p++ ;
                        }
                        
                    }
                    if (stop == true)
                    {
                        break ;
                    }
                    p++;
                    
                }
                
            }
            if (stop == true)
            {
                break;
            }
            p++ ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 384
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
  int h,n;
  cin >> h >> n;
  vector<int> hel(n),point(n);
  for(int i=0; i<n; i++){
      cin >> hel[i] >> point[i];
  }
  vector<int> dp(h,INT_MAX);
  for(int i=0; i<n; i++){
      for(int j=h-1; j>=0; j--){
          if(j+hel[i]>=h){
              dp[j] = min(dp[j] , point[i]);
          }
          else{
              dp[j] = min(dp[j] , dp[j+hel[i]]+point[i]);
          }
      }
  }
  cout << dp[0] << endl;
  
   return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;


// ------------------------

void solve() {
    string S;
    cin >> S;
    int cntA = 0;
    int cntB = 0;
    if(S[0] == 'A'){
        ++cntA; 
        }else{
             ++cntB;
        }
    if(S[1] == 'A'){
        ++cntA; 
        }else{
             ++cntB;
        }
    if(S[2] == 'A'){
        ++cntA; 
        }else{
             ++cntB;
        }


    if(cntA == 3 or cntB == 3){
        cout << "No" << "\n";
        return;
    }

    cout << "Yes" << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] d = new long[N];
        for (int i = 0; i < N; i++) {
            d[i] = scan.nextInt();
        }
        long answer = 0;
        long remain = 0;
        for (int i = 0; i < N; i++) {
            answer += (remain + d[i]) / 2;
            remain = (remain + d[i]) - ((remain + d[i]) / 2) * 2;
            if (d[i] == 0) {
                remain = 0;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 60704
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b)
    printf("%d\n",c);
  else if(a==c)
    printf("%d\n",b);
  else
    printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int flag = 0, flag2 = 0;
    if(sx > tx) flag = 1;
    if(sy > ty) flag2 = 1;
    char c[4] = {'U', 'R', 'D', 'L'};
    for(int i = 0; i < abs(tx - sx); i++){
        if(flag) cout << c[3];
        else cout << c[1];
    }
    for(int i = 0; i < abs(ty - sy); i++){
        if(flag2) cout << c[2];
        else cout << c[0];
    }
    for(int i = 0; i < abs(tx - sx); i++){
        if(flag) cout << c[1];
        else cout << c[3];
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        if(flag2) cout << c[0];
        else cout << c[2];
    }
    for(int i = 0; i < abs(tx - sx) + 1; i++){
        if(flag) cout << c[3];
        else cout << c[1];
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        if(flag2) cout << c[2];
        else cout << c[0];
    }
    if(flag) cout << c[1];
    else cout << c[3];
    if(flag2) cout << c[2];
    else cout << c[0];
    for(int i = 0; i < abs(tx - sx) + 1; i++){
        if(flag) cout << c[1];
        else cout << c[3];
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        if(flag2) cout << c[0];
        else cout << c[2];
    }
    if(flag) cout << c[3];
    else cout << c[1];
    cout << endl;
}

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

#define Yes(i) if(i) cout << "Yes" << endl; else cout << "No" << endl
#define Poss(i) if(i) cout << "Possible" << endl; else cout << "Impossible" << endl

int main(){
    int N, M;
    cin >> N >> M;
    int favorite[N][M];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> favorite[i][j];
        }
    }
    int ans = 1e9;
    vector<bool> if_choose(M, true);
    for(int i = 0; i < M; i++){
        vector<int> choosing(M, 0);
        for(int j = 0; j < N; j++){
            for(int k = 0; k < M; k++){
                if(if_choose[favorite[j][k] - 1]){
                    choosing[favorite[j][k] - 1]++;
                    break;
                }
            }
        }
        int this_ans_number = 0;
        for(int j = 1; j < M; j++){
            if(choosing[this_ans_number] < choosing[j]){
                this_ans_number = j;
            }
        }
        ans = min(ans, choosing[this_ans_number]);
        if_choose[this_ans_number] = false;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    string r;
    cin >> n >> r;
    int f=r.size();
    if (n>=f)
        cout << r << endl;
    else
    {
        for (int i=0; i<n; ++i)
            cout << r[i];
        cout << "..." << endl;
    }
}




Measured memory_bytes: 3628
#coding: UTF-8

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


def InsertionSort(A,N):
    c = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                 minj = j
        if i != minj:
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            c+=1

    for i in range(N - 1):
        print(A[i],end=' ')
    print(A[N - 1])
    print(c)

InsertionSort(A,N)

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

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


Measured memory_bytes: 3624
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys

sys.setrecursionlimit(1000000)

def d_num(num):
    ret = 0
    d = len(str(num))
    for i in range(d - 1):
        ret += (i + 1) * 9 * 10 ** i
    return ret + d * (num - 10 ** (d - 1) + 1)

def search(num, l, r):
    if r - l <= 1:
        return l, num - d_num(l)
    mid = (l + r) / 2
    if d_num(mid) > num:
        r = mid
    else:
        l = mid
    return search(num, l, r)

while True:
    K, N = map(int, raw_input().split())
    if K == 0:
        break

    p = search(K - 1, 0, 10 ** 18)
    S = ''
    for i in range(p[0] + 1, p[0] + 101):
        S += str(i)
    print S[p[1]:p[1] + N]



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


using namespace std;

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

	string s;
	string t;

	cin >> s >> t;

	int ans = 2*n;

	for (int st = 0; st < n; ++st) {
		int ok = 1;
		for (int i = 0; i < n - st; ++i) {
			if (s[st+i] != t[i]) {
				ok = 0;
			}
		}
		if (ok) {
			ans = min(ans, st+n);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int sheet[100][100] = { 0 };
	int x, y;
	int i, j;
	int sumi[100] = { 0 };
	int sumj[100] = { 0 };
	int sumij = 0;
	scanf("%d %d", &x, &y);

	for (i = 0; i < x; i++){
		for (j = 0; j < y; j++){
			scanf("%d", &sheet[i][j]);
			sumi[i] += sheet[i][j];
			sumj[j] += sheet[i][j];
			
		}
		
	}
	
	
	for (i = 0; i <= x ; i++){
		for (j = 0; j <= y; j++){
			
			if ((i == x) && (j == y)){
				printf("%d\n", sumij);
				
			}
			else if (i == x){
				printf("%d ", sumj[j]);
			}
			else if (j == y){
				printf("%d\n", sumi[i]);
			}
			else {
				printf("%d ", sheet[i][j]);
			}
			
				
			
		}
		sumij += sumi[i];
	}
	
	

}

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

int gcd(int a, int b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main() {
    int n;
    cin >> n;
    int g;
    cin >> g;
    while(--n) {
        int t;
        cin >> t;
        g = gcd(g, t);
    }
    for(int i=1; i<=g; ++i) {
        if(g % i == 0) {
            cout << i << endl;
        }
    }
}


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

constexpr int MAX_N = 1e5;

using P = pair<long, long>;
P AB[MAX_N];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i{}; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    AB[i] = P(a, b);
  }
  sort(AB, AB+N);

  long long ans{};
  for (long i{}, remain{M}; i < N && remain > 0; ++i) {
    P p = AB[i];
    int num = min(remain, p.second);
    ans += p.first * num;
    remain -= num;
  }

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


Measured memory_bytes: 1792
# キュー
from collections import deque

n = int(input())
links = [[] for _ in range(n+1)]
for i in range(1,n+1):
    ss = input()
    for j,s in enumerate(ss,1):
        if(s=='1'):
            links[i].append(j)

ans = -1
for i in range(1,n+1):
    ng_flag = False

    depth = [-1] * (n+1)
    depth[i] = 1
    max_depth = 1
    d = deque()
    d.append(i)
    while(d):
        now = d.popleft()
        for j in links[now]:
            if(depth[j] == -1):
                depth[j] = depth[now] + 1
                d.append(j)
                max_depth = max(max_depth, depth[j])
            else:
                if(abs(depth[j] - depth[now]) != 1):
                    ng_flag = True
                    break
        if(ng_flag):
            break
    if(not ng_flag):
        ans = max(ans, max_depth)

print(ans)

Measured memory_bytes: 42604
import java.util.*;

class Restaurant {
  public String name;
  public int score;
  public int index;
  
  public Restaurant(String name, int score, int index) {
    this.name = name;
    this.score = score;
    this.index = index;
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Restaurant> restaurant = new ArrayList<Restaurant>();
    for (int i=1; i<=N; i++) {
      String name = sc.next();
      int score = sc.nextInt();
      restaurant.add(new Restaurant(name,score,i));
    }

    Comparator<Restaurant> workComparator = new Comparator<Restaurant>(){
      @Override
      public int compare(Restaurant r1, Restaurant r2) {
        if (! r1.name.equals(r2.name)) {
        return r1.name.compareTo(r2.name);
        } else if (r1.name.equals(r2.name)) {
          return (r1.score > r2.score) ? -1:1;
        } else {
          return -1;
        }
      }
    };            
    Collections.sort(restaurant, workComparator);
    for (Restaurant r : restaurant) {
      System.out.println(r.index);
    }
  }
}

Measured memory_bytes: 22996
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var len = s.Select(x=>0).ToArray();

            if(s.Length%2==0)
            {
                if (s[s.Length / 2 - 1] == s[s.Length / 2])
                {
                    var current = s.Length / 2 - 1;
                    int ans1 = 0;
                    for (int i = 1; ; i++)
                    {
                        if (current - i < 0 || s[current - i + 1] != s[current - i])
                        {
                            ans1 = s.Length / 2 + i;
                            break;
                        }
                    }
                    current = s.Length / 2;
                    int ans2 = 0;
                    for (int i = 1; ; i++)
                    {
                        if (current + i >= s.Length || s[current + i - 1] != s[current + i])
                        {
                            ans2 = s.Length / 2 + i;
                            break;
                        }
                    }
                    Console.WriteLine(Math.Min(ans1, ans2));
                }
                else
                {
                    Console.WriteLine(s.Length / 2);
                }
            }
            else
            {
                var current = s.Length / 2 ;
                int ans1 = 0;
                for (int i = 1; ; i++)
                {
                    if (current - i < 0 || s[current - i + 1] != s[current - i])
                    {
                        ans1 = s.Length / 2 + i ;
                        break;
                    }
                }
                current = s.Length / 2 ;
                int ans2 = 0;
                for (int i = 1; ; i++)
                {
                    if (current + i >= s.Length || s[current + i - 1] != s[current + i])
                    {
                        ans2 = s.Length / 2 + i;
                        break;
                    }
                }
                Console.WriteLine(Math.Min(ans1, ans2));
            }
            return;

        }
    }
}


Measured memory_bytes: 13336
#include <stdio.h>

#define AO if (n[j - 1] < n[j]){tmp = n[j - 1];n[j - 1] = n[j];n[j] = tmp;}
#define DO if (n[j - 1] > n[j]){tmp = n[j - 1];n[j - 1] = n[j];n[j] = tmp;}

int sort(int n[], int judge);

 
int main(void)
{
    int num;
    int num_p[4];
    int cnt;
    int l, s;
		int i;
		
    while (scanf("%d", &num) != EOF){
				if (num == 0000){
					break;
				}
				
        else if (num % 1111 == 0){
            printf("NA\n");
        }
				
        else {
            cnt = 0;
            
            while (num != 6174){
								num_p[0] = num / 1000;
		            num_p[1] = (num / 100) % 10;
		            num_p[2] = (num / 10) % 10;
		            num_p[3] = num % 10;
								
                l = sort(num_p, 0);
                s = sort(num_p, 1);
                
                num = l - s;
                cnt++;
            }
            printf("%d\n", cnt);
        }
    }
     
    return (0);
}

int sort(int n[], int judge)
{
    int i, j;
    int tmp;
    int ans;
     
    for (i = 0; i < 4; i++){
        for (j = 1; j < 4; j++){
            if (judge == 1){
							DO
            }
						else {
							AO
						}
        }
    }
    ans =(n[0] * 1000) + (n[1] * 100) + (n[2] * 10) + n[3];
		
    return (ans);
}

Measured memory_bytes: 608
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
ans = 0
rep = 0
for i in s:
    if i == "R":
        rep += 1
    else:
        rep = 0
    ans = max(ans, rep)
print(ans)


Measured memory_bytes: 61836
#include <stdio.h>
int main(void){
    int x,y;
    for(;;){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)break;
        if(x<y)
            printf("%d %d\n",x,y);
        else{
          printf("%d %d\n",y,x);
        }
    }
    return 0;
}



Measured memory_bytes: 2040
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    string s;
    scan(s);
    int n = s.length.to!int;
    if (n % 2) {
        writeln("No");
        return;
    }
    foreach (i ; 0 .. n / 2) {
        if (s[2*i .. 2*i + 2] != "hi") {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
  ll a,b,c; cin >> a >> b >> c;
  ll ans = min(a+b,c) + b;
  if(c > a+b) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	long int x,money=100;
	long int cnt=0;
	
	scanf("%ld",&x);
	
	do{
		money = money + (money*0.01); 
		cnt = cnt + 1;
		
//		printf("money = %ld  cnt = %ld  ",money,cnt);
	
	} while(money < x);
	
	printf("%ld",cnt);
	
	return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

	if (A + B < 24) {
		cout << A + B << endl;
		return 0;
	}
	cout << (A + B) - 24 << endl;

	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int x=sc.nextInt();
		if(x==1 || x==2*N-1) {
			pl("No");
		}
		else {
			pl("Yes");
			int[] ary=new int[2*N-1];
			if(x>=N) {
				int diff=x-N;
				int counter=0;
				for(int i=1+diff; i<=2*N-1; i++) {
					ary[counter]=i;
					counter++;
				}
				for(int i=1; i<=diff; i++) {
					ary[counter]=i;
					counter++;
				}
			}
			else if(x<N) {
				int first=N+x;
				int counter=0;
				for(int i=first; i<=2*N-1; i++) {
					ary[counter]=i;
					counter++;
				}
				for(int i=1; i<first; i++){
					ary[counter]=i;
					counter++;
				}
			}
			for(int i=0; i<N*2-1; i++) {
				pl(ary[i]);
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 57488
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  vs k = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
  rep(i, 7){
    if(s == k[i].substr(0, 3)){
      print(7-i);
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int x;
    cin >> x;
    while(x != 0){
        double y[1000] = {},sum = 0, S = 0;
        for (int i = 0; i < x; i++){
            cin >> y[i];
            sum += y[i];
        }
        for (int i = 0; i < x; i++){
            S += ((sum / x) - y[i]) * ((sum / x) - y[i]) / x;
        }
        printf("%lf\n", sqrt(S));
        cin >> x;
    }
    return 0;
    
}


Measured memory_bytes: 3192
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::priority_queue;
int main() {
	int N;
	scanf("%d", &N);
	auto A = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	long long oddsum = 0, evemsum = 0;
	auto oddsums = new long long[N / 2]{};
	auto evensums = new long long[(N + 1) / 2]{};
	long long max = -mod * N;
	for (int i = 0; i < N; i++) {
		if (i & 1) {
			oddsum += A[i];
			oddsums[i / 2] = oddsum;
		}
		else {
			evemsum += A[i];
			evensums[i / 2] = evemsum;
		}
	}
	if (N & 1) {
		max = oddsum;
		auto maxs = new long long[N / 2 + 1]{};
		maxs[0] = max;
		for (int i = 0; i < N / 2; i++) {
			long long sum = evensums[i] + oddsum - oddsums[i];
			max = sum < max ? max : sum;
			maxs[i + 1] = max;
		}
		long long d = 0;
		for (int i = N / 2; i >= 1; i--) {
			d += A[i * 2] - A[i * 2 - 1];
			long long sum = maxs[i - 1] + d;
			max = sum < max ? max : sum;
		}
	}
	else {
		max = oddsum;
		for (int i = 0; i < N / 2; i++) {
			long long sum = evensums[i] + oddsum - oddsums[i];
			max = sum < max ? max : sum;
		}
	}
	printf("%lld", max);
	return 0;
}

Measured memory_bytes: 6388
n=int(input())
list=[]
h=0
d=input().split(" ")
for i in range(n):
  d[i]=int(d[i])
for i in range(1,len(d)):
  if d[i]-d[i-1]<0:
    h+=(d[i-1]-d[i])
    d[i]+=d[i-1]-d[i]
print(h)


Measured memory_bytes: 25320
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int b[1000000];
    int c[1000000];
    int d=0;
    long long e=0;
    for(int i=0;i<a;i++){
		cin>>b[i];
		c[i]=abs(b[i]);
	}
	for(int i=0;i<a;i++){
		if(b[i]==0){
			d=0;
			break;
		}
		if(b[i]<0){
			d++;
		}
	}
	sort(c,c+a);
	if(d%2==0){
		for(int i=0;i<a;i++){
			e=e+c[i];
		}
	}
	else{
		for(int i=0;i<a;i++){
			if(i==0){
				e=e-c[i];
			}
			else{
				e=e+c[i];
			}
		}
	}
	cout<<e<<endl;
}


Measured memory_bytes: 4736
V=list(map(int,input().split()))
if ((V[0] == V[1]) & (V[0] != V[2])) | ((V[1] == V[2]) & (V[1] != V[0])) | ((V[2] == V[0]) & (V[2] != V[1])):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main ()
{
   int a[1001],n;
   while (scanf ("%d",&n)!=EOF)
   {
       int sum=1;
       for (int i=0;i<n;i++)
        scanf ("%d",&a[i]);
       sort (a,a+n);
       for (int i=0;i<n-1;i++)
        if (a[i]!=a[i+1]) sum++;
       printf ("%d\n",sum);
   }
}


Measured memory_bytes: 256