akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var O = cin.ReadLine;
            var E = cin.ReadLine;

            long OLen = O.Length;
            long ELen = E.Length;
            char[] OChrAry = O.ToCharArray();
            char[] EChrAry = E.ToCharArray();

            long diff = OLen - ELen;

            if(diff == 1){
                char[] passwd = new char[ELen * 2 + 1];
                for (long i = 0; i < ELen; i++){
                    passwd[i * 2] = OChrAry[i];
                    passwd[i * 2 + 1] = EChrAry[i];
                }
                passwd[ELen * 2] = OChrAry[OLen - 1];
                WriteLine(passwd);
            }else if(diff == 0){
                char[] passwd = new char[ELen * 2];
                for (long i = 0; i < ELen; i++){
                    passwd[i * 2] = OChrAry[i];
                    passwd[i * 2 + 1] = EChrAry[i];
                }
                WriteLine(passwd);
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#include<vector>
#include<algorithm>

int main(){
	int A,B,M;
	cin >> A >> B >> M;
	int a[A],b[B];
	int mina=100001,minb=100001;
	rep(i,A){
		cin >> a[i];
		if(mina>a[i])mina=a[i];
	}
	rep(i,B){
		cin >> b[i];
		if(minb>b[i])minb=b[i];
	}
	int Min=mina+minb;
	int x,y,c,temp;
	rep(i,M){
		cin >> x >> y >> c;
		temp=a[x-1]+b[y-1]-c;
		if(Min>temp)Min=temp;
	}
	cout << Min ;

	return 0;
}
		


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 99999999
typedef std::pair<int,int> pii;

int main(){
    int sx, sy, tx, ty;
    std::cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    std::cout << std::string(dx, 'R') << std::string(dy,'U');
    std::cout << std::string(dx, 'L') << std::string(dy, 'D');
    std::cout << 'D' << std::string(dx + 1, 'R') << std::string(dy + 1, 'U') << 'L';
    std::cout << 'U' << std::string(dx + 1, 'L') << std::string(dy + 1, 'D') << 'R';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
int i,j,k,n,x,p,q = 0;
    for (;;){
        cin >> n >> x;
        if(n == 0 && x == 0)break;	
        	for (i = 1;i <= n - 2;i++){
        		for (j = i+1;j <=  n - 1;j++){
					for (k = j+1;k <= n;k++){
                        	 p = i + j + k;

                        	    if (p == x){
                        	    	q += 1;

                        	        }  				
					    }
        			}
        	}
        	cout << q << endl;
            q = 0;
    }    

    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,r=0,r_=0;
  cin>>h>>w;
  vector<string> a(h);
  for(auto& s:a){
    cin>>s;
    r+=count(s.begin(),s.end(),'#');
  }
  int x=0;
  for(int y=0;y<h;++y){
    if(a[y][x]=='#')r_++;
    else {
      cout<<"Impossible\n";
      return 0;
    }
    while(x+1<w&&a[y][x+1]=='#'){
      x++; r_++;
    }
  }
  if(r==r_)cout<<"Possible\n";
  else cout<<"Impossible\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int AB = sc.nextInt();
        int BC = sc.nextInt();
        int CA = sc.nextInt();

        System.out.println(solve(AB, BC, CA));

        sc.close();
    }

    static int solve(int AB, int BC, int CA) {
        return AB * BC / 2;
    }
}

Measured memory_bytes: 35632
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, sz(s)) {
		if (s[i] == '2') {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 764
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut cnt: Vec<usize> = vec![0; m + 1];

    for _ in 0..n {
        let k: usize = read();

        for _ in 0..k {
            let f: usize = read();
            cnt[f] += 1;
        }
    }

    println!("{}", cnt.iter().filter(|&x| *x == n).count())
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

void kai(P &p){
    int x = p.first;
    int y = p.second;
    p = P(-y,x);
}

int main() {
    int x, y, a, b; cin >> x >> y >> a >> b;
    P p = P(a-x,b-y);
    kai(p);
    int ansx = a + p.first;
    int ansy = b + p.second;
    kai(p);
    int ansa = ansx + p.first;
    int ansb = ansy + p.second;
    cout << ansx << " " << ansy << " " << ansa << " " << ansb << endl;
}

Measured memory_bytes: 3608
//Problem Set

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    map<int,int>d{};
    rep(i,0,n){
        int s;cin>>s;
        d[s]++;
    }
    nvarep(m,t);
    bool flag = true;
    rep(i,0,m){
        if(d[t[i]]<1)flag=false;
        d[t[i]]--;
    }
    cout<<(flag?"YES":"NO")<<nnn;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll x=(c-a-b);
  if(x<=0){cout<<"No"<<endl;return 0;}
  x*=x;
  ll y=4*a*b;
  //cout<<x-y<<endl;
  if(y<x){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

h,w=ii()
a=[[""]]*h
red=[[""]]*h
blue=[[""]]*h
nil=[0]*h
for j in range(h):
    sl=slist()
    a[j]=[x for x in sl]
    red[j]=[x for x in sl]
    blue[j]=[x for x in sl]
    nil[j]=not('#' in sl)
    
cnt=0
nilcnt=0
for j in range(h):
    
    if nil[j]:
        nilcnt+=1
    else:
        nilcnt=0

        
    if nilcnt>=2:
        red[j]=red[j-1]
        blue[j]=blue[j-1]
    else:
        cnt+=1
        if cnt%2==0:
            if nil[j]:
                red[j][1:w-1]=["#"]*(w-2)
                blue[j][0]="#"
                blue[j][w-1]="#"
            else:
                red[j][0:w]=["#"]*w
        else:
            if nil[j]:
                blue[j][1:w-1]=["#"]*(w-2)
                red[j][0]="#"
                red[j][w-1]="#"
            else:
                blue[j][0:w]=["#"]*w

                
            
#red
for j in range(h):
    print join(red[j])
print ""

#blue
for j in range(h):
    print join(blue[j])


Measured memory_bytes: 9728
N, M = map(int, input().split())
A = list(map(int, input().split()))
ops = [list(map(int, input().split())) for _ in range(M)]
A.sort()
ops.sort(key=lambda x:x[1], reverse=True)

a_index = 0
for op in ops:
    b, c = op
    tail = min(a_index+b, N)
    for i in range(a_index, a_index+b):
        if i >= N:
            a_index = None
            break
        if A[i] > c:
            a_index = None
            break
        A[i] = c
    else:
        a_index += b
    if a_index is None:
        break

print(sum(A))



Measured memory_bytes: 81560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) puts("Good");
    else puts("Bad");
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC105
//
//  Created by hiroaki on 2019/03/18.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

//~~A~~
/*int main() {
    int n,k;
    cin >>n>>k;
    if (n%k==0) {
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}*/

//~~B~~
int main(){
    int n;
    cin >>n;
    if (n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17) {
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define srt(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
 
LL check(char vowel)
{
	return vowel=='a' || vowel=='e' || vowel=='i' || vowel=='o' || vowel=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 

		cin>>str;
		if((str[0]==str[1] && str[1]==str[2]) || (str[1]==str[2] && str[2]==str[3]))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	//}
	exit()
 
 
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    int k;
    cin >> k;

    unsigned long long mask = 0;

    rep(i, k) {
        int b;
        cin >> b;
        mask |= (1ull << b);
    }

    for (unsigned long long i = 0; i < (1ll << n); i++) {

        if ((~((~mask) | i)) != 0) {
            continue;
        }

        printf("%d:", i);
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                printf(" %d", j);
            }
        }
        cout << endl;
    }


}



Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    while (1) {
        int N;
        cin >> N;
        if (N == 0) break;
        int Sum = 1000 - N;
        int C[] = {500, 100, 50, 10, 5, 1};
        int Res = 0;
        int i = 0;
        while (Sum > 0) {
            Res += Sum/C[i];
            Sum %= C[i];
            ++i;
        }
        cout << Res << endl;
    }

    return 0;
}



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

int main() {
  int N,K;
  int A=1;
  cin >> N;
  cin >> K;
  for(int i=0;i<N;i++){
    if(A+K<=A*2){
      A+=K;
    }else{
      A*=2;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i;
  char s[12];
  scanf("%s",&s);
  for(i=0;s[i]!=0;i+=2){
    if((s[i]!='h')|(s[i+1]!='i')){
      i=-1;
      break;
    }
  }
  if(i!=-1){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();	//N個のボール
		long k=sc.nextLong();	//整数K
		int m=0;	//最大値
		int g=0;	//最大公約数
		String ans;	//答え

		for(int i=0;i<n;i++){
			int a=sc.nextInt();
			g=gcd(g,a);	//最大公約数を更新
			m=Math.max(a,m);	//最大値も更新
		}

		if(k%g==0 && k<=m) ans="POSSIBLE";
		else ans="IMPOSSIBLE";

		System.out.println(ans);
	}
	static int gcd(int a, int b) {
		return b>0 ? gcd(b, a%b) : a;
	}
}

Measured memory_bytes: 47600
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string s;
	deque<string> dq;
	cin >> s;
	dq.push_back(s);
	int q; 
	cin >> q;
	int t, f;
	string c;
	bool ch = true;
	REP(i, q){
		cin >> t;
		if(t == 1){
			ch = !ch;
		}
		if(t == 2){
			cin >> f >> c;
			if(f == 1){
				if(ch) dq.push_front(c);
				else dq.push_back(c);
			}
			else{
				if(!ch) dq.push_front(c);
				else dq.push_back(c);
			} 
		}
	}
	if(ch) REP(i, dq.size()) cout << dq[i];
	else for(int i = dq.size()-1; i >= 0; i--){
		for(int j = dq[i].size()-1; j >= 0; j--){
			cout << dq[i][j];
		}
	}
	cout << endl;
}

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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std; 

int main(){
    int n;
    cin>>n;
    map<string,int> m;
    pan(i,n){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<m.size();
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int tmp = a;
    if(b>1){
        ans = 1;
        for(int i=1;i<=20;i++){
            if(tmp>=b){
                break;
            }
            else{
            tmp += a-1;
            ans++; 
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>
#include <cassert>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;

ll solve(ll a, ll b) {
  ll ka=a,kb=b;
  while (a !=b){
    if(a<b){
      a+=ka;
    }else if(a>b){
      b+=kb;
    }
  }
  return a;
}

int main() {
  #ifdef TEST
    assert(solve(2, 3)==6);
    assert(solve(123, 456)==18696);
    assert(solve(100000, 99999)==9999900000);
  #else
    ll a,b;
    cin >> a >> b;
    cout << solve(a,b)<<endl;
  #endif

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    uint32_t D, N;

    cin >> D >> N;
    cout << (uint32_t)(pow(100, D) * (N+N/100)) << endl;
    return 0;
}

Measured memory_bytes: 3288
from collections import deque
S = input()
ds = deque(S)
Q = int(input())
query = []
for i in range(Q):
  tq = list(input().split())
  if (len(tq) == 1):
    query.append(1)
  if (len(tq) == 3):
    query.append([int(tq[1]),tq[2]])
eo = 1
for q in query:
  if q == 1:
    eo = eo*(-1)
  else:
    eoq = eo*q[0]
    if eoq == 1 or eoq == -2:
      ds.extendleft(q[1])
    else:
      ds.extend(q[1])
jds = "".join(ds)
if eo == -1:
  jds = jds[::-1]
print(jds)

Measured memory_bytes: 139644
n,m=map(int,input().split())
x=[0]*n
y=[0]*n
z=[0]*n
for i in range(n):
  x[i],y[i],z[i]=map(int,input().split())
ans=0
for j in range(2):
  for k in range(2):
    for l in range(2):
      A=[]
      for i in range(n):
        A.append(x[i]*(-1)**j+y[i]*(-1)**k+z[i]*(-1)**l)
      A.sort(reverse=True)
      a=0
      for i in range(m):
        a=a+A[i]
      if a>ans:
        ans=a
print(ans)

Measured memory_bytes: 3188
<?php
$N = intval(fgets(STDIN));
$hArray = array_map("intval", explode(" ", trim(fgets(STDIN))));
 
$dp[0] = 0;
$dp[-1] = 10**10;
$hArray[-1] = 10**10;
for($i = 1; $i < $N; $i++){
    $dp[$i] = $dp[$i-1] + abs($hArray[$i] - $hArray[$i-1]);
    $dp[$i] = min($dp[$i], $dp[$i-2] + abs($hArray[$i] - $hArray[$i-2]));
}
echo $dp[$N-1];

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

int main(){
	int a, b, i;
	char op;
	for(i = 0; ;){
		cin >> a >> op >> b;
		if(op == '?'){
			break;
		}
		if(op == '+'){
			cout << a + b << endl;
		}
		else if(op == '-'){
			cout << a - b << endl;
		}
		else if(op == '*'){
			cout << a * b << endl;
		}
		else if(op == '/'){
			cout << a / b << endl;
		}
	}
	
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> bs(M);
    for(int i = 0; i < M; i++)
    {
        cin >> bs.at(i);
    }
    int answer = 0;
    for(int i = 0; i < N; i++)
    {
        int total = 0;
        for(int i = 0; i < M; i++)
        {
            int a;
            cin >> a;
            total += a * bs.at(i);
        }
        total += C;
        if(total > 0){
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume0
{
    public class PlasticBoard
    {
        public static void Main()
        {
            int box = 0;
            int rhombus = 0;

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var data = input.Split(',');
                int n1 = int.Parse(data[0]);
                int n2 = int.Parse(data[1]);
                int n3 = int.Parse(data[2]);

                // n1 == n2が菱形
                if (n1 == n2) { rhombus++; }
                // 三平方の定理が成り立つのが長方形
                if ((n1 * n1) + (n2 * n2) == (n3 * n3)) { box++; }
            }

            Console.WriteLine(box);
            Console.WriteLine(rhombus);
        }
    }
}

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

int main() {
  int n,k;
  cin >> n;
  k = -1;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(n == 4*i + 7*j){
        k = 1;
        cout << "Yes" << endl;
        break;
      }
    }
    if(k>0) break;
  }
  
  if(k == -1) cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int n;int a[100];
int fcost(int num){
  int sum=0;
  REP(i,n){
    sum+=(a[i]-num)*(a[i]-num);
  }
  return sum;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n;
  REP(i,n){
    cin>>a[i];
  }
  int mn=INF;
  for(int i=-100;i<=100;i++){
    mn=min(mn, fcost(i));
  }
  P(mn);
  return 0;
}


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

int main(){
   int N;
   cin >> N;
   vector<int> P(N);
   for (int i = 0; i < N; i++){
      cin >> P[i];
   }
   int usi = P[0];
   int ans = 0;
   for (int i = 0; i < N; i++){
      if (usi >= P[i]){
         ans++;
         usi = P[i];
      }
   }
   cout << ans<< endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb, ans;
	cin >> aa >> bb;
	if(((int64)(bb / 2) - (int64)(aa / 2)) % 2 == 0)
	{
		ans = 1;
	}
	else
	{
		ans = 0;
	}
	if(aa % 2 == 1)
	{
		ans ^= aa;
	}
	else
	{
		ans ^= 1;
	}
	if(bb % 2 == 0)
	{
		ans ^= bb;
	}
	else
	{
		ans ^= 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
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<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}

ll n,m;

int main(){
	Init();
	cin>>n>>m;
	ll res=0;
	for(int i=0;i<=n;i++){
		ll t=nCk(n,i)*nPk(m,i)%mod*nPk(m-i,n-i)%mod*nPk(m-i,n-i)%mod;
		if(i%2==1) (t*=mod-1)%=mod;
		(res+=t)%=mod;
	}
	cout<<res<<endl;
}

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

#define ll long long

int possible(int n, int k, int a[], int l){
    int pieces = 0;
    for(int i=0;i<n;i++){
        pieces += a[i]/l;
        if(a[i]%l==0) pieces -= 1;
    }
    if(pieces<=k) return 1;
    else return 0;
}

int main(){
    int n, k, a[200000];
    scanf("%d%d", &n, &k);
    for(int i=0;i<n;i++) scanf("%d", a+i);
    
    int min = 0, max = (int)1e9 + 1;
    while(max-min>1){
        int middle = (max+min)/2;
        if(possible(n, k, a, middle)){
            max = middle;
        }else{
            min = middle;
        }
    }
    
    printf("%d\n", max);

    return 0;
}

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



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

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		input();
		solve();
	}


	static int n,in[];
	private static void input(){
		n=s.nextInt();
		in=new int[n*3];
		for(int i=0;i<n*3;i++)
			in[i]=s.nextInt();
	}

	private static void solve(){
		Arrays.sort(in);
		long res=0;
		for(int i=0;i<n;i++)
			res+=in[i*2+n];
		System.out.println(res);
	}
}


Measured memory_bytes: 91524
a,z,i,j,d[9999][9];main(k){scanf("%d ",&a);d[a][2]=1;for(i=a;i--;){a=getchar()%4-1;for(j=8;j--;z+=d[0][j])for(k=8;k--;)d[i][j]+=j&k&&j>>a&1?d[i+1][k]%10007:0;}a=!printf("%d\n",z%10007);}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];

    int ans=INF;

    if(n==1){
        cout<<1<<endl;
        return 0;
    }

    rep(i,n){
        rep(j,n){
            if(i==j) continue;

            ll dx=x[j]-x[i],dy=y[j]-y[i];
            int sub=0;
            for(int i2=0;i2<n;i2++){
                for(int j2=0;j2<n;j2++){
                    if(i2==j2) continue;
                    if(dx==x[j2]-x[i2] && dy==y[j2]-y[i2]) sub++;
                }
            }
            ans=min(ans,n-sub);
        }
    }

    cout<<ans<<endl;
} 


Measured memory_bytes: 3608
lst=[]
a,b,k=map(int,input().split())
x=a
for i in range(k):
    if x<=b:
        if x not in lst:
            lst.append(x)
            x+=1
    else:
        break
x=b-k+1
for i in range(k):
    if a<x<=b and x not in lst:
        lst.append(x)
        x+=1
    else:
        x+=1

for num in lst:
    print(num)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double ratio = -1.0;
  int ans_water, ans_sugar;
  for (int i = 0; 100 * a * i <= f; ++i) {
    for (int j = 0; 100 * (a * i + b * j) <= f; ++j) {
      int water = a * i + b * j;
      for (int k = 0; 100 * water + c * k <= f; ++k) {
        for (int l = 0; 100 * water + (c * k + d * l) <= f; ++l) {
          int sugar = c * k + d * l;
          if (e * water < sugar) continue;
          double res = (100.0 * sugar) / (100 * water + sugar);
          if (ratio < res) {
            ratio = res;
            ans_water = 100 * water;
            ans_sugar = sugar;
          }
        }
      }
    }
  }
  cout << ans_water + ans_sugar << " " << ans_sugar << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int dp[n][m] = {};
    string s[n];
    f (n) {
        cin >> s[i];
    }
    dp[0][0] = (s[0][0] == '#');
    for (int i = 1 ; i < n ; i++) {
        if (s[i][0] != s[i-1][0] && s[i][0] == '#') {
            dp[i][0] = dp[i -1][0] + 1;
        }
        else {
            dp[i][0] = dp[i-1][0];
        }
    }
    for (int i = 1 ; i < m ; i++) {
        if (s[0][i] != s[0][i-1] && s[0][i] == '#') {
            dp[0][i] = dp[0][i - 1] + 1;
        }
        else {
            dp[0][i] = dp[0][i - 1];
        }
    }
    for (int i = 1 ; i < n ; i++) {
        for (int j = 1 ; j < m ; j++) {
            dp[i][j] = min(dp[i-1][j] + (s[i][j] == '#' && s[i][j] != s[i-1][j]),
                           dp[i][j-1] + (s[i][j] == '#' && s[i][j] != s[i][j-1]));
        }
    }
    cout << dp[n - 1][m - 1] << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
int G[4][4],sum,ans=6;
int X[6][4][4];
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
int tim[4][4];

void dfs(int dep,int s){
  if(dep==6)return;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++){
      int cnt=0;
      if(!G[i][j])continue;
      G[i][j]--;
      X[dep][i][j]++;
      cnt++;
      queue<P1> q;
      for(int k=0;k<4;k++){
	int ny=i+dy[k],nx=j+dx[k];
	if(ny<0||nx<0||4<=ny||4<=nx)continue;
	if(G[i][j])continue;
	tim[i][j]=0;
	q.push(P1(P(1,k),P(ny,nx)));
      }
      while(!q.empty()){
	P1 t=q.front(); q.pop();
	int y=t.second.first,x=t.second.second;
	int cost=t.first.first,d=t.first.second;
	if(!G[y][x]){
	  if(tim[y][x]==cost)continue;
	  int ny=y+dy[d],nx=x+dx[d];
	  if(ny<0||nx<0||4<=ny||4<=nx)continue;
	  q.push(P1(P(cost+1,d),P(ny,nx)));
	}else{
	  G[y][x]--;
	  X[dep][y][x]++;
	  cnt++;
	  for(int k=0;k<4;k++){
	    int ny=y+dy[k],nx=x+dx[k];
	    if(ny<0||nx<0||4<=ny||4<=nx)continue;
	    if(G[y][x])continue;
	    tim[y][x]=cost;
	    q.push(P1(P(cost+1,k),P(ny,nx)));
	  }
	}
      }
      if(s+cnt==sum)ans=min(ans,dep);
      dfs(dep+1,s+cnt);
      for(int y=0;y<4;y++)
	for(int x=0;x<4;x++){
	  G[y][x]+=X[dep][y][x];
	  if(G[y][x])tim[y][x]=0;
	  X[dep][y][x]=0;
	}
    }
}

int main(){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++){
      cin>>G[i][j];
      G[i][j]=5-G[i][j];
      if(G[i][j]==5)G[i][j]=0;
      sum+=G[i][j];
    }
  dfs(1,0);
  if(sum==0)cout<<0<<endl;
  else if(ans==6)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3112
s=input()
t = set(s)
if len(s) ==1:
    print("YES")
    exit(0)
elif len(s) == 2 and len(t) ==2:
    print("YES")
    exit(0)
if len(t) != 3:
    print("NO")
else:
    a = s.count("a")
    b = s.count("b")
    c = s.count("c")
    M = max(a,b,c)
    m = min(a,b,c)
    if M - m >1 :
        print("NO")
    else:
        print("YES")



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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    set<int> s;
    for (int i = 0; i < N; i++) s.insert(A[i]);
    if (s.size()%2) cout << s.size() << endl;
    else cout << s.size() - 1 << endl;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct INF { template<class T> operator T() { return numeric_limits<T>::max() / 2; } } INF;

const int mx = 1'000'000'000;

int main(){

    int n;
    cin >> n;
    V<P> ps(n);
    rep(i,n) cin >> ps[i].fi >> ps[i].se;

    int ans = 0;

    V<int> sums1(n);
    rep(i,n) sums1[i] = ps[i].fi + ps[i].se;
    sort(all(sums1));
    chmax(ans, sums1[n-1] - sums1[0]);

    V<int> sums2(n);
    rep(i,n) {
        sums2[i] = (mx-ps[i].fi) + (ps[i].se);
    }
    sort(all(sums2));
    chmax(ans, sums2[n-1] - sums2[0]);

    cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>

using namespace std;

const int BUFLEN = 1024;

int main(void) {
  int n;
  cin >> n;
  while (getchar() != '\n');

  int t[100001], x[100001], y[100001];
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    char buf[BUFLEN];
    fgets(buf, BUFLEN, stdin);
    sscanf(buf, "%d %d %d", t + i, x + i, y + i);
  }

  for (int i = 0; i < n; i++) {
    int dx = abs(x[i + 1] - x[i]);
    int dy = abs(y[i + 1] - y[i]);
    int dt = abs(t[i + 1] - t[i]);
    bool ok = dx + dy <= dt and (dx + dy) % 2 == dt % 2;
    if (not ok) {
      cout << "No" << endl;
      return EXIT_SUCCESS;
    }
  }
  cout << "Yes" << endl;
  return EXIT_SUCCESS;
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int N, A, B;
  cin >> N >> A >> B;
  if((B-A) % 2 == 0){
    long int x = (B-A)/2;
    printf("%ld", x);
  }
  else{
    long int y = min(A-1, N-B)+1+(B-A-1)/2;
    printf("%ld", y);
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    string S;

    cin >> S;

    //cout <<std::fixed<< setprecision(10) <<  ans << endl;

    vector<string> days = vector<string>(8);

    days[0] = "SUN";
    days[1] = "MON";
    days[2] = "TUE";
    days[3] = "WED";
    days[4] = "THU";
    days[5] = "FRI";
    days[6] = "SAT";
    days[7] = "SUN";


    if (S == "SUN") {
        cout << 7 << endl;
        return 0;
    }
    REP(i,1,7){
        if(S==days[i]){
            cout << 7-i << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	
vector<int> adj[123456];
vector<int> hs;

bool is_good(int x) {
	for (int node: adj[x]) {
		if (hs[node] >= hs[x]) 
			return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, h;
	cin >> n >> m;
	hs.resize(n+1);
	for (int i = 1; i <= n; ++i) cin >> hs[i];
	for (int i = 0, x, y; i < m; ++i) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		cnt += is_good(i);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 9244
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll dp[3001][3001];
int main(void) {
	int x, y, a, b;
	cin >> x >> y;
	b = (y - 2 * x) / 2;
	a = x - b;
	if(a * b < 0 || y % 2) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 3612
n,m,k = map(int, input().split())
mod = 998244353

fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod

def perm(n, k):
  return fact[n] * rfact[n-k] % mod

def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod

paint = [0]*(n)
ans = 0
for i in range(n-k-1,n):
  ans += comb(n-1,i) * pow(m-1,i,mod)
ans *= m
ans %= mod
print(ans)

Measured memory_bytes: 75628
import java.util.*;

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

        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int flag = h[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            if (flag == h[i] - 1)
                flag = h[i] - 1;
            else if (flag > h[i] - 1)
                flag = h[i];
            else {
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

struct edge{
    int to;
    ll cost;
};

vector<edge> nodes[100000];
int visited[100000] = {};
ll zahyou[100000];

void init(){
    rep(i, 100000) zahyou[i] = -1;
}

bool dfs(int p, int s){
    bool ret = true;
    visited[s] = true;
    rep(i, nodes[s].size()){
        int to = nodes[s][i].to;
        ll cost = nodes[s][i].cost;
        if(to == p) continue;
        if(visited[to]){
            if(zahyou[to] != zahyou[s] + cost) ret = false;
        }
        else{
            zahyou[to] = zahyou[s] + cost;
            ret &= dfs(s, to);
        }
    }
    return ret;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    rep(i, M){
        int l, r; cin >> l >> r;
        l--; r--;
        ll d; cin >> d;
        edge e;
        e.to = r; e.cost = d;
        nodes[l].push_back(e);
        e.to = l; e.cost = -d;
        nodes[r].push_back(e);
    }

    bool res = true;
    rep(i, N){
        if(!visited[i]){
            zahyou[i] = 0;
            res &= dfs(-1, i);
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 18688
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < n - 1; i++) {
            int a = Integer.parseInt(sc.next());
            ary[a - 1]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int num : ary) {
            sb.append(num);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 59560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n;cin>>n;
    int r =0,l=n-1,m=(l+r)/2;
    cout<<r<<endl;
    string b,s;
    cin>>b;
    if(b=="Vacant"){
        return 0;
    }
    cout<<l<<endl;
    cin>>s;
    if(s=="Vacant"){
        return 0;
    }
    rep(i,100){
        cout<<m<<endl;
        cin>>s;
        if(s=="Vacant"){
            return 0;
        }
        if((m-r)%2){
            if(b==s){
                l=m;
            }
            else{
                r=m;
                b=s;
            }
        }
        else{
            if(b==s){
                r=m;
                b=s;
                //cout<<400<<endl;
            }
            else{
                l=m;
            }
        }
        m=(l+r)/2;
    }
}

Measured memory_bytes: 3824