akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      1000007

const int mod = 1e9 + 7;

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

   int n, m;
   cin >> n >> m;
   vector<string> arr(n);
   int dp[n][m];
   for (int i = 0; i < n; ++i)
   {
      cin >> arr[i];
   }

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         if (arr[i][j] == '#')
            dp[i][j] = 0;
         else if (i == 0 and j == 0)
            dp[i][j] = 1;
         else if (i == 0)
            dp[i][j] = dp[i][j - 1];
         else if (j == 0)
            dp[i][j] = dp[i - 1][j];
         else
         {
            if (dp[i - 1][j] > 0 and dp[i][j - 1] > 0)
               dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            else
               dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
         }
         dp[i][j] %= mod;
      }
   }
   cout << dp[n - 1][m - 1] << endl;
   return 0;
}

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

typedef long long ll;

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

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

    int dp[n+1];
    memset(dp, 0, sizeof(dp));

    const int mod = 1e9 + 7;
    int a;
    dp[0] = 1;
    dp[1] = 1; 
    while (m--){
        cin>>a;
        dp[a] = -1;
    }
    if (dp[1] == -1) dp[1] = 0;

    for (int i=2;i<=n;++i){
        if (dp[i] == -1) dp[i] = 0;
        else dp[i] = dp[i-1]+dp[i-2];
        dp[i] %= mod;
    }

    cout<<dp[n]<<endl;
    
    return 0;
}

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int x , k , d;
	
	cin >> x >> k >> d;
	
	int move = abs(x/d);
	
	if(x < 0) {
		if(move <= k) {
			int rem = k - move;
			
			if(rem % 2) {
				int p = x + move*d;
				
				cout << min(abs(p+d) , abs(p-d));
				return;
			}
			else {
				cout << abs(x + move*d);
				return;
			}
		}
		else {
			cout << abs(x+k*d);
			return;
		}
	}
	else {
		if(move <= k) {
			int rem = k - move;
			
			if(rem % 2) {
				int p = x - move*d;
				
				cout << min(abs(p+d) , abs(p-d));
				return;
			}
			else {
				cout << abs(x-move*d) << endl;
				return;
			}
		}
		else {
			cout << abs(x-k*d);
			return;
		}
	}
}

signed main() {
    fast;

    int t = 1;

	//cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3652
s=list(input())
ss=s[:2]
sss=s[2:]
x=int("".join(ss))
y=int("".join(sss))

if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12 :
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n){
            cin>>a[i];
      }
      ll ans=a[0];
      rep0(i,n){
            ans=__gcd(a[i],ans);
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
  int N,M,C;
  int A[30][30];
  int B[30];
  int i,j;
  int ans=0;
  scanf("%d %d %d",&N,&M,&C);
  for(i=1;i<=M;i++){
    scanf("%d",&B[i]);
  }
  for(i=1;i<=N;i++){
    for(j=1;j<=M;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=1;i<=N;i++){
    int s=0;
    for(j=1;j<=M;j++){
      s=s+A[i][j]*B[j];
    }
    if(s+C>0){
      ans=ans+1;
    }
  }
  printf("%d\n",ans);
  return 0;
}
  

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <functional>

#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

ll arr[100009];

void Eratosthenes(ll N){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i]){
			//cout << i << endl;
		}
	}
}


int main(){
    int X=0;
    // int p=0,q=0;
    cin >> X;
    Eratosthenes(100005);

    for(int i = X; i < 100005; i++){
		if(arr[i]){
			cout << i << endl;
            return 0;
		}
    }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long LL;

LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }
LL lcm(LL x, LL y) { return x / gcd(x, y) * y; }

int main() {
    int N;
    LL T, ans = 1;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
//ll INF = 1LL<<40;
int INF = 1LL<<15;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if((to_string(i).size() % 2) == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] chars = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k = scanner.nextInt();
        System.out.println(chars[k-1]);
    }
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    unordered_map<string, int> num_appeared;
    REP(i, N) ++num_appeared[S[i]];
    
    int max_appeared = 0;
    for(auto n: num_appeared) max_appeared = max(max_appeared, n.second);

    vector<string> ans;
    for(auto n: num_appeared){
        if(n.second == max_appeared) ans.push_back(n.first);
    }

    sort(ans.begin(), ans.end());
    for(auto s: ans) cout << s << endl;

    return 0;
}

Measured memory_bytes: 28228
import java.util.*;

public class Main {
	public static final int[] PRIME = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173 , 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281 , 283, 293, 307, 311, 313, 317};

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] sums = new int[100000 / 2 + 1];
		int count = 0;
		for (int i = 3; i < 100000; i += 2) {
			if (isPrime(i) && isPrime((i + 1) / 2)) {
				count++;
			}
			sums[i / 2 + 1] = count;
		}
		StringBuilder sb = new StringBuilder();
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			sb.append(sums[r / 2 + 1] - sums[l / 2]).append("\n");
		}
		System.out.print(sb);
	}
	
	public static boolean isPrime(int x) {
		for (int i = 0; i < PRIME.length; i++) {
			if (x <= PRIME[i]) {
				break;
			}
			if (x % PRIME[i] == 0) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 66340
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    vector< set<int> > num1(26);
    vector< set<int> > num2(26);
    size_t N = S.size();
    for(int i=0; i<N; i++) {
        num1[T.at(i)-'a'].insert(S.at(i)-'a');
        num2[S.at(i)-'a'].insert(T.at(i)-'a');
    }
    for(int i=0; i<26; i++) {
        if(num1.at(i).size() > 1 || num2.at(i).size() > 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int a,b,c,d,x,y;
  cin >> a >> b >> c >> d;
  x=a+b;
  y=c+d;
  if(x>y)
    cout << "Left" << endl;
  else if(x<y)
    cout << "Right" << endl;
  else 
    cout << "Balanced" << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 256
using System;
using System.Linq;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            string[] S = Console.ReadLine().Split();
            long[] A = new long[N];
            for (long i = 0; i < N; i++) A[i] = long.Parse(S[i]);
            long a = 0, b = 0, c = 0;
            long ans = 1;
            long count = 1;
            for(long i = 0; i < N; i++)
            {
                count = 1;
                if (A[i] == a)
                {
                    a++;
                    if (A[i] == b) count++;
                    if (A[i] == c) count++;
                }
                else if (A[i] == b)
                {
                    b++;
                    if (A[i] == c) count++;
                }
                else if (A[i] == c)
                {
                    c++;
                }
                else ans = 0;
                ans = (ans * count) % 1000000007;
            }


            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 19168
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n = read()
    a = reads()
    r = float('inf')
    for i in range(-100, 100+1):
        r = min(r, sum([abs(x-i)**2 for x in a]))
    print(r)

main()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
ans=0
right=0
sum_pls = 0
sum_xor = 0

for left in range(n):

    while right<n and (sum_pls+a[right])==(sum_xor^a[right]):
        sum_pls += a[right]
        sum_xor ^= a[right]
        right+=1

    ans += right - left
    sum_pls -= a[left]
    sum_xor ^= a[left]

print(ans)


Measured memory_bytes: 24228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

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

using namespace std;

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2*g-r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll n, k;
  std::cin >> n >> k;
  std::vector<ll> a(n), s(n+1, 0);
  for(int i=0;i<n;i++){
    std::cin >> a[i];
    s[i+1] = (i==0?0:s[i]) + a[i];
  }
  for(int i=0;i<n;i++){
    s[i+1] = s[i+1] - (i+1);
    s[i+1] = s[i+1] % k;
  }
  ll ans = 0;
  map<ll, ll> mp;
  for(int i=0;i<=n;i++){
    if(mp.find(s[i])==mp.end()){
      mp.emplace(s[i], 1);
    }else{
      ans += mp.at(s[i]);
      ll tmp = mp.at(s[i]);
      mp.erase(s[i]);
      mp.emplace(s[i], tmp+1);
    }
    if(i>=k-1){
      ll tmp = mp.at(s[i-(k-1)]);
      mp.erase(s[i-(k-1)]);
      mp.emplace(s[i-(k-1)], tmp-1);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 15872
ss = gets.chomp

ans = [].fill(1, 0...ss.length)
for i in 0..(ss.length-1-1) do
  if ss[i..i+1] == 'RR' then
    ans[i+2] += ans[i]
    ans[i] = 0
  end
end
(ss.length-1).downto(1) do |i|
  if ss[i-1..i] == 'LL' then
    ans[i-2] += ans[i]
    ans[i] = 0
  end
end
puts ans.join(' ')

Measured memory_bytes: 3196
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    int k, x;
    cin >> k >> x;
    int i = x - (k - 1);
    while (i < x + k)
    {
        cout << i << " ";
        ++i;
    }
    cout << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000

int main(){
  int n;
  cin >> n;
  int b;
  stack<int> s1,s2,ans;
  for(int i=1;i<n+1;i++){
    cin >> b;
    s1.push(b);
  }
  for(int i=n;i>0;i--){
    int target = i;
    while(true){
      int now;
      now = s1.top();
      s1.pop();
      s2.push(now);
      if(now == target){
        ans.push(now);
        s2.pop();
        while(!s2.empty()){
          s1.push(s2.top());
          s2.pop();
        }
        break;
      }
      target -= 1;
      if(target == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }

  while(!ans.empty()){
    cout << ans.top() << endl;
    ans.pop();
  }

  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n, m = gets.split(/ /).collect{|x| x.to_i}

xs = gets.split(/ /).collect{|x| x.to_i}
ys = gets.split(/ /).collect{|x| x.to_i}

len_x = 0
(n - 1).times{|i|
	len_x = (len_x + (xs[i + 1] - xs[i]) * (i + 1) * (n - i - 1)) % MOD
}

len_y = 0
(m - 1).times{|i|
	len_y = (len_y + (ys[i + 1] - ys[i]) * (i + 1) * (m - i - 1)) % MOD
}

puts (len_x * len_y) % MOD


Measured memory_bytes: 15516
#include <iostream>

using namespace std;

int main(){

	double ar = 0,al = 0;
	double br = 0,bl = 0;
	double cr = 0,cl = 0;
	double dr = 0,dl = 0;

	double stur,stul;

	for(int i = 1; i <= 40; i++){
		cin >> stul >> stur;

		if(stul == 0) break;

		if(stul >= 1.1){
			al++;
		}else if(stul < 1.1 && 0.6 <= stul){
			bl++;
		}else if(stul < 0.6 && 0.2 <= stul){
			cl++;
		}else if(stul < 0.2){
			dl++;
		}

		if(stur >= 1.1){
			ar++;
		}else if(stur < 1.1 && 0.6 <= stur){
			br++;
		}else if(stur < 0.6 && 0.2 <= stur){
			cr++;
		}else if(stur < 0.2){
			dr++;
		}
	}

	cout << al << " " << ar << endl;
	cout << bl << " " << br << endl;
	cout << cl << " " << cr << endl;
	cout << dl << " " << dr << endl;

	return 0;
}

Measured memory_bytes: 1284
#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;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int gcd(int a, int b) {
	while (b){
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N;
	cout << 360 / gcd(360, N) << endl;
}

Measured memory_bytes: 3608
#include <cstdio>

int main(int argc, char const *argv[])
{
  int numZero = 0, numOne = 0;
  char c;

  while ((c = getc(stdin)) != '\n') {
    if (c == '1') numOne++;
    else if (c == '0') numZero++;
  }

  if (numOne != 0 && numZero != 0) {
    if (numOne >= numZero) printf("%d\n", numZero*2);
    else printf("%d\n", numOne*2);
  } else printf("0\n");

  return 0;
}


Measured memory_bytes: 128
s = input()
total = 0
n = 2**(len(s)-1)
for i in range(n):
    buf = s[0]
    for j in range(len(s)-1):
        if (i>>j)&1:
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Measured memory_bytes: 3060
let solve h w c =
  for j = 0 to w - 1 do
    c.(0).(j) <- 1 - c.(0).(j);
    for i = 1 to h - 1 do
      c.(i).(j) <- if c.(i).(j) = 1 then 0 else c.(i-1).(j) + 1
    done
  done;
  let rec duduwa ans i j k = function
    | [] -> (ans, [(c.(i).(j), k)])
    | (ch, cj) :: y' when ch >= c.(i).(j) -> duduwa (if ch * (j - cj) > ans then ch * (j - cj) else ans) i j cj y'
    | ys -> (ans, (c.(i).(j), k) :: ys) in
  let rec doit ans = function
    | (i, _, xs) when i = h -> ans
    | (i, j, xs) when j = w -> doit (List.fold_left (fun acc (ch, cj) -> if ch * (w - cj) > acc then ch * (w - cj) else acc) ans xs) (i + 1, 0, [])
    | (i, j, []) -> doit ans (i, j + 1, [(c.(i).(j), j)])
    | (i, j, ((ch, _) :: _ as xs)) when ch < c.(i).(j) -> doit ans (i, j + 1, (c.(i).(j), j) :: xs)
    | (i, j, ((ch, _) :: _ as xs)) when ch > c.(i).(j) ->
      let (ans, ys) = duduwa ans i j j xs in
      doit ans (i, j + 1, ys)
    | (i, j, xs) -> doit ans (i, j + 1, xs) in
  doit 0 (0, 0, [])

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read () = List.map int_of_string (split_on_char ' ' (read_line ()))

let () =
  match read () with
  | [h; w] ->
    let c = Array.make_matrix h w 0 in
    for i = 0 to h - 1 do
      let rec doit j = function
        | [] -> ()
        | x::xs ->
          c.(i).(j) <- x;
          doit (j + 1) xs in
      doit 0 (read ())
    done;
    Printf.printf "%d\n" (solve h w c)
  | _ -> ()

Measured memory_bytes: 25188
#include <iostream>
using namespace std;
 
int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int i=0; i<=3001-R; ++i) {
    for (int j=0; j<=3001-G; ++j) {
      int diff = N - (i*R + j*G);
      if ((diff>=0)&&(diff%B==0)) {
          ++ans;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
        
  

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

int lisOfJ(vector<int> lis, int j) {
  for (int i = lis.size()-1; i >= 0; i--) {
    if (j > lis[i])
      return i+1;
  }
  return 0;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> input_list (n, 0);
  for (int i = 0; i < n; i++)
    cin >> input_list[i];
  vector<int> lis;
  lis.push_back(input_list[0]);
  for (int i = 1; i < n; i++) {
    int holder = lisOfJ(lis, input_list[i]);
    if (holder == lis.size())
      lis.push_back(input_list[i]);
    else if (input_list[i] < lis[holder])
      lis[holder] = input_list[i];  
  }
  cout << lis.size() << endl;
  return 0;
}



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  cout<<(a-b)%c<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char * judge(double);

int main(void) {
    double w;
    while(~scanf("%lf", &w)) {
        printf("%s\n", judge(w));
    }
    return 0;
}

char * judge(double w) {
    if(w > 91) {
        return "heavy";
    } else if(w > 81) {
        return "light heavy";
    } else if(w > 75) {
        return "middle";
    } else if(w > 69) {
        return "light middle";
    } else if(w > 64) {
        return "welter";
    } else if(w > 60) {
        return "light welter";
    } else if(w > 57) {
        return "light";
    } else if(w > 54) {
        return "feather";
    } else if(w > 51) {
        return "bantam";
    } else if(w > 48) {
        return "fly";
    } else {
        return "light fly";
    }
}

Measured memory_bytes: 608
def main():
    """ ????????? """
    S1 = [] # ????????????1(??????????????????)
    S2 = [] # ????????????2(??????????°´????????????????????¨??¢???)
    A = 0 # ?????¢???

    inp = input()
    #inp = "\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\"
    for i in range(len(inp)):
        if inp[i] == chr(0x5c): # \ 
            S1.append(i)
            S2.append([i,0])
        elif inp[i] == chr(0x2f): # /
            if len(S1):
                j = S1.pop()
                d = i - j
                A += d
                k = d
                while len(S2):
                    p = S2.pop()
                    if p[1] > 0:
                        k += p[1]
                    else:
                        S2.append([p[0],k])
                        break
        #print("[{}] {} A={} S1:{} S2:{}".format(i,inp[i],A,S1,S2))
    L = []
    for p in S2:
        if p[1] > 0:
            L.append(p[1])
    print(A)
    if A > 0:
        print("{} {}".format(len(L)," ".join(map(str,L))))
    else:
        print("0")


if __name__ == '__main__':
    main()

Measured memory_bytes: 10156
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

#include <cmath>

void solve() {
    inl(N);

    ll div = 1LL; 
    for (ll i = 2; i * i <= N; i++)
        if (N % i == 0) div = i;

    ll x = N / div;
    ll ret = 1;
    while (x >= 10) {
        ret++;
        x /= 10;
    }
    out(ret);
}


Measured memory_bytes: 3616
R,G,B,N = map(int, input().split())
ans = 0
for i in range(0,1+N//R):
    #print(i,1 + (N-i*R)//G)
    for j in range(0,1 + (N-i*R)//G):
        k = (N-i*R-j*G)//B
        if N == R*i + G*j + B*k:
            ans += 1

print(ans)

Measured memory_bytes: 40556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll c=n/(a+b);
    ll ans=c*a;
    ll rest=n-c*(a+b);
    ans+=min(a,rest);
    cout<<ans<<endl;
}


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

int main(){
	string s; cin >> s;
  	map<char,vector<int>> dist;
  	for(int i=0; i< s.size(); i++){
    	dist[s.at(i)].push_back(i);
      	
    }
  	/*ここからアンバランス探しmapにはアルファベットと出現箇所が紐づけ
    各アルファベットについて、隣り合ってたらok
  	*/
  	bool seikai = false;
  	for(auto& a: dist ){
    	if(a.second.size()>1){
        	for(int i=0; i< a.second.size() - 1; i++ ){
            	if((a.second[i+1] - a.second[i] ==1) ||
                   (a.second[i+1] - a.second[i]==2)){
                	cout << a.second[i] +1<< " " << a.second[i+1] +1;
                  	seikai = true;
                  	goto Finish;
                	
                }
            }
        }
    }
  	Finish:
  	if(!seikai){cout << -1 << " " << -1;}
  	cout << endl;
  	
}


Measured memory_bytes: 1148
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class arc87D {
public:
    void solve(istream& in, ostream& out) {
        string s;
        in >> s;
        int n = s.size();
        int x, y;
        in >> x >> y;
        vector<int> dirx, diry;
        int start = 1, curx = 0, cury = 0;
        int startx = 0;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'T') {
                if (start) start = 0, cury = 1, diry.push_back(0);
                else if (curx) curx = 0, cury = 1, diry.push_back(0);
                else if (cury) curx = 1, cury = 0, dirx.push_back(0);
                else assert(false);
            } else {
                if (start)
                    ++startx;
                else if (curx)
                    ++dirx.back();
                else
                    ++diry.back();
            }
        }
        vector<int> dpx(16001, 0);
        dpx[startx + 8000] = 1;
        for (int i = 0; i < (int)dirx.size(); ++i) {
            vector<int> nxtx(16001, 0);
            for (int j = dirx[i]; j <= 16000; ++j)
                if (dpx[j]) nxtx[j - dirx[i]] = 1;
            for (int j = 0; j + dirx[i] <= 16000; ++j)
                if (dpx[j]) nxtx[j + dirx[i]] = 1;
            dpx = nxtx;
        }
        vector<int> dpy(16001, 0);
        dpy[0 + 8000] = 1;
        for (int i = 0; i < (int)diry.size(); ++i) {
            vector<int> nxty(16001, 0);
            for (int j = diry[i]; j <= 16000; ++j)
                if (dpy[j]) nxty[j - diry[i]] = 1;
            for (int j = 0; j + diry[i] <= 16000; ++j)
                if (dpy[j]) nxty[j + diry[i]] = 1;
            dpy = nxty;
        }
        if (dpx[x + 8000] && dpy[y + 8000])
            out << "Yes\n";
        else
            out << "No\n";
    }
};


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

	arc87D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 572
n=int(input())
act=[0]*n
for i in range(n):
    act[i]=list(map(int,input().split()))
dp=[[0]*3 for _ in range(n)]
dp[0]=[act[0][0],act[0][1],act[0][2]]
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+act[i][0]
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+act[i][1]
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+act[i][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))

Measured memory_bytes: 70604
from itertools import *
N = int(input())
m,a,r,c,h = 0,0,0,0,0
for _ in range(N):
  H =str(input())
  if H[0] == 'M':
    m += 1
  elif H[0] == 'A':
    a += 1
  elif H[0] == 'R':
    r += 1
  elif H[0] == 'C':
    c += 1
  elif H[0] == 'H':
    h += 1

L = [m,a,r,c,h]
L = [i for i in L if i > 0]

if len(L) < 3:
  print(0)
  exit()
else:
  ans = 0
  for l in combinations(L,3):
    a,b,c = l
    ans += (a*b*c)
    
print(ans)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n; cin >> n;
    map<ll, ll> m;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        if(m[a] != 1) m[a]++;
        else m[a]--;
    }
    ll ans = 0;
    for(auto p : m){
        if(p.second) ans++;
    }
    cout << ans  << endl;
}


Measured memory_bytes: 6528
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) #mapでintにしつつinputで取得

for x in a:
    if x == 0:
        print(0)
        exit(0)


for x in a:
    ans *= x
    if ans > MAX:
        print(-1)
        exit(0)
        
        #exit(0)
print(ans)

Measured memory_bytes: 21784
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <functional>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int cnt = 0;
void merge(int A[],int left,int mid,int right)
{
  int i,j,k,l;
  int n1 = mid - left;
  int n2 = right - mid;
  static int L[300000];
  static int R[300000];
  rep(i,n1) {
    L[i] = A[left + i];
  }
  rep(i,n2) {
    R[i] = A[mid + i];
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  i = 0; j = 0;
  for(k=left;k<right;k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int A[],int left,int right) {
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int main(void)
{
  int test = 1;
  int i,j,k,l;
  int n;
  static int A[500000];
  int left,right;
  scanf("%d",&n);
  rep(i,n) {
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  printf("%d",A[0]);
  REP(i,1,n) {
    printf(" %d",A[i]);
  }
  puts("");
  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 7064
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  int N, M;
  cin >> N >> M;
  char e[N][M];
  rep(i, N)rep(j, M)cin >> e[i][j];
  bool ans = true;
  rep(i, N)rep(j, M){
    if (e[i][j] == '#'){
      bool flag = false;
      rep(k, 4){
        int nx = i + dx[k];
        int ny = j + dy[k];
        if (nx >= 0 && ny >= 0 && nx < N && ny < M){
          if (e[nx][ny] == '#'){
            flag = true;
          }
        }
      }
      if (flag) continue;
      else ans = false;
    }
  }
  if (ans) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}      

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, m, d;
signed main() {
	cin >> n >> m >> d;
	if (!d)printf("%.12lf\n", (double)(m - 1) / (double)(n));
	else printf("%.12lf\n", (double)(n - d) * 2 * (double)(m - 1) / (double)(n*n));
	endre;
}


Measured memory_bytes: 256
n,k = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
dp = [False]*(k + 1)
for i in range(min(a), k + 1):
  dp[i] = any(not dp[i - j] for j in a if i - j >= 0)
print('First' if dp[k] else 'Second')


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

// 00 0
// 01 1
// 10 -2
// 11 -1
// * [0-1]
// 1* [-1-2]
// 1** [5432]
// 1*** []
// 0 0
// 1 1
// 10 -2
// 11 -1
// 100 4
// 101 5 (1)
// 110 2 (-2)
// 111 3 (-1)
// 1000 -8
// 1001 -7
// 1010
// 1 1
// 2 110 = 4 -2
// 3 111
// 4 100
// 5 1111
// 6
// 1 -2 4 -8 16 -32
// 1 -1 3 -11 5
//
int main() {
  in(ll, n);
  ll ans = 0;
  while (n) {
    if (n < 0) {
      ll val = -2;
      ll sum = -2;
      while (sum > n) {
        val *= 4;
        sum += val;
      }
      dbg(n, val, sum);
      ans |= -val;
      n -= val;
    } else {
      ll val = 1;
      ll sum = 1;
      while (sum < n) {
        val *= 4;
        sum += val;
      }
      dbg(n, val, sum);
      ans |= val;
      n -= val;
    }
  }
  if (int clz = __builtin_clzll(ans); clz == 64) {
    out(0);
  } else {
    for (int i = 63 - clz; i >= 0; --i) {
      cout << ((ans >> i) & 1);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll X, Y;
    cin >> X >> Y;
    ll a = 2*Y-X;
    ll b = 2*X-Y;
    if(a >= 0 && a%3 == 0) a /= 3;
    else {cout << 0 << endl; exit(0);}
    if(b >= 0 && b%3 == 0) b /= 3;
    else {cout << 0 << endl; exit(0);}
    int n = max(a, b);
    ll inv[n+1];
    rep2(i, 1, n+1){
        inv[i] = 1;
        ll e[30];
        e[0] = i;
        rep2(j, 1, 30){
            e[j] = (e[j-1]*e[j-1]) % MOD;
        }
        ll k = MOD-2;
        int count = 0;
        while(k > 0){
            if(k % 2 == 1){
                inv[i] *= e[count];
                inv[i] %= MOD;
            }
            k /= 2;
            count++;
        }
    }
    ll ans = 1;
    rep2(i, 1, a+1){
        ans *= a+b+1-i;
        ans %= MOD;
        ans *= inv[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  string SS,TT;
  cin >> S >>SS >> T >>TT;
  if(S==T)Out(0);
  else Out(1);
}

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

using namespace std;

using ll = long long;

int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  S[K-1] = 'a' + (S[K-1]-'A');
    
  cout << S << endl;
  
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	
	int i=0,j=0,a,b;
	
	while(1){
	
		scanf("%d %d",&a,&b);
		
		if(a == 0 && b == 0){break;}
		
		while(j != a){
		
			while(i != b){
				if(j == 0 || j == a-1){printf("#");}
				
				else if(i == 0 || i == b-1){printf("#");}
				
				else{printf(".");}
				
				++i;
			}
			printf("\n");
			++j;
			i = 0;
		}
		j = 0;
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

#define assertRange(x,a,b) assert((a) <= (x) and (x) <= (b))
typedef long long ll;
const int INF = 1e9;

const int N = 1e5+10;
int t[N];
int x[N];
int y[N];

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; ++i) {
        int dt = t[i]-t[i-1];
        int len = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        if (len > dt) {
            cout << "No" << endl;
            return 0;
        } else {
            int a = (x[i-1]^y[i-1])&1;
            int b = (x[i]^y[i])&1;
            if ((dt%2 == 0 and a != b) or (dt%2 == 1 and a == b)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_b

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()

x = 0
while True:
    ans = int(x * 1.08)
    if ans == N:
        print(x)
        break
    elif ans > N:
        print(":(")
        break
    x += 1

Measured memory_bytes: 38608
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
  // 整数の入力
  ll X,N;
  cin >> X >> N;
  set<ll> P;
  for (size_t i = 0; i < N; i++)
  {
    ll p;
    cin >> p;
    P.insert(p);
  }
  ll min_diff = BASE_NUM;
  ll min_v = -1;
  for(int i = 0;i <= 101;i++){
    if (min_diff > abs(X - i) && P.find(i) == P.end()){
      min_v = i;
      min_diff = abs(X - i);
    }
  }
  cout << min_v << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    ll m = n/2;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(rall(a));

    ll ans;
    if(n%2 == 1) {
        ll ans1 = 0;
        exrep(i, 0, m-2) {
            ans1 += 2*a[i];
        }
        exrep(i, m-1, m) {
            ans1 += a[i];
        }
        exrep(i, m+1, n-1) {
            ans1 -= 2*a[i];
        }
        ll ans2 = 0;
        exrep(i, 0, m-1) {
            ans2 += 2*a[i];
        }
        exrep(i, m, m+1) {
            ans2 -= a[i];
        }
        exrep(i, m+2, n-1) {
            ans2 -= 2*a[i];
        }
        ans = max(ans1, ans2);
    }
    else {
        ans = 0;
        exrep(i, 0, m-2) {
            ans += 2*a[i];
        }
        ans += a[m-1];
        ans -= a[m];
        exrep(i, m+1, n-1) {
            ans -= 2*a[i];
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[3 * n];
  for(int i = 0; i < 3 * n; i++) cin >> a[i];
  sort(a, a + 3 * n, greater<int>());
  long long sum = 0;
  for(int i = 0; i < n; i++) {sum += a[2 * i + 1];}
  cout << sum << endl;
}


Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();
        int y = scan.nextInt();

        List a = Arrays.asList(new Integer[]{1, 3, 5, 7, 8, 10, 12});
        List b = Arrays.asList(new Integer[]{4, 6, 9, 11});
        
        if (a.indexOf(x) != -1 && a.indexOf(y) != -1 ||
            b.indexOf(x) != -1 && b.indexOf(y) != -1 ||
            x == y) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        
    }
}

Measured memory_bytes: 21844
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn keta(n: i32) -> u32 {
    let mut x = n;
    let mut cnt: u32 = 0;
    while x != 0 {
        x /= 10;
        cnt += 1;
    }
    return cnt;
}
fn main() {
    let n = get!(i32);
    if n < 10 {
        println!("{}", n);
        return;
    } else if n < 100 {
        println!("9");
        return;
    }
    let keta = keta(n);
    // eprintln!("n: {}", n);
    // eprintln!("keta: {}", keta);
    let mut ans = 0;
    if keta % 2 == 0 {
        let mut odd = keta + 1;
        // eprintln!("{}", odd);
        while 0 < odd {
            odd -= 2;
            if odd == 1 {
                ans += 9;
                break;
            }
            ans += 9 * 10_i32.pow(odd - 1);
        }
    } else {
        let minus = 10_i32.pow(keta - 1);
        // eprintln!("minus: {}", minus);
        ans += n - (minus - 1);
        // eprintln!("ans: {}", ans);
        let mut odd = keta;
        while 0 < odd {
            odd -= 2;
            if odd == 1 {
                ans += 9;
                break;
            }
            ans += 9 * 10_i32.pow(odd - 1);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+2)
for i in a:
    dp[i]=-1

dp[0]=1
for i in range(n):
    if dp[i]==-1:continue
    if dp[i+1]!=-1:
        dp[i+1]=(dp[i+1]+dp[i])%mod
    if dp[i+2]!=-1:
        dp[i+2]=(dp[i+2]+dp[i])%mod

print(dp[-2])
#print(dp)

Measured memory_bytes: 7848