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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll a , b ; 
    cin >> a >> b ; 
    
    ll s = a + b ; 
    if ( s % 2 ) { cout << "IMPOSSIBLE" ; return ; }
    
    s >>= 1 ; 
    cout << s ; 
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int n;
vi a(0);
bool isOK(int index,int key) {
    if ( a[index]>key )return true;
    else return false;
}
int binary_search(vector<int> l ,int i,int j){
  ll ng =-1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = j;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    
    if (isOK(mid, abs(a[i]-a[j]))) ok = mid;
    else ng = mid;
  }
  return ok ;
}

int main(){
  cin>>n;
  rep(i,n){int l;cin>>l;a.push_back(l);}
  sort(all(a));
  
  int ans=0;
  for(int i=n-1;i>=2;i--){
    for(int j =i-1;j>=1 ;j-- ){
      ans +=j-binary_search(a,i,j);
      
    }
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int mondai = sc.nextInt();
		int teisyutu = sc.nextInt();
		int[] seitou = new int[mondai];
		int[] pena = new int[mondai];
        int ansOK = 0;
		int ansNG = 0;
		for ( int i = 0; i < teisyutu; i++){
			int number = sc.nextInt() - 1;
			String ret = sc.next();
			if ( seitou[number] == 0){
				if (ret.equals("AC")){
					seitou[number]++;
				} else {
					pena[number]++;
				}
			}
		}
		for ( int i = 0; i < seitou.length; i++){
			if ( seitou[i] == 1){
				ansOK += seitou[i];
				ansNG += pena[i];
			}
		}
		System.out.println(ansOK + " " + ansNG);
	}
}


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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,w,a,b;
    cin >> n >> w;

    vi wws,vvs,dp;

    rep(i,n) {
        cin >> a >> b;
        wws.push_back(a);
        vvs.push_back(b);
    }

    dp.assign(100010,w+1);
    dp[0] = 0;

    rep(i,n) {
        rrep(j,100010) {
            if (dp[j] == w+1) continue;
            dp[j + vvs[i]] = min(dp[j+vvs[i]], dp[j] + wws[i]);
        }
    }

    rrep(i,100010) {
        if (dp[i] < w+1) {
            cout << i << '\n';
            return 0;
        }
    }
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

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

int main(){
  int X; cin>>X;
  if(X==3||X==5||X==7) cout<<"YES\n";
  else cout<<"NO\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	int a,b,c,k;
	cin>>a>>b>>c;
	cin>>k;
	for(int i=0;i<k;i++)
	{
		if(a>=b)
		{
			b*=2;
		}
		else if(b>=c)
		{
			c*=2;
		}
	}
	if(a<b && b<c)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	

}

Measured memory_bytes: 3640
function main(input){
	const args=input.split(' ');
	const a=parseInt(args[0],10);
	const b=parseInt(args[1],10);
	
	if((a*b)%2==0){
		console.log('Even');
	}else{
		console.log('Odd');
	}
		
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29636
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll ans=0,mini=INT_MAX;
    for(ll i=0;i<n;i++)
    {
        if(arr[i]<=mini)
            ans++;
        mini=min(mini,arr[i]);
    }
    cout<<ans;
}


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

int main() {
	int	N;
	cin >> N;
	vector<int>	vec(N);
	rep(i, N)
		cin >> vec.at(i);
	int	count;
	count = 0;
	int	i;
	i = 0;
	while (i < N)
	{
		count++;
		while (i + 1 < N && vec.at(i) == vec.at(i + 1))
			i++;
		if (i + 1 == N)
			break;
		if (vec.at(i) < vec.at(i + 1))
		{
			while (i + 1 < N && vec.at(i) <= vec.at(i + 1))
				i++;
		}
		else
		{
			while (i + 1 < N && vec.at(i) >= vec.at(i + 1))
				i++;
		}
		i++;
	}
	cout << count << endl;
}


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

int main() {
	int a, b; cin >> a >> b;
	int ans = 0;
	for (int i = 0; i < 2; i++) {
		if (a - b > 0) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10][10],m,n,flag;
char kk[10];
void dfs(int x,int y){
	if(x==m-1&&y==n-1){
		for(int i=0;i<m;++i)for(int j=0;j<n;++j){
			if(a[i][j])return;
		}
		flag=1;
		return;
	}
	if(flag==1)return;
	if(a[x+1][y]){
		a[x+1][y]=0;
		dfs(x+1,y);
		a[x+1][y]=1;
	}
	if(a[x][y+1]){
		a[x][y+1]=0;
		dfs(x,y+1);
		a[x][y+1]=1;
	}
	if(!a[x][y+1]&&!a[x+1][y])return;
	
}
int main(){
	scanf("%d%d",&m,&n);
	for(int i=0;i<=m;++i){
		gets(kk);
		for(int j=0;j<n;++j)
		if(kk[j]=='#')a[i-1][j]=1;
	}
	if(a[0][0]){
		a[0][0]=0;
		dfs(0,0);
	}
	if(flag)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
} 

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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define eb emplace_back
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;



int main() {

	int n, m, a, b;
	cin >> n >> m;

	if (m < 2) {
		log("IMPOSSIBLE");
		return 0;
	}

	map<int,set<int>> p;

	rep (i, m) {
		cin>>a>>b;
		if (a!=1 && b!=n) continue;
		p[a].add(b);
	}

	for (auto k: p[1]) {
		if (exist(p[k], n)) {
			log("POSSIBLE");
			return 0;
		}
	}

	log("IMPOSSIBLE");

	return 0;
}



Measured memory_bytes: 28416
n, m = list(map(int, input().split()))
lis = []
for i in range(n):
  lis.append(1)
for i in range(m):
  lis.append(2)
count = 0
for i in range(len(lis)):
  for j in range(i + 1, len(lis)):
    if (lis[i] + lis[j]) % 2 == 0:
      count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, M;
    ll res;
    vector<pair<ll, int>> AB;
    cin >> N >> M;
    res = 0;
    for  (int i = 0; i < N; i++) {
        ll Ai;
        int Bi;
        cin >> Ai >> Bi;
        pair<ll, int> AiBi = make_pair(Ai, Bi);
        AB.push_back(AiBi);
    }
    sort(AB.begin(), AB.end());
    for (int i = 0; i < N; i++) {
        int num = AB.at(i).second;
        ll price = AB.at(i).first;
        if (M >= num) {
            M -= num;
            res += price*num;
        } else {
            res += price*M;
            break;
        }
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n-1), ans(n);
    rep(i,n-1){
        cin >> a[i];
    }
    rep(i,n) ans[i] = 0;
    rep(i,n-1){
        ans[a[i]-1]++;
    }

    rep(i,n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4824
def pr(A):
    N = len(A);
    for i in range(N):
        if i :
            print (" ", end = "");
        print (A[i], end = "")
    print ("")

def insertionSort(A):
    pr(A)
    N = len(A)
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j - 1
        A[j+1] = v
        pr(A)

N = int(input())
A = [int(i) for i in input().split()]

insertionSort(A)



Measured memory_bytes: 6316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);

  int ans = 0, diff = 0, mx;
  rrep(i, n){
    if(i == n-1){
      mx = a.at(i);
    }else{
      if(a.at(i) >= mx){
        mx = a.at(i);
      }else{
        int nd = mx - a.at(i);
        if(nd > diff){
          diff = nd;
          ans = 1;
        }else if(nd == diff){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;
int n,k,c;
char s[2000002];
int flag[2000002];
int L[2000002];
int R[2000002];
int main()
{
	cin>>n>>k>>c;
	cin>>s;
	
	int len=strlen(s),num=0;
	for(int i=0;i<len;i++)
	{	
		if(s[i]=='o') flag[num++]=i;
	}
	int first=0;
	int sum=1;
	L[first]++;

	for(int i=1;i<num&&sum<=k;i++)
	{
		if(flag[i]-flag[first]>c)
		{
			L[i]++;
			first=i;
			sum++;
		}
	}
	if(sum!=k) return 0;
	int last=num-1;
	R[last]++;
	sum=1;
	for(int i=num-2;i>=0&&sum<=k;i--)
	{
		if(flag[last]-flag[i]>c)
		{
			R[i]++;
			last=i;
			sum++;
		}
	}
	if(sum!=k) return 0;
	for(int i=0;i<num;i++)
	{
		if(L[i]==R[i]&&L[i]!=0) cout<<flag[i]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 12544
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int intInput = scan.nextInt();
		for(int i = 1; i <= intInput; i++){
			if(i % 3 == 0){
				System.out.print(" " + i);
			}else if(i % 10 == 3){
				System.out.print(" " + i);
			}else if(String.valueOf(i).contains("3")) {
				System.out.print(" " + i);
			}
			if(intInput == i){
				System.out.println("");
			}
		}
		scan.close();
	}
}

Measured memory_bytes: 22416
#include<stdio.h>

int A[20];

int n, t;

int yn(int , int );

int main(){
  int z,i;

  scanf("%d", &n);
  
  for (i=0;i<n;i++){
    
    scanf("%d", A+i);
  }

  scanf("%d", &z);
  
  for (i=0;i<z;i++){
    
    scanf("%d", &t);
    
    printf("%s\n", yn(0, 0)?"yes":"no");
  }
  return 0;
}
int yn(int x, int y){
  
  if (y == t) return 1;
  
  if (x>=n || y > t ) return 0;
  
  return yn(x+1, y+A[x]) || yn(x+1, y);
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
  vector< T > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

void solve(void)
{
  int N;
  cin>>N;
  int Y;
  cin>>Y;
  bool check = false;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= N; j++)
    {
      if(i+j>N)continue;
      int k = N - i -j;
      chmax(k,0);
      if(k*1000 + j*5000 + i*10000 == Y)
      {
        cout<<i<<" "<<j<<" "<<k<<endl;
        return;
      }

    }
    
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
 
int main(){
    string W, S;
    int cnt = 0;
    cin >> W;
    for(int i=0;i<W.size();i++) W[i]=tolower(W[i]);
    while(1){
        cin >> S;
        if(S == "END_OF_TEXT") break;
        for(int i=0;i<S.size();i++) S[i]=tolower(S[i]);
        if(S == W) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3156
import java.util.Scanner;
public class Main {
	 	public static void main(String[] args) {
	 		Scanner sc = new Scanner(System.in);
	 		int max1 = 0;
	 		int max2 = 0;
	 		int max3 = 0;
	 		for (int n=1;n<=10;n++ ){
	 			int t = sc.nextInt();
	 			if (t>=max1){
	 				max3 = max2;
	 				max2 = max1;
	 				max1 = t;
	 			}else if (t>=max2){
	 				max3 = max2;
	 				max2 = t;
	 			}else if (t>=max3){
	 				max3 = t;
	 			}
	 		}
	 		System.out.println(max1);
	 		System.out.println(max2);
	 		System.out.println(max3);
	 	}
}

Measured memory_bytes: 17236
class Solution:
    def solve(self, N: int, M: int, s, c):

        answer = ["."] * N

        for i in range(M):

            if answer[s[i]-1] == str(c[i]):
                continue
            elif answer[s[i]-1] == ".":
                answer[s[i]-1] = str(c[i])
            else:
                return -1

        if N == 1:
            if answer[0] == ".":
                return 0
            else:
                return answer[0]
        else:
            if answer[0] == "0":
                return -1
            else:
                if answer[0] == ".":
                    answer[0] = "1"
                return "".join(answer).replace(".", "0")


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    s, c = [], []
    for i in range(M):
        si, ci = map(int, input().split())
        s.append(si)
        c.append(ci)

    # solve
    solution = Solution()
    print(solution.solve(N, M, s, c))


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

int main(){
    int N;
    std::cin >> N;
    if (N%1000 == 0){
        std::cout << 0 << "\n";
    }else{
        std::cout << 1000-N%1000 << "\n";
    }
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int k,x;
	cin >> k >> x;

	for(int i = x-k+1; i <= x+k-1; i++){
		cout << i << " ";
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main() {
	int N, M, C;
	cin >> N >> M >> C;
	//長さMの配列を作る。
	vector<int> B(M);
	for(int i = 0; i < M;i++){
	    cin >> B[i];
	}
	
	//N×Mの配列を作る
	//Aは、vector<int>の長さNの配列
	//これを、vector<int>(M)で初期化(長さMの配列)
	vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0;i < N;i++){
        for(int j = 0;j < M;j++){
            cin >> A[i][j];
        }
    }	
    int ans = 0;
    for (int i = 0;i < N;i++){
         int sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        sum += C;
        if ( sum > 0) ans++;
    
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string a,b,c;
   cin >> a >> b >> c;
   cout << a[0] << b[0] << c[0] << endl;
}

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

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine("a {0} b", inputs[0]>inputs[1]?">":inputs[0]==inputs[1]?"==":"<");
        }
    }
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    int H, W, D;
    cin >> H >> W >> D;

    int N = H * W;

    vvi A(H, vi(W));
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    //数字から位置を取得できるようにする
    vector<pair<int, int>> pos(N);
    rep(i, H)
    {
        rep(j, W)
        {
            pos[A[i][j]] = make_pair(i, j);
        }
    }

    int count = N / D + 1;

    vvll dp(D, vll(count));

    rep(i, D)
    {
        //iからi+Dに移動するコストを計算
        reple(j, 0, count + 1)
        {
            int next = i + D * (j + 1);
            if (next >= N) break;

            auto p = pos[i + D * j];
            auto q = pos[next];
            
            dp[i][j + 1] = (ll)abs(p.first - q.first) + (ll)abs(p.second - q.second);
        }

        //累積和
        rep(j, count - 1) dp[i][j + 1] += dp[i][j];
    }

    int Q;
    cin >> Q;

    rep(i, Q)
    {
        int L, R;
        cin >> L >> R;
        L--;
        R--;

        int g = L % D;
        int l = L / D;
        int r = R / D;

        cout << dp[g][r] - dp[g][l] << endl;
    }

    return 0;
}

Measured memory_bytes: 9132
#include <iostream>
#include <string>
using namespace std;
static const int MAX = 1001;
 
void lcs(string X, string Y) {
    int dp[MAX][MAX];  
    int i,j;
 
    int xLength = X.size();
    int yLength = Y.size();
 
 
    // initialize dp[][]
    for (i = 1; i <= xLength; i++)
        dp[i][0] = 0;
    for (i = 1; i <= yLength; i++)
        dp[0][i] = 0;
 
    for (i = 1; i <= xLength; i++){
        for (j = 1; j <= yLength; j++){
            // Because the original string is 0-based , so subtracted from 1
            if (X[i - 1] == Y[j - 1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
 
    // testing code: print out the dp[][]
    // cout << "j";
    // for (j = 1; j <= yLength; j++)
    //  cout << ' ' << j ;
    // cout << endl;
         
 
    // for (i = 1; i <= xLength; i++){
    //  cout << i << '.';
    //  for (j = 1; j <= yLength; j++){
    //      cout << dp[i][j] << ' ';
    //  }
    //  cout << endl;
    // }
 
    cout << dp[xLength][yLength] << endl;
}
 
int main() {
    int n , i;
    string X, Y;
 
    cin >> n;
    for (i = 0 ; i < n; i++ ) {
        cin >> X;
        cin >> Y;
        lcs(X, Y);
    }
 
    return 0;
 
}

Measured memory_bytes: 6984
#include<iostream>
#include<vector>
#include<queue>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int>   vi;
typedef vector<vi >   vvi;

//tree.
//queue.
int main(){
	int n,q;
	cin>>n>>q;
	
	vvi tree(n);
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}
	
	vi v(n,0);
	REP(i,q){
		int p,x;
		cin>>p>>x;
		v[p-1]+=x;
	}
	
	vi jud(n,false);
	queue<int> que;
	que.push(0);
	jud[0]=true;
	while(!que.empty()){
		int parent=que.front();
		que.pop();
		REP(i,tree[parent].size()){
			int child=tree[parent][i];
			if(!jud[child]){
				v[child]+=v[parent];
				que.push(child);
				jud[child]=true;
			}
		}
	}
	
	REP(i,n) cout<<v[i]<<endl;
}


Measured memory_bytes: 16372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		
		int sum = num * 800;
		
		if(num >= 15) {
			sum = sum - (num / 15) * 200;
		}
		
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

class sai{
public:
  int men[6];

  void e();
  void n();
  void s();
  void w();
  void kat();
  void kah();
};

void sai::e(){
  int t = men[0];
  men[0] = men[3];
  men[3] = men[5];
  men[5] = men[2];
  men[2] = t;
}
void sai::n(){
  int t = men[0];
  men[0] = men[1];
  men[1] = men[5];
  men[5] = men[4];
  men[4] = t;
}
void sai::s(){
  int t = men[0];
  men[0] = men[4];
  men[4] = men[5];
  men[5] = men[1];
  men[1] = t;
}
void sai::w(){
  int t = men[0];
  men[0] = men[2];
  men[2] = men[5];
  men[5] = men[3];
  men[3] = t;
}
void sai::kat(){
  int t = men[1];
  men[1] = men[2];
  men[2] = men[4];
  men[4] = men[3];
  men[3] = t;
}
void sai::kah(){
  int t = men[1];
  men[1] = men[3];
  men[3] = men[4];
  men[4] = men[2];
  men[2] = t;
}

int main(){
  sai sa;
  for(int i = 0; i < 6; i++) scanf("%d", &sa.men[i]);
  int q;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    int ue, mae;
    scanf("%d %d", &ue, &mae);
    for(int j = 0; j < 6; j++){
      if(ue == sa.men[0]) break;
      if(j < 3) sa.n();
      else if(j == 3) sa.e();
      else if(j == 4){
        sa.e();
        sa.e();
      }
    }
    for(int j = 0; j < 4; j++){
      if(mae == sa.men[1]) break;
      sa.kat();
    }
    printf("%d\n", sa.men[2]);
  }
}



Measured memory_bytes: 2704
h,w,k=map(int, input().split())
s=[list(input()) for i in range(h)]
p=[[-1]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='S':
            sta=(i,j)
np=[(1,0),(-1,0),(0,1),(0,-1)]
q={sta}
p[sta[0]][sta[1]]=0
step=0
while step<k and q:
    step+=1
    nq=set()
    while q:
        now=q.pop()
        for i,j in np:
            nx,ny=now[0]+i,now[1]+j
            if nx<0 or nx==h or ny<0 or ny==w:continue
            if s[nx][ny]=='.' and p[nx][ny]==-1:
                p[nx][ny]=step
                nq.add((nx,ny))
    q=nq.copy()

ans=10**9
for i in range(h):
    for j in range(w):
        if p[i][j]>=0:
            an=min(i,j,h-i-1,w-j-1)
            if ans>an:ans=an
print(-(-ans//k)+1)

Measured memory_bytes: 78684
n = int(input())
dp = [[0]*3 for i in range(n)]
for i in range(n):
    # print(i)
    tl = list(map(int,input().split()))
    if i == 0 :
        for j in range(3):
            dp[0][j]+=tl[j]
    else:
        for _ in range(3):
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+tl[0]
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+tl[1]
            dp[i][2] = max(dp[i-1][0],dp[i-1][1])+tl[2]
    # print(dp)
# print(dp)
print(max(dp[n-1]))

Measured memory_bytes: 59756
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <tuple>
#include <math.h>
#include <iomanip>

using namespace std;

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


int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double th=a*a*b/2.;
    double pi=3.1415927;

    if(x<=th){
        double tmp=x*2./a/b;
        cout <<fixed << setprecision(15)<< atan(b/tmp)*180./pi << endl;
    }else{
        double tmp=(a*a*b-x)*2./a/a;
        cout <<fixed << setprecision(15)<< atan(tmp/a)*180./pi << endl;
    }


    return 0;
}

Measured memory_bytes: 4128
n,k = map(int,input().split())
*l, = map(int,input().split())
seenl = [1]
seen = {1}
temp=1
for i in range(k):
  temp=l[temp-1]
  if temp in seen:
    lenloop = len(seenl)-seenl.index(temp)
    r = (k-i-1)%lenloop
    temp = seenl[seenl.index(temp):][r]
    break
  seenl.append(temp)
  seen.add(temp)
print(temp)

Measured memory_bytes: 32264
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007

const int N=100005;
int n,k;
int ara[105];
int dp[N];
int solve(int k)
{
    dp[0]=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-ara[j]<0) continue;
            else if(dp[i-ara[j]]==0) dp[i]=1;
        }
    }
    return dp[k];
}
int main()
{
    fastio;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>ara[i];
    if(solve(k)) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

}


Measured memory_bytes: 4016
def f():
    h, w, n = map(int, input().split())
    md = 10 ** 9 + 7
    k = [list(map(int, input().split())) for _ in range(n)] + [[h, w]]

    # 壁をマンハッタン距離順に
    k.sort(key=lambda x: x[0] + x[1])

    # 階乗と逆元とコンビネーションを事前準備
    fct = [1]
    re_fct = []
    fct_i = 1
    for i in range(1, h + w + 1):
        fct_i = fct_i * i % md
        fct += [fct_i]
    # fct_i**(md-2)が逆元re_i
    re_i = 1
    p = md - 2
    while p:
        if p & 1:
            re_i = re_i * fct_i % md
        p >>= 1
        fct_i = fct_i ** 2 % md
    for i in range(h + w, -1, -1):
        re_fct += [re_i]
        re_i = re_i * i % md
    re_fct = re_fct[::-1]
    cmb = lambda a, b: fct[a] * re_fct[b] * re_fct[a - b] % md

    # こっから本体
    dp = [0] * (n + 1)
    for i, [r, c] in enumerate(k):
        dpi = cmb(r + c - 2, r - 1) % md
        for j in range(i):
            dr, dc = r - k[j][0], c - k[j][1]
            if dr >= 0 and dc >= 0:
                dpi = (dpi - dp[j] * cmb(dr + dc, dr)) % md
        dp[i] = dpi
    print(dp[-1])


f()


Measured memory_bytes: 62544
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a,b,ch[200000],cnt[200000],tot,tp[200000];
vector<int> v[200000];
void dfs(ll n){
    tot+=cnt[n];
    ch[n]+=tot;
    for(auto x:v[n]){
        if(tp[x]==0){
            tp[x]=1;
            dfs(x);
        }
    }
    tot-=cnt[n];
    return ;
}
int main(void){
    cin>>n>>m;
    tp[0]=1;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        cnt[a]+=b;
    }
    dfs(0);
    for(int i=0;i<n;i++){
        cout<<ch[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 24320
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> p){
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    p[0]/=2;
    ll ans = 0;
    rep(i, N)
        ans += p[i];
    cout << ans<< endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#if defined(_MSC_VER) || defined(ONLINE_JUDGE)
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
using LL=long long;
using VI=vector<int>;      using VL=vector<LL>;
using VS=vector<string>;   using VD=vector<double>;
using VVI=vector<VI>;      using VVL=vector<VL>;
using PII=pair<int, int>;  using PLL=pair<LL, LL>;
const int inf = (int)1e9;  const double pi = acos(-1.0);
const LL MOD = 1000000007; const string Snum = "0123456789";
const int dx[] = { -1,0,1,0,-1,-1,1,1 }, dy[] = { 0,1,0,-1,-1,1,-1,1 };

template<class T>void Sort(T& a) { sort(all(a)); }
template<class T>void RSort(T& a) { sort(rall(a)); }
template<class T>void Reverse(T& a) { reverse(all(a)); }
template<class T>void Unique(T& a) { a.erase(unique(all(a)), a.end()); }
template<class T>T Sorted(T a) { Sort(a); return a; }
template<class T>T RSorted(T a) { RSort(a); return a; }
template<class T>T Reversed(T a) { Reverse(a); return a; }
template<class T>T Uniqued(T a) { Unique(a); return a; }
template<class T>auto Max(const T& a) { return *max_element(all(a)); }
template<class T>auto Min(const T& a) { return *min_element(all(a)); }
template<class T>int MaxPos(const T& a) { return max_element(all(a)) - a.begin(); }
template<class T>int MinPos(const T& a) { return min_element(all(a)) - a.begin(); }
template<class T, class U>int Count(const T& a, const  U& v) { return count(all(a), v); }
template<class T, class U>int Find(const T& a, const U& v) { auto pos = find(all(a), v); return pos == a.end() ? -1 : pos - a.begin(); }
template<class T, class U>U Sum(const T& a, const U& v) { return accumulate(all(a), v); }
template<class T, class U>int Lower(const T& a, const U& v) { return lower_bound(all(a), v) - a.begin(); }
template<class T, class U>int Upper(const T& a, const U& v) { return upper_bound(all(a), v) - a.begin(); }
template<class T, class P>int CountIf(const T& a, P f) { return count_if(all(a), f); }
template<class T, class P>void RemoveIf(T& a, P f) { a.erase(remove_if(all(a), f), a.end()); }
template<class T>T Age(T n, T m) { return (n + m - 1) / m; }
template<class T>T Gcd(T n, T m) { return m ? Gcd(m, n % m) : n; }
template<class T>T Lcm(T n, T m) { return n / Gcd(n, m) * m; }
template<class T>T Pow(T a, T n) { T r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
template<class T>T Powmod(T a, T n, T m = MOD) { T r = 1; while (n > 0) { if (n & 1)r = r * a % m, n--; else a = a * a % m, n /= 2; }return r; }
string operator*(string s, int n) { string ret; rep(i, n)ret += s; return ret; }


int main() {
	int a; cin >> a;
	string s; cin >> s;
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    String[] T = sc.nextLine().split(" ");
    
    int[] A = new int[N+1];
    int[] B = new int[N];
    for(int i = 0; i < N; i++){
      A[i] = Integer.parseInt(S[i]);
      B[i] = Integer.parseInt(T[i]);
    }
    A[N] = Integer.parseInt(S[N]);
    
    long ans = 0;
    for(int i = 0; i < N; i++){
      if(A[i] <= B[i]){
        ans += A[i];
        B[i] -= A[i];
        if(A[i+1] <= B[i]){
          ans += A[i+1];
          A[i+1] = 0;
        }else{
          ans += B[i];
          A[i+1] -= B[i];
        }
      }else{
        ans += B[i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 58212
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0) break;
			if(x > y){
				System.out.println(y+" "+x);
			}else{
				System.out.println(x+" "+y);
			}
		}
	}
}

Measured memory_bytes: 35924
s = input()
cnt = 0
while cnt < 100000:
    n = len(s)
    s = ''.join(s.split('ST'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    else:
        break
    i = s.find('ST')
    
    stlen = 0
    if i > 0:
        for j in range(min(i, len(s)-2-i)):
            if s[i-j-1] == 'S' and s[i+j+2] == 'T':
                stlen += 1
            else:
                break
        s = s[:i-stlen] + s[i+stlen+2:]
        cnt += 1 + stlen
print(len(s))

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if((a.at(a.size()-1)==b.at(0))&&(b.at(b.size()-1)==c.at(0))){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int cnt[105],tot;
int main(){	
  	int n,k,m,i,j,a;	
  	scanf("%d%d",&n,&k);	
  	for(i=1;i<=k;i++){		
   		scanf("%d",&m);		
   		for(j=1;j<=m;j++){			
      		scanf("%d",&a);			
    		cnt[a]++;//记录拥有Snack的Snuke		
   		}	
  	}		
  	for(i=1;i<=n;i++)		
    	if(cnt[i])tot++;//统计拥有的Snack的Snuke数量	
  	printf("%d\n",n-tot);//输出没有拥有的Snack的Snuke数量	
  	return 0;
}

Measured memory_bytes: 1736
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [a, b, c] :: [Int] <- map read . words <$> getContents
    putStrLn $ if b - a == c - b then "YES" else "NO"

Measured memory_bytes: 508
N = int(input())
A = [int(input()) for i in range(N)]
A_m = str(max(A))
a = A.index(int(A_m))
A = sorted(A)
if A.count(int(A_m)) >= 2:
    print((A_m + '\n')*(N-1) + A_m)
else:
    print((A_m + '\n')*a + str(A[-2]))
    if N-(a+1) == 1:
        print(A_m)
    elif N-(a+1) < 1:
        pass
    else:
        print((A_m + '\n')*(N-(a+2)) + A_m)


Measured memory_bytes: 14992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
typedef pair<int,int> P;

const int K=26; //size of used alphabets.
const int N=2e5+5;

struct Vertex{
	int nxt[K];
	bool isLeaf=false;
	Vertex(){
		fill(nxt,nxt+K,-1);
	}
};

vector<Vertex> trie(1);
vector<int> path[N];
string s[N];
int res;

void add(int id,const string& s){
	int v=0;
	for(const char& ch:s){
		int c=ch-'a';
		path[id].pb(v);
		if(trie[v].nxt[c]==-1){
			trie[v].nxt[c]=trie.size();
			trie.emplace_back();
		}
		v=trie[v].nxt[c];
	}
	trie[v].isLeaf=true;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;++i){
		cin>>s[i];
		reverse(s[i].begin(),s[i].end());
		add(i,s[i]);
	}
	for(int i=0;i<n;++i){
		set<char> c;
		for(int j=int(s[i].size())-1;~j;--j){
			c.insert(s[i][j]);
			int v=path[i][j];
			for(char ch:c)
				res+=trie[v].nxt[ch-'a']!=-1&&trie[trie[v].nxt[ch-'a']].isLeaf;
		}
	}
	cout<<res-n<<'\n';
}



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

int A[2][110];
int dp[2][110];

int main()
{
  int N; cin >> N;

  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }

  dp[0][0] = 0;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      dp[i][j+1] = max(dp[i][j+1], dp[i][j]+A[i][j]);

      if (i == 0) {
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]+A[i][j]);
      }
    }
  }

  cout << dp[1][N] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef pair<int,int> P;
const int mod=1e9+7;
vector<int> dp,ans,a,g[200005];
void dfs(int v,int p=-1){
  int i=lower_bound(all(dp),a[v])-dp.begin();
  int old=dp[i];
  dp[i]=a[v];
  ans[v]=i;
  if(p!=-1)ans[v]=max(ans[v],ans[p]);
  for(auto u:g[v]){
    if(u==p)continue;
    dfs(u,v);
  }
  dp[i]=old;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  a=ans=vector<int>(n);
  rep(i,n)cin>>a[i];
  rep(i,n-1){
      int u,v;cin>>u>>v;
      --u;--v;
      g[u].push_back(v);
      g[v].push_back(u);
  }
  dp=vector<int>(n+1,mod);
  dp[0]=-1;
  dfs(0);
  rep(i,n)cout<<ans[i]<<endl;
  return 0;
  }


Measured memory_bytes: 27924
def run(h, w, a):
    ret1 = []
    for i in range(h):
        if a[i] != '.'*w:
            ret1.append(a[i])
    wi = []
    for i in range(len(ret1[0])):
        for j in range(len(ret1)):
            if ret1[j][i] == '#':
                wi.append(i)
                break
    ret = []
    for i in range(len(ret1)):
        s = ''
        for j in wi:
            s += ret1[i][j]
        ret.append(s)
    return ret


def read_line():
    h, w = map(int, input().split())
    a = []
    for i in range(h):
        a.append(input())
    return (h, w, a)


def main():
    h, w, a = read_line()
    ret = run(h, w, a)
    for i in range(len(ret)):
        print(ret[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
import bisect
input = sys.stdin.readline

N = int(input())
As = [int(input()) for _ in range(N)]
sortedAs = sorted(As)

parity = 0
for i in range(1, N, 2):
    index = bisect.bisect_left(sortedAs, As[i])
    if index % 2 == 0:
        parity += 1

print(parity)

Measured memory_bytes: 8296
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tmp = 0
e_t = []
for i in t:
    tmp+=i
    e_t.append(tmp)

def calc_end_speed(s):
    end_time = e_t[s]
    ma = 10**10
    for i in range(s+1, n):
        ma = min(e_t[i-1] - end_time + v[i], ma)
    return min(e_t[-1] - end_time, v[s], ma)

ans = 0
start_speed = 0

for sect in range(n):
    end_speed = min(calc_end_speed(sect), start_speed+t[sect])
    turn_time = (t[sect]+end_speed-start_speed)/2
    acce_end = min(v[sect]-start_speed, turn_time)
    dece_start = max(t[sect]-(v[sect]-end_speed) ,turn_time)
    max_speed = start_speed+acce_end
    ans += (start_speed+max_speed)*acce_end/2
    ans += max_speed*(dece_start-acce_end)
    ans += (end_speed+max_speed)*(t[sect]-dece_start)/2
    start_speed = end_speed

print(ans)

Measured memory_bytes: 3064
// 2020.4.15

#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int N, Y;

    cin >> N >> Y;

    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N - a; b++) {
            int c = N - a - b;

            if (a * 10000 + b * 5000 + c * 1000 == Y) {
                cout << a << " " <<  b << " " << c << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  LL A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  LL kouhoa,kouhob;
  kouhoa=Y*C*2+max(X-Y,0LL)*A;
  kouhob=X*C*2+max(Y-X,0LL)*B;
  LL a=max(X,Y)*C*2;
  cout<<min(a,min(kouhoa,min(kouhob,A*X+B*Y)))<<endl;
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>

#include <complex>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin, (v).end);


typedef unsigned long long int ull;
typedef long long lint;

using namespace std;














int main(){
    int N;
    


    //入力
    cin >> N;
    cout << N*N << endl;

    return 0;
}

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



int main(){
    int a,b;
    cin >> a >> b;
    if (a > b) {
        for (int i = 0;i < a;i++) {
        cout << b;
        }
    } else {
        for (int i = 0;i < b;i++) {
        cout << a;
        }
    }

}


Measured memory_bytes: 256