akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

#define rep(i,n) for (long long int i = 0; i < (n); i++)

using namespace std;

int main(int argc, char* argv[]){
  long long int K, A, B;
  cin >> K >> A >> B;

  for (long long int i = A; i <= B; i++){
    if(i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
miti={}
for k in range(3):
    b, c = map(int, input().split())
    miti.setdefault(b,[]).append(c)
    miti.setdefault(c,[]).append(b)
    
miti_count=[]
memo=[]

a_mati=len(miti[1])
miti_count.append(a_mati)
if a_mati==2:
    memo.append(1)
    
b_mati=len(miti[2])
miti_count.append(b_mati)
if b_mati==2:
    memo.append(2)

c_mati=len(miti[3])
miti_count.append(c_mati)
if c_mati==2:
    memo.append(3)

d_mati=len(miti[4])
miti_count.append(d_mati)
if d_mati==2:
    memo.append(4)
    
if len(memo)==2 and miti_count.count(1)==2:
    if (memo[1] in miti[memo[0]])==True and (memo[0] in miti[memo[1]])==True:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

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

int fn (int n){

    if(n%2==0){
        n=n/2;
    }
    else{
        n=3*n+1;
    }
    return n;
}
int main () {
int A; cin >> A;
int count=0;
int i=1;
int table[1000000];
table[0]=A;
while(count==0){
    table[i]=fn(table[i-1]);
    for(int j=0;j<i;++j){
        if(table[i]==table[j]){count=i+1;}
    }
    i=i+1;
}

cout << count  << endl ;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#define maxn 200+1
using namespace std;
int n,a[maxn],ans;
int main()
{
	scanf("%d",&n);
	int md=n<<1;
	for(int i=1;i<=md;++i)
	{
		scanf("%d",&a[i]);
	}
    sort(a+1,a+1+md);
    for(int i=1;i<=md;i+=2)
    {
        ans+=a[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
<?php
$gcds = array();
$lcms = array();

function gcd($m, $n) {
	if($m > $n) {
		list($m, $n) = array($n, $m);
	}

	$gcd_a = $m;
	$gcd_b = $n;

	while (($surplus = $gcd_a % $gcd_b) !== 0) {
		$gcd_a = $gcd_b;
		$gcd_b = $surplus;
	}
	
	return $gcd_b;
}

function lcm($m, $n) {
	return $m * $n / gcd($m, $n);
}

while (($stdin = trim(fgets(STDIN))) !== '') {

	$input = explode(' ', $stdin);

	$a = intval($input[0]);
	$b = intval($input[1]);

	$answers[] = gcd($a, $b).' '.lcm($a, $b)."\n";
}

foreach ($answers as $ans) {
	echo $ans;
}

Measured memory_bytes: 6652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int X[1000], Y[1000], P[1000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		P[i] = (abs(X[i]) + abs(Y[i])) % 2;
		if (P[i] != P[0]) {
			cout << -1 << endl;
			return 0;
		}
	}
	vector<int> arm;
	for (int i = 30; i >= 0; i--) arm.push_back(1 << i);
	if (!P[0]) arm.push_back(1);
	cout << arm.size() << endl;
	for (int i = 0; i < arm.size(); i++) {
		if (i > 0) cout << " ";
		cout << arm[i];
	}
	cout << endl;
	for (int i = 0; i < N; i++) {
		int tx = X[i] - Y[i], ty = X[i] + Y[i];
		vector<bool> x(arm.size()), y(arm.size());
		for (int j = 0; j < arm.size(); j++) {
			if (tx >= 0) tx -= arm[j], x[j] = 1;
			else tx += arm[j], x[j] = 0;
			if (ty >= 0) ty -= arm[j], y[j] = 1;
			else ty += arm[j], y[j] = 0;
		}
		for (int j = 0; j < arm.size(); j++) {
			if (x[j]) {
				if (y[j]) cout << "R";
				else cout << "D";
			}
			else {
				if (y[j]) cout << "U";
				else cout << "L";
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    priority_queue<long long> p;
    for (int i = 0; i < n; i++) {
        long long c; cin >> c;
        p.push(c);
    }
    long long ans = 0;
    while (!p.empty()) {
        long long t = p.top(); p.pop();
        if (m) {
            m--;
            p.push(t/2);
        } else ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main() {
	// your code goes here
	string t;
	cin>>t;
	for(int i=0;i<t.size();i++){
	if(t[i]=='?'){
		t[i]='D';
	}
	}
	cout<<t<<endl;
	
	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int A, B, X;
    cin >> A >> B >> X;

    if (A <= X && X <= A + B) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
        else:
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m = map(int,input().split())
A = [0]*m
B = [0]*m
for i in range(m):
    A[i],B[i] = map(int,input().split())

ans = 0
for i in range(m):
    u = UnionFind(n)
    for j in range(m):
        if i==j:continue
        a,b = A[j]-1,B[j]-1
        u.union(a,b)
    for j in range(n):
        u.find(j)
    if len(set(u.parents))!=1:
        ans+=1
print(ans)





Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m, T;
	cin >> n >> m >> T;
	vector<ll> a(T, -1);
	rep(i, n){
		ll x; cin >> x;
		a[x % T] = max(a[x % T], x / T);
	}
	vector<ll> dp(T, -1);
	dp[0] = 0;
	
	auto mul = [](const vector<ll> &a, const vector<ll> &b){
		const int T = a.size();
		vector<ll> c(T, -1);
		rep(i, T) if(a[i] >= 0) rep(j, T) if(b[j] >= 0){
			if(i + j >= T) c[i + j - T] = max(c[i + j - T], a[i] + b[j] + 1);
			else c[i + j] = max(c[i + j], a[i] + b[j]);
		}
		return c;
	};
	for(; m; m /= 2){
		if(m & 1) dp = mul(a, dp);
		a = mul(a, a);
	}
	
	int Q; cin >> Q;
	while(Q--){
		ll x, y; cin >> x >> y;
		ll mx = -1;
		for(; x < T; x++) mx = max(mx, dp[x]);
		cout << (mx >= y ? "yes" : "no") << endl;
	}
	return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    multiset<int> S1, S2, tmp;
    for(int i=0; i<(1<<N); i++) {
        int S;
        cin >> S;
        S1.insert(S);
    }

    cerr << *S1.rbegin() << endl;
    S2.insert(*S1.rbegin());
    S1.erase(--S1.end());

    for(int d=0; d<N; d++) {
        tmp = S2;
        for(auto itr=tmp.rbegin(); itr!=tmp.rend(); itr++) {
            auto l = S1.lower_bound(*itr);
            if(l == S1.begin()) {
                cout << "No" << endl;
                return 0;
            } else {
                --l;
                S2.insert(*l);
                S1.erase(l);
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,m; cin >> n >> m;
    int res = (n+1)*(m+1)- (n+1)*2-(m-1)*2;
    cout << res << endl;;
}


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

int main()
{
    int x;
    cin >> x;
    cout << 1-x << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int M = 0;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int p;
    cin >> p;
    ans += p;
    M = max(M, p);
  }
  ans -= M / 2 ;
  cout << ans << endl;
}


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

int main(){
  int W,H,x,y;
  cin>>W>>H>>x>>y;
  
  cout<<(float)W*H/2.0<<" ";
  if(2*x==W&&2*y==H){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
 
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int K = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node(i);
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }
    int[][] block = new int[K][2];
    for (int i = 0; i < K; i++) {
      block[i][0] = scanner.nextInt() - 1;
      block[i][1] = scanner.nextInt() - 1;
    }
 
    int[] group = new int[N];
    Arrays.fill(group, -1);
    int gid = 0;
    for (int i = 0; i < N; i++) {
      if (group[i] < 0) {
        dfs(nodes[i], group, gid);
        gid++;
      }
    }
    int[] gsize = new int[gid];
    for (int i = 0; i < N; i++) {
      gsize[group[i]]++;
    }
    int[] res = new int[N];
    for (int i = 0; i < N; i++) {
      res[i] = gsize[group[i]] - nodes[i].adjacent.size() - 1;
    }
    for (int i = 0; i < K; i++) {
      int c = block[i][0];
      int d = block[i][1];
      if (group[c] == group[d]) {
        res[c]--;
        res[d]--;
      }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      sb.append(res[i]).append(' ');
    }
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }
 
  private static void dfs(Node node, int[] group, int gid) {
    group[node.id] = gid;
    for (Node n : node.adjacent) {
      if (group[n.id] < 0) dfs(n, group, gid);
    }
  }
 
  private static class Node {
    private final int id;
    private final List<Node> adjacent = new ArrayList<>();
 
    private Node(int id) {
      this.id = id;
    }
  }
}

Measured memory_bytes: 124616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll maisuu[300010];
ll cnt[300010];
ll nnn;
int f(int k,int m){
	ll ans=k*m;
	for(int i=nnn-1;i>=0&&ans>0;i--){
		ans-=min(m,maisuu[i])*cnt[i];
	}
	return ans<=0;
}

ll a[300010];
ll temp[300010];
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	sortup(a,n);
	rep(i,0,n){
		int t=i;
		while(a[t]==a[i])t++;
		temp[t-i]++;
		i=t-1;
	}
	rep(i,1,n+1)if(temp[i]){
		maisuu[nnn]=i;
		cnt[nnn]=temp[i];
		nnn++;
	}
	
	rep(k,1,n+1){
		ll l=0,r=n/k+1;//l可能,r不可能
		while(r-l>1){
			int m=(l+r)/2;
			if(f(k,m))l=m;
			else r=m;
		}
		printf("%lld\n",l);
	}
}

Measured memory_bytes: 6952
#include<bits/stdc++.h>
using namespace std;
const int N=85,low=85*85*2;
int a[N][N],b[N][N];
bitset<N*N*4>dp[N][N];
int mx[N][N];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&b[i][j]);
    dp[1][1].set(a[1][1]-b[1][1]+low,1);
    dp[1][1].set(b[1][1]-a[1][1]+low,1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        if(i==1&&j==1) continue;
        int x=abs(a[i][j]-b[i][j]);
        dp[i][j]=(dp[i-1][j]<<x)|(dp[i-1][j]>>x)|(dp[i][j-1]<<x)|(dp[i][j-1]>>x);
    }
    int ans=1e9;
    for(int i=0;i<=low*2;i++)
        if(dp[n][m][i])
        {
            ans=min(ans,abs(i-low));
        }
    printf("%d\n",ans);
}


Measured memory_bytes: 24448
#include <stdio.h>

int main() {
  int a,b;
  scanf("%d %d\n",&a,&b);

 if (a>b) {
   printf("a > b\n");
 }
  
 if (a<b) {
   printf("a < b\n");
 }
  
 if (a==b) {
   printf("a == b\n");
 }
  
  return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var Q = input[1];
            var S = Read();
            var cnt = new int[N + 1];
            var max = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'C')
                {
                    cnt[i + 1] = cnt[i] + 1;
                    max++;
                }
                else cnt[i + 1] = cnt[i];
            }
            for (int i = 0; i < Q; i++)
            {
                input = ReadArrayInt();
                var l = input[0];
                var r = input[1];
                var ans = cnt[r - 1] - cnt[l - 1];
                Console.WriteLine(ans);
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 18492
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

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

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = cin.ReadInt;

            Console.WriteLine((a * b) / 2);
        }
    }

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


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, 0, n)
    {
        int t;
        cin >> t;
        mp[min(8, t / 400)]++;
    }
    int ans = 0;
    rep(i, 0, 8)
    {
        if (mp[i] > 0)
            ans++;
    }
    if (ans == 0 && mp[8] > 0)
    {
        ans++;
        mp[8]--;
    }
    cout << ans << " " << ans + mp[8] << endl;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;

#define show(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

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


int main()
{
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

  int n; string cad;
  map<string, int> veredict;

  cin >> n;
  while(n--){
    cin >> cad;
    veredict[cad]++;
  }

  cout << "AC" << " x " <<veredict["AC"] << endl;
  cout << "WA" << " x " <<veredict["WA"] << endl;
  cout << "TLE" << " x " <<veredict["TLE"] << endl;
  cout << "RE" << " x " <<veredict["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3532
package main

import (
	"fmt"
	"sort"
)


func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int,n )
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort( sort.Reverse(sort.IntSlice(a)))
	ans := 0
	t := n -1 // 何回足せるか
	for i := 0; i < n; i++ {
		lim := 2
		if i == 0 {
			lim = 1
		}
		for j := 0; j < lim; j++ {
			if t > 0 {
				ans += a[i]
				t--
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6500
#include <iostream>

using namespace std;

const int Maxn = 50;
int l[Maxn];

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; ++i){
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j){
            int a;
            cin >> a;
            l[a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i <= m; ++i) {
        if (l[i] == n) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
	int N,ans=-1;
	int A[100005][3];
	int dp[100005][3];
	
	scanf("%d",&N);
	
	for (int i=0;i<N;i++) for (int j=0;j<3;j++) scanf("%d",&A[i][j]);
	for (int i=1;i<N;i++) for (int j=0;j<3;j++) dp[i][j]=-1;
	for (int i=0;i<3;i++) dp[0][i] = A[0][i];
	
	
	for (int i=1;i<N;i++) {
		for (int j=0;j<3;j++){
			for (int k=0;k<3;k++){
				if (j==k) continue;
				dp[i][j] = max(dp[i][j],A[i][j] + dp[i-1][k]);
			}
		}
	}
	
	for (int i=0;i<3;i++) ans = max(ans,dp[N-1][i]);
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    return min((N+A-1)/A*B,(N+C-1)/C*D);
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e+9;
#define rep(i, n) for(int i = 0; i < n;i++)
#define REP(i, n) for(int i = 0; i <= n;i++)

int main(){
    string s;
    cin>>s;
    int flag = 0;
    rep(i,s.size()){
        if(i%2==0 and s[i]=='L'){
            flag=-1;
        }else if(i%2==1 and s[i]=='R'){
            flag = -1;
        }
    }
    if(flag<0)
        cout << "No"<< endl;
    else
        cout << "Yes" << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M;
int A[222222],B[222222];
vint G[111111];

int col[111111];
bool dfs(int v,int c){
    col[v]=c;
    for(auto u:G[v]){
        if(col[u]!=-1){
            if(col[u]==c)return false;
        }
        else if(!dfs(u,1-c))return false;
    }
    return true;
}

signed main(){
    cin>>N>>M;
    UnionFindTree uf(N);
    rep(i,M){
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        G[A[i]].pb(B[i]);
        G[B[i]].pb(A[i]);
        uf.unite(A[i],B[i]);
    }

    memset(col,-1,sizeof(col));
    int a=0,b=0,k=0;
    rep(i,N){
        if(uf.find(i)!=i)continue;
        if(uf.size(i)==1)k++;
        else{
            if(dfs(i,0))b++;
            else a++;
        }
    }

    cout<<a*a+2*a*b+2*b*b+2*N*k-k*k<<endl;
    return 0;
}


Measured memory_bytes: 14848
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int cnt[100001];

int main()
{
    int N;
    cin >> N;
    int a[100000];
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cnt[a[i]] += 1;

    int ans = 0;
    for(int i = 0; i < 100000-2; ++i){
        int tmp = cnt[i] + cnt[i+1] + cnt[i+2];
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

struct  UndirectedGraph{
    vector<vector<int>> g;
    vector<int> clr;
    vector<int> dis;
    int V;

    UndirectedGraph(int V) : V(V),
    g(vector<vector<int>>(V)),
    clr(vector<int>(V,0))
    {}

    //don't add (v,u) after adding (u,v)
    void add_edge(int u,int v){
        g[u].push_back(v);
        g[v].push_back(u);
    }


    //二部グラフ判定
    bool dfs_nib(int v,int c){
        clr[v]=c;
        for(auto x:g[v]){
            if(clr[x]==c) return false;
            if(clr[x]==0 && !dfs_nib(x,-c) ) return false;
        }
        return true;
    }
    bool isNib(){
        bool ret=true;
        for(int i=0;i<V;i++)if(clr[i]==0){
            if(!dfs_nib(i,1)){
                ret=false;break;
            }
        }
        return ret;
    }

    //distance
    void bfs(int st){
        dis=vector<int>(V,INF);
        vector<bool> checked(V,false);
        dis[st]=0;
        queue<int> q;
        q.push(st);
        while(!q.empty()){
            auto now=q.front();q.pop();
            if(checked[now]) continue;
            checked[now]=true;
            for(auto x:g[now]){
                if(checked[x]) continue;
                dis[x]=dis[now]+1;
                q.push(x);
            }
        }
    }
};

signed main(){
    int n;
    cin>>n;
    UndirectedGraph g(n);
    char s[n][n];
    rep(i,n){
        rep(j,n){
            char t;cin>>t;
            s[i][j]=t;
            if(t=='1'&&i>j){
                g.add_edge(i,j);
            }
        }
    }
    if(!g.isNib()){
        cout<<-1<<endl;
        return 0;
    }

    int ans=0;
    rep(i,n){
        g.bfs(i);
        int x=*max_element(ALL(g.dis));
        ans=max(x,ans);
    }   
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=n-1;i>=0;i--)cin>>a[i]>>b[i];
	int water=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int cur=water+a[i];
		int nxt=(cur+b[i]-1)/b[i];
		nxt*=b[i];
		int diff=nxt-cur;
		water+=diff;
		ans+=diff;
	}
	cout<<ans;
}


Measured memory_bytes: 4808
#coding: UTF-8

N = int(input())

a = [int(input()) for i in range(N)]

ans = set()

maxv = -9999999999
minv = a[0]
for i in range(1,N):
    if (a[i] - minv) > maxv:
        maxv = a[i] - minv
    if a[i] < minv:
        minv = a[i]

print(maxv)

Measured memory_bytes: 15648
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<string> ans = {"SS", "SW", "WS", "WW"};

  rep(i, 4) {
    loop(idx, 1, n - 1) {
      if (s[idx] == 'o') {
        if (ans[i][idx] == 'S')
          ans[i] += ans[i][idx - 1];
        else
          ans[i] += ans[i][idx - 1] == 'S' ? "W" : "S";
      } else {
        if (ans[i][idx] == 'S')
          ans[i] += ans[i][idx - 1] == 'S' ? "W" : "S";
        else
          ans[i] += ans[i][idx - 1];
      }
    }
  }
  rep(i, 4) ans[i] += ans[i] + ans[i];

  rep(i, 4) {
    int flag = true;
    loop(idx, n, 2 * n) {
      if (s[idx - n] == 'o') {
        if (ans[i][idx] == 'S' && (ans[i][idx - 1] != ans[i][idx + 1])) flag = false;
        if (ans[i][idx] == 'W' && (ans[i][idx - 1] == ans[i][idx + 1])) flag = false;
      } else {
        if (ans[i][idx] == 'S' && (ans[i][idx - 1] == ans[i][idx + 1])) flag = false;
        if (ans[i][idx] == 'W' && (ans[i][idx - 1] != ans[i][idx + 1])) flag = false;
      }
    }
    if (flag) {
      loop(j, n, 2 * n) cout << ans[i][j];
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 2236
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while (true) {
		int h, w;
		cin >> h >> w;
		if (h == 0 || w == 0) return 0;
		for (int i = 0; i < w; i++) cout << "#";
		cout << endl;
		for (int i = 1; i < h - 1; i++) {
			for (int j = 0; j < w; j++) {
				if (j == 0 || j == w - 1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		for (int i = 0; i < w; i++) cout << "#";
		cout << endl;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, lim;
string s;
vector<string> ans;
void dfs(int cur, int curl){
    if (cur == n){
        if (curl == lim)
            ans.push_back(s)    ;
        return ;
    }
    if (curl == lim){
        for (int i = 0; i <= lim; ++i)
            s[cur] = i + 'a', dfs(cur + 1, curl);
    }else {
        for (int i = 0; i <= curl; ++i)
            s[cur] = i + 'a', dfs(cur + 1, curl);
        if (curl < lim)
            s[cur] = curl + 1 + 'a', dfs(cur + 1, curl + 1);
    }
}
void init(){
    n = read();
}
void solve(){
    for (int i = 0; i < n; ++i)
        s.push_back('a');
    s[0] = 'a';
    for (int j = 1; j <= n; ++j){
        lim = j - 1;
        dfs(1, 0);
    }
    sort(ans.begin(), ans.end());
    for (auto& x: ans)
        cout << x << endl;
}
int main(){
    init();
    solve();
    return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int n, cur = 0;
	cin >> n;
	bool ok = 0;
	FOR(n)
	{
		int x, y;
		cin >> x >> y;
		if (x == y)
			cur++;
		else
			cur = 0;
		if (cur == 3)
		{
			ok = 1;
		}
	}
	cout << (ok ? "Yes" : "No");
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "No" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
int dp[1<<26];
//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    ll N=S.size();
    rep(i,1<<26) dp[i]=INF;
    dp[0]=0;
    int bit=0;
    rep(i,N){
        bit^=1<<(S[i]-'a');
        rep(j,26){
            mini(dp[bit],dp[bit^(1<<j)]+1);
        }
    }
    cout<< max(1,dp[bit]) <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 262804
from sys import stdin
high = [0] * 10000
par = [i for i in range(10000)]
def findSet(x):
    if par[x] == x: return x
    par[x] = findSet(par[x])
    return par[x]
def unite(x, y):
    x = findSet(x)
    y = findSet(y)
    if x == y: return
    if high[x] > high[y]: par[y] = x;
    else:
        par[x] = y
        if high[x] == high[y]: high[y] += 1
def same(x, y):
    return findSet(x) == findSet(y)
n, q = map(int, stdin.readline().split())
ans = []
for i in range(q):
    t, a, b = map(int, stdin.readline().split())
    if t == 0: unite(a, b);
    elif t == 1: ans.append(1 if same(a, b) else 0)
print(*ans, sep='\n')

Measured memory_bytes: 10028
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;




int a[10001];
int res[111][111];

int n,m;
int c;
int main(){
   //ios::sync_with_stdio(0);
   // freopen("in.in","r",stdin);
    //freopen("out_1.out","w",stdout);
    
    cin>>n>>m;
    cin>>c;
    for(int i=0;i<c;i++)
        scanf("%d",&a[i]);
    
    int d = 1;
    int i=0,j=0;
    int cur = 0;
    while(cur != c){
        while(a[cur]){           
            a[cur]--;
            res[i][j] = cur+1;
            if(d == 1 && j == m - 1){
                i++;
                d = -1;
            }
            else if(d == -1 && j == 0){
                i++;
                d = 1;
            }
            else{
                j += d;
            }
        }
        cur++;
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            printf("%d ",res[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 384
import itertools

N,A,B,C = map(int,input().split())
Comb = itertools.product([0,1,2,3],repeat=N)

L = []
for i in range(N):
  l = int(input())
  L.append(l)
  
# 各竹について  
# 0 : 使用しない
# 1 : 竹Aの材料にする  
# 2 : 竹Bの材料にする 
# 3 : 竹Cの材料にする
# 竹A,B,Cの作成法 :
# とりあえず全部合成 → 目的の長さに合わせる

ans = float('inf')
for X in Comb:
  tmp = 0
  m_A,m_B,m_C = [],[],[]
  for i in range(N):
    if(X[i] == 1): m_A.append(L[i])
    elif(X[i] == 2): m_B.append(L[i])
    elif(X[i] == 3): m_C.append(L[i])
  # 空の竹リストがないなら    
  if(len(m_A)*len(m_B)*len(m_C) != 0):      
    for take_list,take_len in zip([m_A,m_B,m_C],[A,B,C]):
      tmp += (len(take_list)-1)*10 # 合成
      tmp += (abs(take_len-sum(take_list)))*1 # 延長or短縮
    ans = min(ans,tmp)
  
print(ans)  

Measured memory_bytes: 3064
#include <stack>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, L[2009], R[2009], st[4009], col[2009][2009], dp[2009][2009]; string s[2009];
int calc(vector<int> v) {
	int n = v.size(), t = 0;
	for (int i = 0; i < n; i++) {
		while (t > 0 && v[st[t - 1]] >= v[i]) t--;
		L[i] = (t == 0 ? 0 : st[t - 1] + 1);
		st[t++] = i;
	}
	t = 0;
	for (int i = n - 1; i >= 0; i--) {
		while (t > 0 && v[st[t - 1]] >= v[i]) t--;
		R[i] = (t == 0 ? n : st[t - 1]);
		st[t++] = i;
	}
	int ret = 0;
	for (int i = 0; i < n; i++) ret = max(ret, v[i] * (R[i] - L[i] + 1));
	return ret;
}
int solve() {
	int ret = max(H, W);
	for (int i = 0; i < H - 1; i++) {
		stack<int> st;
		for (int j = 0; j < W - 1; j++) {
			if (col[i][j] == 0) dp[i][j] = (i == 0 ? 2 : dp[i - 1][j] + 1);
			else dp[i][j] = 1;
		}
		vector<int> v(dp[i], dp[i] + W - 1);
		ret = max(ret, calc(v));
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (s[i][j] != s[i][j + 1]) col[i][j] = 1;
		}
	}
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (col[i][j] != col[i + 1][j]) col[i][j] = 1;
			else col[i][j] = 0;
		}
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
using namespace std;

int main()
{
    ll n,m,i,j,k,t;

    cin>>n;

    string s;

    map<string,ll>mp;

    for(i=0;i<n;i++){

        cin>>s;

        mp[s]++;
    }

    cout<<"AC"<<" x "<<mp["AC"]<<endl;
     cout<<"WA"<<" x "<<mp["WA"]<<endl;
      cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
       cout<<"RE"<<" x "<<mp["RE"]<<endl;
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;
typedef pair<int,int> pii;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define all(v) v.begin(), v.end()
#define MOD 1000000007

int main(){
    IO
    char C;
    cin >> C;
    cout << (char)(C+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
vecint a;
vec2int dp;
int n, k;
bool rec(int p, int q) {
  // if (p <= 0) return false;
  if (dp[p][q] != -1) return dp[p][q] == 1 ? true : false;
  int r = 0;
  if (q == 0) r = 1;
  REP(i, n) {
    if (p >= a[i]) {
      if (!rec(p - a[i], r)) {
        dp[p][q] = 1;
        return true;
      }
    }
  }
  dp[p][q] = 0;
  return false;
}
int main() {
  init();
  cin >> n >> k;
  a.resize(n);
  for (auto& e : a) cin >> e;
  dp = vector<vector<int> >(k + 1, vecint(2, -1));
  // REP(i, a[0]) dp[i][0] = dp[i][1] = 0;
  // for (const auto& e : a) dp[e][0] = dp[e][1] = 1;
  // // REP(i, k + 1) { cout << i << " " << dp[i][0] << " " << dp[i][1] << endl;
  // }
  cout << (rec(k, 0) ? "First" : "Second") << endl;
  // REP(i, k + 1) { cout << "i: " << dp[i][0] << " " << dp[i][1] << endl; }
}



Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef long double ld;
using namespace std;

const int MAXN = 100000;
vector<int> g[MAXN + 1], path;
int st = 1, used[MAXN + 1];

void dfs(int v) {
    path.push_back(v);
    used[v] = 1;
    for(auto u: g[v]) {
        if(!used[u]) {
            dfs(u);
            break;
        }
    }
}


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

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1);
    reverse(path.begin(), path.end());
    path.pop_back();
    dfs(1);
    reverse(path.begin(), path.end());
    cout << (int)path.size() << "\n";
    for(auto x: path)
        printf("%d ", x);
    printf("\n");
    return 0;
}

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

struct point {
  int x, y;
};

int main() {
  vector<point> G(4);
  for (int i=0; i<2; ++i) cin >> G[i].x >> G[i].y;
  for (int i=2; i<4; ++i) {
    G[i].x = G[i-1].x - (G[i-1].y - G[i-2].y);
    G[i].y = G[i-1].y + (G[i-1].x - G[i-2].x);
    cout << G[i].x << ' ' << G[i].y << (i==2 ? " " : "\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
/*
K	Ìdikgj
light fly	48.00kg Èº
fly	48.00kg ´51.00kg Èº
bantam	51.00kg ´54.00kg Èº
feather	54.00kg ´57.00kg Èº
light	57.00kg ´60.00kg Èº
light welter	60.00kg ´64.00kg Èº
welter	64.00kg ´69.00 kg Èº
light middle	69.00kg ´75.00 kg Èº
middle	75.00kg ´81.00 kg Èº
light heavy	81.00kg ´91.00 kg Èº
heavy	91.00kg ´
*/
//	cut here before submit 
//	freopen("testcase.class", "r", stdin);
	const string c[] = { "light fly", "fly", "bantam", "feather", "light",
	"light welter", "welter", "light middle", "middle", "light heavy", "heavy" };
	const double w[] = { 48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0 };
	string str = "";
	int cn = sizeof(c)/sizeof(c[0]);
	int wn = sizeof(w)/sizeof(w[0]);

//	cout << "cn: " << cn << endl;
//	cout << "wn: " << wn << endl;
	int i;

	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		stringstream ss(str);
		double wight;
		ss >> wight;
		if (wight <= w[0]){
			cout << c[0] << endl;
		}else if (wight > w[wn - 1]){
			cout << c[cn - 1] << endl;
		}else{
			for (i = 1; i < wn; ++i){
				if (wight > w[i-1] && wight <= w[i] ){
					cout << c[i] << endl;
					break;
				} // end if
			} // end for
		} // end if

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
d = int(input())
c = list(map(int,input().split()))
ans = []
fin = [1]*d
pen = [0]*26
sattemp = 0
sat = 0
sl = [list(map(int,input().split())) for i in range(d)]
for k in range(300):
    for l in range(30):
        for i in range(d):
            s = sl[i]
            sp = sum(pen)
            temp = -(10**9)
            for j in range(26):
                if s[j]*l*0.1-(sp-pen[j])*(k*0.01) > temp:
                    temp = s[j]*l*0.1-(sp-pen[j])*(k*0.01)
                    tempans = j+1
            ans += [tempans]
            sattemp += s[tempans-1]-sp+pen[tempans-1]
            for j in range(26):
                pen[j] += c[j]
                pen[tempans-1] = 0
        if sattemp > sat:
            sat = sattemp
            fin = ans
        ans = []
        pen = [0]*26
        # print(k,sattemp)
        sattemp = 0
for i in fin:
    print(i)

Measured memory_bytes: 77056
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
stool = 0
for i in range(N):
    for j in range(i+1,i+2):
        if j >= N:
            break
        if A[i] > A[j]:
            stool += A[i] - A[j]
            A[j] += A[i] - A[j]

print(stool)

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

using namespace std;

int a[3];
int main(){
	int a1,a2,a3,mi=1000000000;
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(i!=j){
				mi=min(mi,max(a[j],a[i])-min(a[j],a[i])+max(a[j],a[3-i-j])-min(a[j],a[3-i-j]));
			}
		
		}
	}
	printf("%d",mi);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

int calc(int x) {
	if (x == 1) {
		return 1;
	} else {
		return 1 + calc(x / 2) * 2;
	}
}

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

	int H;

	cin >> H;

	cout << calc(H) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		String [] A = new String[N];
		String [] B = new String[M];
		
		for(int i=0;i<N;i++){
			A[i] = sc.next();
			}
		for(int i=0; i<M;i++){
			B[i] = sc.next();
			}
		
		int a=0;
		for(int i=0; i<N; i++){
			for(int j=0; j<M; j++){
				if(A[i].indexOf(B[j])!=-1){
					if((i>j)||(j>i)){break;}
					a = 1;//部分一致
					}
				else{
				    a = 0;//部分一致ではない
					}
				}
			}
		if(a==1){
			System.out.println("Yes");
			}
		else if(a==0){
		 System.out.println("No");
		 }
		}
	}

Measured memory_bytes: 21844