akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MP make_pair

typedef long long LL;
typedef pair<int,int> PII;

int main(){

  int x, y;
  while (cin>>x>>y, x||y) {
    vector<int> v(1e6,-1);
    for (int i = 0; ; ++i) {
      if (v[x] >= 0) {
        cout << v[x] << ' ' << (x ? i-v[x] : 0) << endl;
        break;
      }
      v[x] = i;
      x *= 10; x %= y;
    }
  }

}

Measured memory_bytes: 4800
#include <stdio.h>

int main(void){

  char s[27];
  scanf("%s", s);
  int check[26];
  for (int i = 0; i < 26; i++) {
    check[i] = 0;
  }
  int flag = 1;
  for (int i = 0; i < 27; i++) {
    if (s[i] < 'a' || s[i] > 'z') {
      break;
    }
    check[s[i]-'a']++;
    if (check[s[i]-'a'] > 1) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    printf("yes\n");
  } else {
    printf("no\n");
  }

  return 0;
}

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

N = int(input())
A = list(map(int, input().split()))

Max = [[(0, A[0])]]
ans = 0
for bit in range(1, (1<<N)):
    dic = {bit: A[bit]}
    for i in range(N):
        if bit&(1<<i) != 0:
            for ind, val in Max[bit-(1<<i)]:
                dic[ind] = val
    com = []
    for ind, val in dic.items():
        if len(com) < 2:
            com.append((ind, val))
        else:
            if com[0][1] < com[1][1]:
                if com[0][1] < val:
                    com[0] = (ind, val)
                elif com[1][1] < val:
                    com[1] = (ind, val)
            else:
                if com[1][1] < val:
                    com[1] = (ind, val)
                elif com[0][1] < val:
                    com[0] = (ind, val)               
    Max.append(com)
    tmp = com[0][1] + com[1][1]
    if tmp > ans:
        ans = tmp
    print(ans)

Measured memory_bytes: 123496
#include<stdio.h>
int main(void)
{
	int N[10000]={0},i,j,k,m,n,q,c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&q);
		N[i]=q;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&q);
		for(j=0;j<n;j++)
		{
			if(N[j]==q){c++;break;}
		}
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a;
  cin >> a;
  string s;
  cin >> s;
  long long b = stoll(s.substr(0, (int) s.length() - 3)) * 100 + stoll(s.substr((int) s.length() - 2));
  cout << a * b / 100 << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
 // cout<<12<<endl<<endl<<endl;
  int W,H;
  cin>>H>>W;
  char masume[H+1][W+1];
  for (int i=0;i<H; i++) {
    string s;
    cin>>s;
    for (int j=0; j<W; j++) {
      masume[i][j] = s[j];
    }
  }
  
  // i want to get space
  
  //cout<<endl;
  
  set <int> tate,yoko;
  //tate
  for(int i=0;i<H;i++){
    bool flag=true;
    for(int j=0;j<W;j++){
      if(masume[i][j]=='#') flag=false;
    }
    if( flag) {tate.insert(i);}//cout<<i<<endl;}
  }
  
  //yoko
  for(int i=0;i<W;i++){
    bool flag=true;
    for(int j=0;j<H;j++){
      if(masume[j][i]=='#') flag=false;
    }
    if( flag) {yoko.insert(i);}//cout<<i<<endl;}
  }
  
  
  
  for(int i=0;i<H;i++){
    bool g=false;
    for(int j=0;j<W;j++){
      if(tate.find(i) != tate.end() or yoko.find(j) != yoko.end()){continue;}//cout<<1<<endl;continue;}
      cout<<masume[i][j];g=true;
    }
    if(not g) continue;
    cout<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	int N;
	cin>>N;
	
	int ans = 100;
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		int cnt = 0;
		while(a%2==0){
			cnt++;
			a/=2;
		}
		ans = min(ans,cnt);
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n && n) {
    int ans=0;
    for(int i=1; i<=12; i++) {
      int a,b;
      cin >> a >> b;
      if(n>0) {
	n-=a-b;
	if(n<=0) ans=i;
      }
    }
    if(ans) pr(ans);
    else pr("NA");
  }
  return 0;
}


Measured memory_bytes: 1160
N, M, X = map(int,input().split())
S = map(int,input().split())
Fees = list(S)
Goal1 = []
Goal2 = []
count1 = 0
count2 = 0
point0 = 0

for i in range(X):
    point0 += 1
    Goal1.append(point0)
# print(Goal1)

for j in range(N-X):
    X += 1
    Goal2.append(X)
# print(Goal2)

for fee in Fees:
    if fee in Goal1:
        count1 += 1
    if fee in Goal2:
        count2 += 1

if count1 >= count2:
    print(count2)
if count1 < count2:
    print(count1)
















# Fee = list(S)
# print(Fee)
# count1 = 0
# count2 = 0
# for i in range(N-X):
#     X += 1
#     if X in Fee:
#         count1 += 1
# print(X)
# for j in range(N):
#     X -= 1
#     if X in Fee:
#         count2 += 1
#
# if count1 <= count2:
#     print(count1)
# if count1 > count2:
#     print(count2)

Measured memory_bytes: 9092
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b= sc.nextInt();
		System.out.print((int)a/b+" ");
		System.out.print((int)a%b+" ");
		System.out.print(String.format("%.5f", (double)a/b));
	}
}



Measured memory_bytes: 26372
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});
	return 0;
}

Measured memory_bytes: 3668
<?php

  list($h, $n) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $x=0;
  for($i=0;$i<$n;$i++){
    $x+=$a[$i];
  }
  if($h > $x){
    echo "No";
  }else{
    echo "Yes";
  }

Measured memory_bytes: 12792
#include <stdio.h>
#include <math.h>
int isPrime(int);
int main(){
  int n,i,count=0;
  int Number[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&Number[i]);
    count+=isPrime(Number[i]);
  }
  printf("%d\n",count);
  return 0;
}

int isPrime(int x){
  int i=3;
  if(x==2){
    return 1;
  }
  if(x<2 || x%2==0){
    return 0;
  }
  while(i<=sqrt(x)){
    if(x%i==0)return 0;
      i=i+2;
  }
  return 1;
}
  

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;
int a[100005];
int main()
{
    ios::sync_with_stdio(false);
    int n,t;cin>>n>>t;
    int mx,mn;t=0;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0) mn=a[i];
        mn=min(mn,a[i]);
        t=max(t,a[i]-mn);
    }
    for(int i=0;i<n;i++)
    {
        if(i==0) mn=a[i];
        mn=min(mn,a[i]);
        if(a[i]-mn==t) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }

int n, m;
int c[25];
int dp[50005];

// int coin(int cost) {
//     if (cost == 0) return 0;
//     if (dp[cost] >= 0) return dp[cost];
//     int ret = INT_MAX;
//     for (int i = 0; i < m; ++i) {
//         if (cost - c[i] >= 0) ret = min(ret, coin(cost - c[i]) + 1);
//     }
//     return dp[cost] = ret;
// }

int coin(int cost) {
    for (int i = 0; i <= cost; ++i) dp[i] = INT_MAX;
    dp[0] = 0;
    for (int i = 0; i <= cost; ++i) {
        for (int j = 0; j < m; ++j) {
            dp[i + c[j]] = min(dp[i + c[j]], dp[i] + 1);
        }
    }
    return dp[cost];
}
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> c[i];
    memset(dp, -1, sizeof(dp));
    int ans = coin(n);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3316
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	int N,K,x,ans=1000000000;
    cin>>N>>K;
    vector<int>h(N);
    REP(i,N){
        cin>>x;
        h[i]=x;
    }

    sort(h.begin(),h.end(),greater<int>());
    REP(i,N-K+1){
        if(h[i]-h[i+K-1]<ans){
            ans=h[i]-h[i+K-1];
        }
    }

    cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int64_t i=0; i<N-1; i++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(N-1) << endl;
}

int main(){
  double R; cin >> R;
  cout << 3.1415926535 * 2 * R << endl;
}

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;


long long modpow(long long a, long long n, long long mod){
    long long res=1;
    while(n>0){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    int a[n];
    int mod=1e9+7;
    for(int i=0;i<n;i++)cin>>a[i];
    bool flag=true;
    sort(a,a+n);
    if(n%2==0){
        for(int i=0;2*i<n;i++){
            if(a[2*i]!=2*i+1||a[2*i+1]!=2*i+1)flag=false;
        }
    }else if(n%2!=0){
        if(a[0]!=0)flag=false;
        for(int i=1;2*i<n;i++){
            if(a[2*i-1]!=2*i||a[2*i]!=2*i)flag=false;
        }
    }
    if(flag==false)cout<<0<<endl;
    else{
        cout<<modpow(2,n/2,mod)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3908
n, c = map(int,input().split())
x = []
v = []
for i in range(n):
    s, t = input().split()
    x.append(int(s))
    v.append(int(t))
vl1 = [0]
vl2 = [0]
suml = 0
vr1 = [0]
vr2 = [0]
sumr = 0
for i in range(n):
    suml += v[i]
    #vl1.append(vl1[i] if vl1[i] > suml - x[i] else suml - x[i])
    #vl2.append(vl2[i] if vl2[i] > suml - x[i]*2 else suml - x[i]*2)
    vl1.append(max(vl1[i],suml - x[i]))
    vl2.append(max(vl2[i],suml - x[i]*2))
    sumr += v[n-1-i]
    #vr1.append(vr1[i] if vr1[i] > sumr - c + x[n-1-i] else sumr - c + x[n-1-i])
    #vr2.append(vr2[i] if vr2[i] > sumr - (c - x[n-1-i])*2 else sumr - (c + x[n-1-i])*2)
    vr1.append(max(vr1[i],sumr - c + x[n-1-i]))
    vr2.append(max(vr2[i],sumr - (c - x[n-1-i])*2))
print(max( [max(vl1[i]+vr2[n-i],vr1[i]+vl2[n-i]) for i in range(n+1)] ))

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

using namespace std;

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

    int a, b, c, d;
    a = n / 1000;
    b = (n % 1000) / 100;
    c = (n % 100) / 10;
    d = (n % 10) / 1;

    if((a == b && b == c) || (b == c && c == d)){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n;
	std::cin >> n;

	int max = -1;
	int sum = 0;
	int num;

	for (int i = 0; i < n; i++) {
		std::cin >> num;
		if (num > max)
			max = num;
		sum = sum + num;
	}

	sum = sum - max / 2;
	std::cout << sum << std::endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	static long long aa[86];
	int n, i;

	scanf("%d", &n);
	aa[0] = 2;
	aa[1] = 1;
	for (i = 2; i <= 86; i++)
		aa[i] = aa[i - 1] + aa[i - 2];
	printf("%lld\n", aa[n]);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char> (w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < h;) {
        bool z = true;
        rep(j, w) {
            if(a[i][j] == '#') {z = false; break;}
        }
        if(z) {
            a.erase(a.begin() + i);
            h--;
        } else {
            i++;
        }
    }

    for(int j = 0; j < w;) {
        bool z = true;
        rep(i, h) {
            if(a[i][j] == '#') {z = false; break;}
        }
        if(z) {
            for(auto it = a.begin(); it != a.end(); it++) {
                it->erase(it->begin() + j);
            }
            w--;
        } else {
            j++;
        }
    }

    rep(i, h) {
        rep(j, w) {
            cout << a[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3636
from bisect import bisect_right as br 
from bisect import bisect_left as bl

f=lambda:map(int,input().split())
N=int(input())
A=list(f())
B=list(f())
C=list(f())
A.sort()
B.sort()
C.sort()


B2=[]
C2=[]
for b in B:
    B2.append(bl(A,b))
for c in C:
    C2.append(bl(B,c))
    
B3=[]
for b in B2:
    if B3:
        B3.append(B3[-1]+b)
    else:
        B3.append(b)
    
res=sum([B3[C2[i]-1] if C2[i]!=0 else 0 for i in range(N)])
print(res)

Measured memory_bytes: 109700
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int n;
	cin>>n;
	ll ans=0;
	vector<ll>l(n);
	rep(i,n)cin>>l[i];
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			for(int k=j+1;k<n;++k){
				ll sum=l[i]+l[j]+l[k];
				ll maxv=max({l[i],l[j],l[k]});
				if(l[i]==l[j])continue;
				if(l[j]==l[k])continue;
				if(l[i]==l[k])continue;
				if(maxv<sum-maxv){
					++ans;
				}
			}
		}
	}
	cout<<ans;
}

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


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int memo[MAXN][3];
int a[MAXN][3];

int main() {
	int n; rd(n);
	for (int i = 1; i <= n; i++) for (int j = 0; j < 3; j++)
		rd(a[i][j]);

	int ans = 0;
	for (int i = n; i >= 1; i--) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) if (k != j)
				memo[i][j] = max(memo[i][j], a[i][j] + memo[i+1][k]);
			ans = max(ans, memo[i][j]);
		}
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 6048
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int a,b;
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W') a++;
        if(s[i]=='R') b++;
    }
    int r=0;
    for(int i=0;i<b;i++)
    {
        if(s[i]=='R') r++;
    }
    cout<<min(b-r,a);
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 998244353
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define sz(x) (ll)((x).size())
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define msi map<string,ll>
#define mii map<ll,ll>
#define mp  make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define mem(x,val) memset(x,val,sizeof(x))
#define r0 return 
const long long INF=1e18;
template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
#define dbgv(container) {cerr << #container << " : \n"; int cnt = 0; for (auto& x: container) cerr << #container << "[" << cnt++ << "] = " << x << '\n';} 
#define dbgvv(container) {cerr << #container << " : \n"; int c1=0,c2=0; for (auto& x : container){c2 = 0; for (auto& y : x) {cerr << #container << "[" << c1 << "][" << c2++ << "] = " << y << '\n';}c1++;}}
#define dbg(...)__f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

//code begins here
ll dp[100005][4],n,a[100005][3];
ll calc(ll i,ll p)
{
	if(i==n+1) return 0;
	if(dp[i][p]!=-1) return dp[i][p];
	dp[i][p]=-INF;
	rep(j,0,3)
	{
		if(j!=p) dp[i][p]=max(calc(i+1,j)+a[i][j],dp[i][p]);
	}
	return dp[i][p];
}
void solve()
{
 	cin>>n;
 	mem(dp,-1);
 	rep(i,1,n+1) cin>>a[i][0]>>a[i][1]>>a[i][2];
 	cout<<calc(1,3);
}
signed main()
{
	fast
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 12032
#include <stdio.h>

int main(int argc, const char * argv[]){
    int a,b,c, tmp;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll z=1000000000+7;
ll dp[3005][3005];
string s="";
ll lcs(string a,string b, ll n, ll m)
{
  ll i,j;
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=m;j++)
    {
      if(i==0||j==0)
      {
        dp[i][j]=0;
      }
      else if(a[i-1]==b[j-1])
      {
        dp[i][j]=1+dp[i-1][j-1];
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
	return dp[n][m];
}

void plcs(string a,string b,ll n,ll m)
{
   ll i = n, j = m;
   while (i > 0 && j > 0)
   {
      if (a[i-1] == b[j-1])
      {
          s.push_back(a[i-1]);
          i--;
          j--;
      }
      else if (dp[i-1][j]>dp[i][j-1])
         i--;
      else
         j--;
   }
  reverse(s.begin(),s.end());
  cout<<s;
 }

int main()
{
	IOS;
  int t=1;
  //cin>>t;
  while(t--)
  {
    memset(dp,-1,sizeof(dp));
    ll r,ans=0,p=0,i,n,m,c,d;
    string a,b;
    cin>>a;
    cin>>b;
    n=a.length();
    m=b.length();
    ans=lcs(a,b,n,m);
  //  cout<<ans<<"\n";
    plcs(a,b,n,m);
	}
	return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int K =sc.nextInt();
		int S =sc.nextInt();
		int P =0;
		int Q =0;
		
		for (int X=0; X<K+1; X++){
			for (int Y=0; Y<K+1; Y++){
					P=S-X-Y;
					if(0<=P && P<=K){
					Q++;
					}
			}
		}
			System.out.println(Q);
	}
}

Measured memory_bytes: 21844
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    set<string> S;
    READV(T);
    while(T--)
    {
        string Z;
        cin>>Z;
        S.insert(Z);
    }
    cout<<S.size()<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 19412
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        int d = n % 10;

        if (d == 3) {
            System.out.println("bon");
        }
        else if (d== 0 || d == 1 || d == 6 || d == 8) {

            System.out.println("pon");
        }
        else {
            System.out.println("hon");
        }
    }


}

Measured memory_bytes: 35768
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

int n ;
cin >> n ;
vector<ll> a(n) ;
vector<ll> c(n+1) ;

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

ll tmp = 0 ;
for (int i = 1; i <= n ; i++)
{
    tmp += c[i]*(c[i]-1)/2 ;
}

for (int i = 0; i < n ; i++)
{
   ll b = c[a[i]]*(c[a[i]]-1)/2 ;
   ll af = (c[a[i]]-1)*(c[a[i]]-2)/2 ;
   cout << tmp -b + af << endl ;
}


return 0; 
}

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] values = new int[N];
        for (int i=0; i<N; i++) {
            values[i] = scanner.nextInt();
        }
        int count = 0;
        hoge: while (true) {
            for (int i=0; i<N; i++) {
                if (values[i] % 2 != 0) {
                    break hoge;
                }
                values[i] = values[i] / 2;
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21332
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    
    n = I()
    if n%2 == 0:
        ans = 0
        for i in range(1,27):
            ans += n//(2*pow(5,i))
        print(ans)
    else:
        print(0)

main()


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

int main() {
    string S;
    cin>>S;
    vector<int> amari(2019,-1);
    amari[0]=1;
    int amari_now=0,ans=0,kurai_mod=1;
    for(int i=S.size();i>0;i--){
        int t = stoi(S.substr(i-1,1));
        amari_now=(t*kurai_mod+amari_now)%2019;
        if(amari[amari_now]==-1){
            amari[amari_now]=1;
        }else{
            ans+=amari[amari_now];
            amari[amari_now]++;
        }
        kurai_mod=(kurai_mod*10)%2019;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3768
# -*- coding: utf-8 -*-
num = int(input())
ab = []
for i in range(num):
    a,b = map(int,input().split())
    tmp = [b,a]
    ab.append(tmp)

ab_sorted = sorted(ab,reverse = True)

f = True
next_st = ab_sorted[0][0]
for b,a in ab_sorted:
    if next_st < 0:
        f = False
        break
    elif next_st > b:
        next_st = b-a
    else:
        next_st = next_st-a
    if next_st<0:
        f = False
        break

if f == False:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 37284
a,b,c,d=input()
zenhan=int(a)*10+int(b)
kouhan=int(c)*10+int(d)
if zenhan>=13 or zenhan==0:
  if kouhan>=13 or kouhan==0:
    print('NA')
  else:
    print('YYMM')
else:
  if kouhan>=13 or kouhan==0:
    print('MMYY')
  else:
    print('AMBIGUOUS')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

template <class T> class MultiArray2
{
    public:
        T* _a;
        int _w;
        int _h;
        MultiArray2(int w, int h, bool clr = false)
        {
            _w = w; _h = h;
            _a = new T[_w * _h];
            if(clr) memzero();
        }

        void memzero()
        {
            memset(_a, 0, _w * _h * sizeof(T));
        }

        ~MultiArray2()
        {
            delete _a;
        }

        T* operator[](int i)
        {
            return _a + (i * _h);
        }

        void print()
        {
            for( int j = 0; j < _h; j++ )
            {
                for( int i = 0; i < _w; i++ )
                {
                    cout << (*this)[i][j] << " ";
                }
                cout << endl;
            }
        }
};

template <class T> class MultiArray3
{
    public:
        T** _a2;
        T* _a;
        int _d1;
        int _d2;
        int _d3;
        MultiArray3(int d1, int d2, int d3, bool clr = true)
        {
            _d1 = d1; _d2 = d2; _d3 = d3;
            _a = new T[_d1 * _d2 * _d3];
            _a2 = new T*[_d1 * d2];
            for(int i = 0; i < d1 * d2; i++ ) _a2[i] = _a + (i * _d3);
            if(clr) memzero();
        }

        void memzero()
        {
            memset(_a, 0, _d1 * _d2 * _d3 * sizeof(T));
        }

        ~MultiArray3()
        {
            delete _a;
            delete _a2;
        }

        T** operator[](int i)
        {
            return _a2 + (i * _d2);
        }
};

int main()
{
    int r, c, k;
    cin >> r >> c >> k;
    MultiArray2<_LL> v(r, c, true);
    rep(l, k)
    {
        _LL rt, ct, vt;
        cin >> rt >> ct >> vt;
        rt--; ct--;
        v[rt][ct] = vt;
    }
    MultiArray3<_LL> dp(r, c, 4, true);
    rep(i, r)
        rep(j, c)
        {
            if( i != 0 ) 
                rep(m, 4) dp[i][j][0] = max( dp[i][j][0], dp[i - 1][j][m] );
            if( j != 0 )
                rep(m, 4) dp[i][j][m] = max( dp[i][j][m], dp[i][j - 1][m] );
            for( int m = 2; m >= 0; m-- )
                dp[i][j][m + 1] = max( dp[i][j][m + 1], dp[i][j][m] + v[i][j] );
        }

    _LL ans = 0;
    rep(m, 4) ans = max( ans, dp[r-1][c-1][m] );
    cout << ans;
    return 0;    
}

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

typedef long long int LLI;

int N;
LLI S;
LLI ans;
LLI minb = 0x7fffffff;
LLI A[214514];
LLI B[214514];

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%lld%lld", &A[i], &B[i]);
    if (A[i] > B[i]) minb = min(minb, B[i]);
    S += A[i];
  }

  if (minb == 0x7fffffff) {
    puts("0");
    return 0;
  }

  ans = S - minb;
  printf("%lld\n", ans);
}





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

struct activity{
	int A,B,C;
};

int solve(vector<activity>ar,int n){
	int dp[n+1][3];
	dp[1][0] = ar[1].A;
	dp[1][1] = ar[1].B;
	dp[1][2] = ar[1].C;

	for(int i=2;i<=n;i++){
		dp[i][0] = ar[i].A+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = ar[i].B+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = ar[i].C+max(dp[i-1][0],dp[i-1][1]);
	}

	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}

int main(){
	int n;
	cin>>n;
	vector<activity> ar(n+1);
	for(int i=1;i<=n;i++){
		cin>>ar[i].A;
		cin>>ar[i].B;
		cin>>ar[i].C;
	}

	cout<<solve(ar,n);
}

Measured memory_bytes: 6676
<?php
$line = trim(fgets(STDIN));
if(preg_match('/RRR/', $line)) {
    echo "3";
} else if(preg_match('/RR/', $line)) {
    echo "2";
} else if(preg_match('/R/', $line)) {
    echo "1";
} else {
    echo "0";
}

Measured memory_bytes: 16396
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0]+a[1] == a[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b)a=b;};

const Int MAX = 1010;

double dp[2][MAX][MAX];
double dfs(Int k,Int i,Int j){
  double &res=dp[k][i][j];
  //cout<<k<<" "<<i<<" "<<j<<endl;
  assert(i>=0&&j>=0);
  if(res>=0) return res;  
  res=0;
  if(i==0||(k==0&&i<=j*2)) return res;
  if(!k){
    if(j) res+=dfs(0,i-2,j-1)*double(j)/double(i-j);
    res+=dfs(1,i,j+1)*double(i-2*j)/double(i-j);
  }else{
    assert(j>=1);
    res+=dfs(0,i-2,j-1)*double(1)/double(i-j);
    res+=(dfs(0,i-2,j-1)+1.0)*double(j-1)/double(i-j);
    res+=(dfs(0,i,j+1)+1.0)*double(i-j*2)/double(i-j);
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      dp[0][i][j]=dp[1][i][j]=-1;
  Int n;
  while(cin>>n,n){
    cout<<fixed<<setprecision(12)<<dfs(0,n,0)<<endl;
  }
}



Measured memory_bytes: 19188
package main

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

var as []int

func solve(m int, i int) string {
	if m == 0 {
		return "yes"
	}
	if i > len(as)-1 {
		return "no"
	}
	res := solve(m-as[i], i+1)
	if res == "yes" {
		return "yes"
	}
	res = solve(m, i+1)
	if res == "yes" {
		return "yes"
	}
	return "no"
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)
	for n > 0 {
		as = append(as, nextInt(sc))
		n--
	}
	q := nextInt(sc)
	var ms []int
	for q > 0 {
		ms = append(ms, nextInt(sc))
		q--
	}

	for _, m := range ms {
		result := solve(m, 0)
		fmt.Println(result)
	}
}



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

main(){
	string n;
  	int s = 0;
  	cin >> n;
  	for(int i = 0; i< n.size(); i ++){
      s+= n[i]-'0';
    }
  	cout << (stoi(n)%s == 0?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n, 0), sum1(n + 1, 0), sum2(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < n; ++i) {
        sum1[i + 1] = sum1[i] + a[i];
        sum2[i + 1] = sum2[i] + max(0LL, a[i]);
    }

    ll ans = 0;
    for (int i = 0; i <= n - k; ++i) {
        ll sum = max(0LL, sum1[i + k] - sum1[i]);
        sum += sum2[i] + sum2[n] - sum2[i + k];
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<string.h>

int main(){
    int h,a;
    scanf("%d%d",&h,&a);
    if(h%a>0){
        printf("%d\n",h/a+1);
    }
    else{
        printf("%d\n",h/a);
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int count=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(a[i]+a[j]>a[k])count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    ll n,res=0;
    cin >> n;
    vector<int>a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)cin >> c[i];

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    rep(i,n){
        ll m = b[i];
        ll lb = lower_bound(a.begin(),a.end(),m)-a.begin();
        ll ub = upper_bound(c.begin(),c.end(),m)-c.begin();
        ub = n-ub;
        res+=lb*ub;
    }    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l;
	cin >> l;
	//cout << l*l*l/3.0/3.0/3.0 << endl;
	printf("%.12f\n", (double)l*l*l/27);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool graph[8][8];

int dfs(int v, int N, bool visited[8])
{
  bool all_visited=true;

  for(int i=0; i<N; i++){
    if(!visited[i])  all_visited=false;
  }

  if(all_visited)  return 1;

  int ret=0;
  for(int i=0; i<N; i++){
    if(!graph[v][i])  continue;
    if(visited[i])  continue;

    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }

  return ret;
}

int main()
{
  int N, M;
  cin>>N>>M;
  
  for(int i=0; i<M; i++){
    int a, b;
    cin>>a>>b;
    graph[a-1][b-1]=graph[b-1][a-1]=true;
  }

  bool visited[8];
  for(int i=0; i<N; i++)  visited[i]=false;

  visited[0]=true;
  cout<<dfs(0, N, visited)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const LL MOD = 1000000007LL;
map<P, LL> memo;
LL f(LL S,LL X) {
	if (S == 0) return 1;
	if (memo.find(P(S, X)) != memo.end()) return memo[P(S, X)];
	LL ret = f(S / 2, X / 2);
	if (S >= 1 && X >= 1) ret += f((S - 1) / 2, (X - 1) / 2);
	if (S >= 2) ret += f((S - 2) / 2, X / 2);
	return memo[P(S, X)] = ret%MOD;
}
int main() {
	LL N;
	cin >> N;
	cout << f(N, N) << endl;
}

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	string S, T;
	cin >> S >> T;

	string ans = "No";
	for (int i = 0; i < S.size(); ++i) {
		string S2 = S[S.size() - 1] + S;
		S = S2.substr(0, S.size());

		if (S == T) {
			ans = "Yes";
			break;
		}
	}

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


Measured memory_bytes: 3604
a,b,c=map(int,raw_input().split())
red1=a*b*(c/2)
blue1=a*b*(c-c/2)
red2=a*(b/2)*c
blue2=a*(b-b/2)*c
red3=(a/2)*b*c
blue3=(a-a/2)*b*c
print min(abs(red1-blue1),abs(red2-blue2),abs(red3-blue3))


Measured memory_bytes: 2568
using namespace std;
#include<iostream>
int main()
{
  int n;
  cin>>n;
  int ac=0,wa=0,tle=0,re=0;
  while(n--)
  {
    string s;
    cin>>s;
    if(s=="AC")
        ac++;
    else if(s=="WA")
        wa++;
    else if("TLE"==s)
        tle++;
    else
        re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3624
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1001001001;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int p = INF;
	int ans = 0;
	rep(i, n) {
		int now = a[i];
		p = min(now, p);
		if (now == p) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
N, MOD = int(input()), 10 ** 9 + 7

memo = [{} for _ in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)

        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]

        if ''.join(t).count('AGC') >= 1:
            return False

    return True


def dfs(cur, last3):
    global N, MOD, memo

    if last3 in memo[cur]:
        return memo[cur][last3]

    if cur == N:
        return 1

    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD

    memo[cur][last3] = ret

    return ret


print(dfs(0, 'TTT'))


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

class Program
{
	static void Main(string[] args)
	{
		string[] nm = Console.ReadLine().Split();

		int n = int.Parse(nm[0]);
		int m = int.Parse(nm[1]);

		int[] cs = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

		int[] minCounts = new int[50001];

		// コイン1枚で実現できる金額には枚数1を入れておく
		for (int ci = 0; ci < m; ci++)
		{
			minCounts[cs[ci]] = 1;
		}

		// 1から順番に辿る
		for (int i = 1; i <= n; i++)
		{
			minCounts[i] = GetMinCounts(i, minCounts);
		}
		System.Console.WriteLine(minCounts[n]);
	}

	// Kを実現する最小コイン枚数を返す
	static int GetMinCounts(int k, int[] minCounts)
	{
		// 記録済み
		if (minCounts[k] > 0) return minCounts[k];

		// 頭と後ろからの組み合わせで最小値を計算
		int min = k;
		for (int j = 1; j < k; j++)
		{
			if (k - j < j) return min;
			int current = minCounts[k - j] + minCounts[j];
			if (current < min) min = current;
		}
		return min;
	}
}



Measured memory_bytes: 9824
private val scanner = java.util.Scanner(System.`in`)

private fun readInts(n: Int) = Array(n) { scanner.nextInt() }
private fun readLongs(n: Int) = Array(n) { scanner.nextLong() }
private fun readLineInts() = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
private fun readLineLongs() = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()

fun main(args: Array<String>) {
    val s = readLine()!!.toInt()

    fun f(n: Int) = if (n % 2 == 0) n / 2 else n * 3 + 1

    val list = mutableListOf(s)
    for (i in 2..100000000) {
        val m = f(list.last())

        if (m in list) {
            println(i)
            return
        }

        list.add(m)
    }
}

Measured memory_bytes: 33560
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll sx = in(), sy = in(), tx = in(), ty = in();
    REP(i, tx - sx) {
        cout << 'R';
    }
    REP(i, ty - sy) {
        cout << 'U';
    }
    REP(i, tx - sx) {
        cout << 'L';
    }
    REP(i, ty - sy + 1) {
        cout << 'D';
    }
    REP(i, tx - sx + 1) {
        cout << 'R';
    }
    REP(i, ty - sy + 1) {
        cout << 'U';
    }
    cout << "LU";
    REP(i, tx - sx + 1) {
        cout << 'L';
    }
    REP(i, ty - sy + 1) {
        cout << 'D';
    }
    cout << 'R' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{


int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
std::cout << ((x>2*y)?x-2*y:0) << '\n';
}


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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int n, k, cont=0;
    cin >> n >> k;
    while(n/k!=0){
        cont++;
        n/=k;
    }
    cont++;
    cout << cont << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
 
    int cou = 0;
    for(int i=0; i<=X; i++){
    if(Y==i*2+(X-i)*4){
        cou++;
}
}
    if(cou>0){
   	System.out.println("Yes");
    }else{
	System.out.println("No");
      }
}
}
  

Measured memory_bytes: 35652
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(b / a > c) {
			System.out.println(c);
		}else {
			System.out.println(b / a);
		}

		sc.close();
		
		
		
	}
}

Measured memory_bytes: 23892
def dfs_bomb(A,x,y):

	X = [ 1, 0,-1, 0, 2, 0,-2, 0, 3, 0,-3, 0]
	Y = [ 0, 1, 0,-1, 0, 2, 0,-2, 0, 3, 0,-3]

	A[x][y] = "0"

	for i in range(12):
		xx = x + X[i]
		yy = y + Y[i]

		if 0 <= xx < 8 and 0 <= yy < 8:
			if A[xx][yy] == "1":
				dfs_bomb(A,xx,yy)

if __name__ == '__main__':

	cnt = int(input())

	for i in range(cnt):
		input()
		A = []
		for _ in range(8):
			A.append(list(input()))

		y = int(input()) - 1
		x = int(input()) - 1

		dfs_bomb(A,x,y)

		print("Data "+str(i+1)+":")
		for z in range(8):
			print("".join(A[z]))




Measured memory_bytes: 5632
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, T;
    cin >> n >> T;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    vector<ll> B(n);
    ll mi = A[0];
    B[0] = 0;
    repi(i, n) {
        mi = min(mi, A[i]);
        B[i] = A[i] - mi;
    }

    ll maxB = *max_element(all(B));
    ll res = 0;
    rep(i, n) {
        if (maxB == B[i]) res++;
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4852
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int a[205];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	for(int i=0;i<n;i++) {
		a[i] = l + i;
	}
	int mn_neg = INT_MAX, mn_pos = INT_MAX;
	for(int i=0;i<n;i++) {
		if(a[i] < 0) mn_neg = min(mn_neg, -a[i]);
		else mn_pos = min(mn_pos, a[i]);
	}
	int ans = 0;
	for(int i=0;i<n;i++) ans += a[i];
	int mn_diff = INT_MAX, pr = 0;
	for(int i=0;i<n;i++) {
		int ret = 0;
		for(int j=0;j<n;j++) {
			if(i==j) continue;
			ret += a[j];
		}
		if(abs(ans-ret) < mn_diff) {
			mn_diff = abs(ans-ret);
			pr = ret;
		}
	}
	cout << pr;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans(0);
  for(int i(1);i<n;i++){
    int cnt(0);
    for(char c='a';c<='z';c++){
      bool left=false,right=false;
      for(int j(0);j<i;j++){
        if(s[j]==c)left=true;
      }
      for(int j(i);j<n;j++){
        if(s[j]==c)right=true;
      }
      if(left&&right)cnt++;
      if(ans<cnt)ans=cnt;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256