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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int a[N];
vi g[1000];

signed main() {
   #ifdef Flash
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n, kol = 0, kol1 = 0, p;
   cin >> n >> p;
   for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0) kol++;
        else kol1++;
   }
   if (p == 0) {
        int ans = 0, o = 1, o1 = 1;
        for (int i = 0; i <= kol; i++) {
            if (i != 0) {
                o*= (kol + 1 - i);
                o/= o1;
                o1++;
            }
            int oo = 1, oo1 = 1;
            ans+= o;
            for (int j = 1;  j <= kol1; j++) {
                 oo*= (kol1 - j + 1);
                 oo/= oo1;
                 oo1++;
                 if (j % 2 == 0)
                 ans+= o * oo;
            }
        }
        cout << ans;
        return 0;
   }
   else {
    int ans = 0, o = 1, o1 = 1;
        for (int i = 1; i <= kol1; i++) {
            o*= (kol1 + 1 - i);
            o /= o1;
            o1++;
            if (i % 2 == 1) {
                ans+= o;
                int oo = 1, oo1 = 1;
                for (int j = 1;  j <= kol; j++) {
                     oo*= (kol - j + 1);
                     oo/= oo1;
                     oo1++;
                     ans+= o * oo;
                }
            }
        }
        cout << ans;
   }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		if ((a / 10) % 111 == 0 || (a % 1000) % 111 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

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

    int n;
    string a, b, c;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        set<char>st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += st.size() - 1;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,a,b;
  cin>>K>>a>>b;
  for (int i=a; i<b+1; i++){
    if (i%K==0){
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}

Measured memory_bytes: 3576
def LI():
  return [int(s) for s in input().split()]

N = int(input())

A_s = LI()
B_s = LI()

counter = 0

for i in range(N):
  if A_s[i] > B_s[i]:
    counter+=B_s[i]
  elif B_s[i] < A_s[i] + A_s[i+1]:
    counter+=B_s[i]
    A_s[i+1] = A_s[i+1] - (B_s[i]-A_s[i])
  else:
    counter+=A_s[i]+A_s[i+1]
    A_s[i+1] = 0
    
print(counter)

Measured memory_bytes: 19156
def fnt(arr,n): 
  
     
     
     
    count = 0
  
     
    for i in range(0,n-2): 
  
         
        k = i + 2
  
        # Fix the second element 
        for j in range(i+1,n): 
  
             
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
  
             
            if(k>j): 
                count += k - j - 1
  
    return count
 
 
n=int(input())
arr=input()
arr=arr.split()
arr=list(map(int,arr))
arr.sort()
print(fnt(arr,n))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
#define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";
 
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    set<string> s;
    for(ll i=0;i<n;i++)
    {
        string x;
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
}

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int A, B;
    cin >> A >> B;
    cout << (A * B) << endl;
}

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,p; cin>>a>>p;
	int b=a*3;
	cout<<(b+p)/2;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#include <regex>
#include <fstream>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll x;

	cin >> x;

	if (x == 0) {
		cout << 1 << endl;
	}
	else if(x == 1) {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    x, y = LI()
    count = 0
    while x <= y:
        x *= 2
        count += 1
    print(count)
main()



Measured memory_bytes: 6320
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int x,y,z;cin >> x >> y >> z;
  cout << z << " " << x << " " << y << "\n";
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<long double>A(n);
  long double ans=0;
  rep(i,n){
    cin >> A[i];
    ans+=1/A[i];
  }
  cout << fixed << setprecision(10) << 1/ans << endl;
}

Measured memory_bytes: 256
n,a,b,c = map(int, input().split())
l=list(int(input()) for i in range(n))
v=[a,b,c]
v.sort()
ans=10**20
for i in range(4**n):
    x=[0,0,0]
    cnt=0
    for j in range(n):
        p=i%4
        i=i//4
        if p==0:
            if x[0]!=0:
                cnt+=10
            x[0]+=l[j]
        elif p==1:
            if x[1]!=0:
                cnt+=10
            x[1]+=l[j]
        elif p==2:
            if x[2]!=0:
                cnt+=10
            x[2]+=l[j]
        else:
            continue

    x.sort()
    if x[0]==0:
        continue
    else:
        cnt+=abs(x[0]-v[0])+abs(x[1]-v[1])+abs(x[2]-v[2])
        ans=min(cnt,ans)
print(ans)

Measured memory_bytes: 45676
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for (int i = 0; i < n; i++) {
        cin >> m[i];
    }
    sort(m.begin(), m.end());
    x -= accumulate(m.begin(), m.end(), 0);
    int cnt = n;
    cnt += x / m[0];

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();

    let mut iter = input.split_whitespace();
    let a = iter.next().unwrap().parse::<i32>().unwrap();
    let b = iter.next().unwrap().parse::<i32>().unwrap();

    match a.cmp(&b) {
        cmp::Ordering::Less => println!("a < b"),
        cmp::Ordering::Greater => println!("a > b"),
        cmp::Ordering::Equal => println!("a == b"),
    }
}



Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a= sc.next();
		String b= sc.next();
		String c= sc.next();
		System.out.print((char)a.charAt(0));

		System.out.print((char)b.charAt(0));

		System.out.print((char)c.charAt(0));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a,b;
  a=0;
  b=0;
  int l;
  int k;//goukei
  k=0;
  cin>>n;
  vector<int> vec(n); 
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    k=k+vec.at(i);
  }
  for (l = 0; a*2< k; l++){ 
    a=a+vec.at(l);
  }
  for (int p = 0; p < l-1; p++) {
    b=b+vec.at(p);
  }
  int A= max(a,k-a) -min(a, k-a);
  int B= max(b,k-b) -min(b, k-b);
  if(A>B){
    cout<<B;
  }
  else{
    cout<<A;
  }
}

Measured memory_bytes: 256
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in(),n=t.in(),r=t.in(),i=Math.floor(r/e)*n;console.log(i)}}]);

Measured memory_bytes: 22964
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a) memset((a),0,sizeof(a))
#define MCLR(a) memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int MAX_V = 1000;

class BipartiteMatching {
public:
    int V;
    VI G[MAX_V];
    int match[MAX_V];
    bool used[MAX_V];

    BipartiteMatching(int n){
        V = n;
    }

    void add_edge(int u, int v){
        G[u].PB(v);
        G[v].PB(u);
    }

    bool dfs(int v){
        used[v] = true;
        REP(i, G[v].size()){
            int u = G[v][i], w = match[u];
            if(w < 0 || !used[w] && dfs(w)){
                match[v] = u;
                match[u] = v;
                return true;
            }
        }

        return false;
    }

    int solve(){
        int res = 0;
        memset(match, -1, sizeof(match));
        REP(v, V){
            if(match[v] < 0){
                memset(used, 0, sizeof(used));
                if(dfs(v)){
                    res++;
                }
            }
        }

        return res;
    }
};

int main(){
    int x, y, e;
    cin >> x >> y >> e;
    BipartiteMatching bm(x+y);
    REP(i, e){
        int a,b;
        cin >> a >> b;
        b+=x;
        bm.add_edge(a,b);
    }

    cout << bm.solve() << endl;

}

Measured memory_bytes: 3328
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
ll tot=0;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
    tot=tot^a;
}
vector<ll>ans;
for(ll i=0;i<n;i++)
{
    ans.pb(tot^v[i]);
}
for(ll i=0;i<ans.size();i++)
{
    cout<<ans[i]<<" ";
}
return 0;
}


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

int main()
{
	int a[101][101];
	int b[101];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));

	int n,m;
	cin >> n >> m;

	rep(i,n)
	{
		rep(j,m)
		{
			cin >> a[i][j];
		}
	}

	rep(i,m)
	{
		cin >> b[i];
	}

	rep(i,n)
	{
		long long sum = 0;
		rep(j,m)
		{
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}


	return 0;
}

Measured memory_bytes: 1204
N=int(input())
S=input()

r=S.count('R')
g=S.count('G')
b=S.count('B')

count=r*g*b

for i in range(N):
  for d in range(N):
    j=i+d
    k=j+d
    if k>=N:
      break
    if S[i] != S[j] and S[j] !=S[k] and S[k] != S[i]:
      count -=1

print(count)
      

Measured memory_bytes: 9104
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
ll n,a[MAXN],b[MAXN],cnt,ans;
vector<ll>vec;
bool cmp(ll x,ll y)
{
	return x>y;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	forn(i,n)cin>>a[i];
	forn(i,n)cin>>b[i];
	forn(i,n)
	{
		if(a[i]<b[i])
		{
			cnt+=b[i]-a[i];
			ans++;
		}
		else if(a[i]>b[i])
			vec.pb(a[i]-b[i]);
	}
	sort(vec.begin(),vec.end(),cmp);
	forn(i,vec.size())
	{
		if(cnt==0)
		{
			cout<<ans<<endl;
			return 0;
		}
		if(cnt>vec[i])
		{
			ans++;
			cnt-=vec[i];
		}
		else
		{
			cnt=0;
			ans++;
		}
	}
	if(cnt==0)cout<<ans;
	else cout<<-1;
	return 0;
}


Measured memory_bytes: 2428
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int n = 0;  //AとBの公約数の個数

    for(int i = 1; i <= min(A, B); i++) {
        if(A % i == 0 && B % i == 0) {
            n++;
        }
    }

    int a[n];   //AとBの公約数の配列

    int i = 0;
    for(int j = 1; j <= min(A, B); j++) {
        if(A % j == 0 && B % j == 0) {
            a[i++] = j;
        }
    }

    cout << a[n-K];
    
    cout << 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);
        long n = sc.nextInt();
        long m = sc.nextInt();
        long ans = 0;
        if (n == 1 && m == 1) {
            ans = 1;
        } else if (n == 1) {
            ans = m - 2;
        } else if (m == 1) {
            ans = n - 2;
        } else {
            ans = (m - 2) * (n - 2);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  string str;

  cin>>str;

  int cnt=0;
  
  for(int i=0;i<str.length();i++){

    if(str[i]=='1'){
      cnt++;
    }
  }

  cout<<cnt<<endl;
  
  return 0;

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1000000000000000000

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = MOD;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int dp[3005][3005];

void solve_abc_d() {
	string s, t;

	cin >> s >> t;

	rep2(i, 1, s.size() + 1)rep2(j, 1, t.size() + 1) {
		if (s[i - 1] == t[j - 1]) {
			dp[i][j] = dp[i - 1][j - 1] + 1;
		}
		else {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	string ans;
	ll i = s.size();
	ll j = t.size();
	ll len = dp[i][j];
	while (len) {
		if (s[i - 1] == t[j - 1]) {
			ans = s[i - 1] + ans;
			i--;
			j--;
			len--;
		}
		else if(dp[i][j] == dp[i - 1][j]){
			i--;
		}
		else {
			j--;
		}
	}

	cout << ans;

	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


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

cnt = 0
if n == 1:
  print (1)
  exit()
c = 0
for i in range(n-1):
  if c == 2 and a[i+1] < a[i]:
    cnt += 1
    c = -1
  elif c == 1 and a[i+1] > a[i]:
    cnt += 1
    c = -1
  else:
    if c < 1:
      if a[i+1] > a[i]:
        c = 2
      elif a[i+1] == a[i]:
        c = 0
      else:
        c = 1
print (cnt+1)

Measured memory_bytes: 20304
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

bool f = true;

void dfs(string &S, string ans, int calc, int i){
    if (i == 3) {
        if (calc == 7){
            cout << ans << "=7\n";
            f = false;
            return;
        }
        return;
    }
    dfs(S, ans + '+' + S[i+1], calc + (S[i+1] - '0'), i+1);
    if (f) dfs(S, ans + '-' + S[i+1], calc - (S[i+1] - '0'), i+1);
}

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

string S; cin >> S;
string ans = S.substr(0,1);
int calc = S[0] - '0';

dfs(S, ans, calc, 0);

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int[][][] room = new int[5][4][11]; //4?£????3??????10?????????????¬??????????

		int n = scan.nextInt(); //?????±?????°
		int b = 0; 				//?£??????°
		int f = 0;				//?????°
		int r = 0;   			//??¨?±??????????
		int v = 0;				//????????°

		for(int i = 0; i < n; i++){ //????¨?????????±?????\???????????±????????°?????°?????????
			 b = scan.nextInt();
			 f = scan.nextInt();
			 r = scan.nextInt();
			 v = scan.nextInt();

			room[b][f][r] = room[b][f][r] + v;
		}

		for(int i = 1; i <= 4; i++){
			for(int j = 1; j <= 3; j++){
				for(int k = 1; k <= 10; k++){
						System.out.print(" " + room[i][j][k]);
				}
				System.out.println();
			}
			if(i != 4 ){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29184
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    p=list(map(float,input().split()))
    dp=[[float(0)]*(N+1) for _ in range(N+1)]
    dp[0][0]=float(1)
    for i in range(N):
        for omote in range(i+2):
            dp[i+1][omote]+=dp[i][omote]*(1-p[i])
            if omote>=1:
                dp[i+1][omote]+=dp[i][omote-1]*p[i]
    ans=0
    for i in range(-(-(N+1)//2)):
        ans+=dp[N][-(1+i)]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 112092
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;
typedef pair<ll, ll> Pll; 

int main()
{
	while (1) {
		int d, e;
		cin >> d >> e;
		if (!d && !e) break;
		double ans = 10101010;
		rep(i,0,floor(d*1.0/2)+1) {
			int x = i, y = d-i;
			ans = min(ans, abs(e - sqrt(x*x+y*y)));
		}
		printf("%.12lf\n",ans);
	}

	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll evaluate(int contest,int date,vector<ll>&last,vector<ll>&c,vll&s){
  ll point_today = 0;
  point_today += s[date][contest];
  ll minus = 0;
  for (ll j=1; j <= 26;j++){
    minus += c[contest] * (date - last[contest]);
  }
  return point_today;
}

int main(){
  ll d;
  cin >> d;//全日数
  vl c(27);
  for(ll i=1;i<=26;i++){//c_i==c[i]
    cin >> c[i];
  }
  vll s(d + 1, vl(27)); //s_d,i==s[d][i]
  for (ll i = 1; i <= d; i++){
    for (ll j = 1; j <= 26;j++){
      cin >> s[i][j];
    }
  }
  vl t;
  vl last(27, 0);//last(d,i)==last[i]
  //ll satisfy = 0;
  for (ll date = 1; date <= d;date++){
    priority_queue<pair<ll, int>> q;
    for (ll contest = 1; contest <= 26;contest++){
      q.push(mp(evaluate(contest, date, last,c,s), contest));
    }
    t.pb(q.top().S);
    //satisfy += q.top().F;
    last[q.top().S] = date;
  }
  rep(i,d){
    print(t[i]);
  }
}

Measured memory_bytes: 3712
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**18
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = - INF
    used = [0] * N
    candidate = []

    for i in range(N):
        if used[i]: continue
        now = i
        used[i] = 1
        tmp = [i]
        
        while P[now]-1 not in tmp:
            used[P[now]-1] = 1
            tmp.append(P[now]-1)
            now = P[now]-1
        
        candidate.append(tmp)

    # 各ループごとにK回以内で回して最大値を調べていく
    for tmp in candidate:
        M = len(tmp)
        accumT = []
        for t in tmp:
            accumT.append(C[t])
        loop = 3
        accumT = [0] + list(accumulate(accumT*loop))
        res = - INF

        if K <= M:# ループにならない
            for i in range(loop*M+1):
                for j in range(i+1,loop*M+1):
                    if j - i > K: 
                        break
                    res = max(res,accumT[j]-accumT[i])
            ans = max(ans,res)
        else:
            SUM = accumT[M]
            if SUM > 0:
                addition = SUM * (K//M - 1)# K//M回回らない方がいい場合がある
                for i in range(loop*M+1):
                    for j in range(i+1,loop*M+1):
                        if j - i > K%M+M:
                            break
                        res = max(res,accumT[j]-accumT[i])
                ans = max(ans,res+addition)
            else:
                for i in range(loop*M+1):
                    for j in range(i+1,loop*M+1):
                        if j - i > M:
                            break
                        res = max(res,accumT[j]-accumT[i])
                ans = max(ans,res)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69768
#include<bits/stdc++.h>
using namespace std;
int a[129]={0,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
int x;
int main()
{
    cin>>x;
    for(int i=x;i>=1;i--)
    if(a[i]==1){cout<<i<<endl;break;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    ll N,K,S;
    cin>>N>>K>>S;
    rep(i,0,K){
        cout<<S<<" ";
    } 
    rep(i,0,N-K){
        if(S == 1000000000)cout<<1<<" ";
        else cout<<1000000000<<" ";
    }

    return 0;
}

Measured memory_bytes: 1280
N, T = map(int, raw_input().split())

data = []
for i in range(N):
    c, t = map(int, raw_input().split())
    if t <= T:
        data.append(c)

if len(data) == 0:
    print("TLE")
else:
    data = sorted(data)
    print(data[0])


Measured memory_bytes: 2568
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>

using namespace std;

char A[105];
char B[105];
char C[105];
int flaga,flagb,flagc;
char flag;

int main()
{
	/*scanf("%s",A);
	scanf("%s",B);
	scanf("%s",C);*/
	while(cin >> A >> B >> C){
	int la = strlen(A);
	int lb = strlen(B);
	int lc = strlen(C);
		flag = 'a';//Alice先来
		flaga = -1;
		flagb = -1;
		flagc = -1;
	while(true){

		if(flaga == la){
			printf("A\n");
			break;
		}
		else if(flagb == lb){
			printf("B\n");
			break;
		}
		else if(flagc == lc){
			printf("C\n");
			break;
		}
		if(flag == 'a'){
			flaga++;
			flag = A[flaga];
		}
		else if(flag == 'b'){
			flagb++;
			flag = B[flagb];
		}
		else if(flag == 'c'){
			flagc++;
			flag = C[flagc];
		}
	}
	}
	return 0;
}

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

using namespace std;

int h,w,k;
char mass[10][10];
int ans=0;

void retsu(int n){

    if(n==w){
        int cnt = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(mass[i][j]=='#')cnt++;
            }
        }
        if(cnt==k)ans++;
        return;
    }
    retsu(n+1);
    
    char bkp[10][10];
    for(int i=0;i<h;i++){
        bkp[i][n] = mass[i][n];
        mass[i][n] = 'r';
    }
    retsu(n+1);
    for(int i=0;i<h;i++){
        mass[i][n] = bkp[i][n];
    }

}

void gyo(int n){

    if(n==h){
        retsu(0);
        return;
    }

    gyo(n+1);
    
    char bkp[10][10];
    for(int i=0;i<w;i++){
        bkp[n][i] = mass[n][i];
        mass[n][i] = 'r';
    }
    gyo(n+1);
    for(int i=0;i<w;i++){
        mass[n][i] = bkp[n][i];
    }

}

int main(){


    cin >> h >> w >> k;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> mass[i][j];

    gyo(0);

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3632
from bisect import bisect
inpl = lambda: list(map(int, input().split()))

N = int(input())
X = inpl()
L = int(input())
Q = int(input())
R = [[0]*(N) for k in range(17)]

for i in range(N):
    R[0][i] = bisect(X, X[i]+L) - 1

for k in range(16):
    for i in range(N):
        R[k+1][i] = R[k][R[k][i]]


def reach(a, d):
    O = format(d, "b").zfill(17)[::-1]
    for k in range(16, -1, -1):
        if O[k] == "1":
            a = R[k][a]
    return a


def bisearch(a, b):
    a, b = a-1, b-1
    if b < a:
        a, b = b, a
    OK = b-a
    NG = 0

    while abs(OK - NG) > 1:
        mid = (OK+NG)//2
        if reach(a, mid) >= b:
            OK = mid
        else:
            NG = mid
    return OK

print(*[bisearch(*inpl()) for _ in range(Q)], sep="\n")

Measured memory_bytes: 99864
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    if(A+B>C+D)
    {
        cout<<"Left";
    }
    else
    {
        if(A+B<C+D)
        {
            cout<<"Right";
        }
        else{cout<<"Balanced";}
    }
	return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if ((a - b - 1) % 2) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
  return 0;
}



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

// pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
// gp_hash_table<int, int> table;

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1e18;

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;

    cin >> n >> m;

    vector< string > a(n);

    for(string &s : a) cin >> s;

    vector< vector< int > > color(n, vector< int >(m));
    int cur = 1;

    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            if(color[i][j]) continue;
            queue< pii > q;
            color[i][j] = cur;
            q.push({i, j});
            while(!q.empty()) {
                int vi, vj;
                tie(vi, vj) = q.front();
                q.pop();
                for(int di = -1;di <= 1;di++) {
                    for(int dj = -1;dj <= 1;dj++) {
                        if(di && dj || !di && !dj) continue;
                        int ti = vi + di;
                        int tj = vj + dj;
                        if(ti < 0 || ti >= n || tj < 0 || tj >= m) continue;
                        if(a[ti][tj] != a[vi][vj] && !color[ti][tj]) {
                            color[ti][tj] = color[vi][vj];
                            q.push({ti, tj});
                        }
                    }
                }
            }
            cur++;
        }
    }

    vector< vector< int > > cnt(cur, vector< int >(2, 0));

    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cnt[ color[i][j] ][ a[i][j] == '#' ]++;
        }
    }

    ll res = 0;

    for(int c = 1;c < cur;c++) {
        res += 1ll * cnt[c][0] * cnt[c][1];
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (a+ b > c + d){
    cout << "Left" << endl;
  }else if (a + b < c + d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
def f(s,t):
    return (t-s)//2 if(t-s)%2==0 else (t-s-1)//2+1
n,a,b=map(int,input().split())
print((b-a)//2 if (b-a)%2==0 else min(a-1+f(1,b-a+1),n-b+f(a+n-b,n)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

  int n, m; cin >> n >> m;
  vector<int> l(m), r(m), c(m);
  vector<tuple<int,int,int>> edge(m);
  for(int i = 0; i < m; i++){
    cin >> l[i] >> r[i] >> c[i];
    l[i]--, r[i]--;
    edge[i] = make_tuple(l[i], r[i], c[i]);
  }
  sort(edge.begin(),edge.end());

  vector<int> dp(n, INF);
  dp[0] = 0;
  SegmentTree<int> seg(dp,INF,[&](int x,int y){
    return min(x,y);
  });
  for(int i = 0; i < m; i++){
    auto e = edge[i];
    int left = get<0>(e), right = get<1>(e), cost = get<2>(e);
    dp[right] = min(dp[right], seg.getval(left, right) + cost);
    seg.update(right, dp[right]);
  }
  int ans = dp[n-1];
  if(ans >= INF) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8448
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans = String::new();

    let mut set: HashSet<&str> = HashSet::new();
    for _i in 0..n {
        let command = iterator.next().unwrap();
        let s = iterator.next().unwrap();

        if command == "insert" {
            set.insert(s);
        } else if command == "find" {
            if set.contains(s) {
                ans += "yes\n";
            } else {
                ans += "no\n";
            }
        }
    }

    return ans.trim().to_string();
}



Measured memory_bytes: 41644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int gu = 0;
    int pa = 0;
    rep(i,len){
        if (S[i] == 'g') gu++;
        if (S[i] == 'p') pa++;
    }
    cout << (gu - pa) / 2 << endl;
}

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

int main(){
  int i,j,x,n,*A,s;
  scanf("%d",&n);
  A=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  x=A[n-1];
  i=-1;
  for(j=0;j<n-1;j++)
    {
      if(A[j]<=x){
	i=i+1;
	s=A[j];
	A[j]=A[i];
	A[i]=s;
      }
    }
  s=A[i+1];
  A[i+1]=A[n-1];
  A[n-1]=s;

  s=i+1;
  
  for(i=0;i<n;i++){
    if(i==s)
      printf("[%d]",A[i]);
    else
      printf("%d",A[i]);
    if(i<n-1)
      printf(" ");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 996
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var A = ReadLine().Split(' ').Select(int.Parse).OrderByDescending(x => x).ToArray();

        var ans = A[0] * 10 + A[1] + A[2];

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


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

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

using namespace std;

typedef long long ll;

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

// mを法としたときのaのモジュラ逆元を求める
template< typename T >
T mod_inverse(T a, T m) {
  T x, y;
  extgcd(a, m, x, y);
  return (m+x%m) % m;
}

// return nCk % mod
template< typename T >
T mod_comb(T n, T k, T mod) {
  T mul = 1, div = 1;
  for (T i = 0; i < k; i++) {
    mul *= (n-i);
    mul %= mod;
    div *= (i+1);
    div %= mod;
  }
  return mul * mod_inverse(div, mod) % mod;
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  ll x, y; cin >> x >> y;

  if ( (x + y) % 3 != 0 ) {
    cout << 0 << endl;
    return 0;
  }

  // n: a + b
  ll n = (x+y) / 3;
  ll a = (2 * y - x) / 3;
  ll b = n-a;
  if (a < 0 || b < 0) {
    cout << 0 << endl;
    return 0;
  }
  const ll mod = ll(1e9)+7;
  cout << mod_comb(n, a, mod) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		StringBuilder s = new StringBuilder();
		for (String e : sc.nextLine().split(" ")) s.append(e.charAt(0));
		System.out.println(s.toString().toUpperCase());
		sc.close();		
	}

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

}

Measured memory_bytes: 35620
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

static const int MAX=100;
static const long long INF=(1LL<<32);

int n;
long long d[MAX][MAX];

void wf(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(d[i][k]==INF) continue;
      for(int j=0;j<n;j++){
        if(d[k][j]==INF) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
}

int main(){
  int e,u,v,c;
  cin>>n>>e;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j) d[i][j]=0;
      else d[i][j]=INF;
    }
  }

  for(int i=0;i<e;i++){
    cin>>u>>v>>c;
    d[u][v]=c;
  }

wf();

  bool negative=false;
  for(int i=0;i<n;i++) if(d[i][i]<0) negative=true;

  if(negative){
    cout<<"NEGATIVE CYCLE"<<endl;
  }
  else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
       if(j) cout<<" ";
       if(d[i][j]==INF) cout<<"INF";
       else cout<<d[i][j];
      }
      cout<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
LL G[N][N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            scanf("%lld",&G[i][j]);
 
    bool flag=false;
    LL res=0;
    for(int i=1;i<=n&&!flag;i++){
        for(int j=i+1;j<=n&&!flag;j++){
            bool flag2=false;
            for(int k=1;k<=n&&!flag;k++){
                if(G[i][k]+G[k][j]<G[i][j])
                    flag=true;
                else{
                    if(i!=k&&j!=k&&G[i][j]==G[i][k]+G[k][j])
                        flag2=true;
                }
            }
            if(!flag2)
                res+=G[i][j];
        }
    }
 
    if(flag)
        printf("-1\n");
    else
        printf("%lld\n",res);
 
    

}

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

int main(int argc, char* argv[]) {
	int H, W;

	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(i % 2 == 0){
					if(j % 2 == 0) printf("#");
					else printf(".");
				}else{
					if(j % 2 == 0) printf(".");
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

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

#define ll long long
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define pii pair<ll, ll>

using namespace std;

int solve();

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

const ll MOD = 998244353;
const int MAXN = (int)3e5 + 1000;

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

ll c[MAXN];

ll Pow(ll x, ll y)
{
    if (y == 0)
        return 1;
    ll ans;
    if (y % 2 == 0)
    {
        ans = Pow(x, y / 2);
        return ((ans * ans) % MOD);
    }
    else
        return ((x * Pow(x, y - 1)) % MOD);
}

int solve()
{
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    c[0] = 1ll;
    for (ll i = 1; i <= n; i++)
    {
        c[i] = (c[i - 1] * 1ll * (n - i + 1)) % MOD;
        c[i] = (c[i] * Pow(i, MOD - 2)) % MOD;
        ///cerr << i << " " << Pow(i, MOD - 2) << endl;
    }

    ll g = gcd(a, b);
    if (k % g != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    a /= g; b /= g; k /= g;
    if (k == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    for (ll x = 0; a * x <= k && x <= n; x++)
    {
        if ((k - a * x) % b != 0)
            continue;
        ll y = (k - a * x) / b;
        if (y > n)
            continue;
        ll cur = c[x] * c[y];
        cur %= MOD;
        ans += cur;
        if (ans >= MOD)
            ans -= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<vector>
#include<iostream>
#include<queue>

using ll = long long;
using namespace std;

int N, M;

int main(void) {

    cin >> N >> M;
    priority_queue<int, vector<int>> q;

    int tmp;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        q.push(tmp);
    }

    while(M--){
        int t = q.top();
        q.pop();
        q.push(t/2);
    }

    ll ans = 0;
    while(!q.empty()) {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;
}

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

using namespace std;

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

Measured memory_bytes: 256