akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
	int i, N, K, x, y, count[2][2000][2000] = {};
	char c;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) {
		scanf("%d %d %c", &x, &y, &c);
		if (c == 'B') count[0][x%(K*2)][y%(K*2)]++;
		else count[1][x%(K*2)][y%(K*2)]++;
	}
	
	int j, ans = 0, tmp, diff[2000] = {};
	for (x = 0; x < K; x++) {
		for (y = 0; y < K; y++) {
			diff[x] -= count[0][x][y] - count[1][x][y];
			ans += count[0][x][y];
		}
		for (; y < K * 2; y++) {
			diff[x] += count[0][x][y] - count[1][x][y];
			ans += count[1][x][y];
		}
	}
	for (; x < K * 2; x++) {
		for (y = 0; y < K; y++) {
			diff[x] += count[0][x][y] - count[1][x][y];
			ans += count[1][x][y];
		}
		for (; y < K * 2; y++) {
			diff[x] -= count[0][x][y] - count[1][x][y];
			ans += count[0][x][y];
		}
	}
	for (x = 0, tmp = ans; x < K; x++) {
		tmp += diff[x] + diff[x+K];
		if (tmp > ans) ans = tmp;
	}
	for (; x < K * 2; x++) {
		tmp -= diff[x] + diff[x-K];
		if (tmp > ans) ans = tmp;
	}
	for (y = 0; y < K; y++) {
		for (x = 0; x < K; x++) {
			diff[x] += (count[0][x][y] - count[1][x][y] - count[0][x][y+K] + count[1][x][y+K]) * 2;
			tmp -= count[0][x][y] - count[1][x][y] - count[0][x][y+K] + count[1][x][y+K];
		}
		for (; x < K * 2; x++) {
			diff[x] -= (count[0][x][y] - count[1][x][y] - count[0][x][y+K] + count[1][x][y+K]) * 2;
			tmp += count[0][x][y] - count[1][x][y] - count[0][x][y+K] + count[1][x][y+K];
		}
		for (x = 0; x < K; x++) {
			tmp += diff[x] + diff[x+K];
			if (tmp > ans) ans = tmp;
		}
		for (; x < K * 2; x++) {
			tmp -= diff[x] + diff[x-K];
			if (tmp > ans) ans = tmp;
		}
	}
	for (; y < K * 2; y++) {
		for (x = 0; x < K; x++) {
			diff[x] += (count[0][x][y] - count[1][x][y] - count[0][x][y-K] + count[1][x][y-K]) * 2;
			tmp -= count[0][x][y] - count[1][x][y] - count[0][x][y-K] + count[1][x][y-K];
		}
		for (; x < K * 2; x++) {
			diff[x] -= (count[0][x][y] - count[1][x][y] - count[0][x][y-K] + count[1][x][y-K]) * 2;
			tmp += count[0][x][y] - count[1][x][y] - count[0][x][y-K] + count[1][x][y-K];
		}
		for (x = 0; x < K; x++) {
			tmp += diff[x] + diff[x+K];
			if (tmp > ans) ans = tmp;
		}
		for (; x < K * 2; x++) {
			tmp -= diff[x] + diff[x-K];
			if (tmp > ans) ans = tmp;
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 32996
S = input()
count_C = 0
index_C = 0
if S[0] == 'A':
  for i in range(2,len(S)-1):
    if S[i] == 'C':
      count_C+=1
      index_C = i
  if count_C == 1:
    s = S[1:index_C]+S[index_C+1:]
    if s.islower():
      print('AC')
    else:
      print('WA') 
  else:
    print('WA') 
else:
  print('WA')

Measured memory_bytes: 3060
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define MAXN 
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
const int MD = (int)1e9+7;
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	

	int s,w;
	cin>>s>>w;

	if(s>w) cout<<"safe\n";
	else cout<<"unsafe\n";
 
 
 
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r;
    cin >> r;
    cout << (3 * r * r) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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


int main(){
    int a[5], k;
    rep(i, 5) cin >> a[i];
    cin >> k;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(a[j] - a[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>
 
#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
 
 
using namespace std;

const int max_n = 1e6 + 10;

char s[max_n];
int n;

int main() {
	scanf("%s", s);
	n = strlen(s);
	FOR(i,0,n-1) {
		if (s[i] == s[i+1]) {
			printf("%d %d\n", i+1, i+2);
			return 0;
		}
	}
	FOR(i,0,n-2) {
		if (s[i] == s[i+2]) {
			printf("%d %d\n", i+1, i+3);
			return 0;
		}
	}
	printf("-1 -1\n");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,t;
	cin>>n>>t;
	int c,u,ans=100000;
	for (int i = 0; i < n; ++i)
	{
		cin>>c>>u;
		if(u<=t) ans=min(ans,c);
	}
	if(ans==100000) cout<<"TLE\n";
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int n, k, tab[5010], v, maks, ans, ptr, jest;
int dp[5010][5010], d[5010];

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>k;
	for( int a = 1; a <= n; a++ )cin>>tab[a];
	dp[0][0] = 1;
	for( int a = 1; a <= n; a++ )
	{
		v = tab[a];
		for( int b = k; b >= 0; b-- )
		{
			dp[a][b] = max( dp[a][b], dp[a-1][b] );
			if( b >= v && dp[a-1][b-v] )dp[a][b] = 1;	
		}
	}
	d[0] = 1;
	for( int a = n; a >= 1; a-- )
	{
		v = tab[a];
		
		if( a == 1 )
		{
			for( int b = k-1; b >= 0; b-- )
			{
				if( d[b] )
				{
					maks = b;
					break;	
				}
			}
//			cout<<a<<" "<<maks<<endl;
			if( maks + tab[a] >= k )ans++;
		}
		else if( a == n )
		{
			for( int b = k-1; b >= 0; b-- )
			{
				if( dp[a-1][b] )
				{
					maks = b;
					break;	
				}
			}
//			cout<<a<<" "<<maks<<endl;
			if( maks + tab[a] >= k )ans++;	
		}
		else
		{
			ptr = k-1;
			jest = 0;
			for( int b = 0; b < k; b++ )
			{
				if( !dp[a-1][b] )continue;
				while( b + ptr >= k || !d[ptr] )ptr--;
//				cout<<a<<" "<<b<<" "<<ptr<<endl;
				if( b + ptr + tab[a] >= k )jest = 1;
			}
			ans += jest;
		}
		v = tab[a];
		for( int b = k; b >= 0; b-- )
		{
			if( b >= v && d[b-v] )d[b] = 1;
		}
//		cout<<ans<<endl;
	}
//	cout<<ans<<endl;
	cout<<n-ans<<endl;
	return 0;
}
 


Measured memory_bytes: 98304
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> h(n);
  rep(i, n) {
    cin>>h[i];
  }

  int ans = 0;
  int cur = 0;
  rep(i, 1, n){
    if (h[i-1]>=h[i]){
      cur++;
      chmax(ans, cur);
    }
    else{
      cur = 0;
    }
  }
  cout << ans << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int GoalNumber[11]={0,9,26,75,217,629,1826,5307,15438,44941,130900};
int goal=0;
int ans=0;
int n;
deque<int> dq;
void Get(int depth,int num){
	if(depth==goal+1){
		ans++;
		if(ans==n){
			for(int x:dq)
				cout<<x;
			exit(0);
		}
		return;
	}
	if(num!=0){
		dq.push_back(num-1);
		Get(depth+1,num-1);
		dq.pop_back();
	}
	dq.push_back(num);
	Get(depth+1,num);
	dq.pop_back();
	if(num!=9){
		dq.push_back(num+1);
		Get(depth+1,num+1);
		dq.pop_back();
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	while(n>GoalNumber[goal]){
		n-=GoalNumber[goal];
		goal++;
	}
	for(int i=1;i<=9;i++){
		dq.push_back(i);
		Get(2,i);
		dq.pop_back();
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=10000005;
//const int MAXN=105;
const int mod=1e9+7;
const int inv2=(mod+1)>>1;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
int pre[2*MAXN],inv[2*MAXN],inver[2*MAXN];
int H,W,K;
int main()
{
	pre[0]=1;for(int i=1;i<2*MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[2*MAXN-1]=pow_mod(pre[2*MAXN-1],mod-2);
	for(int i=2*MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	inver[1]=1;for(int i=2;i<2*MAXN;i++)inver[i]=1LL*(mod-(mod/i))*inver[mod%i]%mod;
	H=read();W=read();K=read();
	int ans=0,t1=inver[W+H],t2=1LL*inver[W+H]*(W+H-2)%mod;
	for(int i=2;i<=K;i++)
	{
		int t=1LL*t1*inver[W+H-i+1]%mod;
		ad(ans,1LL*(K-i+1)*t%mod);
		t1=1LL*t1*inver[W+H-i+1]%mod*(W+H-i)%mod;
		ad(t1,1LL*t2*inver[W+H-i+1]%mod);
		t2=1LL*t2*inver[W+H-i+1]%mod*(W+H-i-1)%mod;
	}
	ans=2LL*ans*H%mod*W%mod;
	int sum=0;
	for(int i=1;i<=K;i++)
	{
		int t=1LL*inv[W+H]*pre[W+H-i]%mod*pre[W+H-1]%mod*inv[W+H-i]%mod;
		ad(sum,1LL*(K-i+1)*t%mod);
	}
	ad(ans,1LL*(W+H)*sum%mod);
	ans=1LL*ans*pre[W+H]%mod*inv[W+H-K]%mod;
	ad(ans,1LL*pre[W+H]*inv[W+H-K]%mod*K%mod);
//	ad(ans,1LL*pre[W+H]*inv[W+H-K]%mod);
	pr2(ans);
	
	return 0;
}



Measured memory_bytes: 234624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nab = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var p = (long)Math.Pow(10, 9) + 7;
            var all = Power(2, nab[0], p);
            var combA = CombinationCount(nab[0], nab[1], p);
            var combB = CombinationCount(nab[0], nab[2], p);
            var result = (all - combA - combB - 1) % p;
            if (result < 0) result += p;
            Console.WriteLine(result);
        }

        static long PermutationCount(long n, long k, long mod)
        {
            if (n < k) throw new ArgumentException();
            var result = 1L;
            for (var i = 0; i < k; i++)
                result = (result * (n - i) % mod) % mod;
            return result;
        }

        static long CombinationCount(long n, long k, long mod)
        {
            if (n < k) throw new ArgumentException();
            k = Math.Min(k, n - k);
            var top = PermutationCount(n, k, mod);
            var bottom = PermutationCount(k, k, mod);
            return (top * Power(bottom, mod - 2, mod)) % mod;
        }

        static long Power(long x, long y, long mod)
        {
            var result = 1L;
            while (y > 0)
            {
                if ((y & 1) == 1) result = ((result % mod) * (x % mod)) % mod;
                x = ((x % mod) * (x % mod)) % mod;
                y >>= 1;
            }
            return result;
        }
    }
}


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

using namespace std;
using ll = long long;

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

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

  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0, d = 2;
  while (d <= n) {
    d *= 5;
    ans += n / d;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main(){
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut iter = s.split_whitespace();
    let mut tm = Vec::new();
    for _ in 0..5 {
        tm.push(iter.next().unwrap().parse::<i32>().unwrap());
    }
    let mut nzmin = 10;
    for &i in tm.iter() {
        if i % 10 == 0 {continue;}
        nzmin = std::cmp::min(i % 10,nzmin);
    }
    let mut ans = 0;
    for &i in tm.iter() {
        ans += (i + 9) / 10 * 10;
    }
    if nzmin != 0 {ans -= 10 - nzmin};
    println!("{}",ans);
}


Measured memory_bytes: 4352
import numpy as np
N, M, K = map(int, input().split())
A = [0]
B = [0]
A += list(map(int, input().split()))
B += list(map(int, input().split()))
A_cumsum = np.cumsum(A, dtype='int64')
B_cumsum = np.cumsum(B, dtype='int64')

def binary_search(k):
    if B_cumsum[-1] <= k:
        return M
    right = M
    left = 0
    while right != left:
        mid = (left + right) // 2
        if B_cumsum[mid] > k:
            right = mid
        else:
            left = mid + 1
    return left - 1

ans = 0
for i in range(N+1):
    count = 0
    if A_cumsum[i] <= K:
        count += i
    else:
        break
    count += binary_search(K - A_cumsum[i])
    if ans < count:
        ans = count
print(ans)

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s, t;
  cin >> s >> t;
  rep(i, s.size()) s[i] -= 'a';
  rep(i, t.size()) t[i] -= 'a';
  if(s.size() > t.size()) swap(s, t);
  int ans = 0;
  reps(len, 1, s.size()+1) {
    set< vector<int> > st;
    vector<int> v(26);
    rep(i, len) v[s[i]]++;
    st.insert(v);
    reps(i, len, s.size()) {
      v[s[i-len]]--;
      v[s[i]]++;
      st.insert(v);
    }
    vector<int> w(26);
    bool flag = false;
    rep(i, len) w[t[i]]++;
    if(st.count(w)) flag = true;
    reps(i, len, t.size()) {
      if(flag) break;
      w[t[i-len]]--;
      w[t[i]]++;
      if(st.count(w)) flag = true;
    }
    if(flag) ans = len;
  }
  cout << ans << endl;


  return 0;
}

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

//DFS
int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, -1);
        queue<int> q;
        auto qpush = [&](int v, int d){
            if(dist.at(v) != -1) return;
            dist.at(v) = d;
            q.push(v);
        };
        qpush(sv, 0);
        while(!q.empty()){
            int v = q.front(); q.pop();
            if(v < n - 1) qpush(v + 1, dist.at(v) + 1);
            if(v > 0) qpush(v - 1, dist.at(v) + 1);
            if(v == x) qpush(y, dist.at(v) + 1);
            if(v == y) qpush(x, dist.at(v) + 1);
        }
        rep(i, n){
            ans.at(dist.at(i))++;
        }
    }
    rep2(i, 1, n){
        cout << ans.at(i) / 2 << endl;
    }
}

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

int pasta[3], juice[2], m = INT_MAX;

int main(void){
  for(int i = 0; i < 3; i++) cin >> pasta[i];
  for(int i = 0; i < 2; i++) cin >> juice[i];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 2; j++){
      int n = pasta[i] + juice[j] - 50;
      if(n < m) m = n;
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int h[6][7]={
  {0,300,500,600,700,1350,1650},
  {0,  0,350,450,600,1150,1500},
  {0,  0,  0,250,400,1000,1350},
  {0,  0,  0,  0,250, 850,1300},
  {0,  0,  0,  0,  0, 600,1150},
  {0,  0,  0,  0,  0,   0, 500}
};
int main(){
  int n,m;
  while(cin>>n,n){
    int a,b;
    int m1,m2;
    cin>>a>>b;
    m1=a*100+b;
    cin>>m;
    cin>>a>>b;
    m2=a*100+b;
    if(n>m)swap(n,m);
    bool han=true;
    if(m2<1730||1950<m1||(m1<1730&&1930<m2))han=false;
    if((m==7&&n<4)||(m==6&&n==1))han=false;
    int ans=h[n-1][m-1];
    if(han)ans/=2;
    ans=(ans+49)-(ans+49)%50;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <fstream>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(i=0; i<n; i++)
#define fk(i, k, n) for(i=k; i<n; i++)
#define fn(i, n) for(i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
    int N;
    cin>>N;
    if(N%1000==0){
        cout<<"0";
        return 0;
    }else{
        int c = ceil(N/1000)+1;
        cout<<1000*c - N;
    }
    
    return 0;
}

Measured memory_bytes: 3160
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

st  = ri()
if st == "ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 62208
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
	static long long dp[2][100001];
	long long N, A, B;
	while(cin >> N >> A >> B){
		vector<long long> S(N);
		for(int i=0;i<N;i++) cin >> S[i];
		int valid[2] = {0, 0};
		dp[0][0] = dp[1][0] = 1;
		for(int i=1;i<N;i++){
			dp[0][i] = dp[1][i] = 0;
			auto lastIdx = [&](int start, long long dif){
				int low = start-1, high = i;
				while(high - low > 1){
					int mid = (low+high)/2;
					if(mid > 0 && S[i] - S[mid-1] < dif) high = mid;
					else low = mid;
				}
				return low;
			};
			int idx = lastIdx(valid[1], A);
			dp[0][i] = dp[1][idx] - (valid[1] > 0 ? dp[1][valid[1]-1] : 0);
			dp[0][i] = (dp[0][i] + dp[0][i-1] + MOD)%MOD;
			idx = lastIdx(valid[0], B);
			dp[1][i] = dp[0][idx] - (valid[0] > 0 ? dp[0][valid[0]-1] : 0);
			dp[1][i] = (dp[1][i] + dp[1][i-1] + MOD)%MOD;
			if(S[i]-S[i-1] < A) valid[0] = i;
			if(S[i]-S[i-1] < B) valid[1] = i;
		}
		long long res = 0;
		res = (res + dp[0][N-1])%MOD;
		if(valid[0] > 0) res = (res - dp[0][valid[0]-1] + MOD)%MOD;
		res = (res + dp[1][N-1])%MOD;
		if(valid[1] > 0) res = (res - dp[1][valid[1]-1] + MOD)%MOD;
		cout << res << endl;
	}
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n+1];
  rep(i,n)cin >> k[i+1];
  int ans[n+1];
  rep(i,n){
    int y=n-i;
    int tmp=0;
    int u=2*y;
    while(u<n+1){
      tmp+=ans[u];
      u+=y;
    }
    int e=tmp%2;
    if(k[y]==e)ans[y]=0;
    else ans[y]=1;
  }
  int cnt=0;
  vector<int> p(1,0);
  rep(i,n){
    cnt+=ans[i+1];
    if(ans[i+1]==1)p.push_back(i+1);
  }
  cout << cnt << endl;
  if(cnt==0)return 0;
  rep(i,cnt-1)cout << p[i+1] << " ";
  cout << p[cnt] << endl;
}  




Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int hoge(ll n, int cnt){
  if(n%2){
    return cnt;
  }else{
    return hoge(n/2,cnt+1);
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ans=0;
  cin>>N;
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    ans+=hoge(a,0);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import numpy as np
#from functools import reduce

def main():
    N, W = list(map(int, input().split()))
    bomb_map = np.zeros((N+2, W+2))
    for i in range(1,N+1):
        bomb_map[i,1:-1] = np.array(list(map(lambda x: 0 if x =='.' else 1, input())))

    new_map = bomb_map[:-2,:-2] + bomb_map[:-2,1:-1] + bomb_map[:-2,2:] \
                + bomb_map[1:-1,:-2] + bomb_map[1:-1,1:-1] + bomb_map[1:-1,2:] \
                    + bomb_map[2:,:-2] + bomb_map[2:,1:-1] + bomb_map[2:,2:]

    new_map = new_map * (bomb_map[1:-1,1:-1] * -2 + 1)

    result = [[str(int(i)) if i >= 0 else '#' for i in l] for l in new_map.tolist()]


    for l in result:
        print("".join(l))


if __name__ == '__main__':
    main()

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const int MAX_H = 30000;
int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(MAX_H, INF));

    dp[0][0] = 0;
    rep(i, N) {
        rep(j, MAX_H) {
            if (j < A[i]) {
                chmin(dp[i + 1][j], dp[i][j]);
            }
            else {
                chmin(dp[i + 1][j], min(dp[i][j], dp[i + 1][j - A[i]] + B[i]));
            }
        }
        for (int j = MAX_H - 2; j >= 0; j--) {
            chmin(dp[i + 1][j], dp[i + 1][j + 1]);
        }
    }

    cout << dp[N][H] << endl;
    return 0;
}

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

int main()
{
    int d,g;cin>>d>>g;
    vector<int> p(d);
    vector<int> c(d);
    int i,j,k;
    int ans=1e4;
    int kans,score;
    for(i=0;i<d;i++)cin>>p.at(i)>>c.at(i);
    for(i=0;i<(1<<d);i++)
    {
        kans=0;
        score=0;
        vector<bool> solved(d,false);
        for(j=0;j<d;j++)
        {
            if(i&(1<<j))
            {
                kans+=p.at(j);
                score+=p.at(j)*100*(j+1)+c.at(j);
                solved.at(j)=true;
            }
        }
        priority_queue<int> q;
        for(j=0;j<d;j++)
        {
            if(!solved.at(j))
            {
                for(k=0;k<p.at(j)-1;k++)q.push(100*(j+1));
            }
        }
        while(score<g&&!q.empty())
        {
            score+=q.top();
            q.pop();
            kans++;
        }
        if(score>=g)ans=(kans<ans)?kans:ans;
    }
    cout<<ans<<endl;
}


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

int low[200001], hi[200001];

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

  for (int i = 0; i < n; ++i) {
    low[i] = hi[i] = i;
  }

  std::vector<std::pair<int, int>> arm;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    arm.push_back(make_pair(x, n - 1 - y));
  }
  sort(arm.begin(), arm.end());

  for (int i = 0; i < m; ++i) {
    int y = arm[i].second;
    // cout << "swap " << y << " " << low[y] << " " << hi[y] << ", " <<
    //     low[y+1] << " " << hi[y+1];
    low[y + 1] = low[y];
    hi[y] = hi[y + 1];
    // cout << " -> " << low[y] << " " << hi[y] << ", " << low[y+1] << " " << hi[y+1] <<endl;
  }

  for (int i = n - 1; i >= 0; --i) {
    if (i != n - 1) {
      cout << " ";
    }
    cout << hi[i] - low[i] + 1;
  }
  cout << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  double a,b,c,d,e,f;
  while(~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)){
    // ax+by=c
    // dx+ey=f
    double x,y;
    x = (b*f-c*e)/(b*d-a*e);
    y = (c*d-a*f)/(b*d-a*e);
    if(abs(x)<1e-9) x = abs(x);
    if(abs(y)<1e-9) y = abs(y);
    // x = round(x*1000.0)/1000.0;
    // y = round(y*1000.0)/1000.0;
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1240
#!/usr/local/bin/python3
# https://atcoder.jp/contests/agc040/tasks/agc040_a

ans = 0
S = input().replace('><', '>,<').split(',')
for s in S:
    n = s.count('<')
    m = s.count('>')
    ans += (n*(n-1))//2 + (m*(m-1))//2 + max(n, m)

print(ans)


Measured memory_bytes: 19020
A, B = map(int, input().split())
A -= 1
ak, amod = divmod(A, 4)

cum_a = 0
if amod == 0:
    cum_a = A
elif amod == 1:
    cum_a = 1
elif amod == 2:
    cum_a = 4*ak + 3
else:
    cum_a = 0

bk, bmod = divmod(B, 4)
cum_b = 0
if bmod == 0:
    cum_b = B
elif bmod == 1:
    cum_b = 1
elif bmod == 2:
    cum_b = 4*bk + 3
else:
    cum_b = 0

print(cum_a ^ cum_b)

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

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

    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ll L, R;
    cin >> L >> R;
    if(R - L >= 2018){
        cout << 0 << endl;
      	return 0;
    }

    L = L % 2019;
    R = R % 2019;

    int ans = 2018;
    if (L >= R) ans = 0;
    for (int i = L; i < R; i++) {
        for (int j = i+1; j <= R; j++) {
            ans = min(ans, (i*j)%2019);
            if (ans == 0) break;
        }
        if (ans == 0) break;
    }
    cout << ans << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

const int MAX = 100000;

int n,m;
int q;
int a[MAX];
bool used[MAX];
int t[MAX];
int t_i;
int rev[MAX];
int cnt[MAX+1];

int main(){
  scanf("%d%d%d",&n,&m,&q);
  REP(i,q)scanf("%d",a+i),--a[i];
  // calc target sequence
  FORR(i,0,q){
    int c = a[i];
    if(!used[c]){
      used[c] = true;
      t[t_i++] = c;
    }
  }
  REP(i,m){
    if(!used[i])t[t_i++] = i;
    rev[t[i]] = i;
  }
  // split
  cnt[0] = n;
  FORR(i,0,q){
    int c = a[i];
    int id = rev[c];
    if(cnt[id]>0){
      cnt[id]--;
      cnt[id+1]++;
    }
  }
  REP(i,m){
    if(cnt[i]>0){
      bool flag = true;
      FOR(j,i,m-1){
        flag = flag && t[j]<t[j+1];
      }
      puts(flag?"Yes":"No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
ll A, B, C, D, N;

int main(){
	cin >> N >> A >> B >> C >> D;

	double d = 1e18;
	ll m;
	for(int l=0; l<N; l++){
		if(abs((B-A) - (l-0.5*(N-1))*(C+D)) < d){
			m = l;
			d = abs((B-A) - (l-0.5*(N-1))*(C+D));
		}
		//cout << (l-0.5*(N-1))*(C+D) << endl;
	}

	if(m < 0) m=0;
	if(m > (N-1)) m=N;
	//cout << m << " " << d << endl;
	//cout << m*(C+D)-D*(N-1) << " " << B-A << " " << m*(C+D)-(N-1)*C << endl;

	if(m*(C+D)-(N-1)*D <= B-A && B-A <= m*(C+D)-(N-1)*C){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
for i in range(k):
    num=q.get()
    if num%10!=0:
        q.put(num*10+num%10-1)
    q.put(num*10+num%10)
    if num%10!=9:
        q.put(num*10+num%10+1)
        
print(num)

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

class Program
{
    static void Main(string[] args) {
        char[] s = Console.ReadLine().ToCharArray();
        Console.WriteLine(solve(s, s.Length));
    }
    static int solve(char[] s, int n) {
        char[] s1 = new char[n];
        char[] s2 = new char[n];
        for(int i = 0; i < n; i ++) {
            if(i%2==0) s1[i] = '1';
            else s1[i] = '0';
        }
        for(int i = 0; i < n; i ++) {
            if(i%2==0) s2[i] = '0';
            else s2[i] = '1';
        }
        int count1 = 0;
        int count2 = 0;
        for(int i = 0; i < n; i ++) {
            if(s[i] != s1[i]) count1 ++;
        }
        for(int i = 0; i < n; i ++) {
            if(s[i] != s2[i]) count2 ++;
        }
        return Math.Min(count1,count2);
    }
}

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

typedef long long ll;

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<ll> sum(n);
    sum.at(0) = a.at(0);
    for(i = 1;i < n;++i){
        sum.at(i) = sum.at(i-1) + a.at(i);
    }
    ll alsum = sum.at(n-1);
    ll ans = abs(alsum - 2*sum.at(0));
    for(i = 1;i < n-1;++i){
        if(ans > abs(alsum - 2*sum.at(i))){
            ans = abs(alsum - 2*sum.at(i));
        }
    }
    cout << ans << endl;
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    ll ans=0;
    rep(i,0,n)rep(j,i+1,n)ans+=a[i]*a[j];
    printf("%lld\n",ans);
    return 0;
}

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

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793

#define DEBUG 1

int main(void) {
    int n;
    string s;
    cin >> n;
    cin >> s;
    if (s.length() % 2) { 
        cout << "No" << endl;
        return 0;
    }
    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;


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

	int n;

	string a;

	cin>>n>>a;
	int ans = 0;
	for(int i=0;i<n;i++){
		ans++;
		char curr = a[i];
		while(a[i]==curr)i++;
		i--;
	}
	cout<<ans<<endl;
}		



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

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

    int n;
    cin >> n;
    map<long long, long long> mp;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        mp[a]++;
    }

    vector<pair<long long, long long>> P;
    for(auto x: mp){
        if(x.second < 2) continue;
        P.push_back({x.first, x.second});
    }

    sort(P.rbegin(), P.rend());

    long long x = 0, y = 0;
    for(int i = 0; i < P.size(); i++){
        if(x == 0){
            if(P[i].second >= 4){
                x = P[i].first;
                y = P[i].first;
                break;
            }else{
                x = P[i].first;
            }
        }else{
            y = P[i].first;
            break;
        }
    }

    cout << x * y << endl;

    return 0;
}

Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector< vector<int> > v(100000);
	for (int i = 2; i < 100000; i++)
		if (v[i].size() == 0)
			for (int j = i; j < 100000; j += i)
				for (int k = j; k % i == 0; k /= i)
					v[j].push_back(i);
	for (;;) {
		int m, a, b; cin >> m >> a >> b;
		if (m == 0) break;
		for (; v[m].size() != 2 || a * v[m][1] > b * v[m][0]; m--);
		cout << v[m][0] << ' ' << v[m][1] << endl;
	}
}

Measured memory_bytes: 6812
if __name__ == "__main__":
    N, T = map(int,input().split(' '))
    c = []
    t = []
    for i in range(N):
        c1, t1 = [int(i) for i in input().split(' ')]
        c.append(c1)
        t.append(t1)

    min = "None"
    for i in range(N):
        if T >= t[i]:
            if min == "None":
                min = c[i]
            else:
                if min > c[i]:
                    min = c[i]
    if min == "None":
        print("TLE")
    else:
        print(min)

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

using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

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

string g[100];

int h,w;
int main(){
    while(cin>>h>>w && h){
        vector<string> v;
        rep(i,h)cin>>g[i];
        rep(i,h)rep(j,w){
            rep(d,4){
                string s;
                for(int ii=i, jj=j; s.size()==0 || ii!=i || jj!=j;
                    ii=(ii+h+dy[d])%h, jj=(jj+w+dx[d])%w){
                    s += g[ii][jj];
                    if(s.size()==1) continue;
                    v.push_back(s);
                    reverse(s.begin(),s.end());
                    v.push_back(s);
                    reverse(s.begin(),s.end());
                }
            }
        }

        sort(v.rbegin(),v.rend(),[](const string& s, const string& t){
                if(s.size()==t.size()) return s>t;
                return s.size()<t.size();
            });

        string ans="";
        rep(i,v.size()-1){
            if(v[i]==v[i+1]){
                ans=v[i];
                break;
            }
        }
        if(ans=="")ans="0";
        cout<<ans<<endl;
    }
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    if (!a[0]) {
        cout << 0 << '\n';
        return 0;
    }
    ll s = 1;
    const ll MX = 1e18;
    auto safe = [&] (ll x, ll y) {
        if (x > MX / y) return false;
        return true;
    };
    for (int i = 0; i < n; i++) {
        if (safe(s, a[i])) {
            s *= a[i];
        } else {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

unsigned long long nCr(long n, long r) {
    unsigned long long ans = 1;
    for (long i = 1 ; i < r + 1; ++i) {
        ans = ans * (n-i+1)/ i;
    }
    return ans;
}

int main() {
    

    ll n;
    cin >> n;
    vector <string> v;
    for (ll i=0;i<n;i++){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    ll now = 1;
    for (ll i=0;i<n;i++){
        if(i != 0){
            if(v[i-1] == v[i]){
                now++;
//                cout << "move" << endl;
            }else{
                ans += nCr(now,2);
                now = 1;
            }
        }
//        cout << now << endl;
    }
    ans += nCr(now,2);
    cout << ans << endl;

}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	string s, t;
	cin >> s >> t;

	ll ans = 0;
	rep(i, s.size()){
		if (s[i] != t[i]) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3888
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean isY = false;
		for(int i = 0; i < N; i++) {
			String S = sc.next();
			if(S.equals("Y")) isY = true;
		}
		System.out.println(isY ? "Four" : "Three");
	}
}


Measured memory_bytes: 21844