akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1){
      cout << "Three" <<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	ll N;
	ll K;
	cin >> N >> K;
	ll d[10];
	for (ll i = 0; i < K; i++) {
		cin >> d[i];
	}
	for (ll i = N; i < 100000; i++) {
		bool flag = true;
		ll x = i;
		while (x != 0) {
			for (ll j = 0; j < K; j++) {
				if (x % 10 == d[j]) {
					flag = false;
				}
			}
			x = x / 10;
		}
		if (flag) {
			cout <<i << endl;
			break;
		}
	}
}


	







Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

typedef long long ll;

using namespace std;

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


	int ans=min(N*A,B);

	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t Count(const string &S) {
  int64_t result = 0;
  const int64_t N = static_cast<int64_t>(S.length());
  vector<int64_t> counts;
  counts.push_back(1);
  for (int64_t i = 1; i < N; ++i) {
    if (S.c_str()[i] == S.c_str()[i - 1]) {
      ++counts[counts.size() - 1];
    } else {
      counts.push_back(1);
    }
  }
  if (counts.size() == 1U) {
    return -1;
  } else {
    for (int64_t i = 0; i < static_cast<int64_t>(counts.size()); ++i) {
      result += counts[i] / 2;
    }
  }
  return result;
}

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

  string S;
  int64_t K;
  cin >> S >> K;
  const int64_t N = static_cast<int64_t>(S.length());

  int64_t result;
  if (S == string(N, S[0])) {
    result = N * K / 2;
  } else {
    const int64_t first = Count(S);
    const int64_t second = Count(S + S);
    result = first + (second - first) * (K - 1);
  }
  cout << result << endl;

  return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  sort(V.rbegin(), V.rend());
  int alice = 0, bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += V[i];
    } else {
      bob += V[i];
    }
  }
  cout << alice - bob;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
const int N = 400001;
int fac[N+1];
int inv[N+1];
ll COM(ll n,ll k){
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}

/*----------------------------------------------------------------*/
signed main(){

    int n,k;
    cin >> n >> k;

    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }


    if(n > k){
        int ans = 0;
        rep(i,k+1){
            int d = (fac[n-1]*inv[i]%MOD*inv[n-1-i]%MOD * COM(n,i))%MOD;
            ans += d;
            ans %= MOD;
            cerr << d << endl;
        }
        cout << ans << endl;
        return 0;
    }else{
        int d = (fac[2*n-1]*inv[n]%MOD*inv[n-1]%MOD)%MOD;
        cout << d << endl;
    }





    

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc156.contest.atcoder.jp/tasks/abc156_b

Measured memory_bytes: 6528
#ドワンゴ

N=int(input())
pl=[]
tl=[]
for i in range(N):
    songname,time=input().split()
    pl.append(songname)
    tl.append(int(time))
    
X=input()

ind=pl.index(X)

if ind!=N:
    print(sum(tl[ind+1:]))
else:
    print(0)

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

char mat[1002][1002];
ll dp[1002][1002];
ll mod = 1e9+7;

ll grid(ll r, ll c,ll h, ll w){
	if(r==h && c==w)
		return 1;
	if(r>h || c>w)
		return 0;
	
	if(dp[r][c]!=-1)
		return dp[r][c];

	if(mat[r][c]=='.')
		return dp[r][c] = (grid(r+1,c,h,w)%mod + grid(r,c+1,h,w)%mod)%mod;
	else
		return dp[r][c] = 0;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++){
    	for(int j=1;j<=w;j++){
    		cin>>mat[i][j];
    	}
    }
    memset(dp,-1,sizeof(dp));
    cout<<grid(1,1,h,w);
}


Measured memory_bytes: 12560
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 1000100;
string a[maxn];
int arr[maxn], n;

vector<pair<int,int> > v;

int main() {
	cin>>n;

	int minind = -1, maxind = -1;
	int minbal = INT_MAX, maxbal = INT_MIN;

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

		int bal = 0;
		for(char j:a[i]) {
			if(j == '(') bal--;
			else bal++;
		}

		if(a[i][0] == '(' && bal < minbal) {
			minbal = bal;
			minind = i;
		}
		else if(a[i][sz(a[i])-1] == ')') {
			if(bal > maxbal) {
				maxbal = bal;
				maxind = i;
			}
		}
	}

	if(minind == -1 || maxind == -1) {
		cout<<"No\n";
		return 0;
	}

	arr[0] = minind;
	arr[n-1] = maxind;

	for(int i=0;i<n;i++) {
		if(i == minind || i == maxind) {
			continue;
		}

		int bal = 0;
		for(char j:a[i]) {
			if(j == '(') bal--;
			else bal++;
		}

		v.pb(mp(bal, i));
	}

	sort(v.begin(), v.end());

	for(int i=0;i<n-2;i++) {
		arr[i+1] = v[i].second;
	}

	int bal = 0;
	for(int i=0;i<n;i++) {
		for(char j:a[arr[i]]) {
			if(j == '(') bal--;
			else bal++;

			if(bal > 0) {
				cout<<"No\n";
				return 0;
			}
		}

	}

	if(bal != 0) {
		cout<<"No\n";
	}
	else {
		cout<<"Yes\n";
	}
}

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

int main(){
  string s;
  char s1, s2, s3;
  cin >> s;
  int count = 0;
  
  for ( int i=0;i<3;i++){
    if ( s.at(i) == '1' ){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
S = input()
T = input()

len_S = len(S)
len_T = len(T)

ans = 10**10
for i in range(len_S - len_T+1):
    num = 0
    for j in range(len_T):
        if S[i+j] != T[j]:
            num+=1
    ans = min(ans, num)

print(ans)

Measured memory_bytes: 9124
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	cout << S.substr(0,S.size() - 8) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    string s;
    cin >> s;

    s = s.substr(0, s.size() - 1);
    ll n = s.size();
    for(size_t i = 0; i < n; i++) {
        s = s.substr(0, s.size() - 1);
        // cout << s << endl;
        if(s.size() % 2 != 0)
            continue;

        bool res = true;

        if(s.substr(0, s.size() / 2) != s.substr(s.size() / 2))
            res = false;

        if(res) {
            cout << s.size();
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <string>
using namespace std;


int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  for (int i = 0; i < N; i++) {
    if( i != K - 1) cout << S[i];
    else {
      string s = S.substr(K-1,1);
	  transform(s.cbegin(), s.cend(), s.begin(), ::tolower);
      cout << s; 
    }
  }
  
  cout << endl;

  return 0;
}


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

int linear(int a[], int key, int n);
int main()
{
	int i, j, n, q, c = 0;
	int s[100000], t[100000];

	cin >> n;
	for (i = 0; i < n; i++) cin >> s[i];
	
	cin >> q;
	for (i = 0; i < q; i++) cin >> t[i];

	for (i = 0; i < q; i++) {
		c = c + linear(s, t[i], n);
	}
	cout << c << endl;

}
int linear(int a[], int key, int n)
{
	int i = 0;
	a[n] = key;
	while (a[i] != key) {
		i++;
	}
	if (i >= n) {
		return 0;
	}
	else {
		return 1;
	}
}

Measured memory_bytes: 3112
A,B=[int(z) for z in input().split(" ")]

K=((B-A)//2)%2
if A%2==0 and B%2!=0:
  ans=(K+1)%2
elif A%2==0 and B%2==0:
  ans=K ^ B
elif A%2!=0 and B%2==0:
  ans=K^A^B
else:
  ans=K^A

print(ans)

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

int z(int x){
  return max(x,-x);
}

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  for(int i=0;i<N;i++){
    cin >> W.at(i);
    sum += W.at(i);
  }
  int delta = sum - 2*W.at(0);
  int ans = z(delta);
  for(int i=1;i<N;i++){
    delta = delta - 2*W.at(i);
    ans = min(ans,z(delta));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int MX = 1e5+5;


int n,W;
vector <int> v,w;
int dp[MX][104];

int solve(int weight, int ind){
    if(weight>W) return -1e17;
    if(ind == n + 1) return 0;
    if(dp[weight][ind] != -1) return dp[weight][ind];
    long long ans = -1e17;
    ans = max(ans, solve(weight + w[ind], ind + 1) + v[ind]);
    ans = max(ans, solve(weight, ind + 1));
    return dp[weight][ind] = ans;
}

int32_t main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>W;
    v.resize(n+1);
    w.resize(n+1);
    for(int i=1 ; i<=n ; i++) cin>>w[i]>>v[i];
    cout<<solve(0,1);
    return 0;
}


Measured memory_bytes: 81536
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}

	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &n) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (n = 0; c >= 33 && c <= 126; s[++n] = c, c = gc());
		s[n+1] = '\0';
	}
	inline void rds(string &s) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (s.clear(); c >= 33 && c <= 126; s.pb(c), c = gc());
	}

	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	template <class I>
	inline void printa(I *a, int n) {
		for (int i = 1; i <= n; i++) print(a[i], " \n"[i==n]);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(char *s, int n) {
		for (int i = 1; i <= n; i++) pc(s[i]);
		pc('\n');
	}
	inline void prints(string s) {
		int n = s.length();
		while (t < n) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printa;
using io::printc;
using io::prints;

int main() {
	int k;
	rd(k);
	if (k == 1) return prints("1\n1"), 0;
	int n = (k + 3) / 4 * 2;
	print(n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			int c = (i + j) % n;
			if ((i & 1) && c + n < k) c += n;
			print(c + 1, " \n"[j==n-1]);
		}
	return 0;
}

Measured memory_bytes: 4544
#include <cstdio>
#include <algorithm>
typedef long long int64;

int64 n, a, b;

inline int digits(int64 a) {
    int ret = 0;
    while (a > 0) a /= 10, ++ret;
    return ret;
}

int main()
{
    scanf("%lld", &n);
    int ans = 114514;
    for (int64 a = 1; a * a <= n; ++a) if (n % a == 0) {
        int cur = std::max(digits(a), digits(n / a));
        if (ans > cur) ans = cur;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}

int main() {
  ll N, X;
  cin >> N >> X;

  vector<ll> Abs(N);
  for (ll i = 0; i < N; i++) {
    ll x;
    cin >> x;
    Abs[i] = abs(x - X);
  }

  sort(begin(Abs), end(Abs));

  // すべてに共通する最大の約数が答えだ
  const auto ans = accumulate(cbegin(Abs), cend(Abs), *crbegin(Abs), gcd<ll>);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import scala.collection.mutable.Queue

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w = sc.nextInt()
  val g = Array.fill(h)(sc.next().map(_ == '#').toArray)
  val walls = g.map(_.count(identity)).sum
  val sp = bfs(0, 0, h, w, g)(h-1)(w-1)
  println(if (sp == -1) -1 else (w * h) - walls - sp - 1)

  def bfs(sx: Int, sy: Int, w: Int, h: Int, g: Array[Array[Boolean]]): Array[Array[Int]] = {
    val ans = Array.fill(w, h)(-1)
    val queue = Queue((sx, sy))
    ans(sx)(sy) = 0
    queue.enqueue((sx, sy))

    val d = List((1,0),(-1,0),(0,1),(0,-1))
    while (queue.nonEmpty) {
      val (x1, y1) = queue.dequeue
      for ((dx, dy) <- d) {
        val x2 = x1 + dx
        val y2 = y1 + dy
        if (0 <= x2 && x2 < w && 0 <= y2 && y2 < h && !g(x2)(y2) && ans(x2)(y2) == -1) {
          ans(x2)(y2) = ans(x1)(y1) + 1
          queue.enqueue((x2, y2))
        }
      }
    }
    ans
  }
}


Measured memory_bytes: 58584
Sd = input()
T = input()

Sdl = len(Sd)
Tl = len(T)

ans_str = ''

# inspect strings in reverse order
for i in reversed(range(Sdl - Tl + 1)):
  # if there is a character that hits, compare it with the string T.
  if Sd[i] == T[0] or Sd[i] == '?':
    is_match = True
    # loop for length of string T
    for j in range(Tl):
      # if string Sd doesn't match T and is not '?'
      if Sd[i + j] != T[j] and Sd[i + j] != '?':
        is_match = False
        break
    # if there is a T that meets the conditions, replace part of Sd
    if is_match:
      ans_str = Sd[:i] + T + Sd[i + Tl:]
      break

if ans_str:
  print(ans_str.replace('?', 'a'))
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
///////////////////////////////////////////////
//		 ©Ahmad Haulian Yoga Pratama		 //
//          SMA TARUNA NUSANTARA		     //
//                MAGELANG					 //
//				   157503 					 //
// 		   	 All Right Reserved				 //
///////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
#define scanint(n) scanf("%d",&n)
#define scanll(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define reset(a,b) memset(a,b,sizeof a)
#define ll long long
#define MAXAND 0x7fffffff
#define MOD 1000000007
#define lch(x) (2*x)
#define rch(x) (2*x+1)
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo lch(idx),l,MID
#define tengen rch(idx),MID+1,r
/*
template <class T> void inp(T &N){
    char ch;
    int sign = 1;
    while(ch = getchar_unlocked(), isspace(ch)) {

    };
    N = 0;
    if(ch == '-')
        sign = -1;
    else N = ch - '0';
    while(ch = getchar_unlocked(), isdigit(ch))
        N = (N << 3) + (N << 1) + ch - '0';
    N *= sign;
}
*/
int n,h,a,b;
vector<pii>ve;
int cel(int a,int b){
	int tot=a/b;
	if(a%b)return tot+1;
	return tot;
}

int main(){
	cin>>n>>h;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		ve.pb(mp(a,2));
		ve.pb(mp(b,1));
	}
	sort(ALL(ve));
	reverse(ALL(ve));
	int jaw=0;
	for(int i=0;i<ve.size();i++){
		pii now=ve[i];
		if(now.s==2){
			jaw+=cel(h,now.f);
			break;
		}
		else{
			jaw++;
			h-=now.f;
		}
		if(h<=0)break;
		//cout<<h<<endl;
	}
	cout<<jaw<<endl;
}



Measured memory_bytes: 2420
import sys
input = sys.stdin.readline
s=input().strip()
q=int(input())
from collections import deque
que=deque(s)
mae=1
for _ in range(q):
    query=list(input().split())
    if query[0]=="1":
        mae*= -1
    else:
        if mae==1:
            if query[1]=="1":
                que.appendleft(query[2])
            else:
                que.append(query[2])
        else:
            if query[1]=="1":
                que.append(query[2])
            else:
                que.appendleft(query[2])
    #print(que)
if mae==1:
    print("".join(que))
else:
    print("".join(list(que)[::-1]))


Measured memory_bytes: 70748
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  int a[n],sum=0;
  for(auto &i:a) cin >>i;
  sort(a,a+n);
  for(int i=0; i<n; i++){
    if(i==n-1) a[i]/=2;
    sum+=a[i];
  }
  cout <<sum;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3692
'''
スタックを用いた逆ポーランド記法の計算機の実装
・文字列が数字であればスタックに積む
・文字列が演算子であれば、スタックから2個値を取り出し演算結果をスタックに積む
'''

from collections import deque


def reverse_polish_notation(lst):
    stack = deque()
    for i in lst:
        if str(i).isdecimal():
            stack.append(int(i))
        else:
            if i == "+":
                b = stack.pop()
                a = stack.pop()
                stack.append(a+b)
            if i == "-":
                b = stack.pop()
                a = stack.pop()
                stack.append(a-b)
            if i == "*":
                b = stack.pop()
                a = stack.pop()
                stack.append(a*b)
    return stack[0]


lst = list(input().split())
print(reverse_polish_notation(lst))


Measured memory_bytes: 6008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        int x = fr.nextInt();
        if(360%x==0){
            System.out.println(360/x);
        }
        else{
            int count=1;
            int angle = x;
            while(true){
                if(angle%360==0){
                    break;
                }
                else{
                    count++;
                    angle+=x;
//                    System.out.println(angle);
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 32536
N = int(input())
A = list(map(int, input().split()))

t = [-1] * (N + 1)
t[0] = 1000
for i in range(N):
    k = t[i] // A[i]
    y = t[i] % A[i]
    for j in range(i, N):
        t[j + 1] = max(t[j + 1], k * A[j] + y)
print(t[N])


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

int main(){
  int N;
  cin >> N;
  double ans = 0;

  for (int i = 0; i < N; i++)
  {
    double num;
    string s;
    cin >> num >> s;
    if (s == "BTC") //""わすれた
    {
      num *= 380000.0; //＝つけ忘れた
    }
    ans += num;
  }
  cout << ans <<endl;
}

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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

long long divmod(long long a, long long b, long long m)
{
    return a*powmod(b, m-2, m)%m;
}

int main()
{
    long long M = 1000003;

    vector<long long> G(M+1);
    G[1] = 1;
    for (int i=2; i<=M; i++)
        G[i%M] = (i-1)*G[i-1]%M;

    int Q;
    cin>>Q;
    for (int i=0; i<Q; i++)
    {
        long long x, d, n;
        cin>>x>>d>>n;
        if (d==0)
            cout<<powmod(x, n, M)<<endl;
        else
        {
            long long xd = divmod(x, d, M);
            if (n>M-xd)
                cout<<0<<endl;
            else
                cout<<powmod(d, n, M)*divmod(G[(xd+n)%M], G[xd], M)%M<<endl;
        }
    }
}


Measured memory_bytes: 8704
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int A = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		switch(X){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			X = 0;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			X = 1;
			break;
		case 2:
			X = 2;
			break;
		}
		switch(Y){
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			Y = 0;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			Y = 1;
			break;
		case 2:
			Y = 2;
			break;
		}
		if(X==Y){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int a,b,c;
char s[2333];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	if (len<=2) printf("%s\n",s);
	else printf("%c%d%c\n",s[0],len-2,s[len-1]);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
#define N 55
int n, a[N];
double s;
int main(){
	n = read();
	for (register int i = 1; i <= n; ++i) a[i] = read();
	std :: sort(a + 1, a + 1 + n);
	s = a[1];
	for (register int i = 2; i <= n; ++i)
		s = (s + a[i]) / 2;
	printf("%.10lf\n", s);
}

Measured memory_bytes: 128
import numpy as np

N, T = input().split()
N = int(N)
T = int(T)
c = np.zeros(N)
t = np.zeros(N)
for i in range(N):
    cc, tt = input().split()
    c[i] = int(cc)
    t[i] = int(tt)
if (t < T).sum() > 0:
    n = np.min(c[t <= T])
    print(int(n))
else:
    print("TLE")

Measured memory_bytes: 12488
#include <bits/stdc++.h>
int main(int argc, char** argv)
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a, b, c, x;
    cin >> a >> b >> c;

    int i = 0;
    for (auto s : { a,b,c })
        x.push_back(s[i++]);
    cout << x << "\n";
    return 0;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  while(1){
    int n,m; cin >> n >> m; if(n == 0 and m == 0) break;
    vvi stu(m,vi(1270));
    int r; cin >> r;
    rep(i,r){
      int t,a,b,s; cin >> t >> a >> b >> s;
      b--;
      if(s) stu[b][t]++;
      else stu[b][t]--;
    }
    rep(i,m) rep(j,1269)
      stu[i][j+1] += stu[i][j];
    //dump(stu);
    int q; cin >> q;
    rep(i,q){
      int ts,te,a; cin >> ts >> te >> a; a--;
      int ans = 0;
      FOR(j,ts,te)
	if(stu[a][j]) ans++;
      cout << ans << endl;
    }
  }
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int serch=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(serch==a[i]){
			serch++;
		}
	}
	if(serch==1){
		cout<<-1<<endl;
	}else{
		cout<<n-serch+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    string s;
    cin >> s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='S') cout << 2 <<endl;
    else if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout <<3<<endl;
    else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R') cout <<2 <<endl;
    else if(s[0]=='R'&&s[1]=='S'&&s[2]=='R') cout <<1 <<endl;
    else if(s[0]=='S'&&s[1]=='S'&&s[2]=='R') cout <<1 <<endl;
    else if(s[0]=='R'&&s[1]=='S'&&s[2]=='S') cout <<1 <<endl;
    else if(s[0]=='S'&&s[1]=='R'&&s[2]=='S') cout <<1 <<endl;
    else cout << 0 <<endl;
}

Measured memory_bytes: 3624
N = input().split()
for i in range(2):
    if i == 0:
        A = int(N[i])
    elif i == 1:
        B = int(N[i])

X_1 = A + B
X_2 = A - B
X_3 = A * B

max = X_1

if max < X_2:
    max = X_2
if max < X_3:
    max = X_3

print(max)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(void){
    char S[114],T[114];
    scanf("%s %s",S,T);
    int yamada=strlen(S);
    int homo=strlen(T);
    for(int i=yamada-homo;i>=0;i--){
        int buri=0;
        for(int j=0;j<homo;j++){
            if(S[i+j]!=T[j]&&S[i+j]!='?'){buri=1;break;}
        }
        if(buri==0){
            for(int j=0;j<homo;j++)S[i+j]=T[j];
            for(int j=0;j<yamada;j++)if(S[j]=='?')S[j]='a';
            printf("%s",S);
            return 0;
        }
    }
    printf("UNRESTORABLE");
    return 0;
}


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

namespace ABC081B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] strary = Console.ReadLine().Split(' ');
            int[] an;
            an = new int[n];
            for (int i = 0; i < n; i++)
            {
                an[i] = int.Parse(strary[i]);
            }

            int j = 0;
            Boolean warikirenai = false;

            while (true)
            {
                for (int i = 0; i < n; i++)
                {
                    if (an[i] % 2 == 0)
                    {
                        an[i] = an[i] / 2;
                    }
                    else
                        warikirenai = true;
                }
                if (warikirenai)
                    break;
                else
                    ++j;
            }
            Console.WriteLine("{0}",j);
            Console.Read();
        }
    }
}


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

int main() {
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '#') ++cnt;
        }
    }
    cout << (h + w - 1 == cnt ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  bool nasu = false;
  string s;
  cin >> s;
  deque<char> str;
  rep(i, s.size()){
    str.push_back(s[i]);
  }
  int q;
  cin >> q;
  int t, f;
  char c;
  rep(i, q){
    cin >> t;
    if(t == 1){
      if(nasu){
	nasu = false;
      } else {
	nasu = true;
      }
    } else {
      cin >> f >> c;
      if(f == 1){
	if(!nasu){
	  str.push_front(c);
	} else {
	  str.push_back(c);
	}
      } else {
	if(!nasu){
	  str.push_back(c);
	} else {
	  str.push_front(c);
	}
      }
    }
  }
  if(!nasu){
    rep(i, str.size()){
      cout << str[i];
    }
  } else {
    for(int i = str.size() - 1;i >= 0;i --){
      cout << str[i];
    }
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 976
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
array=[a,b,c,d,e]
flag=True
 
for i in range(5):
  for j in range(5):
    if array[i]-array[j] > k:
      flag=False
      print(":(")
      break
  if not flag:
    break
      
if flag:
  print("Yay!")

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

void swap(char *s1, char *s2)
{
    char tmp[128];
    strcpy(tmp, s1);
    strcpy(s1, s2);
    strcpy(s2, tmp);
}

int big(char *s1, char *s2, int len)
{
    for (int i = 0; i < len; ++i) {
        if (s1[i] > s2[i]) {
            return 1;
        }
        if (s1[i] < s2[i]) {
            return 0;
        }
    }
    return 0;
}

int main(int argc, char **argv)
{
    int n, l;
    scanf("%d %d", &n, &l);

    char s[128][128];
    for (int i = 0; i < n; ++i) {
        scanf("%s", s[i]);
    }

    for (int i = 0; i < n-1; ++i) {
        for (int j = 0; j+1 < n-i; ++j) {
            if (big(s[j], s[j+1], l)) {
                swap(s[j], s[j+1]);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%s", s[i]);
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 128
from math import cos, sin, radians

x, y, d = 0, 0, 90
while 1:
    a, b = map(int, raw_input().split(','))
    if a == b == 0:
        break
    x += a * cos(radians(d))
    y += a * sin(radians(d))
    d = (d - b) % 360
print int(x)
print int(y)

Measured memory_bytes: 4412
#!/usr/bin/env python3
import sys


def solve(N, X):
    Y = sorted(list(zip(X, range(N))))
    n = N // 2
    d = dict()
    for i in range(N):
        m = n - (i >= n)
        d[Y[i][1]] = Y[m][0]
    for k, v in (sorted(d.items(), key=lambda x: x[0])):
        print(v)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77912
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    int ans=k*pow(k-1,n-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int n,m,x;cin>>n>>m>>x;
    vector<int>c(n);
    int a[n][m];
    int mn = 1e9;
    bool flag = false;
    rep(i,n){cin>>c[i];rep(j,m)cin>>a[i][j];}
    for (int bit = 0; bit < (1<<n); ++bit){
        int sum[m]={0};
        int pri = 0;
        bool can = true;
        rep(i,n){
            if (bit & (1<<i)){pri+=c[i];rep(j,m){sum[j]+=a[i][j];}}
        }
        rep(i,m){if(sum[i]<x){can = false;}}
        if(can){mn = min(mn, pri);flag = true;}
    }
    if(!flag)co(-1);
    else co(mn);

}


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

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

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int num3 = sc.nextInt();

        if(num1 >= num2 && num1 >= num3) {
            System.out.print(10*num1 + num2 + num3);
        } else if (num2 >= num1 && num2 >= num3) {
                        System.out.print(10*num2 + num1 + num3);

        } else {
                        System.out.print(10*num3 + num2 + num1);
}


    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
int main(){
    string s; cin >> s;
    if((s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) || (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) || (s[0]==s[3] && s[1]==s[2] && s[0]!=s[1])){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
return 0;
}

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

using namespace std;

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

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

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

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

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  cin>>n;
  map<int, int> mp;
  REP(i, n){
    int a;
    cin>>a;
    // DEBUG(mp.count(a));
    if(mp.count(a)){
      cout<<"NO"<<'\n';
      return 0;
    }
    mp.insert(make_pair(a, 1));
  }
  cout<<"YES"<<'\n';
  return 0;
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int x = 0;
    for(int i = 1; i <= b-a; i++) {
      x += i;
    }
    System.out.println(x-b);
  }
}

Measured memory_bytes: 32280
#include<iostream>

using namespace std;

int main(){
  int W,a,b,ans;
  cin >> W >> a >> b;

  if(a<b){
    if(a+W>=b) ans = 0;
    else ans = b-(a+W);
  } else {
    if(b+W>=a) ans = 0;
    else ans = a-(b+W);
  }

  cout << ans << endl;


  return 0;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, u, v = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)


def calc_dist(s):
    dist = [-1] * (N + 1)
    dist[s] = 0
    node = [s]
    while node:
        s = node.pop()
        d = dist[s]
        for t in edge[s]:
            if dist[t] != -1:
                continue
            dist[t] = d + 1
            node.append(t)
    return dist[1:]


taka = calc_dist(u)
aoki = calc_dist(v)
ans = 0

for x, y in zip(taka, aoki):
    if x <= y:
        ans = max(ans, y - 1)

print(ans)


Measured memory_bytes: 29836
/*
ID: iCoder0020
PROG: Knapsack 1
LANG: C++                  
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define w(n) info[n].first
#define v(n) info[n].second

int32_t main()
{
	int N,W;
	cin>>N>>W;
	vector<int>dp(W+1, 0);
	pair<int, int> info[N];
	for(int n = 0; n<N; n++)
	{
		cin>>w(n)>>v(n);
		for(int j = W-w(n); j>=0; j--)
			dp[w(n)+j] = max(dp[w(n)+j], v(n) + dp[j]);
	}
	cout<<dp[W]<<endl;
	return 0;	
}

Measured memory_bytes: 1024
N = int(input())
Ass = tuple(tuple(map(int, input().split())) for _ in range(N))
index = [0 for _ in range(N)]

Q = set(range(N))
ans = -1
while Q:
    ans += 1
    Q2 = Q.copy()
    Q.clear()
    for i in Q2:
        if index[i] >= N - 1:
            continue
        t = Ass[i][index[i]] - 1
        if Ass[t][index[t]] == i + 1:
            Q.add(i)
            Q.add(t)
    for i in Q:
        index[i] += 1

if min(index) < N - 1:
    print(-1)
else:
    print(ans)

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    double x = n/2;
    double y = n - x;
    cout << fixed << setprecision(11) << y/n << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<deque>
using namespace std;
 
int main()
{
	deque<int> d;
	int dist[100010];
	dist[1]=1;
	d.push_back(1);
	
	int k;
	cin>>k;
	
	for (int i = 0; i <= k; ++i)
		dist[i] = 100000000;
	dist[1]=1;
	
	while(d.size()!=0)
	{
		int x=d.front();
		d.pop_front();
		
		if(dist[(x*10)%k]>dist[x]){
			dist[(x*10)%k]=dist[x];
			d.push_front((x*10)%k);
		}
		
		if(dist[(x+1)%k]>dist[x]+1){
			dist[(x+1)%k]=dist[x]+1;
			d.push_back((x+1)%k);
		}
	}
	
	cout<<dist[0]<<endl;
	return 0;
}

Measured memory_bytes: 896
S = input()
N = len(S)
ans = [0]*N
r_switch = []
l_switch = []
cur = S[0]
for i, si in enumerate(S):
    if si != cur:
        if cur == "R":
            r_switch.append(i-1)
        else:
            l_switch.append(i-1)
        cur = si

idx = 0
for i, si in enumerate(S):
    if si == "L":
        continue
    swi = r_switch[idx]
    if i >= swi:
        idx += 1
        if idx > len(r_switch):
            break
    if (swi - i) % 2 == 0:
        ans[swi] += 1
    else:
        ans[swi + 1] += 1


idx = -1
for i, si in enumerate(reversed(S)):
    i = N-i-1
    if si == "R":
        continue

    if i <= swi:
        idx -= 1
        if idx < -N:
            break
    swi = r_switch[idx]
    if (i - swi) % 2 == 0:
        ans[swi] += 1
    else:
        ans[swi+1] += 1
print(*ans, sep=" ")


Measured memory_bytes: 10216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t x;
  cin >> x;
 
  while( (x%100) > 5){
    x = x - 105;
  }
  
  if(99 < x){
    cout << 1 << endl;
  }
  else if(x < 100){
    cout << 0 << endl;
  }    

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    long long K;
    cin >> S >> K;
    int N = S.size();
    long long A = 0;
    long long B = 0;
    long long count = 1;

    if (N == 1){
        cout << K/2 << endl;
        return 0;
    }

    for (int i = 1; i < N; i++) {
        if (S.at(i) == S.at(i-1)){
            count++;
            if (i == N-1){
                if (count == N){
                    cout << N*K/2 << endl;
                    return 0;
                }
                else {
                    A += count/2;
                }
            }
        }
        else {
            A += count/2;
            count = 1;
        }
    }

    S += S;
    count = 1;
    for (int i = 1; i < N*2; i++) {
        if (S.at(i) == S.at(i-1)){
            count++;
            if (i == N*2-1){
                B += count/2;
            }
        }
        else {
            B += count/2;
            count = 1;
        }
    }
    long long C = A + (B-A)*(K-1);
    cout << C << endl;
}


Measured memory_bytes: 3572
n = int(input())
a_list = list(map(int, input().split()))
a_list.reverse()
result = True
for i in range(n-1):
  if a_list[i+1] >= a_list[i]+2:
    result = False
    break
  elif a_list[i+1] == a_list[i]+1:
    a_list[i+1] -= 1
  if i == n-2 and a_list[i+1] <= a_list[i]:
    result = True
if result:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,k;cin>>n>>k;
    ll tmp=(n/k);
    ll ans=tmp*tmp*tmp;
    if(!(k%2)){
        if((n%k)>=(k/2)) tmp++;
        ans+=tmp*tmp*tmp;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let _n = get!(usize);
    let mut v = vec![0];
    v.append(&mut get!([i32]));
    v.push(0);
    let mut sum = 0;
    for i in 1..v.len() {
        sum += (v[i - 1] - v[i]).abs();
    }
    for i in 1..v.len() - 1 {
        let ans =
            sum + (v[i - 1] - v[i + 1]).abs() - ((v[i - 1] - v[i]).abs() + (v[i] - v[i + 1]).abs());
        println!("{}", ans);
    }
}


Measured memory_bytes: 7292
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int d = 2e4 + 1;
const int N = 2e4 + 10;

int n, a[N], b[N];

int main() {
	scanf("%d", &n);
	a[1] = 10; b[1] = 8e8 + 10;
	for (int i = 2; i <= n; i++) {
		a[i] = a[i - 1] + d;
		b[i] = b[i - 1] - d;
	}
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		b[x] += i;	
	}
	for (int i = 1; i <= n; i++)
		printf("%d%c", a[i], " \n"[i == n]);
	for (int i = 1; i <= n; i++)
		printf("%d%c", b[i], " \n"[i == n]);
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}

/*
重複する文字をまず考えない
間が奇数個なら先手の勝利だが端が重複するなら後手の勝利
間が偶数個なら後手の勝利だが端が重複するなら先手の勝利

重複する文字は...
重複する前に狙って取り除けば取り除いたときに重複せずに済む
よって最後3文字残ったとき以外は必ず回避可能
*/

int main() {
    string S;
    cin >> S;
    int N = S.length();
    if ((N % 2) ^ (S[0] == S[N-1])) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }


}


Measured memory_bytes: 512