akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var S = GetStr().ToCharArray();
            var SS = S.Distinct().ToArray();
            var ans = S.Length == SS.Length ? "yes" : "no";

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13152
#include<stdio.h>
int main(){
   int N;
   scanf("%d",&N);

   if(N%10==2 ||N%10==4 ||N%10==5 ||N%10==7 ||N%10==9){
      printf("%s\n","hon");
   }else if(N%10==0 || N%10==1 ||N%10==6 ||N%10==8){
      printf("%s\n","pon");
   }else if(N%10==3){
      printf("%s\n","bon");
   }
   
   return 0;
}


Measured memory_bytes: 1660
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC040 A
"""

ali = list(input())

zeroflag = False
lastflag = False

if ali[0] == '<':
    ali.insert(0, '>')
    zeroflag = True
if ali[-1] == '>':
    ali.append('<')
    lastflag = True

itop = []
ibtm = []
# print(ali)

for (i, x) in enumerate(ali[:-1]):
    # print(i)
    if x == '>' and ali[i+1] == '<':
        ibtm.append(i+1)
    if x == '<' and ali[i+1] == '>':
        itop.append(i+1)
itop.append(len(ali))

# print(itop)
# print(ibtm)

s = 0
nowtop = 0
toplheight = [-10]
toprheight = []

for l in range(len(itop)):
    nexttop = itop[l]
    nowbtm = ibtm[l]
    lint = nowbtm - nowtop - 1
    rint = nexttop - nowbtm - 1
    s += (lint)*(lint+1)//2
    s += (rint)*(rint+1)//2
    toprheight.append(lint)
    toplheight.append(rint)
    # print('l',l)
    # print('s',s)
    nowtop = nexttop

toprheight.append(-10)

if zeroflag:
    del toplheight[0]
    del toprheight[0]
if lastflag:
    toplheight.pop()
    toprheight.pop()

while toplheight:
    left = toplheight.pop()
    right = toprheight.pop()
    s += max(left, right)+1

print(s)



Measured memory_bytes: 21512
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int N;
string S;
int main()
{
  int i;
  cin >> N >> S;
  if (N%2) {
    printf("No\n");
    return 0;
  }
  for (i=0; i<N/2; i++) {
    if (S[i] != S[i+N/2]) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

long long N, X;

int main() {
	scanf("%lld%lld", &N, &X);

	long long sum = N;

	long long r = max(X, N-X);
	long long c = min(X, N-X);

	while (c) {
		long long t = r / c;
		long long tt = c;
		sum += t*c==r ? c*(t*2-1) : c*t*2;
		c = r % c;
		r = tt;
	}

	printf("%lld\n", sum);

	return 0;
}


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

namespace ABC138D
{
    class Program
    {
        static List<List<int>> ki;
        static int[] ans;
        static void Main(string[] args)
        {
            string[] NQ = Console.ReadLine().Split(' ');
            int N = int.Parse(NQ[0]);
            int Q = int.Parse(NQ[1]);
            int[] a = new int[N - 1];
            int[] b = new int[N - 1];
            int[] p = new int[Q];
            int[] x = new int[Q];
            ki = new List<List<int>>();
            for(int i = 0; i < N; i++)
            {
                ki.Add(new List<int>());
            }
            for (int i = 0; i < N - 1; i++)
            {
                string[] ab = Console.ReadLine().Split(' ');
                a[i] = int.Parse(ab[0]);
                b[i] = int.Parse(ab[1]);
                ki[a[i] - 1].Add(b[i]);
                ki[b[i] - 1].Add(a[i]);
            }
            int[] plus = new int[N];
            for (int i = 0; i < Q; i++)
            {
                string[] px = Console.ReadLine().Split(' ');
                p[i] = int.Parse(px[0]);
                x[i] = int.Parse(px[1]);
                plus[p[i] - 1] += x[i];
            }
            //Console.WriteLine(string.Join(" ", ki[1]));
            ans = new int[N];
            Queue<int> q = new Queue<int>();
            q.Enqueue(1);
            q.Enqueue(0);
            q.Enqueue(0);
            tansaku(q, plus);
            Console.WriteLine(string.Join(" ", ans));
        }
        static void tansaku(Queue<int> q, int[] plus)
        {
            if (q.Count == 0)
            {
                return;
            }
            else
            {
                int num = q.Dequeue();
                int oya = q.Dequeue();
                int count = q.Dequeue();
                int l = ki[num - 1].Count;
                ans[num - 1] = count + plus[num - 1];
                for (int i = 0; i < l; i++)
                {
                    if (ki[num - 1][i] != oya)
                    {
                        q.Enqueue(ki[num - 1][i]);
                        q.Enqueue(num);
                        q.Enqueue(ans[num - 1]);
                    }
                }
                tansaku(q, plus);
            }
        }
    }
}


Measured memory_bytes: 91352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	string s;
	cin >> s;
	if (s.back() == 's') s += "es";
	else s += "s";
	cout << s << '\n';
}

Measured memory_bytes: 3620
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	static final int ROW = 0;
	static final int COLUMN = 1;
	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[][] matrix = new int[n + 1][2];

		for(int i = 1; i < n + 1 ; i++){
			String[] tmpArray = br.readLine().split(" ");
			matrix[i][ROW] = Integer.parseInt(tmpArray[ROW]);
			matrix[i][COLUMN] = Integer.parseInt(tmpArray[COLUMN]);
		}
		
		int[][] DPResult = new int[n + 1][n + 1];
		for(int i = 0 ; i < n + 1; i++){
			Arrays.fill(DPResult[i], 0);
		}
		
		//DP??§?¨??????§????????°????????????
		for(int i = 1; i <= n ; i++){
			for(int j = 1; j <= n - i ;j++){
				int currentI = j;
				int currentJ = i + j;
				if( currentI + 1 == currentJ ){
					//DPResult[i][j] = matrix[j][ROW]*matrix[j][COLUMN]*matrix[j + 1][COLUMN];
					DPResult[currentI][currentJ] = matrix[currentI][ROW] * matrix[currentI][COLUMN] * matrix[currentI + 1][COLUMN];
				}
				else {
					int tmpResult = Integer.MAX_VALUE;
					
					for(int k = currentI ; k < currentJ ; k++){
						int tmp;
						//System.out.println("I "+currentI+" J"+currentJ+" k"+k);
						tmp = DPResult[currentI][k] + DPResult[k+1][currentJ] 
								+ matrix[currentI][ROW]*matrix[k][COLUMN]*matrix[currentJ][COLUMN];
						if(tmp < tmpResult){
							tmpResult = tmp;
						}
						
						DPResult[j][j+i] = tmpResult;
					}
					
				}
			}
			
		}
		
		//TEST PRINT
		/*
		for(int i = 1; i <= n ; i++){
			for(int j = 1; j <= n ;j++){
				System.out.print(DPResult[i][j] + " ");
			}
			System.out.println();
		}*/
		System.out.println(DPResult[1][n]);
	}

}

Measured memory_bytes: 24520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N;
	cin >> N;
	set<char> S;
	for(int i = 0; i < N; i++){
		char s;
		cin >> s;
		S.insert(s);
	}
	int X = S.size();
	cout << ((X == 3) ? "Three" : "Four") << endl;
}


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

using namespace std;

int main(void)
{
    int n;
    vector<int> a;
    bool flag = true;

    cin>>n;

    for(int i = 0;i < n;i++) {
	int temp;
	
	cin>>temp;

	if(flag)
	    a.insert(a.begin(),temp);
	else
	    a.insert(a.end(),temp);

	flag = !flag;
    }

    if(n % 2 == 0)
	for(int i = n;i > 0;i--)
	    cout<<a[i-1]<<" ";
    else
	for(int i = 0;i < n;i++)
	    cout<<a[i]<<" ";

    return 0;
}


Measured memory_bytes: 3188
n, p = map(int, input().split())
A = [int(i) for i in input().split()]

odd = 0
even = 0
for i in range(n):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1
        
if odd == 0:
    if p == 0:
        print(2 ** n)
    else:
        print(0)
else:
    print(2 **(n - 1))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000

using namespace std;

int prime[MAX];

int main()
{
	prime[0] = prime[1] = 0;

	REP(i,2,MAX)
	{
		prime[i] = 1;
	}

	REP(i,2,MAX)
	{
		if(prime[i])
		{
			for(int j = i*2;j < MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	int n;

	while(cin >> n)
	{
		for(int i= n-1;i > 0;i--)
		{
			if(prime[i] == 1) 
			{
				cout << i << " ";
				break;
			}
		}
		for(int i = n+1; i < MAX;i++)
		{
			if(prime[i] == 1) 
			{
				cout << i << endl;
				break;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 5064
#include<stdio.h>
int main() {
	int R;
	scanf("%d", &R);
	if (R >= 2800) {
		printf("AGC\n");
	}
	else if(R>=1200){
		printf("ARC\n");
	}
	else {
		printf("ABC\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int A,B,K;
   cin>>A>>B>>K;
   vector<int>vec(min(A,B));
   int i=0;
  for(int ans=min(A,B);ans>0;ans--){
   if(A%ans==0){
     if(B%ans==0){
       vec[i]=ans;
       i++;
       }
     }
    }
   cout<<vec[K-1]<<endl;
   return 0;
   }

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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    string s, t;
    cin >> s >> t;
    reg int Ans = 0;
    for (reg int i = 0; i < (int)s.size(); i++)
        if (s[i] == t[i]) Ans++;
    cout << Ans << endl;
    return 0;
}

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

int main() {
    int n,t;
    cin>>n>>t;
    int ans=1e9;
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a>>b;
        if(b<=t){
            ans=min(ans,a);
        }
    }
    if(ans==1e9)cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin>>s;

    rep(i,s.length())if(s[i] == ',')s[i]=' '; 
	cout<<s<<endl;
  
    return 0;
}


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

int main(){
    map<pair<ll,ll> , int> m;
    int N; cin >> N;
    int MAX = 1;
    if(N == 1) cout << 1 << endl;
    else{
        vector<pair<ll, ll> > pairs(N);
        for(int i = 0; i < N; i++){
            ll x, y; cin >> x >> y;
            pairs[i] = make_pair(x,y);
        }
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if( i == j) continue;
                ll dx = pairs[i].first - pairs[j].first;
                ll dy = pairs[i].second - pairs[j].second;
                auto ite = m.find(make_pair(dx,dy));
                if(ite == m.end()){
                    m[make_pair(dx,dy)] = 1;
                }else{
                    m[ite->first]++;
                    MAX = max(ite->second,MAX);
                }
            }
        }
        cout << N - MAX << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    if(a+b>=c)cout<<b+c<<endl;
    else cout<<b+a+b+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    LL n, m;
    cin >> n >> m;
    VPLL p(m), pp(m);
    REP(i,m)
    {
        cin >> p[i].first >> p[i].second;
        pp[i].first = p[i].first;
        pp[i].second = p[i].second;
    }

    map<string, LL> mp;

    sort(p.begin(), p.end());
    LL tmp = p[0].first, rank = 1;
    REP(i,m)
    {
        if (p[i].first!=tmp) rank = 1, tmp = p[i].first;
        //cout << p[i].first << " " << p[i].second << endl;
        string title = to_string(p[i].first) + to_string(p[i].second);
        mp[title] = rank;
        rank++;
    }

    REP(i,m)
    {
        string title = to_string(pp[i].first) + to_string(pp[i].second);
        cout << setfill('0') << right << setw(6) << pp[i].first;
        cout << setfill('0') << right << setw(6) << mp[title];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 14328
#include<cstdio>

char str[20];
int date[11][10];

int main()
{
	while(scanf("%s",str)!=EOF)
	{
		for(int i=0;i<10;i++)
		{
			date[0][i]=str[i]-'0';
		}
		for(int i=1;i<10;i++)
		{
			for(int j=0;j<10-i;j++)
			{
				date[i][j]=date[i-1][j]+date[i-1][j+1];
			}
		}
		printf("%d\n",date[9][0]%10);
	}
	return 0;
}

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 300007

int N, M;
int f[MAX_N], g[MAX_N];
char s[MAX_N];

int main() {
    read(N), read(M);
    scanf("%s", s + 1);
    bool vis = false;
    int len = 0, mn = N;
    Rep(i, M) {
        if (s[i] != s[1]) {
            if (!vis || (len & 1)) chmin(mn, len / 2 + 1);
            vis = true, len = 0;
        } else
            ++len;
    }
    // printf("%d\n", len);
    if (!vis) {
        int a = 0, b = 1;
        Lep(i, N) {
            std::swap(a, b);
            inc(b, a);
        }
        printf("%d\n", add(mul(a, 2), b));
        return 0;
    }
    if (N & 1) return puts("0"), 0;
    N >>= 1;
    f[0] = g[0] = 1;
    Rep(i, N) {
        f[i] = g[i - 1];
        if (i > mn) inc(f[i], MOD - g[i - mn - 1]);
        // printf("%d %d %d\n", i, g[i - 1], f[i]);
        g[i] = add(f[i], g[i - 1]);
    }
    int res = 0;
    Rep(i, mn) inc(res, mul(mul(i, 2), f[N - i]));
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int n, m, Q;
int G[2002][2002];
int sum[2002][2002];
int cnt[2002][2002];
int e1[2002][2002], e2[2002][2002];
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> Q;
    string s;
    for(int i = 1; i <= n; i++){
        cin >> s;
        for(int j = 1; j <= m; j++){
            G[i][j] = s[j-1] == '0' ? 0 : 1;
            cnt[i][j] = G[i][j] + cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1];
        }
    }   
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++){
            e1[i][j] = e1[i][j-1] + (G[i][j] & G[i-1][j]);
        }
    for(int j = 1; j <= m; j++)
        for(int i = 1; i <= n; i++){
            e2[i][j] = e2[i-1][j] + (G[i][j] &G[i][j-1]);
        }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++){
            if(G[i][j] == 1 && G[i-1][j] == 1) sum[i][j]++;
            if(G[i][j-1] == 1 && G[i][j] == 1) sum[i][j]++;
            sum[i][j] += sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1];
        }

    int x1,x2,y1,y2;
    for(int q = 1; q <= Q; q++){
        cin >> x1 >> y1 >> x2 >> y2;
        if(x1 > x2) swap(x1, x2);
        if(y1 > y2) swap(y1, y2);
        int e = sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1] -(e1[x1][y2] - e1[x1][y1-1]) - (e2[x2][y1] - e2[x1-1][y1]);
        int v = cnt[x2][y2]-cnt[x1-1][y2]-cnt[x2][y1-1]+cnt[x1-1][y1-1];
//        cout << v << " "<< e<< endl;
        cout << v-e << endl;
    }
     return 0;
}

Measured memory_bytes: 80128
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int pmin = Integer.MAX_VALUE;
	int jmin = Integer.MAX_VALUE;
	for(int i=0; i<3; i++){
	    int p = sc.nextInt();
	    if(p<pmin)pmin = p;
	}
	for(int i=0; i<2; i++){
	    int j = sc.nextInt();
	    if(j<jmin)jmin = j;
	}

	System.out.println(pmin+jmin-50);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
#define MAX_HP 1000000000

int main(void)
{
    int A,B,C;

    std::cin >> A >> B >> C;

    if( A== B && B == C && C == A ){

        std::cout << "No";
        return 0;
    }
    if( A != B && B != C && C != A ){

        std::cout << "No";
        return 0;
    }

    std::cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#define _USE_MATH_DEFINES
#define LL long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

int smax(int *ary) {
	int m = 0;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (m < ary[i]) m = ary[i];
	return m;
}

int nmax(int *ary) {
	int max = 0, num;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) {
			max = ary[i];
			num = i;
		}
	return max, num;
}

int main() {
	int a, b, c, a1, b1;
	cin >> a >> b >> c;
	if (a <= b) {
		a1 = a;
		b1 = MIN(b, c);
	}
	else {
		a1 = b;
		b1 = MIN(a, c);
	}
	cout << a1 + b1 << endl;
	return 0;
}



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

int main() {
  int a,b,c,d,e,x=10,y,z,Ans;
  cin >> a >>b >>c >>d >>e;
  
  if(x>a%10 && a%10 != 0) {
    x = a%10;
  }
  if(x>b%10 && b%10 != 0) {
    x = b%10;
  }
  if(x>c%10 && c%10 != 0) {
    x = c%10;
  }
  if(x>d%10 && d%10 != 0) {
    x = d%10;
  }
  if(x>e%10 && e%10 != 0) {
    x = e%10;
  }
  if(e%10 == 0){
    z += 1;
  }
  if(a%10 == 0){
    z += 1;
  }

  if(b%10 == 0){
    z += 1;
  }

  if(c%10 == 0){
    z += 1;
  }

  if(d%10 == 0){
    z += 1;
  }


  y = a/10 + b/10 + c/10 + d/10 + e/10;
  Ans = y*10 +40 - z*10 +x;
  cout<< Ans << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll BIG_MOD = ll(1e9)+7;
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = BIG_MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= BIG_MOD;
	if (u < 0) { u += BIG_MOD; }
	return u;
}
// 順列
ll permutation(ll n, ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) {
		result = (result * i) % BIG_MOD;
	}
	return result;
}
// 組み合わせ
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % BIG_MOD;
	}
	return (p * modinv(div)) % BIG_MOD;
}

int main() {
	int X, Y;
	cin >> X >> Y;

	ll n = (X + Y) / 3;
	ll m = (2 * X - Y) / 3;

	if (X != n + m || Y != 2 * n - m || 0 > n || 0 > m || m > n) {
		cout << 0 << endl;
		return 0;
	}

	cout << (combination(n, m)) << endl;
  return 0;
}


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

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

  if(X == 7 || X == 5 || X ==3){
      cout << "YES" << endl;
  }else{
      cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<int,double> pdd;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}
map<string,int> M;
int t[100];

int32_t main(){
	fastio;
	int n;
	cin>>n;
	string s;
	for(int i=1;i<=n;i++){
		cin>>s>>t[i];
		M[s] = i; 
	}
	cin>>s;
	int res=0;
	for(int j=M[s]+1;j<=n;j++){
		res+=t[j];
	}
	cout<<res<<endl;
	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    ll h,ans=0;
    scanf("%lld",&h);
    if(h==1)
        ans=1;
    else
    {
        ll cnt=1;
        ans=1;
        while(h>1)
        {
            h=h/2;
            cnt=cnt*2;
            ans=ans+cnt;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 444;
int uf[maxn], has[maxn];
int in[maxn], out[maxn];
int find(int x){
	if(x == uf[x]) return x;
	return uf[x] = find(uf[x]);
}
int main(){
	iota(uf, uf + maxn, 0);
	int n, h; cin >> n >> h;
	for(int i = 0; i < n; i++){
		int a, b, c, d; cin >> a >> b >> c >> d;
		int x = (c == 0) ? (a + 200) : c;
		int y = (d == 0) ? b : (d + 200);
		out[x]++;
		in[y]++;
		uf[find(x)] = find(y);		
	}
	for(int i = 1; i <= h; i++){
		if(out[i] > in[i]) return !printf("NO\n");
		if(in[i] > out[i]) has[find(i)] = 1;
	}
	for(int i = 200 + 1; i <= 200 + h; i++){
		if(in[i] > out[i]) return !printf("NO\n");
		if(in[i] < out[i]) has[find(i)] = 1;
	}
	for(int i = 1; i <= h; i++){
		if((in[i] || out[i]) && !has[find(i)]) return !printf("NO\n");
		if((in[200+i] || out[200+i]) && !has[find(200+i)]) return !printf("NO\n");
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{

	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int syurui=0,max_omosa=0;		// 品物のの種類と入れられる最大の重さ
		int[] weight,value;
		int[][] dp;

		try {
			str=bfr.readLine();
			if(str.equals("")) {
				System.exit(0);
			}
			else {
				stk=new StringTokenizer(str," ");
				syurui=Integer.parseInt(stk.nextToken());
				max_omosa=Integer.parseInt(stk.nextToken());
				weight=new int[syurui+1];
				value=new int[syurui+1];
				dp=new int[syurui+1][max_omosa+1];


				for(int i=0; i<syurui; i++) {
					str=bfr.readLine();
					stk=new StringTokenizer(str," ");
					value[i+1]=Integer.parseInt(stk.nextToken());
					weight[i+1]=Integer.parseInt(stk.nextToken());

				}

				for(int i=1; i<syurui+1; i++) {
					for(int j=1; j<max_omosa+1; j++) {
						if(j<weight[i]) {
							dp[i][j]=dp[i-1][j];
						}
						else {
							dp[i][j]=Math.max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
						}
					}
				}
				System.out.println(dp[syurui][max_omosa]);
			}
		}catch(IOException e) {

		}
	}
}


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

using namespace std;

const int MAX_N = 100000;
const int NF = -1; // not find

int N, L;
int Is[MAX_N + 2];
int Tm[MAX_N + 2];

int search ( int i )
{
	if (Tm[i] != NF) {
		return Tm[i];
	}
	int mx = 0;
	if (Is[i+1] > Is[i]) {
		mx = max(mx, search(i+1));
	}
	if (Is[i-1] > Is[i]) {
		mx = max(mx, search(i-1));
	}
	return Tm[i] = L - Is[i] + mx;
}

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

	while (cin >> N >> L) {
		fill(Is, Is+MAX_N+2, 0);
		fill(Tm, Tm+MAX_N+2, NF);
		for (int i = 0; i < N; ++i) {
			cin >> Is[i+1];
		}

		int mx = 0;
		for (int i = 0; i < N; ++i) {
			mx = max(mx, search(i+1));
		}

		cout << mx << endl;
	}

	return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k;
int ra[1001];
vector<int> vec;

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) cin >> ra[i + 1];
	rep(i, n) ra[i + 1] += ra[i];
	
	rep(i, n) {
		for (j = i + 1; j <= n; j++) {
			vec.push_back(ra[j] - ra[i]);
		}
	}
	sort(vec.begin(), vec.end());
	
	int offset = 0;
	int ans = 0;
	for (i = 39; i >= 0; i--) {
		for (j = offset; j < vec.size(); j++) {
			if ((vec[j] >> i) & 1) {
				break;
			}
		}
		int cnt = (int)vec.size() - j;
		if (cnt >= k) {
			ans += (1LL << i);
			offset = j;
		}
		
		for (j = offset; j < vec.size(); j++) {
			if ((vec[j] >> i) & 1) {
				vec[j] -= (1LL << i);
			}
		}
		sort(vec.begin() + offset, vec.end());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

DX = [-1,0,1,0]
DY = [0,1,0,-1]
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            count = 0
            for dx,dy in zip(DX, DY):
                if H-1>=h-dy >= 0 and W-1>=w-dx >= 0 and S[h-dy][w-dx] == ".":
                    count += 1
            if count == 4:
                print("No")
                exit()
print("Yes")

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

ans = 0
for i in range(n):
  ans += min((a[i]+a[i+1]), b[i])
  a[i+1] = max(0, a[i+1] - max(0, b[i]-a[i]))
print(ans)

Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

int main () {
  int n, r;
  int m = -1;
  int res = - 1e9;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> r;
    if(i == 0) {
      m = r;
      continue;
    }
    res = max(res, r - m);
    m = min(r, m);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3088
ABC = list(map(int, input().split()))
ABC.sort()
cnt = 0
while not ABC[0] == ABC[1] == ABC[2]:
    ABC.sort()
    if ABC[2] - ABC[0] > 1:
        ABC[0] += 2
        cnt += 1
    else:
        if ABC[0] == ABC[1]:
            ABC[0] += 1
            ABC[1] += 1
            cnt += 1
        else:
            ABC[1] += 1
            ABC[2] += 1
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll mod=1e9+7;
const ll maxs=1e6+6;
ll max2d=1e3+3;
ll INF = 9e18;

int main(){
    rapido;
    ll n;
    cin>>n;
    vll GCD;
    ll sum = 0;
    for(ll i=1; i<=n; i++)
        for(ll j=1; j<=n; j++)
            for(ll k=1; k<=n; k++)
                sum += __gcd(i, __gcd(j,k));
    cout<<sum<<"\n";
    return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, k - q);
  rep(i, q) {
    int a;
    cin >> a;
    a--;
    p[a]++;
  }
  rep(i, n) {
    if (p[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
def dfs():
    tt = 0
    for u in range(N):
        if colors[u] == WHITE:
            tt = dfs_visit(u, tt)

def dfs_visit(u, tt):
    tt += 1
    colors[u] = GLAY
    d[u] = tt
    for v in range(N):
        if adjacency_list[u][v] == 1 and colors[v] == WHITE:
            tt = dfs_visit(v, tt)
    tt += 1
    colors[u] = BLACK
    f[u] = tt
    return tt


N = int(input())
adjacency_list = [[0 for j in range(N)] for i in range(N)]
for _ in range(N):
    u, k, *v = map(int, input().split())
    for i in v:
        adjacency_list[u-1][i-1] = 1

WHITE = 0
GLAY = 1
BLACK = 2
colors = [WHITE for _ in range(N)]
d = [0 for _ in range(N)]
f = [0 for _ in range(N)]

dfs()

for i in range(N):
    print("{} {} {}".format(i+1, d[i], f[i]))


Measured memory_bytes: 5764
import warnings


n = 0
i = 0
while (n == 0): 

	i = i + 1

	data = map(int, raw_input().split())
	x = data[0]
	y = data[1]

	if(x == 0 and y == 0):
		break
	else:
		if x > y:
			print "%s %s" % (y, x)
		else:
			print "%s %s" % (x, y)

Measured memory_bytes: 4208
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char name[1000];
    char es[] = "es";
    char s[] = "s";
    scanf("%s", name);
    
//    printf("%s\n", name);
//    
//    printf( "文字列長 %lu\n", strlen(name) );
  
    if(name[strlen(name)-1]=='s'){
        // 文字列の連結
        strcat(name, es);
        printf("%s\n", name);
    }else{
        // 文字列の連結
        strcat(name, s);
        printf("%s\n", name);
    }
    
    return 0;
}


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

int main(void){

  int l,a,b,c,d,res1,res2;

  cin >> l >> a >> b >> c >> d;

  res1 = a / c;
  res2 = b / d;

  if(a % c != 0) res1++;
  if(b % d != 0) res2++;

  l -= max(res1,res2);

  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3076
from sys import stdin
s = "A" + stdin.readline().rstrip()
AZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = 0
for i in range(1,len(s)):
    if AZ.find(s[i]) <= AZ.find(s[i-1]):
        ans += 1
print(ans)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int sum[110];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, w[110];
	cin>>n;
	REP(i, n){
		cin>>w[i];
		sum[i+1]=sum[i]+w[i];
	}
	int ans=1e9;
	REP(i, n-1){
		CHMIN(ans, abs(sum[i+1]-(sum[n]-sum[i+1])));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> P;
typedef pair<ll,pair<ll,ll>> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int main(){
    bool flag=true;
    int H,W,N,sr,sc,l,r,u,d;
    cin>>H>>W>>N;
    cin>>sr>>sc;
    string S,T;
    cin>>S>>T;

    l=1; r=W; u=1; d=H;
    for(int i=N-1;i>=0;i--){
        if(T[i]=='U'){
            d=min(d+1,H);
        }else if(T[i]=='D'){
            u=max(1,u-1);
        }else if(T[i]=='L'){
            r=min(r+1,W);
        }else l=max(1,l-1);

        if(S[i]=='U'){
            u++;
            if(u>d) flag=false;
        }else if(S[i]=='D'){
            d--;
            if(d<u) flag=false;
        }else if(S[i]=='L'){
            l++;
            if(l>r) flag=false;
        }else{
            r--;
            if(r<l) flag=false;
        }
    }
    if(flag && l<=sc && sc<=r && u<=sr && sr<=d)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
int par[200010],rankh[200010],size[200010];
void init(int n) {
	for(int i=0; i<=n;i++){
		par[i]=i;
		rankh[i]=0;
		size[i]=1;
	}
}
int find(int x){
	if(par[x]==x)return x;
	else return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(rankh[x]<rankh[y]){
		par[x]=y;
		size[y]+=size[x];
	}
	else{
		par[y]=x;
		if(rankh[x]==rankh[y])rankh[x]++;
		size[x]+=size[y];
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
int n,a[200010],b[200010];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		b[a[i]]=i;
	}
	init(n);
	int ans=0;
	for(int i=n;i>=1;i--){
		if(b[i]==n-1){
			if(a[n-2]>i)ans+=(size[find(n-2)]+1)*i;
			else ans+=i;
		}
		else if(b[i]==0){
			if(a[1]>i)ans+=(size[find(1)]+1)*i;
			else ans+=i;
		}
		else{
			if(a[b[i]-1]>i&&i<a[b[i]+1])ans+=(size[find(b[i]-1)]+1)*(size[find(b[i]+1)]+1)*i;
			else if(a[b[i]-1]>i)ans+=(size[find(b[i]-1)]+1)*i;
			else if(i<a[b[i]+1])ans+=(size[find(b[i]+1)]+1)*i;
			else ans+=i;
		}
		if(a[b[i]-1]>i)unite(b[i]-1,b[i]);
		if(i<a[b[i]+1])unite(b[i],b[i]+1);
	}
	cout<<ans<<endl;
	ggr;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;


	return 0;
}


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

int K, S;

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

    cin >> K >> S;

    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S-x-y;
            if (0 <= z && z <= K) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

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


	int N = getint();
	int s1 = 0;
	ll kotae1 = 0;
	int s2 = 0;
	ll kotae2 = 0;
	int a = 0;
	rep(i, N / 2) {
		a = getint();
		s1 += a;
		s2 += a;
		if (s1 <= 0) {
			kotae1 += 1 - s1;
			s1 = 1;
		}
		if (s2 >= 0) {
			kotae2 += s2 + 1;
			s2 = -1;
		}
		a = getint();
		s1 += a;
		s2 += a;
		if (s2 <= 0) {
			kotae2 += 1 - s2;
			s2 = 1;
		}
		if (s1 >= 0) {
			kotae1 += s1 + 1;
			s1 = -1;
		}
	}
	if (N & 1) {
		a = getint();
		s1 += a;
		s2 += a;
		if (s1 <= 0) {
			kotae1 += 1 - s1;
			s1 = 1;
		}
		if (s2 >= 0) {
			kotae2 += s2 + 1;
			s2 = -1;
		}
	}
	printf("%lld", min(kotae1, kotae2));

	Would you please return 0;
}

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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int n,k;
    cin>>n>>k;
    multiset<int> s;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        s.insert(temp);
    }
    if(k>=n)
    cout<<"0";
    else{
    while(k--)
    {
        s.erase(--s.end());
    }
    ll sum=0;
    for(auto i:s)
    {
        sum+=i;
    }
    cout<<sum;
    }  

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 13044
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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








int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> p(n);
    REP(i, n){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    vector<bool> used(n);
    ll ans = 0;
    bool ok = true;
    while(ok){
        ok = false;
        REP(i, n && !ok){
            if(!used[i] && p[i] <= a){
                for(ll j = i + 1; j < n && !ok; j++){
                    if(!used[j] && p[j] > a && p[j] <= b){
                        for(ll k = j + 1; k < n && !ok; k++){
                            if(!used[k] && p[k] > b){
                                used[i] = used[j] = used[k] = true;
                                ok = true;
                                ans++;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

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

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

    int ans = 0;
    int active = 0;
    for(int i = 0; i < n; i++){
        if(active >= h[i]);
        else ans += h[i] - active;
        active = h[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define MAX 200

int main(void) {
    char First[MAX];
    char Copy1[MAX];
    char Copy2[MAX];
    int m, h, length;
    char str;

    while(1) {
      scanf("%s", First);

      if(strcmp(First, "-") == 0) {
        break;
      }

      scanf("%d", &m);

      length = strlen(First);
      for(int i=0; i<m; ++i) {
        scanf("%d", &h);
        strncpy(Copy1, First, h);
        strncpy(Copy2, &First[h], length-h);
        strncpy(First, Copy2, length-h);
        strncpy(&First[length-h], Copy1, h);
      }

      printf("%s\n", First);

    }
}



Measured memory_bytes: 2116