akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int query(string S){
    cout <<"? "<< S << endl;
    cout.flush();
    int ans;
    cin >> ans;
    return ans;
}

int main(){
    vector<string> temp;
    
    //全ての文字をセット
    for(char j='A';j<='Z';j++){
        string S="";
        for(int i=0;i<128;i++)S+=j;
        temp.push_back(S);
    }
    for(char j='a';j<='z';j++){
        string S="";
        for(int i=0;i<128;i++)S+=j;
        temp.push_back(S);
    }
    for(char j='0';j<='9';j++){
        string S="";
        for(int i=0;i<128;i++)S+=j;
        temp.push_back(S);
    }
    //各種類と長さを取得
    int L=0;
    for(string &S:temp){
        int a = query(S);
        int t = 128-a;
        S=S.substr(0,t);
        L+=t;
    }
    
    
    sort(temp.begin(), temp.end(),[](string a,string b){return a.size()>b.size();});
    while(!temp.back().size())temp.pop_back();
    
    while(temp.size()!=1){
      sort(temp.begin(), temp.end(),[](string a,string b){return a.size()>b.size();});
      string X=temp.back(),Y=temp[temp.size()-2],XY="";
      int mQi=L-(int)Y.size();
      while(X.size()&&Y.size()){
        string Q = XY + X[0] + Y;
        int Qi = query(Q);
        if(Qi<mQi){
            mQi=Qi;
            XY+=X[0];
            X=X.substr(1);
        }else{
            XY+=Y[0];
            Y=Y.substr(1);
        }
        //mQi=Qi;
      }
      XY+=X;
      XY+=Y;
      temp.pop_back();
      temp.pop_back();
      temp.push_back(XY);
    }
    
    cout << "! " << temp[0] << endl;
}


Measured memory_bytes: 3776
from itertools import permutations

n, m = map(int, input().split())

tu = [[] for j in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    tu[a].append(b)
    tu[b].append(a)

na = [i for i in range(2,n+1)]
ans = 0

for nara in permutations(na):
    st = 1
    f = True
    for i in range(n-1):
        if not nara[i] in tu[st]:
            f = False
        st = nara[i]
    if f == True:
        ans += 1



print(ans)

Measured memory_bytes: 3064
use io::*;

fn main()
{
    let con =read_string();
    let mut sc =Scanner::new(&con);

    let mut N:i64 = sc.next();
    if N==0
    {
        println!("0");
        return;
    }
    let mut v:Vec<i64> =Vec::new();
    while N!=0
    {
        let mut n = abs(N);
        let mut d = n%2;
        v.push(d);
        N = (N-d)/(-2);
    }

    for i in 0..v.len()
    {
        print!("{}",v[(v.len()-1-i) as usize]);
    }
}

fn abs(x:i64)->i64
{
    if(x<0)
    {
        return (-1)*x;
    }
    x
}

pub mod io {
    use std;
    use std::str::FromStr;
 
    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }
 
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
 
        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }
 
        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }
 
        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }
 
    pub fn read_string() -> String {
        use std::io::Read;
 
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
 
    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
X,N=map(int,input().split())
if N!=0:
  P=list(map(int,input().split()))
else:
  P=[]
if X not in P:
  print(X);exit()

r=1000
ans=0
for i in range(200,-200,-1):
  if i not in P:
    if r>=abs(i-X):
      r=abs(i-X)
      ans=i
print(ans)

Measured memory_bytes: 61804
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int dp[101][4][4][4];
int mod = 1000000007;
int main() {
  int N; cin >> N;
  dp[0][3][3][3] = 1;
  for ( int len = 0; len < N; len++ ) {
    for ( int c1 = 0; c1 < 4; c1++ ) {
      for ( int c2 = 0; c2 < 4; c2++ ) {
	for ( int c3 = 0; c3 < 4; c3++ ) {
	  for ( int a = 0; a < 4; a++ ) {
	    if ( a == 2 && c1 == 1 && c2 == 0 ) continue;
	    if ( a == 2 && c1 == 0 && c2 == 1 ) continue;
	    if ( a == 1 && c1 == 2 && c2 == 0 ) continue;
	    if ( a == 2 && c2 == 1 && c3 == 0 ) continue;
	    if ( a == 2 && c1 == 1 && c3 == 0 ) continue;	    
	    dp[len+1][c2][c1][a] += dp[len][c3][c2][c1];
	    dp[len+1][c2][c1][a] %= mod;
	  }
	}
      }
    }
  }
  int ans = 0;
  for ( int c1 = 0; c1 < 4; c1++ ) {
    for ( int c2 = 0; c2 < 4; c2++ ) {
      for ( int c3 = 0; c3 < 4; c3++ ) {
	ans += dp[N][c1][c2][c3];
	ans %= mod;
      }    
    }    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
string s,t;
cin>>s>>t;
sort(s.begin(),s.end());
sort(t.begin(),t.end(),greater<char>());
if(s<t){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}












Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int h,w,m[505][505],r[505][505],b[505][505],o[505];
int main(void){
    scanf("%d%d",&h,&w);
    for(int i=0;i<w;i++){
        r[0][i]=1;
        r[h-1][i]=1;
    }
    for(int i=0;i<h;i++){
        r[i][0]=1;
        r[i][w-1]=1;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            scanf(" %c",&c);
            if(c=='#'){
                m[i][j]=1;
                r[i][j]=1;
                b[i][j]=1;
                o[i]=1;
            }
        }
    }
    int e=0;
    for(int i=1;i<h-1;i++){
        if(o[i]==1&&e==1){
            for(int j=1;j<w-1;j++)r[i][j]=1;
            e=0;
        }else{
            for(int j=1;j<w-1;j++)b[i][j]=1;
            e=1;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(r[i][j])cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(b[i][j])cout<<'#';
            else cout<<'.';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt n;
	std::cin >> n;
	lnt ans=0;
	for(lnt i=1;i<=n;i++) {
		lnt y=n/i;
		ans+=(y*(y+1)*i)>>1;
	}
	print(ans);
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		int count=0;
		loop:for(int i=0;;i++){
			for(int k=0;k<n;k++){
				if(a[k]%2!=0){
					break loop;
				}
			}
			for(int s=0;s<n;s++){
				a[s]/=2;
			}
			count++;
		}

		System.out.println(count);




	}
}


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

int main(){
    ll k;
    cin >> k;
    cout << 50 << endl;
    ll num = k / 50;
    ll rem = k % 50;
    ll base = 49 + num;
    rep(i, 0, rem) cout << base + 1 << (i == 49 ? "\n" : " ");
    rep(i, rem, 50) cout << base - rem << (i == 49 ? "\n" : " ");
    cout << endl;
    return 0;
}

Measured memory_bytes: 3504
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	static long[] fact;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		for (i = 0; i < n; i++) {
			a[i] = parseLong(sc.next());
		}
		sc.close();
		Arrays.sort(a);
		double a2 = (double)a[n-1]/2;
		double mn = 1000000000;
		int mnp = 0;
		for (i = 0; i < a.length; i++) {
			if(abs(a[i]-a2) < mn) {
				mn = abs(a[i]-a2);
				mnp = i;
			}
		}
		out.printf("%d %d%n", a[n-1], a[mnp]);
	}
}


Measured memory_bytes: 47524
n = int(input())
prits = [0 for i in range(n+1)]

for i in range(1,n+1):
    k = 2
    while k*k<=i:
        while i%k == 0:
            i = i//k
            prits[k] += 1
        k += 1
    if i>1 :
        prits[i] += 1
#print(prits)

a,b,c,d,e = [],[],[],[],[]

for i in range(len(prits)):
    num = prits[i]
    if num >=2:
        e.append(i)
    if num >=4:
        d.append(i)
    if num >=14:
        c.append(i)
    if num >=24:
        b.append(i)
    if num >=74:
        a.append(i)

#print(len(a),len(b),len(c),len(d),len(e))

ans = 0
ans += len(a)
ans += len(c)*(len(d)-1)
ans += len(b)*(len(e)-1)
ans += len(d)*(len(d)-1)*(len(e)-2)//2

print(ans)


Measured memory_bytes: 38256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

int main() {
  ll x, y;
  cin >> x >> y;

  ll a, b;
  a = min(x, y);
  b = max(x, y);

  ll ans;
  if (a == 1 && b == 2) ans = 3;
  if (a == 2 && b == 3) ans = 1;
  if (a == 1 && b == 3) ans = 2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.S<b.S)
    return true;
    return false;
}
void solve()
{
    int a1,b1;
    cin>>a1>>b1;string a=to_string(a1),b=to_string(b1);
    string s1=a,s2=b;
    for(int i=1;i<b1;i++)
    s1+=a;
    for(int i=1;i<a1;i++)
    s2+=b;
    if(s1<s2)
    cout<<s1<<endl;
    else
    cout<<s2<<endl;
}
int main()
{
    solve();
    return 0;
}


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

namespace abc127D
{
    class Program
    {
        static void Main(string[] args)
        {
            string N_M = Console.ReadLine();
            string[] c = N_M.Split(' ');
            int N = Convert.ToInt32(c[0]);
            int M = Convert.ToInt32(c[1]);

            string A_All = Console.ReadLine();
            string[] Astr = A_All.Split(' ');
            long[] A = new long[Astr.Length];
            for (int i = 0; i < N; i++)
            {
                A[i] = Convert.ToInt64(Astr[i]);
            }

            int[] B = new int[M];
            int[] C = new int[M];

            for (int i = 0; i < M; i++)
            {
                string B_C = Console.ReadLine();
                string[] a = B_C.Split(' ');
                B[i] = Convert.ToInt32(a[0]);
                C[i] = Convert.ToInt32(a[1]);
            }
            Array.Sort(A);
            Array.Sort(C, B);

            int[] Z = new int[A.Length];
            int count = 0;
            for (int i = M - 1; i >= 0; i--)
            {
                for (int j = 0; j < B[i]; j++)
                {
                    Z[count] = C[i];
                    count++;
                    if (count >= Z.Length) break;
                }
                if (count >= Z.Length) break;
            }

            long otpt = 0;
            for (int z = 0; z < N; z++)
            {
                otpt = otpt + Math.Max(A[z],Z[z]);
            }
            Console.WriteLine(Convert.ToString(otpt));
            Console.ReadKey();
        }
    }
}


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

using namespace std;

int main() {

	string A, B, C;
	cin >> A >> B >> C;

	if((A[(int)A.length() - 1] == B[0]) && (B[(int)B.length() - 1] == C[0])) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;

    ll r = 0, t = 0;
    for(ll i=0; i<n; i++) {
        ll s = max(0ll, (a[i]-(t+1) + t) / (t+1));
        r += s;
        if(a[i] == t+1) t++;
        if(!t) t=1;
    }
    cout << r << endl;
}


Measured memory_bytes: 1024
from itertools import accumulate
N, K = map(int, input().split())
*V, = map(int, input().split())

ans = 0
for a in range(N+1):
    for b in range(N+1):
        if a+b>N:continue
        
        if a and b:
            qa, qb = list(accumulate([0]+sorted(V[:a]))), list(accumulate([0]+sorted(V[-b:])))
            sa, sb = sum(V[:a]), sum(V[-b:])
            for c in range(a+1):
                for d in range(b+1):
                    if a+b+c+d<=K:
                        ans = max(ans, sa+sb-qa[c]-qb[d])
        elif a:
            qa = list(accumulate([0]+sorted(V[:a])))
            sa = sum(V[:a])
            for c in range(a+1):
                if a+c<=K:
                    ans = max(ans, sa-qa[c])
        elif b:
            qb = list(accumulate([0]+sorted(V[-b:])))
            sb = sum(V[-b:])
            for d in range(b+1):
                if b+d<=K:
                    ans = max(ans, sb-qb[d])

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=110;
int d[N];
inline bool Main(){
	int n=ni,mx=0;
	memset(d,0,sizeof(d));
	for(int i=1;i<=n;i++){
		int tmp=ni;
		d[tmp]++;
		apmax(mx,tmp);
	}
	int l=0,r=mx;
	for(;l<r;l++,r--){
		d[r]-=2;
		if(d[r]<0){
			return false;
		}
	}
	if(l==r){
		d[l]--;
		if(d[l]<0){
			return false;
		}
	}
	int t=max(l,r)+1;
	for(int i=0;i<t;i++){
		if(d[i]){
			return false;
		}
	}
	return true;
}
int main(){
	puts(Main()?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 256
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005
 */
#include <iostream>
#include <sstream>

#define N 2

using namespace	std;

long
gcd(long a, long b)
{
	return a % b == 0 ? b : gcd(b, a % b);
}
long
lcm(long a, long b)
{
	long t = gcd(a, b);
	return t ? (a * b) / t : 0;
}
int
main()
{
	string line;
	while (getline(cin, line)) {
		istringstream iss(line);
		long a, b;
		iss >> a >> b;
		cout << gcd(a, b) << ' ' << lcm(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#define MOD 1000003

using namespace std;

typedef long long ll;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		t >>= 1;
	}
	return ans;
}

ll inv(ll x)
{
	return qpow(x, MOD-2);
}

ll fac[MOD+5];

void init()
{
	fac[0] = 1;
	for(int i=1; i<MOD; i++) fac[i] = fac[i-1] * i % MOD;
}

int main()
{
	int q, x, d, n;
	init();
	read(q);
	for(int i=1; i<=q; i++)
	{
		read(x), read(d), read(n);
		if(x == 0) printf("0\n");
		else if(d == 0) printf("%lld\n", qpow(x, n));
		else
		{
			ll t = x * inv(d) % MOD;
			int r = t+(n-1);
			if(r >= MOD) printf("%lld\n", 0);
			else printf("%lld\n", fac[r] * inv(fac[t-1]) % MOD * qpow(d, n) % MOD);
		}
	}
	return 0;
}

Measured memory_bytes: 8704
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        int g = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 0; i <= n; i += r) {
            for (int j = 0; j <= n - i; j += g) {
                int remain = n - (i + j);
                if (remain % b == 0) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}


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

int H,W;
const int MAX_R = 20;
const int MAX_C = 20;

char data[MAX_R][MAX_C];
bool vis[16][4][MAX_R][MAX_C];


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

const int U = 0;
const int R = 1;
const int D = 2;
const int L = 3;

void input(){
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> data[i][j];
    }
  }
}

bool run(int d,int x,int y,int buf){
  while(1){
    switch(data[y][x]){
    case '<': 
      d = L;
      break;
    case '>':
      d = R;
      break;
    case '^':
      d = U;
      break;
    case 'v':
      d = D;
      break;
    case '_':
      if(buf == 0)d = R;
      else d = L;
      break;
    case '|':
      if(buf == 0)d = D;
      else d = U;
      break;
    case '?':
      for(int i = 0 ; i < 4 ; i++){
	int nx,ny;
	nx = (x + dx[i] + W)%W;
	ny = (y + dy[i] + H)%H;
	if(vis[buf][i][ny][nx])continue;
	vis[buf][i][ny][nx] = true;
	if(run(i,nx,ny,buf))return true;
      }
      break;
    case '.':
      break;
    case '@':
      return true;
      break;
    case '+':
      buf = (buf+1)%16;
      break;
    case '-':
      buf = (16+buf-1)%16;
      break;
    default: // numbe
      buf = (data[y][x] - '0');
      break;
    }
    x = (x + dx[d] + W)%W;
    y = (y + dy[d] + H)%H;
    if(vis[buf][d][y][x])return false;
    vis[buf][d][y][x] = true;
  }
  return false;
}

int main(){
  input();
  for(int ii = 0 ; ii < 16 ; ii++){
    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < H ; j++){
	for(int k = 0 ; k < W ; k++){
	  vis[ii][i][j][k] = false;
	}
      }
    }
  }
  vis[0][R][0][0] = true;
  if(run(R,0,0,0))cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll n;
	ll a, b;
	ll ans=0LL;
	cin >>n>>a>>b;
	if((a%2)==(b%2)){
		ans = abs(b - a) / 2LL;
	}else{
		ans = abs(a + b) / 2;
		chmin(ans, abs(n - a + n - b+2) / 2LL);
	}
	cout<<ans<<endl;
}
/*
3 5

2 3 5/2 = 3
1 2
1 1

1 2 = 1  == 3/2=1
1 1

4 1
3 1
2 2
2 3
1 2
1 1

7 8
8 9
9 10

*/

Measured memory_bytes: 3552
#include <iostream>
#include <set>

using namespace std;

set<int> mths{ 1,2,3,4,5,6,7,8,9,10, 11, 12 };

int main()
{
	int a, b, x;
	cin >> x;
	a = x / 100;
	b = x % 100;

	int m_a = mths.count(a);
	int m_b = mths.count(b);


	if (m_a && m_b)
	{
		cout << "AMBIGUOUS" << endl;
		return 0;
	}

	if (m_a)
	{
		cout << "MMYY" << endl;
		return 0;
	}

	if (m_b)
	{
		cout << "YYMM" << endl;
		return 0;
	}

	cout << "NA" << endl;
}


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

char chess(int H, int W) {
   if((H+W)%2==0) {
       return '#';
   }
}

int main(void){
   int H,W;
   while(true) {
       cin >> H >> W;
       if (H == 0 && W == 0) {
           break;
       }
       for(int j = 0; j < H; j++){
           for(int i = 0; i < W; i++) {
               cout << chess(i,j);
           }
           cout << endl;
       }
       cout << endl;
   }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define mk make_pair

int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(c>=b)
	c=b-1;
	cout<<floor((a*c)/b)-a*floor(c/b);
}


Measured memory_bytes: 3784
def find_conb(result_list,candidate,result,cond):
    
    if len(result)>3:
        return
    
    #2つめの要素の処理で処理が完了する
    #->level3の展開が不要になる
    if len(result)==2:
        res=cond-sum(result)
        if res in candidate:
            result_list.append(result[:]+[res])
            return
        else:
            return
    
    if sum(result) == cond and len(result)==3:
        return
        result_list.append(result[:])
        return
    
    #和が超えたら終了
    if sum(result) > cond:
        return
    
    #候補がなくなったら終了
    if len(candidate) == 0:
        return
    #canditateの最小値がcondを超えたら枝仮
    if candidate[0] >= cond:
        return
    

    
    n=candidate.pop(0)
    
    # print(result[:]+[n])
    find_conb(result_list,candidate[:],result[:]+[n],cond)
    #nを含まないとき
    find_conb(result_list,candidate[:],result[:],cond)
    

def run():
    
    data_list=[]
    
    while True:
        n,x=tuple(map(int,input().split()))
        
        if n==0 and x==0:
            break
        
        data_list.append((n,x))
    
    
    for n,x in data_list:
        #組み合わせの計算
        #動的計画法が必要
        result_list = []
        candidate=[i for i in range(1,n+1)]
        cond=x
        result=[]
        find_conb(result_list,candidate,result,cond)
        
        print(len(result_list))
    # print(result[:]+[n])
    find_conb(result_list,candidate[:],result[:]+[n],cond)
    #nを含まないとき
    find_conb(result_list,candidate[:],result[:],cond)
    

def run():
    
    data_list=[]
    
    while True:
        n,x=tuple(map(int,input().split()))
        
        if n==0 and x==0:
            break
        
        data_list.append((n,x))
    
    
    for n,x in data_list:
        #組み合わせの計算
        #動的計画法が必要
        result_list = []
        candidate=[i for i in range(1,n+1)]
        cond=x
        result=[]
        find_conb(result_list,candidate,result,cond)
        
        print(len(result_list))

run()


Measured memory_bytes: 5724
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int[] list = new int[N];
			int result = 0;
			for(int i = 0 ; i < N ; i++){
				list[i] = sc.nextInt();
				result += list[i];
			}
			if(result % 10 == 0){
				Arrays.sort(list);
				for(int i  = 0 ; i < N ; i++){
					if(list[i] % 10 != 0){
						result -= list[i];
						break;
					}
					if(i == N-1){
						result = 0;
					}
				}
				
			}
			System.out.println(result);
		}catch(Exception e){
			e.printStackTrace();
		}
	} 
}

Measured memory_bytes: 21716
h,w,k=map(int,input().split())
mat=[]
cake=[[0 for _ in range(w)]for _ in range(h)]
straw=[]
cnt=1
for i in range(h):
    s=list(input())
    mat.append(s)
    for k in range(w):
        if s[k]=='#':
            cake[i][k]=cnt
            cnt+=1
for i in range(h):
    for j in range(w-2,-1,-1):
        if cake[i][j]==0:
            cake[i][j]=cake[i][j+1]
for i in range(h):
    for j in range(1,w):
        if cake[i][j]==0:
            cake[i][j]=cake[i][j-1]
for i in range(h-2,-1,-1):
    for j in range(w):
        if cake[i][j]==0:
            cake[i][j]=cake[i+1][j]
for i in range(1,h):
    for j in range(w):
        if cake[i][j]==0:
            cake[i][j]=cake[i-1][j]
for i in range(h):
    print(*cake[i])


Measured memory_bytes: 53596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long A, B, C, K, count, countA, countB, countC;
 cin >> A >> B >> C >> K;
 count=0;
  while(1){
      countA=min(A, K);
      K-=countA;
      count+=countA;
      if(K==0)break;
      countB=min(B, K);
      K-=countB;
      if(K==0)break;
      countC=min(C, K);
      count-=countC;
      break;
  }    
cout << count << endl;
}

Measured memory_bytes: 3632
/*
17D8101013F 森田　匡博
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>

bool search_x(int S[], int key, int n)
{
  int left, right, mid;
  left = 0;
  right = n;
  while(left != right) {
    mid = int((left + right) / 2);
    if(S[mid] == key) {
      return true;
    }
    else if(key < S[mid]) {
      right = mid;
    }
    else {
      left = mid + 1;
    }
  }

  return false;
}

int main()
{
  int n, q;

  std::cin >> n;
  int S[n];

  for(int i = 0; i < n; i++) {
    std::cin >> S[i];
  }

  std::cin >> q;
  int T[n];

  for(int i = 0; i < q; i++) {
    std::cin >> T[i];
  }

  int c = 0;

  for(int i = 0; i < q; i++) {
    if(search_x(S, T[i], n)) {
      c++;
    }
  }
  

  std::cout << c << "\n";

  return 0;

}



Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    rep(i, 2) {
        rep(j, 2) {
            if (c[i + 1][j] - c[i][j] != c[i + 1][2] - c[i][2]) {
                cout << "No\n";
                return 0;
            }
            if (c[j][i + 1] - c[j][i] != c[2][i + 1] - c[2][i]) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll a; ld b;
    cin >> a >> b;
    ll ans = a*b;
    cout << ans << endl;

}

Measured memory_bytes: 3720
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        int c = 1;


        for (int i = K; i < N; i += K - 1) {
            c++;
        }

        System.out.println(c);
    }
}


Measured memory_bytes: 23892
n, a, b = map(int, input().split())
ans = 0
if a > b:
  ans = 0
elif n == 1 and a != b:
  ans = 0
elif n == 1 and a == b:
  ans = 1
else:
  ans = (b - a) * (n - 2) + 1
print(ans)

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}

inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}



int main()
{
    ///freopen("output.txt","w",stdout);
   // freopen("input.txt","r",stdin);

    FastIO;
    lli n,g;
    while(cin>>n>>g){
        lli p[n] , c[n];
        lli ans = 0;
        for(int i=0; i<n; i++){
            cin>>p[i]>>c[i];
            ans += p[i];
        }

        for(int mask=0; mask<1024; mask++){
            lli score = 0 , problem = 0;
            for(int i=0; i<n; i++){
                if(mask&(1<<i)){
                    score += 100*(i+1)*p[i] + c[i];
                    problem += p[i];
                }
            }
            for(int i=n-1; i>=0 && score<g; i--){
                if((mask&(1<<i)) == 0){
                    for(int j=p[i]; j; j--){
                        lli l = (j-1)*100*(i+1) + score;
                        lli k =  j*100*(i+1) + score;
                        if(l<g){
                            score = k;
                            problem += j;
                            break;
                        }
                    }
                }
            }
            if(score>=g){
                ans = min(ans, problem);
            }
        }

        cout<<ans<<endl;
    }

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});
//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i, min(k, 13+1)){ // log2(5000) < 13
        string t = s;
        reverse(all(t));
        s += t;
        reverse(all(s));
        string now = s.substr(0, n);
        REP(i, n)now = min(now, s.substr(i, n));
        reverse(all(now));
        s = now;
    }
    reverse(all(s));
    cout << s << endl;
}   

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, p, mis int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		fmt.Scan(&p)
		if p != i {
			mis++
		}
	}
	if mis <= 2 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
T GCD(T x, T y)
{
    if (x < y)
    {
        const T a = x;
        x = y;
        y = a;
    }
    T b = 100000;
    while (b)
    {
        b = x % y;
        x = y;
        y = b;
    }
    return x;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll res = a[0];
    for (int i = 0; i < n; i++)
    {
        res = GCD(res, a[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = 0, n = num;
        while(n > 0){
            sum += n % 10;
            n /= 10;
        }
        if(num % sum == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35672
var
  x,i:Longint;
  a:array[1..4]of Longint;
  b:array[0..4]of Longint;
begin
  for i:=1 to 6 do
  begin
    read(x);inc(a[x]);
  end;
  for i:=1 to 4 do
	inc(b[a[i]]);
  if(b[1]=2)and(b[2]=2)then writeln('YES')else writeln('NO');
end.

Measured memory_bytes: 128
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum()
{
	int p, data = 0; char ch = 0;
	while ((ch != '-') &&( ch < '0' || ch>'9') )//注意运算优先级，逻辑与大于逻辑非
		ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
	if (ch == '-')
		p = -1, ch = getchar();//不能与if平行放置，不懂为什么，可能是bug
	else p = 1;
	while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
	return data * p;
}
inline int ReadPossitive()
{
	char ch; int data = 0;
	ch = getchar();
	while (ch == ' ' || ch == '\n')ch = getchar();
	while (ch != ' ' && ch != '\n' && ch != EOF)
	{
		data = data * 10 + ch - '0';
		ch = getchar();
	}
	return data;
}
//E-mail 374656045@qq.com
class solve {
private:
	int v, e;
	vector<int>*G;
	bool* vis;//有向图必须有vis,一次dfs||bfs能遍历一颗树，但是一个根和一棵树，但是一颗树可能有多个根2->3,1->3;
	int *order;
	int ordersize;
public://采用邻接表建图
	solve(const char kind[])
	{
		initial();
		if (kind == "bfs")
		{
			TsortBfs();
			forup(i, 0, ordersize)
				printf("%d\n", order[i]);
		}
		if (kind == "dfs")
		{
			TsortDfs();
			for(int i=ordersize-1;i>=0;i--)
				printf("%d\n", order[i]);
		}
	}
	void initial()
	{
		v = ReadPossitive(); e = ReadPossitive();
		G = new vector<int>[v];
		vis = new bool[v]();
		order = new int[v];
		ordersize = 0;
		int u, to;
		forup(i, 0, e)
		{
			u = ReadPossitive(); to = ReadPossitive();
			G[u].push_back(to);
		}
	}
	void TsortBfs()
	{
		int *indeg=new int[v]();//初始化入度为0
		forup(i,0,v)
			forup(j, 0, G[i].size())
		{
			indeg[G[i][j]]++;
		}
		forup(i, 0, v)
			if (indeg[i]==0&&!vis[i])
			{
				queue<int>temp;
				temp.push(i);
				int cur, son;
				while (!temp.empty())
				{
					cur = temp.front(); temp.pop(); vis[cur] = true; order[ordersize++] = cur;
					forup(i, 0, G[cur].size())
					{
					    son = G[cur][i];
						indeg[son]--;
						if (indeg[son] == 0 && !vis[son])
							temp.push(son);//避免多根共用的子树被重复操作,所以1->2,3->2的顺序是1,3,2。满足拓扑排序的要求：所有平级的父节点排在子节点前面。
						//先输出多根共用子树中不重合的部分，再输出重合的部分，这是跟TsortDfs不同的最大区别
					}
				}
			}
	}
	void TsortDfs()//思维相对简单一些
	{
		forup(i, 0, v)
			if(!vis[i])dfs(i);//直接递归，不手动写栈了
	}
	void dfs(int i)
	{
		vis[i] = true;
		int son;
		forup(j, 0, G[i].size())
		{
			son = G[i][j];
			if(!vis[son])
			dfs(son);
		}
		order[ordersize++] = i;//注意顺序是逆序的,并且是将多个根共用的子树根据先来后到原则进行剖分，剖分为独立子树输出（345012）
	}
};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);//慎用，cin和scanf混用会导致非MSC++WA
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve solution("bfs");
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;

}




Measured memory_bytes: 3944
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            int d,t,s;
            cin >> d >> t >> s;
            if(d <= t*s)
                cout << "Yes\n";
            else
                cout << "No\n";




           return 0;
        }
          

Measured memory_bytes: 3608
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
ll ar[100]={0},a[55],b[55],c[55],d[55];
ll n,m,q,mx=0,ans=0;
void call(int pos,int nilam)
{
    if(nilam==n)
    {
        for(int j=1;j<=n;j++)
        {
            ans=0;
            for(int jj=1;jj<=q;jj++)
            {
                if(ar[b[jj]]-ar[a[jj]]==c[jj])
                    {
                        ans+=d[jj];
                    }
            }
            mx=max(mx,ans);
        }
        return;
    }
    for(int ii=1;ii<=m;ii++)
    {
        if(ii>=pos)
        {
            ar[nilam+1]=ii;
            call(ii,nilam+1);
        }
    }
}
main()
{
    timesave;
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    for(int i=1;i<=m;i++)
    {
        ar[1]=i;
        call(i,0);
    }
    cout<<mx<<endl;
}






Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
 int arr[3];
  for (int i=0;i<3;i++){
    cin>>arr[i];
  }
  sort(arr,arr+3);
  cout<<arr[0]+arr[1]<<endl;
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b;

	scanf("%d %d",&a,&b);

	if(a<b){
		printf("a < b\n");
	}

	else if(a>b){
		printf("a > b\n");
	}

	else{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 2616
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]
x, y, a = zip(*xya)
xl, xr, yb, yt = 0, w, 0, h
for i in range(n):
    if   a[i] == 1: xl = max(xl, x[i])
    elif a[i] == 2: xr = min(xr, x[i])
    elif a[i] == 3: yb = max(yb, y[i])
    else:           yt = min(yt, y[i])
print((xr-xl)*(yt-yb)*(xr>xl and yt>yb))

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(a == b) {
			System.out.println("Draw");
		}else if(a > b && b > 1 || a == 1) {
			System.out.println("Alice");
		}else if(b > a && a > 1 || b == 1) {
			System.out.println("Bob");
		}
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    set<int> s;
    int a;
    REP(i, n) {
        cin >> a;
        s.emplace(a);
    }
    if (sz(s) == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
from collections import deque
d = deque([9, 8, 7, 6, 5, 4, 3, 2, 1])

K = int(input())
for _ in range(K - 1):
    i = d.pop()
    if i % 10 != 0:
        d.appendleft(i * 10 + i % 10 - 1)
    d.appendleft(i * 10 + i % 10)
    if i % 10 != 9:
        d.appendleft(i * 10 + i % 10 + 1)
print(d.pop())


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

int main(){
    int N, M;
    cin >> N >> M;
    int a[N], b[N];
    int tempa, tempb;
    for(int i = 0; i < M; i++){
        cin >> tempa >> tempb;
        if(tempb > tempa){
            a[i] = tempa;
            b[i] = tempb;
        }else{
            a[i] = tempb;
            b[i] = tempa;
        }
    }
    long long ans[N] = {0};

    for(int i = 0; i < M; i++){
        ans[a[i] - 1]++;
        ans[b[i] - 1]++;
    }
    for(int i = 0; i < N; i++){
        if(ans[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1792