akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.nextLine();
		int p =0;
		int n = s1.length();
		int i;
		for(i=0; i<n; i++)
		{
		    char x = s1.charAt(i);
		    
		    if((i+1)%2 != 0)
		    {
		        
		        if(x == 'R')
		            p = 0;
		        else if(x == 'U')
		            p = 0;
		        else if(x == 'D')
		            p = 0;
		        else
		        {
		            
		            p = 1;
		            break;
		        }
		    }
		    else
		    {
		        
		        if(x == 'L')
		            p = 0;
		        else if(x == 'U')
		            p = 0;
		        else if(x == 'D')
		            p = 0;
		        else
		        {
		            p = 1;
		            break;
		        }
		    }
		}
		if(p == 0)
		    System.out.println("Yes");
		else
		    System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  ll n,a,b; cin >> n >> a >> b;
  ll ans = n/(a+b) * a;
  ans += min(n%(a+b),a);
  cout << ans << endl;
}



Measured memory_bytes: 256
const main = (input: string) => {
  const lines = input.trim().split("\n").slice(1)
  const V = lines[0].split(" ").map(str => parseInt(str))
  const C = lines[1].split(" ").map(str => parseInt(str))
  let answer = 0;

  for (let i = 0; i < V.length; i++) {
    if (V[i] > C[i]) {
      answer += V[i] - C[i];
    }
  }

  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long mod = 1000000007;
long long n , m;
long long ans;
void work () {
	long long i;
	scanf ( "%lld%lld" , &n , &m );
	if ( n < m ) swap ( n , m );
	if ( n - m > 1 ) {
		printf ( "0\n" );
		return ;
	}
	ans = 1;
	if ( n == m ) ans = 2;
	for ( i = 1 ; i <= n ; i++ ) {
		ans = (ans*i) % mod;
	}
	for ( i = 1 ; i <= m ; i++ ) {
		ans = (ans*i) % mod;
	}
	printf ( "%lld\n" , ans );
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 128
require 'set'
loop do
    n = gets.to_i
    break if n == 0
    g = n.times.map{gets.chomp}
    h = Hash.new(Array.new)
    f = ""
    g.each_with_index do |s,i|
        s = s.gsub("\.","").split(":")
        h[s[0]] = s[1].split(",")
        f = s[0] if i == 0
    end
    t = h.to_a[0][0]
    ans = Set.new
    a = h[t]
    while !a.empty?
        a2 = Set.new
        a.each do |m|
            if h.has_key?(m)
                h[m].each do |mm|
                    a2.add(mm)
                end
            else
                ans.add(m)
            end
        end
        a = a2.to_a
    end
    p ans.size
end

Measured memory_bytes: 6460
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(): return "".join(list(map(str, ans)))


N, x = rli()
a = rli()
ans = 2000000000001
magic_time = 0
s_min = a[:]
for i in range(0, N):
    for j in range(N):
        s_min[j] = min(a[j-i], s_min[j])
    ans = min(sum(s_min) + x*i, ans)
print(ans)


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

int main(){
  int h, w;  cin >> h >> w;
  int sh, sw, gh, gw;  cin >> sh >> sw >> gh >> gw;
  vector<vector<int>> field(h+2, vector<int>(w+2, 0)), cost(h+2, vector<int>(w+2, 1e9));
  for(int i=0; i<h; i++){
    string s;  cin >> s;
    for(int j=0; j<w; j++)
      if(s[j] == '.')  field[i+1][j+1] = 1;
  }
  
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pque;
  pque.push({0, {sh, sw}});
  while(!pque.empty()){
    auto now = pque.top();  pque.pop();
    int nowcost = now.first, nowh = now.second.first, noww = now.second.second;
    //cout << "debug : " << nowcost << "  " << nowh << "   " << noww << endl;
    if(nowcost > cost[nowh][noww])  continue;
    int d[] = {1, 0, -1, 0, 1};
    for(int i=0; i<4; i++){
      int nexth = nowh+d[i], nextw = noww+d[i+1];
      if(field[nexth][nextw] && nowcost < cost[nexth][nextw]){
        cost[nexth][nextw] = nowcost;
        pque.push({nowcost, {nexth, nextw}});
      }
    }
    for(int i=-2; i<=2; i++)
      for(int j=-2; j<=2; j++){
        if(i==0 && j==0)  continue;
        if(!(1<=nowh+i && nowh+i<=h && 1<=noww+j && noww+j<=w))  continue;
        if(field[nowh+i][noww+j] && nowcost+1<cost[nowh+i][noww+j]){
          cost[nowh+i][noww+j] = nowcost + 1;
          pque.push({nowcost+1, {nowh+i, noww+j}});
        }
      }
  }
  if(cost[gh][gw] == 1e9)  cost[gh][gw] = -1;

  cout << cost[gh][gw] << endl;
  
  return 0;
}


Measured memory_bytes: 11664
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N;
  int X;
  cin >> N >> X;

  vector<int> L(N);
  int dist = 0;
  int count = 1;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    dist += L[i];
    if (dist <= X) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0154 : Sum of Cards **/
int main()
{
	int N;
	while (cin>>N, N) {
		int c[7], num[7];
		rep(i, N) {
			cin>>c[i]>>num[i];
		}
		int dp[8][1001];
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		
		for (int i=0; i<N; i++) {
			for (int j=0; j<=1000; j++) {
				for (int k=0; k<=num[i]; k++) {
					if (j+k*c[i]<=1000) {
						dp[i+1][j+k*c[i]] += dp[i][j];
					}
				}
			}
		}
		
		
		int G;
		cin>>G;
		rep(i, G) {
			int t; cin>>t;
			cout << dp[N][t] << endl;
		}
	}
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int i, sum = 0, min_r = 10;
      	int[] time = new int[5];
      	for(i = 0; i < 5; i++) {
          time[i] = Integer.parseInt(sc.next());
          if(time[i] % 10 == 0) {
            sum += time[i];
          } else {
          	sum += time[i] + (10 - (time[i] % 10));
            if(min_r > time[i] % 10) min_r = time[i] % 10;
          }
        }
      	System.out.println(sum - (10 - min_r));
    }
}

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

struct dise{
 int lab1, lab2, lab3, lab4, lab5, lab6;
};

int main(){
 dise d1;
 cin >> d1.lab1 >> d1.lab2 >> d1.lab3 >> d1.lab4 >> d1.lab5 >> d1.lab6;

 string command;
 cin >> command;
 for( int j=0; j<command.length(); j++ ){
   if( command[j]=='S' ){
     int tmp = d1.lab1;
     d1.lab1 = d1.lab5;
     d1.lab5 = d1.lab6;
     d1.lab6 = d1.lab2;
     d1.lab2 = tmp;
   }
   if( command[j]=='E' ){
     int tmp = d1.lab1;
     d1.lab1 = d1.lab4;
     d1.lab4 = d1.lab6;
     d1.lab6 = d1.lab3;
     d1.lab3 = tmp;
   }
   if( command[j]=='N' ){
     int tmp = d1.lab1;
     d1.lab1 = d1.lab2;
     d1.lab2 = d1.lab6;
     d1.lab6 = d1.lab5;
     d1.lab5 = tmp;
   }
   if( command[j]=='W' ){
     int tmp = d1.lab1;
     d1.lab1 = d1.lab3;
     d1.lab3 = d1.lab6;
     d1.lab6 = d1.lab4;
     d1.lab4 = tmp;
   }
 }

 cout << d1.lab1 << endl;

 return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=1e6;
char s[N+5];
ll dp[N+5][2];

int main()
{
	ios::sync_with_stdio(false);
	cin>>s+1;
	int len=strlen(s+1);
	dp[0][1]=1;
	for(int i=1;i<=len;i++)
		s[i]-='0';
	for(int i=1;i<=len;i++)
	{
		dp[i][0]=min(dp[i-1][0]+s[i],dp[i-1][1]+(s[i]?10-s[i]:1));
		dp[i][1]=min(dp[i-1][0]+(s[i]?s[i]+1:1),dp[i-1][1]+9-s[i]); 
	}
	cout<<min(dp[len][0],dp[len][1]+1)<<endl; 
 	return 0;
}

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

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		puts("0");
		return 0;
	}
	printf("%lld\n", std::min(std::min(1ll * a * b, 1ll * b * c), 1ll * a * c));
	return 0;
}

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

int main() {
    string S;
    cin>>S;
    vector<int> a(26, 0);
    for(int i;i<S.size();i++){
        a.at(int(S.at(i))-97)+=1;
    }
    for(int k;k<26;k++){
        if(a.at(k)==0){
            cout<<char(k+97)<<endl;
            return 0;
        }
    }
    
    cout<<"None"<<endl;
    /*
    cout<<char(97);
    for(int h=0;h<26;h++){
        cout<<a.at(h)<<endl;
    }
    */
return 0;}
/*
g++ code.cpp
./a.out
*/

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	int h, w; cin >> h >> w;

	vector<vector<char>>a(h + 2, vector<char>(w + 2));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++){ 
			cin >> a[i][j];
		}
	}
	
	for (int i = 0; i < w + 2; i++) {
		a[0][i] = '#';
		a[h + 1][i] = '#';

	}
	
	for (int i = 1; i < h + 1; i++) {
		a[i][0] = '#';
		a[i][w + 1] = '#';
	}
	
	rep(i, h + 2) {
		rep(j, w + 2) {
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define inf (1<<26)

#define PRIME_MAX 200000
vector<bool> prime(PRIME_MAX+1,true);
vector<int> lst;

void init_prime(){
	prime[0] = prime[1] = false;
	for(int i=2;i*i<=PRIME_MAX;i++)
		if(prime[i]) for(int j=i*i;j<=PRIME_MAX;j+=i)prime[j] = false;
}

int func(int n,int p){
	int bottom = 0;
	rep(i,lst.size()){
		if(lst[i] > n){bottom = i; break;}
	}
	vector<int> ret;
	rep(i,p){
		for(int j = i ; j < p ; j++){
			ret.push_back(lst[bottom+i] + lst[bottom+j]);
		}
	}
	sort(all(ret));
	return ret[p-1];
}
int main(){	
	init_prime();
	rep(i,PRIME_MAX+1)if(prime[i])lst.push_back(i);
	int n,p;
	while(cin >> n >> p, n != -1){
		cout << func(n,p) << endl;
	}
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]?"YES":"NO");
    return 0;
}

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

const int MX=1e9+7;

int dis(string a,string b){
  int ans=MX;
  for(int i=0;i<a.size() && i<b.size();i++){
    if(a[i]!=b[i]){ans=i+1; break;}
  }
  if(ans==MX && a.size()!=b.size()){
    ans=min(a.size()+1,b.size()+1);
  }
  return ans;
}





int main(){
  while(1){
  
  int n;
  cin>>n;
  if(n==0){break;}
  vector<string> vs;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    string st;
    st.push_back(s[0]);
    for(int t=1;t<s.size();t++){
      if(s[t-1]=='a' || s[t-1]=='i' || s[t-1]=='u' || s[t-1]=='e' || s[t-1]=='o'){
	st.push_back(s[t]);
      }
    }
    vs.push_back(st);
  }
  int ans=0;
  for(int i=0;i<n-1;i++){
    for(int t=i+1;t<n;t++){
      ans=max(ans,dis(vs[i],vs[t]));
    }
  }
  cout<<(ans==MX?-1:ans)<<endl;

  }
  return 0;
}



Measured memory_bytes: 3136
#include <stdio.h>

int main()
{
    int t, u;
    int m = 0;
    int s = 0;

    for(int i = 0; i < 5; i++){
        scanf("%d", &t);
        u = (t + 9) / 10;
        m = ((u * 10 - t) > m) ? (u * 10 - t) : m;
        s += u * 10;
    }

    printf("%d\n", s - m);
}

Measured memory_bytes: 128
using Microsoft.VisualBasic.FileIO;
using System;
//1回の操作で最大でも+2
//基本的に+2できる
//ans=(n-1)-(異なっている異なっている個数)
//ans=(n-1)-(グループ数-1)
//ポイント
//(1)LLLなどをLグループとしてまとめる
//(2)一回の操作で連結部分は2か所しか変わらない
namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int k = int.Parse(In[1]);
            char[] C = Console.ReadLine().ToCharArray();
            int g = CountGroups(C) - 2 * k;
            if (g <= 0) g = 1;
            int sum = (n - 1) - (g - 1);
            Console.WriteLine(sum);
        }
        static public int CountGroups(char[] C)
        {
            int cnt=1;
            char temp = C[0];
            for(int i=1; i < C.Length; i++)
            {
                if (temp != C[i])
                {
                    cnt++;
                    temp = C[i];
                }
            }
            return cnt;
        }
    }
}
//うまくいかない
//namespace C
//{
//    class Program
//    {
//        static public int max = 0;
//        static void Main(string[] args)
//        {
//            string[] In = Console.ReadLine().Split(' ');
//            int n = int.Parse(In[0]);
//            int k = int.Parse(In[1]);
//            char[] C = Console.ReadLine().ToCharArray();
//            ccPoint(C);
//            for(int i=0; i <= n - 2; i++)
//            {
//                var CC = new char[n];
//                Array.Copy(C, CC, n);
//                for(int j = i; j <= n - 1; j++)
//                {
//                    for(int m = i; m <= j; m++)
//                    {
//                        if (C[m] == 'L') C[m] = 'R';
//                        if (C[m] == 'R') C[m] = 'L';
//                        ccPoint(C);
//                    }
//                }
//            }
//            Console.WriteLine(max);
//        }
//        static public void ccPoint(char[] C)//count/check
//        {
//            int sum = 0;
//            for(int i=0; i < C.Length - 1; i++)
//            {
//                if (C[i] == C[i + 1]) sum++;
//            }
//            if (sum > max) max = sum;
//        }
//    }
//}


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

using namespace std;

int main() {
  int x;
  scanf("%d", &x);
  x /= 100;
  printf("ai1333");
  for (int i = 0; i < x; i++) {
    printf("3");
  }
  printf("\n");
  return 0;
}



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

class Dice{
public:
    int number[6];   
    int work[6];

    void setLabel(int index,int num){
        number[index] = num; 
    };

    void roll(char tokn){
        for(int i=0;i<6;i++) work[i] = number[i];
        switch(tokn){
            case 'E':
                setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
                break;
                
            case 'S':
                setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
                break;
                
            case 'N':
                setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
                break;
                
            case 'W':
                setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
                break;
        }
    }
    int returnTop(){
        return number[0];
    }

private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }

};


int main() {
    Dice Dice;
    int label;
    for(int i=0;i<6;i++) {
        cin >> label;
        Dice.setLabel(i,label);
    }
    char tokn;
    tokn = getchar();
    while((tokn = getchar()) != '\n'){
        Dice.roll(tokn);
        // cout << tokn << endl;
    }
    cout << Dice.returnTop() << endl;
    return 0;
}



Measured memory_bytes: 3100
from collections import deque

class Node:
    def __init__(self, val):
        self.val = val
        self.child = []

n = int(input())
g = []
# mst = [[] for _ in range(n)]
# mst = [None for _ in range(n)]

for i in range(n):
    g.append(list(map(int, input().split())))

# print(g)

for i in range(n):
    for j in range(n):
        if g[i][j] == -1:
            g[i][j] = 10**5

mst = Node(0)
# done = set()

def getClosestVertex(done):
    w = 10**10
    closest = None
    for i in done:
        for j in range(len(g[i])):
            if j in done:
                continue
            if g[i][j] < w:
                w = g[i][j]
                closest = j
    return closest, w

done = set()
done.add(0)
ans = 0

while True:
    closest, w = getClosestVertex(done)
    if closest is None:
        break
    else:
        done.add(closest)
        ans += w

print(ans)


Measured memory_bytes: 6096
using System;

namespace B___Unhappy_Hacking__ABC_Edit_
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var ans = "";
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == '1')
                    ans += '1';

                else if (s[i] == '0')
                    ans += '0';

                else if (s[i] == 'B' && ans.Length > 0)
                {
                    ans = ans.Remove (ans.Length - 1, 1);
                }
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vii d(n);
    map<int, int> used;
    rep(i, 0, n) {
      cin >> d[i];
      used[d[i]]++;
    }
    cin >> m;
    vii t(m);
    rep(i, 0, m) cin >> t[i];
    sort(ALL(d));
    sort(ALL(t));
    rep(i, 0, m) {
      int pos = lower_bound(ALL(d), t[i]) - d.begin();
      if (used[d[pos]] <= 0 || d[pos] != t[i]) { 
        cout << "NO" << endl;
        return 0;
      } 
      used[d[pos]]--;
    }
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 11264
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    N, W = map(int, input().split())
    #初期化
    dp = [[inf]*N for _ in range(N)]
    for i in range(N):
        dp[i][i] = 0
    abc = [list(map(int, input().split())) for _ in range(W)]
    for a,b,c in abc:
        dp[a-1][b-1] = c
        dp[b-1][a-1] = c

    #kを経由してiからjに行く行き方を考える
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if dp[i][k]==inf or dp[k][j]==inf:
                    continue
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
    
    res = 0
    for a,b,c in abc:
        for k in range(N):
            if dp[a-1][k] == c + dp[b-1][k]:
                res += 1
                break
    print(W - res)

if __name__ == '__main__':
    main()

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

namespace abc076_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = GetStr();
            var T = GetStr();
            var ri = new List<int>();

            if (S.Length < T.Length)
            {
                Console.WriteLine("UNRESTORABLE");
                return;
            }

            for (int i = 0; i < S.Length - T.Length + 1; i++)
            {
                int c = 0;
                for (int j = 0; j < T.Length; j++)
                    if (S[i + j] == T[j] || S[i + j] == '?')
                        c++;

                if (c == T.Length) 
                    ri.Add(i);
            }

            if (ri.Count == 0) 
            { 
                Console.WriteLine("UNRESTORABLE");
                return;
            }

            var rl = new List<string>();

            foreach (var rii in ri)
            {
                string r = "";
                for (int i = 0; i < S.Length; i++)
                {
                    if (rii == i)
                    {
                        r += T;
                        i += T.Length - 1;
                    }
                    else if (S[i] == '?')
                        r += "a";
                    else
                        r += S[i];
                }
                rl.Add(r);
            }
          
            Console.WriteLine(rl.OrderBy(x => x).First());
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
#define MP make_pair
#define PB emplace_back
#define all(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS;
    int n, k;
    cin >> k >> n;
    vector<int> a(n);
    for (int& x : a) cin >> x;
    int ans = a[n - 1] - a[0];
    for (int i = 1; i < n; i++)
    {
        ans = min(ans, a[i - 1] + k - a[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,t,s=0;
  cin>>n>>t;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  rep(i,n){
    if(b[i]>t){
      a[i]=1000;
      s++;
    }
  }
  sort(a.begin(),a.end());
  if(s!=n){
  cout<<a[0]<<endl;
  }else{
    cout<<"TLE"<<endl;
  }
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  ul n;
  cin>>n;
  string w[2];
  ul sc[2]={0,0};

  for (ul i=0;i<n;i++) {
    cin>>w[0]>>w[1];
    if (w[0]<w[1]) sc[1]+=3;
    else if (w[0]>w[1])sc[0]+=3;
    else sc[0]++,sc[1]++;
  }

  cout<<sc[0]<<" "<<sc[1]<<endl;

  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;

int n,m,a[100005],g,mx;

inline int gcd(int x,int y)
{
	return (x%y==0?y:gcd(y,x%y));
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	g=a[1];
	mx=a[1];
	for (int i=2;i<=n;i++)
	{
		mx=max(mx,a[i]);
		g=gcd(g,a[i]);
	}
	if (m>mx || (m%g!=0)) puts("IMPOSSIBLE"); else puts("POSSIBLE");
	return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

long long int sum(long long int min, long long int max){
	return max*(max + 1)/2 - min*(min - 1)/2;
}

long long int MOD = 1'000'000'007;

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

	long long int ans = 0;
	for(int i = k; i <= n + 1; i++){
		ans += sum(n - i + 1, n) - sum(0, i - 1) + 1;
		// cout << sum(n - i + 1, n) << " " << sum(0, i - 1) << endl;

		ans %= MOD;
		// cout << "ans : " << ans << endl;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3632
//
// Created by Jonny on 2018/7/19.
//
#include <iostream>
using namespace std;
#define Max 2000000000;
struct Card {
    char type;
    int key;
};
Card cardA[100005],cardB[100005];
Card c1[50002],c2[50002];

void merge(Card A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        c1[i] = A[left + i];
    }
    for (int j = 0; j < n2; j++) {
        c2[j] = A[mid + j];
    }
    c1[n1].key = c2[n2].key = Max;
    int l = 0,r = 0;
    for (int k = left; k < right; k++) {
        if (c1[l].key <= c2[r].key) {
            A[k] = c1[l];
            l++;
        } else {
            A[k] = c2[r];
            r++;
        }
    }
}

void mergeSort(Card A[],int left,int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int partition(Card A[],int p,int r) {
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].key <= A[r].key) {
            i++;
            Card x = A[j];
            A[j] = A[i];
            A[i] = x;
        }
    }
    Card x = A[r];
    A[r] = A[i + 1];
    A[i+1] = x;
    return (i+1);
}

void quickSort(Card A[],int p,int r) {
    if (p < r) {
        int q = partition(A,p,r);
        quickSort(A,p,q - 1);
        quickSort(A,q + 1,r);
    }
}
int main() {
    int n,stable = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> cardA[i].type;
        cin >> cardA[i].key;
        cardB[i].key = cardA[i].key;
        cardB[i].type = cardA[i].type;
    }
    mergeSort(cardA,0,n);
    quickSort(cardB,0,n-1);

    for (int j = 0; j < n; j++) {
        if (cardA[j].type != cardB[j].type) {
            stable = 0;
            break;
        }
    }
    if (stable == 1) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    for (int k = 0; k < n; k++) {
        cout << cardB[k].type << " " << cardB[k].key << endl;
    }

    return 0;
}



Measured memory_bytes: 5420
N = gets.to_i
S = gets.chomp.chars
table = ('A'..'Z').map.with_index do |a, i|
  [a, i]
end.to_h
inverted = table.invert
ans = S.map do |ch|
  pos = table[ch]
  pos = (pos + N) % table.size
  inverted[pos]
end
puts ans.join('')


Measured memory_bytes: 2172
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
if(min(a)==0):
    print(0)
else:
    for i in range(1,n):
        ans*=a[i]
        if(ans>10**18):
            print(-1)
            break
    else:
        print(ans)

Measured memory_bytes: 21624
#include <stdio.h>

int main(void)
{
	int a, b, x, y;
	
	scanf("%d %d", &a, &b);
	
	x = a * b;
	y = a * 2 + b * 2;
	
	printf("%d %d\n", x, y);
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <complex>
#include <queue>
#include <deque>
#include <cmath>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
const int INF=1<<30;

int main() {
	// your code goes here
	int x,y;
	pr s,g;
	char tmp;
	while(cin >> x >>y&&x){
	vpr p[5];
	REP(i,y) 
	REP(j,x){
		scanf(" %c",&tmp);
		if(tmp-'1'==-39) continue;
		if(tmp!='.')
			switch(tmp){
				case 'S':
					s=pr(j,i);
					break;
				case 'G':
					g=pr(j,i);
					break;
				default :
					p[tmp-'1'].push_back(pr(j,i));
					break;
			}
	}
	
	int minium[]={INF,INF,INF,INF,INF};
	REP(i,5){
		int DP[5][1000];
		REP(j,5) REP(k,1000) DP[j][k]=INF;
		int v=(i+1)%5;
		REP(j,p[v].size()) DP[v][j]=abs(p[v][j].first-s.first)+abs(s.second-p[v][j].second);

		REP(j,3){
			int c=(i+j+1)%5;
			int ne=(c+1)%5;
			REP(k,p[c].size())
				REP(l,p[ne].size())
					DP[ne][l]=min(DP[ne][l],DP[c][k]+abs(p[c][k].first-p[ne][l].first)+abs(p[c][k].second-p[ne][l].second));
		}
		v=(i+4)%5;
		REP(j,p[v].size()) minium[i]=min(minium[i],DP[v][j]+abs(p[v][j].first-g.first)+abs(p[v][j].second-g.second)); 
	}
	int miniums=0;
	REP(i,5)
		if(minium[miniums]>minium[i])
			miniums=i;
	if(minium[miniums]==INF)
	cout << "NA" << endl;
	else
	cout << miniums+1 << " " <<  minium[miniums] << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except nx.NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))

Measured memory_bytes: 56364
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (long long i = 0; i < (n); i++)
#define rep1(i,n) for (long long i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n, T; cin >> n >> T;
    vector<ll> t(n);
    rep(i,n) { 
        cin >> t[i];
    }
    ll duration = 0;
    rep(i,n-1) {
        duration += min(T, t[i+1] - t[i]);
    }
        
    cout << duration + T << endl;

    return 0;
}



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

using namespace std;

int main(){
    int n;
    while(cin>>n&&n!=EOF){
        int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                for(int l=0;l<10;l++){
                    if(i+j+k+l==n)ans++;
                    }
                }
            }
        }
    cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
R = []
for _ in range(n):
    R.append(int(input()))
M = - 10 ** 9 - 5
m = R[0]
for i in range(1, n):
    M = max(M, R[i] - m)
    m = min(m, R[i])
print(M)


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

int main(){
    int a, b;
    cin >> a >> b;
    int A = 0, B = 0;
    for(int i =0; i < b; i++){
        A = 10*A + a;
    }
    for(int i =0; i < a; i++){
        B = 10*B + b;
    }
    string x, y;
    x = to_string(A);
    y = to_string(B);
    if(x < y) cout << x << endl;
    else cout << y << endl;
}

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

int main()
{
  string s;cin>>s;
  set<char> st;
  for (int i=0;i<4;i++)
    st.insert(s[i]);
  
  if (st.size()==2) cout<<"Yes"<<endl;
  else cout<< "No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

const int D = 60;
V<ll> B(D);

void add(ll x){
    for(int i=D-1;i>=0;i--){
        if(B[i] == 0 && x&1LL<<i){ // add to base
            B[i] = x;
            return;
        }else if(x&1ULL<<i){
            x ^= B[i];
        }
    }
}
bool in(ll x){
    for(int i=D-1;i>=0;i--){
        if(B[i] == 0 && x&1LL<<i){ // add to base
            return false;
        }else if(x&1ULL<<i){
            x ^= B[i];
        }
    }
	return true;
}
int solve(){
	rep(i,D) B[i] = 0;
	int N; cin >> N;
	V<ll> A(N); rep(i,N) cin >> A[i];
	string s; cin >> s;
	per(i,N){
		if(s[i] == '0'){
			add(A[i]);
		}else{
			if(!in(A[i])) return 1;
		}
	}
	return 0;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int T; cin >> T;
	while(T--) cout << solve() << endl;
}


Measured memory_bytes: 3652
def another(t):
    if t == "W":
        return "S"
    else:
        return "W"


def ok(t1, t2, t3, op):
    if (op == "o" and t2 == "S") or (op == "x" and t2 == "W"):
        return t1 == t3
    else:
        return t1 != t3

def check(ans):
    for i in range(n - 2):
        c = s[i]
        t = ans[i]
        if (c == "o" and t == "S") or (c == "x" and t == "W"):
            ans[i + 1] = ans[i - 1]
        else:
            ans[i + 1] = another(ans[i - 1])
    t1, t2, t3, t4 = ans[-3], ans[-2], ans[-1], ans[0]
    return ok(t1, t2, t3, s[-2]) and ok(t2, t3, t4, s[-1])

n = int(input())
s = input()

for head, tail in (("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")):
    ans = [""] * n
    ans[0] = head
    ans[-1] = tail
    if check(ans):
        print(*ans, sep="")
        break
else:
    print(-1)


Measured memory_bytes: 7632
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))


Measured memory_bytes: 25148
#include <bits/stdc++.h>
#include <vector>3
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main(){
init();
long long k,a,b;
cin>>k>>a>>b;
for(int i=a;i<=b;i++){
if(i%k==0){
    cout<<"OK";
    return 0;
}}
 cout<<"NG";
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    int ans=0, cu=0;
    for(int i=1;i<n;i++){
        if(h[i]<=h[i-1])cu++;
        else{
            ans=max(ans,cu);
            cu=0;
        }
    }
    ans=max(ans,cu);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    int A,B;
    ll sum = 0;
    ll ans = INF;
    rep1(i,N) {
        sum = 0;
        A = i;
        B = N - i;

        while(A){
            int dig = A % 10;
            sum += dig;
            A = A / 10;
        }
        while(B){
            int dig = B % 10;
            sum += dig;
            B = B / 10;
        }
        ans = min(ans, sum);
    }
    cout << ans << 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;
string s;

int main(){
	cin>>n>>s;
	s+='#';
	int a=0,res=inf;
	for(int i=0;i<=n;i++) if(s[i]=='#') a++;
	for(int i=n;i>=0;i--){
		if(s[i]=='#') a--;
		else a++;
		res=min(res,a);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String str = scan.next();
		
		if (str.substring(0, n / 2).equals(str.substring(n / 2, n))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		scan.close();
	}
}

Measured memory_bytes: 21716
import math

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

l, r = 0, max(A)
while r - l > 1:
    x = (l + r) // 2
    cnt = 0
    for a in A:
        n = math.ceil(a / x)
        # n = (a + x - 1) // x
        cnt += n - 1
    if cnt > K:
        l = x 
    else:
        r = x

print(r)


Measured memory_bytes: 104464
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct sta{
    int a;
    int b;
};

int main(){
    CFS;
    int x, y, z, n, m, s, t;
    cin >> x >> y >> z >> n >> m >> s >> t;
    s--, t--;
    t += n;
    vector<sta> f(n + m);
    mti sand(x + z), katu(y);
    int a, b;
    rep(i, n){
        cin >> f[i].a >> f[i].b;
        f[i].a--, f[i].b--;
        sand[f[i].a].push_back(i);
        katu[f[i].b].push_back(i);
    }
    repl(i, n, n + m){
        cin >> f[i].b >> f[i].a;
        f[i].a--, f[i].b--;
        f[i].a += x;
        sand[f[i].a].push_back(i);
        katu[f[i].b].push_back(i);
    }
    vi dist(n + m, -1);
    queue<int> q;
    q.push(s);
    dist[s] = 0;
    vi fs(x + z, false), fk(y, false);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        if(!fs[f[now].a]){
            for(int nx:sand[f[now].a]){
                if(dist[nx] == -1){
                    dist[nx] = dist[now] + 1;
                    q.push(nx);
                }
            }
            fs[f[now].a]=true;
        }
        if(!fk[f[now].b]){
            for(int nx:katu[f[now].b]){
                if(dist[nx] == -1){
                    dist[nx] = dist[now] + 1;
                    q.push(nx);
                }
            }
            fk[f[now].b]=true;
        }
    }
    cout << dist[t] << endl;
    return 0;
}


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

int main()
{
  const int INF = 1e+9;

  int n, h;
  cin >> n >> h;

  int maxa = -INF, b[100000];
  for(int i = 0; i < n; i++){
    int a;
    cin >> a >> b[i];
    maxa = max(maxa, a);
  }

  sort(b, b+n, greater<int>());

  int i = 0, ans = 0;;
  while(b[i] > maxa && i < n){
    h -= b[i++];
    ans++;
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }

  ans += (h + maxa - 1) / maxa;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    char s[10];
    while (scanf("%s",&s)!=EOF) {
        if  (s[2]==s[3] && s[4]==s[5])
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


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

    int tmp = 0, i = 1;
    while (tmp < n){
        tmp += i;
        i++;
    }
    int no = tmp - n;

    for(int j = 1; j < i; j++) if (j != no) cout << j << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc042/tasks/abc042_a
 */
public class Main {

	public static void main(String[] args) {
		
		int[] a = new int[11];
		Scanner sc = new Scanner(System.in);
		a[sc.nextInt()]++;
		a[sc.nextInt()]++;
		a[sc.nextInt()]++;
		sc.close();
		
		String ans = "NO";
		if(a[5]==2 && a[7]==1){
			ans = "YES";
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23892