akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    vector<string>v;
    f(i,0,n){
        string s;cin>>s;
        sort(s.begin(),s.end());
        v.pb(s);
    }
    sort(v.begin(),v.end());ll cnt=1,ans=0;
   // f(i,0,v.size())cout<<v[i]<<" ";
    f(i,1,v.size()){
        if(v[i]==v[i-1])while(i<v.size() && v[i]==v[i-1]){cnt++;i++;}
        ans+=(cnt*(cnt-1))/2;
        cnt=1;
       // cout<<ans<<" ";
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5748
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0218();
	}
	
	class AOJ0218{
		int math,english,japanese;
		boolean is_A(){
			if(math==100||english==100||japanese==100)return true;
			if((math+english)/2>=90)return true;
			if((math+english+japanese)/3>=80)return true;
			return false;
		}
		
		boolean is_B(){
			if((math+english+japanese)/3>=70)return true;
			if((math+english+japanese)/3>=50&&(math>=80)||english>=80)return true;
			return false;
		}
		
		void doIt(){
			math = in.nextInt();english = in.nextInt();japanese = in.nextInt();
			if(is_A()){
				System.out.println("A");
				return;
			}else if(is_B()){
				System.out.println("B");
				return;
			}else System.out.println("C");
		}
		
		public AOJ0218() {
			while(true){
				int n = in.nextInt();
				if(n<=0)break;
				for(int i=0;i<n;i++)doIt();
			}
		}
	}
	
}

Measured memory_bytes: 26400
N,K,C = map(int,input().split())
S = list(input())
W = [i for i in range(N) if S[i]=="o" ]
# print(W)

def LR(S,f):
    D = {}
    i = 0
    count = 0
    while i<N and count<K:
        if S[i] == "o":
            count += 1
            if f:
                D[count] = i
            else:
                D[m+1-count] = N-1 - i
            i += C
        i += 1
    return D

L = LR(S,True)
m = max(L)
S.reverse()
R = LR(S,False)
# print(L,R)

for i in range(1,m+1):
    if L[i]==R[i]:
        print(L[i]+1)

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

const int mod = 1e9+7;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;
typedef long long ll;
using namespace std;

inline ll qpow(ll x,ll n)
{
    ll res=1;
    for(;n;n>>=1)
    {
        if(n&1)
        res=(res*x)%MOD;
        x=(x*x)%MOD;
    }
    return res;
}
ll fac[MAXN];
ll inv[MAXN];

ll Comb(int n,int m)//需要预处理阶乘f,注f[0]=1;
{
	if(n<m)return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    fac[0] = 1;
    inv[0]=qpow(fac[0],mod-2);
    for(int i = 1; i<MAXN-5;i++)
    {
        fac[i] = (i*fac[i-1])%mod;
        inv[i] = (qpow(fac[i],mod-2));
    }
    ll h,w,a,b;

    scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
    ll sum = Comb(h+w-2,w-1)%mod ;

    for(int i = 1; i <=b ;i++)
    {
        ll temp = ( Comb(h-a+i-2,i-1)*Comb(h-(h-a+1)+w-i,w-i)) %mod;
        while(sum<temp)
            sum=(sum+mod);
        sum = (sum -temp) %mod;
    }
    printf("%lld\n",sum%mod);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int count = 0;
    for(int i = a; i <= b; i++){
        string i_s = to_string(i);
        if(i_s[0] == i_s[4] && i_s[1] == i_s[3]) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int num[4],x,dp[401][51][51][51],ans;
int main()
{
	for(int i=3;i>=1;i--)
		scanf("%d",&num[i]);
	cin>>x;
	x/=50;
	dp[0][0][0][0]=1;
	for(int i=1;i<=x;i++)
		for(int j=0;j<=num[1];j++)
			for(int k=0;k<=num[2];k++)
				for(int l=0;l<=num[3];l++)	
				{
					if(j>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-1][j-1][k][l]:dp[i-1][j-1][k][l];
					if(i>=2&&k>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-2][j][k-1][l]:dp[i-2][j][k-1][l];
					if(i>=10&&l>=1)
						dp[i][j][k][l]=dp[i][j][k][l]?dp[i][j][k][l]*dp[i-10][j][k][l-1]:dp[i-10][j][k][l-1];
				}
	for(int j=0;j<=num[1];j++)
		for(int k=0;k<=num[2];k++)
			for(int l=0;l<=num[3];l++)
				ans+=dp[x][j][k][l];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n, k, h[N], dp[N];

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
      cin >> h[i];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
      dp[i] = inf;
      for(int j = max(0, i - k); j < i; j++)
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 4736
import heapq

n, m = map(int, input().split())
il = list(map(int, input().split()))
q = []
for idx, price in enumerate(il):
    heapq.heappush(q, (-price, idx))

for i in range(m):
    price, idx = heapq.heappop(q)
    price = -price // 2
    heapq.heappush(q, (-price, idx))

sum = 0
for t in q:
    price, idx = t
    sum += -price
print(sum)


Measured memory_bytes: 20552
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const double EPS = 1e-10;
const int INF = 1001001001;

int main()
{
	int t;
	while(scanf("%d", &t), t){
		int n;
		scanf("%d", &n);
		
		int sum = 0;
		rep(i, n){
			int a, b;
			scanf("%d%d", &a, &b);
			sum += b-a;
		}
		
		if(sum < t)
			printf("%d\n", t-sum);
		else
			puts("OK");
	}
	return 0;
}

Measured memory_bytes: 1044
use proconio::*;

fn run() {
    input! {
        mut a: i32,
        b: i32,
        mut c: i32,
        d: i32,
    }
    loop {
        c -= b;
        if c <= 0 {
            println!("Yes");
            return;
        }
        a -= d;
        if a <= 0 {
            println!("No");
            return;
        }
    }
}

fn main() {
    run();
}

Measured memory_bytes: 2148
import sys
input=sys.stdin.readline
from bisect import bisect_left,insort_left
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
t=[int(input())for _ in range(d)]
m=int(input())
dq=[list(map(int,input().split()))for _ in range(m)]
x=[[0]for _ in range(26)]
ans=0
for i in range(d):
  v=t[i]-1
  ans+=s[i][v]-c[v]*(i-x[v][-1]+1)*(i-x[v][-1])//2
  x[v].append(i+1)
for i in range(26):
  ans-=c[i]*(d+1-x[i][-1])*(d-x[i][-1])//2
  x[i].append(d+1)
for dd,q in dq:
  p=t[dd-1]
  t[dd-1]=q
  ans-=s[dd-1][p-1]
  ans+=s[dd-1][q-1]
  pi=bisect_left(x[p-1],dd)
  qi=bisect_left(x[q-1],dd)
  pl=dd-x[p-1][pi-1]
  pr=x[p-1][pi+1]-dd
  ql=dd-x[q-1][qi-1]
  qr=x[q-1][qi]-dd
  del x[p-1][pi]
  x[q-1].insert(qi,dd)
  ans-=c[p-1]*pl*pr
  ans+=c[q-1]*ql*qr
  print(ans)

Measured memory_bytes: 22092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <numeric>

using namespace std;

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<int> p(a), q(b), r(c);
	for (int i = 0; i < a; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> q[i];
	}
	for (int i = 0; i < c; i++) {
		cin >> r[i];
	}

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());

	auto v = r;
	for (int i = 0; i < x; i++) {
		v.push_back(p[i]);
	}
	for (int i = 0; i < y; i++) {
		v.push_back(q[i]);
	}

	sort(v.rbegin(), v.rend());
	long long ans = accumulate(v.begin(), v.begin() + x + y, 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2936
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int t1 = 0, t2 = 0,t3 = 0;
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin>>a;
        a=a%4;
        if(a == 2)
            t2++;
        else if(a == 0)
            t1++;
        else
            t3++;
    }
    if(t2>=1)t2=1;
    if(t1+1<t2+t3 )
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void solve() {
	ll n;
	cin >> n;
	
	Array a(n);
	REP(i, n)cin >> a[i];

	bool flag = true;
	ll pre = -1;
	ll ans = 0;
	REP(i, n) {
		if (a[i] > pre + 1) {
			flag = false;
			break;
		}
		if (pre + 1 == a[i]) ans++;
		else ans += a[i];
		pre = a[i];
	}
	if (!flag) cout << -1 << en;
	else cout << ans-1 << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, h[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> h[i]; }
	
	int p = h[n - 1];
	bool f = true;
	dec(i, n) {
		f &= (h[i] <= p + 1);
		setmin(h[i], p);
		p = h[i];
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define double long double
#define x first
#define y second
#define long long long
#define int long 



           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

int n;
int cache[3002][3002][2];
int arr[3002];
int dp(int i,int j,int c)
{
	if(i>j)
		return 0;
	if(cache[i][j][c]!=-1)
		return cache[i][j][c];
	if(c==0)
		return cache[i][j][c]=max(arr[i]+dp(i+1,j,c^1),arr[j]+dp(i,j-1,c^1));
	else
		return cache[i][j][c]=min(dp(i+1,j,c^1),dp(i,j-1,c^1));
}
int32_t main()
{
    IOS
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
    	cin>>arr[i];
    	sum+=arr[i];
    }
    memset(cache,-1,sizeof(cache));
    cout<<(2*dp(0,n-1,0)-sum);
}

Measured memory_bytes: 141184
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  
    for( i=0 ; i<=VMAX+1 ; i++ ){
        C[i] = 0;
    }

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

    for( i=1 ; i<VMAX+1 ; i++ ){
        C[i] = C[i] + C[i-1];
    }

    for( j=1 ;j<n+1 ; j++ ){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for( i=1 ; i<n+1 ; i++ ){
        if( i>1 && i<n+1 ) printf(" ");
        printf("%d",B[i]);
    }

    printf("\n");



  return 0;
}



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


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

int main()
{
  int N,of=0,zf=0;
  long long a,ans=1,cp;
  cin >> N;
  vector<long long> A;
  
  REP(i,N){
	cin >> a;
    
    if(a==0){
      zf=1;
    }
    A.push_back(a);
    ans *= a;
    if(ans > 1000000000000000000)of=1;
  }
  
  cp = ans;
  if(!of){
    REP(i,N){
      cp /= A[i];
    }
    if(cp != 1)of=1;
  }
  
  if(zf){
    cout << 0 << endl;
  }else if(of){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 4252
n=int(input())
s1=list(input())
s2=set()
s3=set()
tmp_s2=[]
tmp_s3=[]
max=0
for i in range(n-1):
    for j in range(i+1):
        tmp_s2.append(s1[j])
    s2=set(tmp_s2)
    tmp_s2.clear()
    for j in range(i+1,n):
        tmp_s3.append(s1[j])
    s3=set(tmp_s3)
    tmp_s3.clear()
    if max<len(s2&s3):
        max=len(s2&s3)
    s2.clear()
    s3.clear()
print(max)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    C = list(map(int, input().split()))

    dp = [f_inf] * (n + 1)
    dp[0] = 0
    for c in C:
        for i in range(1, n + 1):
            if i - c >= 0:
                dp[i] = min(dp[i], dp[i - c] + 1)
    print(dp[-1])


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 7524
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int yen,cnt=0;
	while (cin >> yen, yen) {
		if (cnt++)cout << endl;
		int c10, c50, c100, c500;
		cin >> c10 >> c50 >> c100 >> c500;
		int sum = c10 + c50 + c100 + c500;
		int resi, resj, resk, resl, ressum;
		resi = resj = resk = resl = ressum = -10000;
		for (int i = 0; i <= c10; i++) {
			for (int j = 0; j <= c50; j++) {
				for (int k = 0; k <= c100; k++) {
					for (int l = 0; l <= c500; l++) {
						int x = i * 10 + j * 50 + k * 100 + l * 500;
					//	cout << "x is " << x << "  x - yen is " << x-yen << endl;
						if (x - yen >= 0) {
							int out = i + j + k + l;
							int dif = x - yen;
							int p, q, r, s;
							p = dif / 500;
							dif = dif % 500;
							q = dif / 100;
							dif = dif % 100;
							r = dif / 50;
							dif = dif % 50;
							s = dif / 10;
							dif = dif % 10;
							int in = p + q + r + s;
							if (ressum < out - in) {
								ressum = out - in;
								resi = i;
								resj = j;
								resk = k;
								resl = l;
							}


						}
					}
				}
			}
		}
		if (resi)cout << "10 " << resi << endl;
		if (resj)cout << "50 " << resj << endl;
		if (resk)cout << "100 " << resk << endl;
		if (resl)cout << "500 " << resl << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();

		 if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)  ){
			 System.out.println("Yes");
		 }else {
			 System.out.println("No");
		}

		scanner.close();
	}
}


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

int main(void) {
    char a;
    cin >> a;
    switch (a) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            cout << "vowel\n";
            break;
        default:
            cout << "consonant\n";
            break;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string O,E;
  cin>>O>>E;
  vector<char> ans;
  for(int i=0;i<E.size();i++){
    ans.push_back(O[i]);
    ans.push_back(E[i]);
  }
  
  if(O.size()-E.size()==1){
    ans.push_back(O[O.size()-1]);
  }
  for(auto &e:ans){
    cout<<e;
  }
}

Measured memory_bytes: 256
INF = Float::INFINITY

def dfs(a, b, c, k)
  
  if k == N
    return [a, b, c].min == 0 ? INF : (A-a).abs + (B-b).abs + (C-c).abs - 10 * 3
  end
  
  x = dfs(a+L[k], b, c, k+1) + 10
  y = dfs(a, b+L[k], c, k+1) + 10
  z = dfs(a, b, c+L[k], k+1) + 10
  w = dfs(a, b, c, k+1)
  
  [x, y, z, w].min
end
 
N, A, B, C = gets.split.map{|t|t.to_i}
L = Array.new(N){ gets.to_i }
 
puts dfs(0, 0, 0, 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

//最短経路問題はBFSが最適！
int main() {
    // 頂点数と辺数
    int n, m, a, b; 
    cin >> n >> m;

    // グラフ入力受取 (ここでは無向グラフを想定)
    graph g(n+1);
    REP(i, m){
        cin >> a >> b;
        g[a].push_back(b);//aから辿れる頂点の配列
        g[b].push_back(a);//bから辿れる頂点の配列
    }

    // BFSのためのデータ構造
    vector<int> dist(n+1, -1); // 始点からの距離。全頂点を「未訪問」に初期化。
    vector<int> pre(n+1, -1); // 始点に向かう一つ先の点。
    queue<int> que;//始点に近い順に訪問していくのでqueue。

    // 初期条件 (頂点1を初期ノードとする)
    dist[1] = 0;
    que.push(1);

    // BFS開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        // キューから先頭頂点を取り出す
        int v = que.front();
        que.pop();
        // vから辿れる頂点をすべて調べる
        for (int nv : g[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            // 新たな頂点nvについて距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            pre[nv] = v;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    FOR(i, 2, n) cout << pre[i] << endl;
    return 0;
}

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

const int MAXN = 5 * 1e3;
vector<vector<int>> dp(MAXN+5, vector<int>(MAXN+5));

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	for(int i = n-1; i >= 0; i--){
		for(int j = n-1; j >= 0; j--){
			if(s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
		}
	}
	
	
	int res = 0;
	rep(i,n){
		for(int j = i; j < n; j++){
			if(dp[i][j] <= j-i) res = max(res, dp[i][j]); // not duplicate
		}
	}
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 98304
// https://atcoder.jp/contests/abc062/tasks/abc062_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int H, W;
    cin >> H >> W;
    H += 2, W += 2;
    vector<vector<char>> a(H, vector<char>(W));
    REP(i, W) a[0][i] = '#', a[H - 1][i] = '#';
    for (int i = 1; i < H - 1; ++i)
    {
        a[i][0] = '#', a[i][W - 1] = '#';
        for (int j = 1; j < W - 1; ++j)
        {
            cin >> a[i][j];
        }
    }
    REP(i, H)
    {
        REP(j, W)
        {
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    ll res=0;
    res=n*(n-1)/2;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int x = in.nextInt();
		if (a <= x && x <= a + b) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 21844
n = int(input())
ans = 0
sorted_word = {}

for i in range(n):
  word = ''.join(sorted(input()))
  sorted_word.setdefault(word, 0)
  sorted_word[word] += 1

def pair_num(n):
  return (n * (n - 1)) // 2

print(sum(map(pair_num, sorted_word.values())))

Measured memory_bytes: 62040
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin >> a >> b >> c;
    ll pre1,pre2,pre3;
    pre1=abs(((a/2)*b*c)-(a-(a/2))*b*c);
    pre2=abs(((b/2)*a*c)-(b-(b/2))*a*c);
    pre3=abs(((c/2)*b*a)-(c-(c/2))*b*a);
    cout << min(pre1,min(pre2,pre3)) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


a, b = Is()
print(max(a+b, a-b, a*b))

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Point{
    int x;
    int y;
    vector<Point> next;
    void get_next(vector<vector<int>> map){
        int py=y+1;int px=x;
        if(map[py][px]!=inf){
            Point buf;
            buf.x=px;buf.y=py;
            next.push_back(buf);
        }
        py=y-1;px=x;
        if(map[py][px]!=inf){
            Point buf;
            buf.x=px;buf.y=py;
            next.push_back(buf);
        }
        py=y;px=x+1;
        if(map[py][px]!=inf){
            Point buf;
            buf.x=px;buf.y=py;
            next.push_back(buf);
        }
        py=y;px=x-1;
        if(map[py][px]!=inf){
            Point buf;
            buf.x=px;buf.y=py;
            next.push_back(buf);
        }
    }
};
struct Map{
int h;
int w;
char road='.';//道を表す文字
char wall='#';//壁を表す文字
vector<vector<int>> map;
void mkmap(int in_h,int in_w,vector<string> const& input){
    h=in_h;w=in_w;
    for(int i=0;i<=h+1;i++){
        map.push_back(vector<int>(w+2,inf));
    }
    //道ならinf-1にする処理
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(input[i][j]==road){
                map[i+1][j+1]--;
            }
            //map[i+1][j+1]=input[i][j];
        }
    }
}
void output(){
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            if(this->map[i][j]==inf)cout<<wall;
            else cout<<map[i][j];
        }
        cout<<endl;
    }
}
void BFS(int sx,int sy){
Point s;s.x=sx;s.y=sy;
queue<Point> que;
vector<vector<int>> memo(h+2,vector<int> (w+2,inf));
que.push(s);
this->map[s.y][s.x]=0;
memo[s.y][s.x]=0;
while(!que.empty()){
    Point buf;
    buf=que.front();
    que.pop();
    buf.get_next(map);
    int num=buf.next.size();
    for(int i=0;i<num;i++){
        if(memo[buf.next[i].y][buf.next[i].x]>memo[buf.y][buf.x]+1){
            que.push(buf.next[i]);
            memo[buf.next[i].y][buf.next[i].x]=memo[buf.y][buf.x]+1;
        }
    }
}
for(int i=0;i<=h+1;i++){
  for(int j=0;j<=w+1;j++){
    map[i][j]=memo[i][j];
  }
}
}
int map_max(){
    int max=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(map[i][j]!=inf){
                if(map[i][j]>max)max=map[i][j];
            }
        }
    }
    return max;
}
int dist(int y,int x){
    return map[y][x];
}
};

signed main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  Map lab;
  lab.mkmap(h,w,s);
  lab.BFS(1,1);
  int res=0;
  rep(i,h){
      rep(j,w){
          if(s[i][j]=='.')++res;
      }
  }
  res-=1;
  res-=lab.dist(h,w);
  if(res<0)res=-1;
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3608
/* Volume0 */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      StringBuilder sb = new StringBuilder();

      for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
          sb.append(i).append("x").append(j).append("=").append(i * j);
          sb.append("\n");
        }
      }
      System.out.print(sb);
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 23940
#include <iostream>
#include <string>

using namespace std;
int dp[101][4][4][4];

int main(){
    int mod = 1e9 + 7 ;
    int N ;
    cin >> N;
    dp[0][3][3][3] = 1;

    // 文字列の長さi
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                for(int l = 0; l < 4; l++)
                {
                    if(dp[i][j][k][l] == 0) continue;
                    for(int newc = 0; newc < 4; newc++)
                    {
                        if (newc == 2 && l == 1 && k == 0) continue;
                        if (newc == 1 && l == 2 && k == 0) continue;
                        if (newc == 1 && l == 0 && k == 2) continue;
                        if (newc == 1 && l == 2 && j == 0) continue;
                        if (newc == 1 && j == 0 && k == 2) continue; 

                        dp[i+1][k][l][newc] += dp[i][j][k][l];
                        dp[i+1][k][l][newc] %= mod ;
                    } 
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                for(int l = 0; l < 4; l++)
                {
                    ans += dp[N][j][k][l];
                    ans %= mod;
                }
            }
        }
    
    cout << ans << endl;
}

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

void solve(long long int arr[], int n,int k){
  if(n==1){
      cout<<arr[0];
  }else if(n==2){
      cout<<abs(arr[1] - arr[0]);
  }else if(n==3 && k==1){
      cout<<abs(arr[1] - arr[0])+abs(arr[1] - arr[2]);
  }else if(n==3 && k==2){
      cout<<min(abs(arr[2] - arr[0]),abs(arr[1] - arr[0])+abs(arr[1] - arr[2]));
  }else{
      long long int dp[n];
      for(int i = 0; i < n; i++)dp[i] = INT_MAX;
      dp[0] = arr[0];
      for(int i = 1; i <= k; i++){
          for(int j = 1; j <= i && j <= k; j++){
             if(i-j == 0)
                dp[i] = min(dp[i],abs(arr[i] - arr[i-j]));
            dp[i] = min(dp[i],dp[i-j]+abs(arr[i] - arr[i-j]));
          }
            
      }
    for(int i=k+1; i<n; i++){
        for(int j = 1; j <= k; j++){
            dp[i] = min(dp[i],dp[i-j]+abs(arr[i] - arr[i-j]));
        }
    }
    
    cout<<dp[n-1];
    }
}

int main(){
    int n,k;
    cin>>n>>k;
    long long int arr[n];
    for(int i = 0; i < n; i++)cin>>arr[i];
    if(n <= k) k = n-1;
    solve(arr,n,k);
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
//constexpr int inf = 3e18;

int D;
int C[26];
int A[365][26];
int con[365];
set<int>st[26];
int score(){
	vector<int>last(26,-1);
	int res=0;
	rep(i,D){
		last[con[i]]=i;
		res+=A[i][con[i]];
		rep(j,26){
			res-=C[j]*(i-last[j]);
		}
	}
	return res;
}
int change(int x,int y){
	int res=A[x][y]-A[x][con[x]];
	auto pre_old=--st[con[x]].lower_bound(x);
	auto next_old=st[con[x]].upper_bound(x);
	res+=(*next_old-x-1)*(*next_old-x)/2*C[con[x]];
	res-=(x-*pre_old+*next_old-*pre_old-1)*(*next_old-x)/2*C[con[x]];
	auto pre_new=--st[y].lower_bound(x);
	auto next_new=st[y].lower_bound(x);
	res+=(x-*pre_new+*next_new-*pre_new-1)*(*next_new-x)/2*C[y];
	res-=(*next_new-x-1)*(*next_new-x)/2*C[y];
	return res;
}
double rand_double(){
	return (double)rand()/RAND_MAX;
}
signed main(){
	cin>>D;
	rep(i,26){
		cin>>C[i];
		st[i].insert(-1);st[i].insert(D);
	}
	vector<int>last(26,-1);
	rep(i,D){
		int mx=-mod,idx;
		rep(j,26){
			cin>>A[i][j];
			if(chmax(mx,A[i][j]+C[j]*(i-last[j])))idx=j;
		}
		con[i]=idx;st[idx].insert(i);
       last[idx]=i;
	}
	int score_=score();
	cerr<<score_<<endl;
	double C=1970*100000;
	while(1000.*clock()/CLOCKS_PER_SEC<=1970){
		int x=rand()%D,y;
		do{
			y=rand()%26;
		}while(con[x]==y);
		int diff=change(x,y);
		double ti=1970-1000.*clock()/CLOCKS_PER_SEC;

		if(diff>=0||ti/C>rand_double()){
			score_+=diff;
			st[con[x]].erase(x);
			con[x]=y;
			st[y].insert(x);
		}
	}
	rep(i,D)cout<<con[i]+1<<"\n";
	cerr<<score_<<" "<<score()<<endl;
}


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

H, W = map(int, input().split())
a = ['']*H
for i in range(H):
    a[i] = input()

dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i+1 < H and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j+1 < W and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD

print(dp[H-1][W-1])

Measured memory_bytes: 53488
package main

import "fmt"

func main() {
  var n, k, x, y, rc int
  fmt.Scan(&n)
  fmt.Scan(&k)
  fmt.Scan(&x)
  fmt.Scan(&y)
  
    for i := 1; i <= n; i++ {
        if i <= k {
            rc += x
        } else {
            rc += y
        }
    }

  fmt.Println(rc)
}

Measured memory_bytes: 512
import sys
from math import sqrt as sq

def main():
    l=[int(e) for e in list(sys.stdin.readline().split())]
    if l[0]>l[1]:
        l=l[::-1]
    for e in range(l[0],0,-1):
        if l[0]%e==0:
            tempQ1=l[0]//e
            if l[1]%e==0:
                tempQ2=l[1]//e
                print(tempQ1*tempQ2*e)
                break


main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

// 3000 3000 3000


int N, S, A[4000], dp[3090][3090];


int main() {

//  freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

  cin>>N>>S;
  rep(i, N) {
    cin>>A[i+1];
  }
  dp[0][0] = 1;

  for(int i = 1;i <= N;i++) {
    dp[i][0] = (2*dp[i-1][0])%mod;
    for(int j = 1;j <= S;j++) {
      dp[i][j] = (2*dp[i-1][j])%mod;
      if(j-A[i] >= 0) {
        (dp[i][j] += dp[i-1][j-A[i]])%=mod;
      }
    }
  }

  cout << dp[N][S] << endl;


  return 0;
}


Measured memory_bytes: 39748
from itertools import combinations

N, D = list(map(int, input().split()))
X = tuple(tuple(map(int, input().split())) for _ in range(N))

def dist(x1, x2):
    return sum((xx1 - xx2) ** 2 for xx1, xx2 in zip(x1, x2))

def is_acceptable(d):
    dd = round(d ** 0.5)
    return dd ** 2 == d

print(sum(is_acceptable(dist(x1, x2)) for x1, x2 in combinations(X, 2)))


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

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

char map[32][32];
int w, h;

int counter;

void count(int x, int y) {
	map[x][y] = '#';
	counter++;
	for (int i = 0; i < 4; i++) {
		int nextX = x + dx[i];
		int nextY = y + dy[i];
		if ((0 <= nextX && nextX < w) && (0 <= nextY && nextY < h)) {
			if (map[nextX][nextY] != '#') {
				count(nextX, nextY);
			}
		}
	}
}

int main() {
	int startX, startY;
	while (cin >> w >> h, w || h) {
		counter = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> map[j][i];
				if (map[j][i] == '@') {
					startX = j;
					startY = i;
				}
			}
		}
		count(startX, startY);
		cout << counter << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s;
    cin >> s;
    Yes((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[3])||(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[2]));
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, P, ans=0;
	ll A[100];

	cin >> N >> P;
	rep(i,N) cin >> A[i];

	ll dp[100][2] = {};
	dp[0][0] = 1;
	rep(i,N){
		dp[i+1][0] += dp[i][0];
		dp[i+1][1] += dp[i][1];
		int k = A[i]%2;
		dp[i+1][0^k] += dp[i][0];
		dp[i+1][1^k] += dp[i][1];
	}

	cout << dp[N][P] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

struct score {
	int mid;
	int fin;
	int ext;
};

int main(void) {

	int i, j, k, n;
	int num = 0;
	int sum;

	struct score student[10000];

	while (1) {
		scanf("%d %d %d", &student[num].mid, &student[num].fin, &student[num].ext);
		if (student[num].mid == -1 && student[num].fin == -1 && student[num].ext == -1) {
			break;
		}
		num++;
	}

	for (i = 0; i < num; i++) {
		if (student[i].mid == -1 || student[i].fin == -1) {
			printf("F\n");
			continue;
		}
		sum = student[i].mid + student[i].fin;
		if (sum >= 80)			printf("A\n");
		else if (sum >= 65)		printf("B\n");
		else if (sum >= 50)		printf("C\n");
		else if (sum >= 30) {
			if (student[i].ext >= 50)		printf("C\n");
			else							printf("D\n");
		}
		else					printf("F\n");
	}

	return 0;

}

Measured memory_bytes: 2600
package main

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

func dummy() {
	math.Abs(1.0)
}

/************I/O***********/

var (
	// ReadString returns a WORD string.
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

// ReadFloat64 returns an float64.
func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func readFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func readRuneSlice() []rune {
	return []rune(readString())
}

/*********math********/
func mod(val int, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func minInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res > val[i] {
			res = val[i]
		}
	}
	return res
}
func maxInt(val ...int) int {
	res := val[0]
	for i := 1; i < len(val); i++ {
		if res < val[i] {
			res = val[i]
		}
	}
	return res
}

const MOD = 1000000007

func main() {
	n := readInt()
	abc := make([][]int, n)
	for i := 0; i < n; i++ {
		abc[i] = readIntSlice(3)
	}
	dp := make([][]int, n)
	dp[0] = abc[0]
	for i := 1; i < n; i++ {

		a := maxInt(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0])
		b := maxInt(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1])
		c := maxInt(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2])
		dp[i] = []int{a, b, c}
	}
	fmt.Println(maxInt(dp[n-1][0], dp[n-1][1], dp[n-1][2]))
}


Measured memory_bytes: 11904
#include <cstdio>

int main(){
    int N, K;
    scanf("%d %d", &N, &K);

    int M[50], bunny[50][50];
    for(int i=0;i<K;i++){
        scanf("%d", M+i);

        for(int j=0;j<M[i];j++){
            scanf("%d", &bunny[i][j]);
            --bunny[i][j];
        }
    }

    int R, d[50][50];
    scanf("%d", &R);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            d[i][j] = 0;
        }
    }
    for(int i=0;i<R;i++){
        int p, q;
        scanf("%d %d", &p, &q);
        --p; --q;
        
        d[p][q] = 1;
        d[q][p] = 1;
    }

    // for(int i=0;i<N;i++){
    //     for(int j=0;j<N;j++){
    //         printf("%d ", d[i][j]);
    //     }
    //     puts("");
    // }
    
    int res = 0;
    for(int i=0;i<K;i++){
        for(int j=0;j<M[i];j++){
            for(int k=0;k<M[i];k++){
                if(d[bunny[i][j]][bunny[i][k]]){++res; break;}
            }
        }
    }

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

Measured memory_bytes: 1032
N = int(input())
result = [0, 0, 0, 0]
for _ in range(N):
    S = input()
    if S == "AC":
        result[0] += 1
    elif S == "WA":
        result[1] += 1
    elif S == "TLE":
        result[2] += 1
    elif S == "RE":
        result[3] += 1
tag = ["AC", "WA", "TLE", "RE"]
for i in range(4):
    print("{0} x {1}".format(tag[i], result[i]))

Measured memory_bytes: 69924
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,aans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>x;
    double xx = 1.01;
    double ans = 100;
    for(i=1;;i++)
    {
        ans = ans * xx;
        ans = floor(ans);
        
        if(ans>=x)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3652
n,w=list(map(int,input().split()))
k=[]
for i in range(n):
    k.append(list(map(int,input().split())))
dp=[[0 for i in range(w+1)] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j<k[i-1][0]:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-k[i-1][0]]+k[i-1][1])
print(dp[n][w])

Measured memory_bytes: 171528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin>>N;
  N--;
  long long total=0;
  long long yakusu=0;
  while(1){
    yakusu++;
    if(N>=yakusu){
      total+=(N/yakusu);
    }
    else{
      break;
    }
  }
  cout<<total;
}

Measured memory_bytes: 3632