akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int a, b;

  cin >> a >> b;

  if (a > b) swap(a, b);

  for (int i=0; i<b; i++)
    cout << a;
  cout << endl;

  return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<char> c(n);
    rep(i,n){
        cin>>c[i];
    }
    int ans=0;
    rep(i,n-2){
        if(c[i]=='A' && c[i+1]=='B' && c[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
// https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
const int MOD = 1e9 + 7;

// 参考
// https://atcoder.jp/contests/s8pc-1/submissions/15772604
template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while (n > 0) {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

void solve() {
    int N;
    cin >> N;
    vector<modint> A(N);
    modint sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    modint ans = 0;
    for (int i = N - 1; i > 0; i--) {
        ans += A[i] * (sum -= A[i]);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

const int M = 998244353;
const int N = 3001;

int mod(int n){
   n %= M;
   return (n + M)%M;
}

int power(int a,int b){
   int ans = 1;
   while(b>0){
      if(b&1)
         ans = mod(ans*a);
      b /= 2;
      a = mod(a*a);
   }
   return ans;
}

int dp[N][N],cnt[N][N];
int n,s;
int a[N];
int inv;

int solve(int id,int pos){
   //cout<<id<<" "<<pos<<endl;
   if(pos == s)
      return power(2,n);
   if(id>=n or pos> s)
      return 0;
   int &tmp = dp[id][pos];
   if(tmp != -1)
      return tmp;
   tmp = solve(id+1,pos);
   tmp +=mod(solve(id+1,pos+a[id])*inv);
   tmp = mod(tmp);
   return tmp;
}

int32_t main() { 
   boost;
   cin>>n>>s;
   inv = power(2,M-2);
   for(int i=0;i<n;i++)
      cin>>a[i];
   memset(dp,-1,sizeof dp);
   int ans = solve(0,0);
   cout<<ans<<endl;
}

Measured memory_bytes: 74236
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int a,b;
	cin >> a >> b;
	int t = (max(-a,0)+max(-b-1,0))%2;
	if(a <= 0 && 0 <= b){
		puts("Zero");
	}
	else if(t == 0){
		puts("Positive");
	}
	else puts("Negative");
}



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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


bool check(vector<vector<int> > grid){
    for (int i = 0; i < 2; i++) {
        for (int j = i+1; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                if ( (grid[i][k] - grid[j][k]) != ( grid[i][k+1] - grid[j][k+1]) ) {
                    return false;
                }
            }
        }
    }

    for (int i = 0; i < 2; i++) {
        for (int j = i+1; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                if ( (grid[k][i] - grid[k][j]) != ( grid[k+1][i] - grid[k+1][j]) ) {
                    return false;
                }
            }
        }
    }

    return true;
}

int main(int argc, char const* argv[])
{
    vector<vector<int> > grid(3);
    for (int i = 0; i < 3; i++) {
        grid[i].resize(3);
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> grid[i][j];
        }
    }

    if (check(grid)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


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


ans = float("inf")
for i in range(n-k+1):
  #tmpの左端と右端の符号が同じなら、端から移動していく
  if (a[i] <= 0 and a[i+k-1] <= 0) or (a[i] >= 0 and a[i+k-1] >= 0):
    cost = max(abs(a[i]), abs(a[i+k-1]))
  #選んだろうそくが正負にまたがる場合、左端と右端の近いほうに移動してから  
  else:
    cost = min(abs(a[i]), abs(a[i+k-1]))*2 + max(abs(a[i]), abs(a[i+k-1]))
    
  if ans > cost:
    ans = cost
    
print(ans)

Measured memory_bytes: 14844
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>

#define MAX_N 1000000

using namespace std;

int main()
{
    int i, x;

    for(i = 1; i <= 5; ++i){
        scanf("%d", &x);
        if(!x){
            printf("%d", i);
            break;
        }
    }

    return 0;

}


Measured memory_bytes: 1732
s = list(map(int,input()))

c = [s[0]]

for i in range(1,len(s)):
    c.append(s[i])
    if c[len(c)-1] != c[len(c)-2]:
        c.pop(len(c)-1)
        c.pop(len(c)-1)

print(len(s) - len(c))


Measured memory_bytes: 4640
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	long long int H,W,ans=999999999;
	cin>>H>>W;
	if(H<W){
		swap(H,W);
	}
	if(H%3==0||W%3==0){
		cout<<"0"<<endl;
		return 0;
	}else{
		ans=min(H,W);
	}
	for(int i=1;i<=H-1;i++){
		long long int st=W*i;
		long long int a=(H-i)*(W/2);
		long long int b=(H-i)*(W-(W/2));

		if(ans>max({st,a,b})-min({st,a,b})){
			ans=max({st,a,b})-min({st,a,b});
		}
	}	
	for(int i=1;i<=W-1;i++){
		long long int st=H*i;
		long long int a=(W-i)*(H/2);
		long long int b=(W-i)*(H-(H/2));

		if(ans>max({st,a,b})-min({st,a,b})){
			ans=max({st,a,b})-min({st,a,b});
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(),p.end(),greater<int>());
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(i == 0) {
            ans += p[i] / 2;
        } else {
            ans += p[i];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> A = new ArrayList<>();
		int aliceSum = 0, bobSum = 0;

		for (int i = 0; i < N; i++) {
			A.add(sc.nextInt());
		}

		Collections.sort(A);
		Collections.reverse(A);

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				aliceSum += A.get(i);
			} else {
				bobSum += A.get(i);
			}
		}

		System.out.println(aliceSum - bobSum);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    string num;
    cin>>num;

    for(int i = 0; i < 3; i++)
    {
        if (num[i]=='1') {
            cout<<'9';
        }else
        {
            cout<<'1';
        }
        
        
    }
    
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
const MOD: i64 = 1e9 as i64 + 7;
use std::collections::HashMap;
fn main() {
    input! {
        n:i64,
    }
    let mut map = HashMap::new();
    for j in 2..n + 1 {
        for k in 2..j + 1 {
            if !is_prime(k) {
                continue;
            }
            if j % k != 0 {
                continue;
            }
            let mut count = 0;
            let mut tmp = j;
            while tmp % k == 0 {
                count += 1;
                tmp /= k;
            }
            let target = map.entry(k).or_insert(0);
            *target += count;
        }
    }
    let mut ans = 1;
    for (_, v) in map {
        ans *= v + 1;
        ans %= MOD;
    }
    println!("{}", ans);
}
fn is_prime(n: i64) -> bool {
    let mut res = true;
    for i in 2..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            res = false;
            break;
        }
    }
    res
}

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

using namespace std;

const int N = int(2e5) + 5;
const int MOD = int(1e9) + 7;
const int inf = int(2e9);

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

    long long N,A,B;
    cin >> N >> A >> B;
    long long t = N/(A+B);
    cout << A*t + min(N % (A+B),A);
    return 0;
}


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

 int main() {
   int A,B;
   cin >> A >> B;
   
   if(A >= 13){
     cout << B << endl;
   }else if(A >= 6 && A <= 12){
     cout << B/2 << endl;
   }else if(A <= 5){
     cout << "0" << endl;
   }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
string s[1011];
vector<int> V[33];
int main()
{
    int n;
    while(1)
    {
        for(int i = 0; i <= 26; i++)
            V[i].clear();
        scanf("%d", &n);
        if(n == 0)
            break;
        for(int i = 0; i < n; i++)
            cin>>s[i];
        int cnt = 0;
        int in[33] = {0};
        for(int i = 0; i < n; i++)
            for(int j = i + 1; j < n; j++)
            {
                int l1 = s[i].size();
                int l2 = s[j].size();
                int flag = 0;
                for(int k = 0; k < max(l1, l2); k++)
                {
                    if(k >= l1 && k <= l2)
                    {
                        break;
                    }
                    if(k >= l2 && k < l1)
                    {
                        puts("no");
                        goto loop;
                    }
                    if(s[i][k] != s[j][k])
                    {
                        V[s[i][k] - 'a'].push_back(s[j][k] - 'a');
                        in[s[j][k] - 'a']++;
                        break;
                    }
                }
            }
        while(1)
        {
            int nxt = -1;
            for(int i = 0; i < 26; i++)
                if(in[i] == 0)
                {
                    nxt = i;
                    break;
                }
            if(nxt == -1)
                break;
            in[nxt]--;
            cnt++;
            for(int i = 0; i < V[nxt].size(); i++)
                in[V[nxt][i]]--;
        }
        if(cnt == 26)
            puts("yes");
        else puts("no");
        loop:;
    }
}

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

///?????£?????????????§£ (Kosaraju)///
#define MAX_V 10000//????????°
int V;
vector<int> G[MAX_V], rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
//cmp[v] = cmp[U]???????????????u, v??????????????£?????????
int cmp[MAX_V];//cmp[v] := ??????v?????????????????£???????????????????????????????????????????????\??????
//??£??\??????????????????
void add_edge(int from, int to){//0origin
	G[from].push_back(to);//???????????????????????°???????????£??\?????????
  	rG[to].push_back(from);//?????????????????°???????????¢??°????????????????????°???????????£??\?????????
}
//????????????dfs
void dfs(int v){
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i){
		if(!used[G[v][i]]) dfs(G[v][i]);
	}
	vs.push_back(v);//????????\????????????????????£?????????????????????vs????????????????????\????????????
}
//2?????????dfs
void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;//??????v???????????????k????????¨?????£???????????§???????????¨??\??????
	for (int i = 0; i < rG[v].size(); ++i){
		if(!used[rG[v][i]]) rdfs(rG[v][i], k);
	}
}
int scc(){
	memset(used, 0, sizeof(used));//0(?????£?????????)??§?????????
	vs.clear();//?????????
	for (int v = 0; v < V; ++v){
		if(!used[v]) dfs(v);
	}
	memset(used, 0 , sizeof(used));
	int k = 0;//?????£???????????????????????????
	for (int i = vs.size() - 1; i >= 0; --i){//vs?????\??£??????????????????????????????dfs
		if(!used[vs[i]]){
			rdfs(vs[i], k); k++;
		}
	}
	return k;
}

int main(void){
	int E, s, t;
	cin >> V >> E;
	rep(i, E){
		cin >> s >> t;
		add_edge(s, t);//??????s??¨t????????¨???????????????s -> t
	}
	scc();//?????£??????????????????
	int q, u, v; cin >> q;
	rep(i, q){
		cin >> u >> v;
		if(cmp[u] == cmp[v]) printf("1\n");
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 4688
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > 9 || b > 9)
	{
		puts("-1");
		return 0;
	}
	printf("%d", a * b);
	return 0;
}

Measured memory_bytes: 256
// Alert!!! This program may have some NARGLE.
// Alert!!! Add a \ to the // at the beginning
//          of the main function if you're gonna use printf or scanf.
#include <bits/stdc++.h>

#define F first
#define pb push_back
#define S second
#define ll long long
#define ld long double
#define us unsigned
#define fileio freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#define pii pair <int, int>

using namespace std;

const int Mod = 1e9 + 7;

int32_t main ()
{//
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int k;
	cin >> k;
	if (k >= 30)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3480
//
// Created by yuu on 2019-04-22.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int N,M,C;
    cin>>N>>M>>C;

    int B[30];
    int A[30][30];
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j < M; ++j) {
            if(i==0){
                cin>>B[j];
            }else{
                cin>>A[i][j];
            }
        }
    }

    int ans = 0;

    for (int i = 1; i <= N; ++i) {
        int temp = 0;
        for (int j = 0; j < M; ++j) {
            temp += B[j] * A[i][j];
        }
        if(temp + C > 0){
            ans ++;
        }
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char g[50];
void swap(int *x,int *y){
	int z;
	z=*x;*x=*y;*y=z;
}
char* sign(char *x,char *y,int c){
	g[0]='\0';
	strcpy(g,"(");
	if(c<3)strcat(g,x); else strcat(g,y);
	switch(c%3){
	case 0: strcat(g," - "); break;
	case 1: strcat(g," + "); break;
	case 2: strcat(g," * "); break;
	}
	if(c<3)strcat(g,y); else strcat(g,x);
	strcat(g,")");
	return g;
}
int calc(int x,int y,int c){
	switch(c){
	case 0:return x-y;
	case 1:return x+y;
	case 2:return x*y;
	case 3:return y-x;
	}
	return 0;
}
int check(int a,int b,int c,int d,int o){
	int i,j,k;
	char p[50],q[50],r[50],s[50];
	sprintf(p,"%d",a);
	sprintf(q,"%d",b);
	sprintf(r,"%d",c);
	sprintf(s,"%d",d);

	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			for(k=0;k<4;k++){
				if(o){
					if(calc(calc(a,b,i),calc(c,d,j),k)==10){
						strcpy(p,sign(p,q,i));
						strcpy(r,sign(r,s,j));
						strcpy(p,sign(p,r,k));
						printf("%s\n",p);return 1;}
				}

				if(calc(calc(calc(a,b,i),c,j),d,k)==10){
					strcpy(p,sign(p,q,i));
					strcpy(p,sign(p,r,j));
					strcpy(p,sign(p,s,k));
					printf("%s\n",p);return 1;}
			}
		}
	}
	return 0;
}
int main(void){
	int a,b,c,d;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF){
		if(a==0 && b==0 && c==0 && d==0)break;
		if(check(a,b,c,d,1))continue;
		if(check(a,c,b,d,1))continue;
		if(check(a,d,c,b,1))continue;
		if(check(c,d,a,b,0))continue;
		if(check(b,d,a,c,0))continue;
		if(check(b,c,a,d,0))continue;
		if(check(a,b,d,c,0))continue;
		if(check(a,c,d,b,0))continue;
		if(check(a,d,b,c,0))continue;
		if(check(c,d,b,a,0))continue;
		if(check(b,d,c,a,0))continue;
		if(check(b,c,d,a,0))continue;
		printf("0\n");
	}
	return 0;
}

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

int main() {
	double w;
	string c;
	while (cin >> w) {
		if (w <= 48.0) {
			c = "light fly";
		}
		else if (w <= 51.0) {
			c = "fly";
		}
		else if (w <= 54.0) {
			c = "bantam";
		}
		else if (w <= 57.0) {
			c = "feather";
		}
		else if (w <= 60.0) {
			c = "light";
		}
		else if (w <= 64.0) {
			c = "light welter";
		}
		else if (w <= 69.0) {
			c  = "welter";
		}
		else if (w <= 75.0) {
			c = "light middle";
		}
		else if (w <= 81.0) {
			c = "middle";
		}
		else if (w <= 91.0) {
			c = "light heavy";
		}
		else {
			c = "heavy";
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    ans1 = max(a)
    half = ans1 / 2
    min_ = abs(a[0] - half)
    ans2 = a[0]
    for i in range(1, N):
        if a[i] != ans1:
            tmp = abs(a[i] - half)
            if tmp <= min_:
                ans2 = a[i]
                min_ = tmp
    print(ans1, ans2)

if __name__ == "__main__":
    main()

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

using namespace std;

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

    int N;
    cin>>N;

    unsigned long long int ans=0;
    for(int i=1;i<=N;i++)
        if(i%3!=0 && i%5!=0)
            ans += i;

    printf("%llu\n", ans);
    return 0;
}


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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if(x >= r && x <= w-r && y >= r && y <= h-r) cout << "Yes" << "\n";
  else cout << "No" << "\n";

  return 0;
}



Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}


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

#include <bits/stdc++.h>

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

  ll num = 0;
  if (a == b) num = 1;
  else if (n >= 2 && a <= b) {
    num = (n - 1) * b + a - ( (n - 1) * a + b) + 1;
  }
  cout << num << endl;

}


Measured memory_bytes: 3636
fh_num = int(input())
oh_num = int(input())
fif_num = int(input())
sum = int(input())

i = 0
j = 0
t = 0
all = 0
count = 0

for i in range(fh_num + 1):
  for j in range(oh_num + 1):
    for t in range(fif_num + 1):
      all = 50 * t + 100 * j + 500 * i
      if all == sum:
        count += 1
      all = 0

print(int(count))

Measured memory_bytes: 3064
from sys import stdin
from math import gcd


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for a in range(1,K+1):
        cnt += a
        for b in range(a+1,K+1):
            ab = gcd(a,b)
            cnt += 6*ab
            for c in range(b+1,K+1):
                cnt += 6*gcd(ab, c)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
    

Measured memory_bytes: 67632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    double n, m;
    int d;
    cin >> n >> m >> d;
    if(d == 0) {
        double ans = (m - 1) / n;
        output(ans, 10);
    }
    else {
        double ans = (n - d) * (m - 1) * 2 / (n * n);
        output(ans, 10);
    }
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

calc ::Int -> [Int] -> Int
calc a [] = -1
calc a (b:bs) | floor(((fromIntegral (b :: Int))::Float) * 1.08::Float) - b == a = b
              | otherwise = calc a bs

main = do
 [a, b] <- getIntList
 let bs = [b*10 .. (b+1)*10-1]
 print $ calc a bs


Measured memory_bytes: 380
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];

			var to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < m; i++) {
				int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				to[ab[0] - 1].Add(ab[1] - 1);
				to[ab[1] - 1].Add(ab[0] - 1);
			}

			var q = new Queue<Tuple<int, int>>();
			q.Enqueue(new Tuple<int, int>(0, 1));
			int ans = 0;
			int goal = ((int)Math.Pow(2, n)) - 1;
			while (q.Count > 0) {
				var cur = q.Dequeue();
				foreach (var next in to[cur.Item1]) {
					if ((cur.Item2 & (1 << next)) == 0) {
						q.Enqueue(new Tuple<int, int>(next, cur.Item2 | (1 << next)));
					}
				}

				if (cur.Item2 == goal) {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13524
import java.util.*;

public class Main {
    public static void main(String[] args){
        String result = "";
        Scanner sc = new Scanner(System.in);
        // 整数Nの入力
        long n = sc.nextLong();
        // 整数Mの入力
        long m = sc.nextLong();
        if (n * 2 < m) {
            result = String.valueOf((n + (m - n * 2) / 4));
        } else {
            result = String.valueOf(m / 2);
        }
        // 出力
        System.out.println(result);
    }
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    //int sum{0};
    lol n; cin >> n;
    int k; cin >> k;
    
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    REP(i, k)
    {
        result += a[i];
    }

    cout << result << endl;
    return 0;
}

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

int f[102][102];

void DFS(int x,int y,int c){
    if(f[x][y]!=c)  return;

    f[x][y]=10;
    DFS(x+1,y,c);
    DFS(x-1,y,c);
    DFS(x,y+1,c);
    DFS(x,y-1,c);
}

void print(int w,int h){
    for(int i=1;i<=w;i++){
        for(int j=1;j<=h;j++){
            cout<<f[i][j]<<' ';
        }
        cout<<endl;
    }
}

int main(){
    int w,h;
    int xs,ys;
    int xg,yg;
    int n;
    while(true){
        cin>>w>>h;
        if(w+h==0)  break;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                f[i][j]=-1;
            }
        }
        cin >> xs >> ys;
        cin >> xg >> yg;
        cin >> n;
        for(int i=0;i<n;i++){
            int c,d,x,y;
            cin >> c >> d >> x >> y;
            if(d==0){
                for(int j = 0; j<4; j++){
                    for(int k = 0; k<2; k++){
                        f[x+j][y+k] = c;
                    }
                }
            }else{
                for(int j = 0; j<2; j++){
                    for(int k = 0; k<4; k++){
                        f[x+j][y+k] = c;
                    }
                }
            }
        }
        //print(w,h);
        DFS(xs,ys,f[xs][ys]);
        //print(w,h);
        if(f[xg][yg]==10){
            cout<<"OK"<<endl;
        }else{
            cout<<"NG"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3052
//AtCoder ABC055 C - Scc Puzzle
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N,M;
    cin>>N>>M;
    // ll cnum=N*2+M;
    // ll ans=cnum/4;
    // cout<<ans<<endl;
    ll snum=N+M/2;
    ll ccnum=M/2;
    ll ans=min(ccnum,snum/(ll)2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    H = int(input())
    W = int(input())
    N = int(input())

    c_row = 0
    c_col = 0
    ans = 0

    while True:
        if N <= 0:
            print(ans)
            break
        else:
            if W - c_col <= H - c_row:
                N -=  H - c_row
                c_col += 1
                ans += 1
            else:
                N -=  W - c_col
                c_row += 1
                ans += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A,B := sc.NextInt(), sc.NextInt()
	fmt.Println(A+B/2)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
declare function require(x: string): any;

var input = require("fs").readFileSync("/dev/stdin", "utf8");
input = input.split("\n");

const s = input.shift();
const n = s.length;

let dp:Array<Array<number>> = [];
for(let i=0; i<n; i++){
	dp[i] = [];
}

for(let i=0; i<n; i++){
	for(let ii=i; ii<n; ii++){
		if(ii == i){
			dp[i][ii] = +s[ii];
		}
		else{
			dp[i][ii] = dp[i][ii-1]*10 + (+s[ii]);
		}
	}
}

let result = 0;

const lim = 1<<(n-1);
for(let b=0; b<lim; b++){
	let l = 0;
	for(let i=0; i<n; i++){
		if(b & 1<<i){
			result += dp[l][i];
			l = i+1;
		}
		else if(i==n-1){
			result += dp[l][i];
		}
	}
}

console.log(result);



Measured memory_bytes: 7372
#include<stdio.h>
int main()
{
  int a, b, c, k, m, s, i;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  if(a > b){
    m = a;
  }else{
    m = b;
  }
  if( m < c){
    m = c;
  }
  s = m;
  for(i = 0; i < k; i++){
    s *= 2;
  }
  s = a + b + c + s - m;

  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;
const int INF=2e9;

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

    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    int cnt=0;
    auto merge=[&](int l,int m,int r)
    {
        vector<int> x(m-l+1,INF),y(r-m+1,INF);
        for(int i=0;i<m-l;i++) x[i]=a[l+i];
        for(int i=0;i<r-m;i++) y[i]=a[m+i];
        int i=0,j=0;
        for(int k=l;k<r;k++){
            cnt++;
            if(x[i]<y[j]) a[k]=x[i++];
            else a[k]=y[j++];
        }
    };
    function<void(int,int)> merge_sort=[&](int l,int r)
    {
        if(r-l>1){
            int m=(l+r)/2;
            merge_sort(l,m);
            merge_sort(m,r);
            merge(l,m,r);
        }
    };
    merge_sort(0,N);
    for(int i=0;i<N;i++){
        cout<<a[i]<<(i==N-1? '\n':' ');
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    long long niza[n];
    if(n==1)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    for(long long i=0; i<n; i++)
    {
        cin>>niza[i];
    }
    for(long long i=n; i>=1; i--)
    {
        if(niza[i]>=niza[i-1])continue;
        else
        {
            if(niza[i]>=niza[i-1]-1)
            {
                niza[i-1]--;
                continue;
            }
            else
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

long long n, m, x;
vector<long long> c;
vector<vector<long long>> a;

long long solve();

int main() {
  cin >> n >> m >> x;
  c.resize(n);
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    a[i].resize(m);
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = (long long)(1e16);
  for (int i = 0; i < (1 << n); ++i) {
    vector<long long> sum(m, 0);
    long long cos = 0;
    for (int j = 0; j < n; ++j)
      if (i >> j & 1) {
        cos += c[j];
        for (int k = 0; k < m; ++k) sum[k] += a[j][k];
      }
    bool ch = 1;
    for (int j = 0; j < m; ++j)
      if (sum[j] < x) ch = 0;
    if (ch) res = min(res, cos);
  }
  if (res > (long long)(1e15)) return -1;
  return res;
}

Measured memory_bytes: 3660
from collections import deque
a,b=map(int,input().split())
e=[[]for i in range(a)]

for i in range(a-1):
  c1,c2=map(int,input().split())
  e[c1-1].append(c2-1)
  e[c2-1].append(c1-1)

g=[[]for i in range(a)]
f=deque()
f.append((0,-1))
ans=[0 for _ in range(a)]
for i in range(b):
  ten,p=map(int,input().split())
  ans[ten-1]+=p
i=0
while len(f)!=0:
  i,fr=f.popleft()
  for j in e[i]:
    if j==fr:
      continue
    else:
      ans[j]+=ans[i]
      f.append([j,i]) 
print(*ans)
    
  

  
  


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  int a[2][n];
  REP(i, n) { a[0][i] = read(); }
  REP(i, n) { a[1][i] = read(); }
  int ans = 0;
  REP(i, n) {
    int tmp = 0;
    for (int j = 0; j <= i; j++)
      tmp += a[0][j];
    for (int j = i; j < n; j++)
      tmp += a[1][j];
    chmax(ans, tmp);
  }
  print(ans);
}


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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    char x; cin >> x;
    cout << char(x + 1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveA();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C, D; cin >> A >> B >> C >> D;

	int res = min(A, B) + min(C, D);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    string X; cin >> X;
    stack<char> s;

    rep(i,X.size()) {
        if(X[i] == 'S') s.push(X[i]);
        else {
            if(s.empty() or s.top() == 'T') s.push(X[i]);
            else s.pop();
            
        } 
    }
    cout << s.size() << endl;

}









Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

ll mod=1e9+7;

int main(){
      ll n,m;
      cin>>n>>m;
      ll x[n+1],y[m+1];
      rep1(i,n) cin>>x[i];
      rep1(j,m) cin>>y[j];
      ll s_x=0;
      ll s_y=0;
      rep1(i,n){
            s_x+=(2*i*x[i]-(n+1)*x[i]);
      }
      rep1(j,m){
            s_y+=(2*j*y[j]-(m+1)*y[j]);
      }
      s_x%=mod;
      s_y%=mod;
      cout<<(s_x*s_y)%mod<<endl;

      return 0;
}

Measured memory_bytes: 1792
{
  const main = (input: string) => {
    const r = reader(input)
    const n = r.n()
    const s = r.s()

    const a = s.substring(0, n / 2)
    const b = s.substring(n / 2)

    console.log(a === b ? 'Yes' : 'No')
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  long long N;
  cin >> N;
  
  long long num = N + 1;
  
  vector<long long> A(num);
  
  vector<long long> B(N);
 
  
  for(long long i = 0;i < num;++i){
    cin >> A[i];
  }
  
  for(long long i = 0;i < N;++i){
    cin >> B[i];
  }
  
  long long num2 = 0;
  
  for(long long i = 0;i < N;++i){
    if(A[i] + A[i + 1] < B[i]){
      num2 = A[i] + A[i + 1] + num2;
      A[i + 1] = 0;
    }
    else{
      if(A[i] < B[i]){
        A[i + 1] = A[i] + A[i + 1] - B[i];
      }
        num2 = B[i] + num2;
    }
  }
  cout << num2 << endl;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);



using P = pair<int, int>;

int dp[3005][3005];

int main() {
    int n,t; cin >> n >> t;
    vector<P> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;

    // 一番時間がかかるのを最後に食べるという方針にする
    // 昇順ソートしておけば、i番目を最後に食べるときに、i-1まででt-1までに食べれる最大量を求めるので済む
    sort(ab.begin(), ab.end());
    int ans = 0;
    rep(i, n) {
        rep(j, t) {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = j+ab[i].first;
            if(nj < t) chmax(dp[i+1][nj], dp[i][j] + ab[i].second);
        }
        int now = dp[i][t-1] + ab[i].second;
        chmax(ans, now);
    }
    cout << ans << endl;
    return 0;
}


/**
3 1000
2 40
500 20
500 12


5 900
200 1
100 2
1000 3
900 4
900 5
**/

Measured memory_bytes: 35456
while True:
    integers = list(map(int, input().split(" ")))
    H = integers[0]
    W = integers[1]
    dot = "." * (W - 2)
    if H != 0 and W != 0:
        print("#" * W)
        for i in range(1, H - 1):
            print(f'#{dot}#')
        print("#" * W)
        print("")
    else:
        break


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
ll n;
vector<ll> a;
vector<vector<ll> > adj(300009);
vector<ll> ans;
vector<ll> dp;

pair<ll,pair<ll,ll> >  fun(ll x)
{
  auto it=lower_bound(dp.begin(),dp.end(),x);
  ll f;
  if(it==dp.end()) dp.pb(x),f=-1;
  else f=*it,*it=x;

  ll z=dp.size();
  return {f,{z,it-dp.begin()}};
}

void dfs(ll node,ll par)
{
  pair<ll,pair<ll,ll> >p=fun(a[node]);
  ans[node]=p.ss.ff;

  for(auto j:adj[node])
  if(j!=par)dfs(j,node);

  
  if(p.ff==-1)dp.pop_back();
  else
   dp[p.ss.ss]=p.ff;

}

int main()
{ 

fast;


cin>>n;
a.assign(n,0);
for(ll i=0;i<n;i++)cin>>a[i];
  ans.assign(n,1);


for(ll i=0;i<n-1;i++)
{
  ll x,y;
  cin>>x>>y;
  x--,y--;
  adj[x].pb(y);
  adj[y].pb(x);
}
dp.reserve(300000);
dfs(0,-1);

for(ll i=0;i<n;i++)
cout<<ans[i]<<'\n';


}

Measured memory_bytes: 33984
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val i = scanner.nextInt()
    val s = scanner.next()

    val r = s.toCharArray()
        .map { it.plus(i) }
        .map {
            if (it <= 'Z') {
                it
            } else {
                it - 26
            }
        }
        .joinToString("")

    println(r)
}


Measured memory_bytes: 32312