akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;

// Driver code 
int main() 
{ 
    ll n,W,V=100000;
    cin>>n>>W;
    ll val[n+1],w[n+1];
    vector<vector<ll>> dp(101,vector<ll>(100005,INT_MAX));
    loop(i,n) cin>>w[i+1]>>val[i+1];
    dp[0][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=V;j++)
        {
            if(j < val[i])
             dp[i][j]= dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j], w[i]+ dp[i-1][j-val[i]]);
        }
    }
    for(ll j=V;j>=0;j--)
    {
        if(dp[n][j] <= W)
          {  cout<<j<<"\n"; break; }
    }
    return 0; 
} 


Measured memory_bytes: 80256
import sys

n = int(input())
l = [input() for i in range(n)]
for i in range(n):
  if i > 0:
    if l[i-1][-1] != l[i][0]:
      print("No")
      sys.exit()
  if l.count(l[i]) > 1:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int ans=SZ(s);
    for(char c='a';c<='z';c++){
        string t=c+s+c;
        vint pos;
        REP(i,SZ(t)){
            if(t[i]==c) pos.push_back(i);
        }
        int Max=0;
        REP(i,SZ(pos)-1){
            Max=max(Max,pos[i+1]-pos[i]-1);
        }
        ans=min(ans,Max);
    }
    cout<<ans<<endl;
}


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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

void solve()
{
    int n,x,t;
    cin >>n>>x>>t;
    
    int temp =  n/x;
    if(n%x!=0)
        temp++;
    cout << t*temp ;
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
    {
        solve();
    }
    return 0;
}
/*
 Umang Agrawal
 @skylag
 */


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-

S = list(input())

sorted_list = sorted(list(set(S)))
abc_list = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for str1 in abc_list:
    if str1 not in sorted_list:
        print(str1)
        exit()
print("None")

Measured memory_bytes: 3956
H, W = map(int, input().split())
a_list = []
for i in range(H):
    a_list.append(input())

a2_list = []
for a in a_list:
    if a.count(".") == W:
        continue
    else:
        a2_list.append(a)
a3_list = []
for j in range(W):
    row = "".join([r[j] for r in a2_list])
    if row.count(".") == len(a2_list):
        continue
    else:
        a3_list.append(row)

for i in range(len(a3_list[0])):
    row = [r[i] for r in a3_list]
    print("".join(row))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    multiset<ll> x;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        auto it = x.lower_bound(a);
        if(it != x.begin()){
            x.erase(--it);
        }
        x.insert(a);
    }
    cout << x.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		int init_B=0;
		int last_A=0;
		int both_BA=0;
		int mid_AB=0;

		for (int i=0;i<N;i++) {
			s[i]=sc.next();
			int n=s[i].length();
			if (s[i].charAt(0)=='B') {
				init_B++;
			}
			if (s[i].charAt(n-1)=='A') {
				last_A++;
			}
			if (s[i].charAt(0)=='B' && s[i].charAt(n-1)=='A') {
				both_BA++;
			}

			for (int j=0;j<n-1;j++) {
				if (s[i].charAt(j)=='A' && s[i].charAt(j+1)=='B') {
					mid_AB++;
				}
			}
		}

		if (init_B==last_A && last_A==both_BA && both_BA>0) {
			init_B--;
		}
		System.out.println(Math.min(init_B,last_A)+mid_AB);
	}
}

Measured memory_bytes: 31872
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  int n;
  cin >> n;
  string s[n];
  rep(i,n)cin >> s[i];
  sort(s,s+n);
  int ans=1;
  rep(i,n-1){
    if(s[i]!=s[i+1])ans++;
  }
  cout << ans;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
const int N = 105 , K = 1e5+5; 
int a[N],n; 
int dp[K][2] ; 

int solve(int k , bool p ){
	if( k < 0 )return p ; 
	int& r = dp[k][p] ; 
	if( r != -1 )return r;
	bool canWin = 0 ;  
	for(int i = 0 ; i < n ; i++ ){
		if(solve(k-a[i],!p)==p){
			canWin = 1 ; 
		}
	}
	return r = (canWin?p:!p) ; 
}
int main(){
	int k ;
	cin >> n >> k; 
	memset(dp,-1,sizeof dp); 
	for(int i =0 ; i < n ;i++)cin >> a[i] ; 
	cout << (solve(k,0)==0?"First":"Second")<<endl; 
}

Measured memory_bytes: 10368
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

ans = 0
0.upto(a) do |aa|
  0.upto(b) do |bb|
    cc = (x - 500 * aa - 100 * bb) / 50
    ans += 1 if cc >= 0 && cc <= c
  end
end
p ans


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

vector<pii> primefactor(int n){
    vector<pii> ret;
    for(int i = 2; i*i <= n; i++)if(n % i == 0){
        int cnt = 0;
        while(n%i == 0)n /= i, cnt++;
        ret.push_back(pii(i,cnt));
    }
    if(n != 1)ret.push_back(pii(n,1));

    return ret;
}

signed main(void) {
    int n;
    cin >> n;
    vp v = primefactor(n);
    int ans = 0;
    rep(i,v.size()){
        int num = v[i].second;
        loop(i,1,num+1){
            ans++;
            num -= i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		String ans = "NO";
		int temp = a;
		int count = 1;
		while (true) {
			if ((temp * count) % b == c) {
				ans = "YES";
				break;
			}
			if (temp > a * b) {
				break;
			}
			temp = temp + a;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
int main( )
{
    int n, i, x, k, mx = -1;
    map<int, int> mp;
    vector<int> v;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> x;
        mp[x]++;
        if (mp[x] == 2)
        {
            v.push_back(x);
            mp[x] = 0;
        }
    }
    sort(v.begin(), v.end());
   int  sz=  v.size();
    if (sz < 2)
    {
        cout << "0\n";
    }
    else
    {
        cout << ( (ll) v[sz - 1] * v[sz - 2]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;
int p[105];
int flg[105];
signed main() {
	int x, n; cin >> x >> n;
	rep(i, n) {
		cin >> p[i]; flg[p[i]]++;
	}
	int ans = inf, s;
	rep(i, 103) {
		if (!flg[i]) {
			if (ans > abs(i - x)) {
				ans = abs(i - x); s = i;
			}
		}
	}
	cout << s << endl;
}

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


int f(string a, string b) {
	int dp[1009][1009];

	for (int i = 0; i <= a.size(); i++) {
		for (int j = 0; j <= b.size(); j++) {
			if (i == 0) dp[i][j] = j;
			else if (j == 0) dp[i][j] = i;
			else if (a[i - 1] == b[j - 1])
				dp[i][j] = dp[i - 1][j - 1];
			else
				dp[i][j] = min(dp[i - 1][j] + 1, min(dp[i][j - 1] + 1, dp[i - 1][j - 1] + 1));
		}
	}
	return dp[a.size()][b.size()];
}

int main() {
	string a, b;
	getline(cin, a);
	getline(cin, b);
	/*cout << "=======" << a << "=======" << endl;
	cout << "=======" << b << "=======" << endl;*/
	cout << f(a, b) << endl;
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	int ans=100000;
	for (int i=0; i<S.length()-2; i++){
	    int a=stoi(S.substr(i, 3));
	    int diff=abs(753-a);
	    ans=min(ans, diff);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
S = input()
def is_year(ss):
    return 0 <= int(ss) <= 99

def is_month(ss):
    return 1 <= int(ss) <= 12

pre = S[:2]
suf = S[2:]
try:
    is_yymm = is_year(pre) and is_month(suf)
    is_mmyy = is_year(suf) and is_month(pre)
    if is_yymm and is_mmyy:
        print('AMBIGUOUS')
    elif is_yymm and not is_mmyy:
        print('YYMM')
    elif not is_yymm and is_mmyy:
        print('MMYY')
    else:
        assert False
except:
    print('NA')


Measured memory_bytes: 3060
main(a,b,c){for(a=b=0,getchar();(c=getchar())!='0';)if(c-'\n')c=='A'?a++:b++;else{printf("%d %d\n",a>b?a+1:a,a<b?b+1:b),a=b=0;if(getchar()=='0')break;}exit(0);}

Measured memory_bytes: 524
package main

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

const mod int64 = 1000000007
const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextStringIntMap() map[string]int {
  var s = NextLine()
  var n int = len(s)
  m := map[string]int{}
  for i:=0;i<n;i++ {
    if v,ok := m[s[i:i+1]];ok {
      m[s[i:i+1]] = v + 1
    } else {
      m[s[i:i+1]] = 1
    }
  }
  return m
}

func main() {
  var ans int64
  _ = NextInt()
  s := NextStringIntMap()
  ans = 1
  for _,v := range s {
    ans *= int64(v+1)
    ans %= mod
  }
  fmt.Println(ans-1)
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) // 15桁まで表示
#define en '\n'
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui, ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
};
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
};
int floor(int a, int b) {
  return (a + b - 1) / b;
};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
const ll mod = 1000000007;
const double PI = acos(-1.0);
ll dp[101][100001];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  int n, W;
  cin >> n >> W;
  vi w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  rep(i, n) rep(j, W + 1) {
    if (j - w[i] < 0)
      dp[i + 1][j] = dp[i][j];
    else {
      dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
    }
  }
  cout << dp[n][W] << en;
}

Measured memory_bytes: 81688
N = int(input().strip())
A = [0] + list(map(int, input().strip().split(' '))) + [0]

full_cost = sum(abs(A[i+1]-A[i]) for i in range(len(A)-1))

for i in range(1,len(A)-1):
  print(full_cost - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))


Measured memory_bytes: 66140
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 200000;
const int MaxM = 200000;
const int MaxSegN = MaxN * 4;
const s64 INF = 0x3f3f3f3f3f3f3f3fll;

int n, m, x, y;
int a[MaxM + 1];

s64 pref[MaxN + 1];

struct seg_tree
{
	s64 seg[MaxSegN];

	inline void update(int p)
	{
		seg[p] = min(seg[p << 1 | 0], seg[p << 1 | 1]);
	}

	void build(int p, int pL, int pR)
	{
		if (pL == pR)
			seg[p] = INF;
		else
		{
			int pM = pL + pR >> 1;
			build(p << 1 | 0, pL, pM);
			build(p << 1 | 1, pM + 1, pR);
			update(p);
		}
	}

	void modify(int p, int pL, int pR, int q, s64 v)
	{
		if (pL == pR)
		{
			seg[p] = min(seg[p], v);
			return;
		}

		int pM = pL + pR >> 1;
		if (q <= pM)
			modify(p << 1 | 0, pL, pM, q, v);
		if (q > pM)
			modify(p << 1 | 1, pM + 1, pR, q, v);

		update(p);
	}

	s64 query(int p, int pL, int pR, int qL, int qR)
	{
		if (pL == qL && pR == qR)
			return seg[p];

		int pM = pL + pR >> 1;
		if (qR <= pM)
			return query(p << 1 | 0, pL, pM, qL, qR);
		else if (qL > pM)
			return query(p << 1 | 1, pM + 1, pR, qL, qR);
		else
		{
			s64 l = query(p << 1 | 0, pL, pM, qL, pM);
			s64 r = query(p << 1 | 1, pM + 1, pR, pM + 1, qR);
			return min(l, r);
		}
	}
};
seg_tree s1, s2;

s64 f[MaxM + 1];

int main()
{
	cin >> n >> m >> x >> y;
	for (int i = 1; i <= m; ++i)
		a[i] = getint();
	for (int i = 2; i <= m; ++i)
		pref[i] = pref[i - 1] + abs(a[i] - a[i - 1]);

	s1.build(1, 1, n);
	s2.build(1, 1, n);

	s64 res = INF;
	for (int i = 2; i <= m; ++i)
	{
		s64 p = abs(a[1] - x) + abs(a[i] - y);
		s64 q = abs(a[1] - y) + abs(a[i] - x);
		f[i] = min(p, q);
		f[i] = min(f[i], s1.query(1, 1, n, 1, a[i]) + a[i]);
		f[i] = min(f[i], s2.query(1, 1, n, a[i], n) - a[i]);
		f[i] += pref[i - 1];

		int v = a[i - 1];
		s64 w = f[i] - pref[i];
		s1.modify(1, 1, n, v, w - a[i - 1]);
		s2.modify(1, 1, n, v, w + a[i - 1]);

		res = min(res, f[i] + pref[m] - pref[i]);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int N;
int a[200010];
lng imos[200010];

int partF[200010];
int partB[200010];
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];

    imos[0] = a[0];
    FOR(i, 1, N-1) {
        imos[i]  = imos[i-1] + a[i];
    }

    partF[1] = 1;
    FOR(i, 2, N-3) {
        lng pa = imos[partF[i-1]-1];
        lng pb = imos[i] - pa;
        int it = partF[i-1];
        lng now = max(pa-pb, pb-pa);
        while(it < i) {
            pa += a[it];
            pb -= a[it];
            lng next = max(pa-pb, pb-pa);
            if(next > now) break;
            now = next;
            it++;
        }
        partF[i] = it;
    }
    partB[N-2] = N-2;
    FORD(i, N-3, 2) {
        lng pa = imos[N-1] - imos[partB[i+1]];
        lng pb = imos[partB[i+1]] - imos[i-1];
        int it = partB[i+1];
        lng now = max(pa-pb, pb-pa);
        while(it>i) {
            pa += a[it];
            pb -= a[it];
            lng next = max(pa-pb, pb-pa);
            if(next > now) break;
            now = next;
            it--;
        }
        partB[i] = it;
    }
    lng ans = 1LL<<60;
    //cerr << ans << endl;
    FOR(i, 2, N-2) {
        int frit = partF[i-1];
        lng f1 = imos[frit-1];
        lng f2 = imos[i-1]-f1;
        int bcit = partB[i];
        lng b1 = imos[N-1]-imos[bcit];
        lng b2 = imos[bcit]-imos[i-1];
        //cerr << f1 << " " << f2<<" "<<b1<<" "<<b2<<endl;
        lng minR = min(min(f1,f2),min(b1,b2));
        lng maxR = max(max(f1,f2),max(b1,b2));
        ans = min(ans, maxR-minR);
    }
    cout << ans << endl;
}


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

int main () {
  int H, W;
  cin >> H >> W;
  char moji;
  vector<char> ABC(0);
  for (moji = 'A'; moji <= 'Z'; moji++) {
    ABC.push_back(moji);
  }

  vector<vector<string>> data(H,vector<string>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == "snuke") {
        cout << ABC.at(j) << i + 1 << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
can = ["dream", "dreamer", "erase", "eraser"]
ss = input().rstrip('\n')

pos = len(ss)
while True:
    found = False
    for cc in can:
        lenz = len(cc)
        if (pos-lenz >= 0) and (ss[pos-lenz:pos] == cc):
            pos = pos - lenz
            found = True
            break
    if (not found) or (pos <= 0): break

if found:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
	void *data;
	struct node *next;
	struct node *prev;
};

struct point{
	int x;
	int y;
};


typedef struct node *NodePointer;

NodePointer nil;

void init(){
	nil = malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
}

void deleteNode(NodePointer t){
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t->data);
	free(t);
}

void backInsert(void *p,int len){
	NodePointer t;
	t = malloc(sizeof(struct node));
	t->data = malloc(len);
	memcpy(t->data,p,len);
	t->next = nil;
	t->prev = nil->prev;
	t->prev->next = t;
	nil->prev = t;
}

void deleteFirst(){
	NodePointer t = nil->next;
	if(t == nil){
		return;
	}
	deleteNode(t);
}

void deleteAll(){
	NodePointer t = nil->next;
	while(t != nil){
		deleteNode(t);
	}
}

void pop(void *np, int len){
	memcpy(np,nil->next->data, len);
	deleteFirst();
}

int main(int argc, char **argv)
{
	int *square;
	char temp[1024];
	int count = 0;
	int r = 0;
	int c = 0;
	int i = 0;
	int j = 0;
	struct point dif[4] = {{0,-1},{1,0},{0,1},{-1,0}}; //??????????

	scanf("%d%d",&r,&c);
	init();

	square = malloc(r * c * sizeof(int));
	
	for(i = 0;i < r;i++){
		scanf("%s",temp);
		for(j = 0;j < c;j++){
			if(temp[j] == '#'){
				struct point blackPoint = {0};
				square[i * c + j] = 0;
				blackPoint.x = j;
				blackPoint.y = i;
				backInsert(&blackPoint,sizeof(blackPoint));
			}
			else{
				square[i * c + j] = -1;
			}
		}
	}
	
	while(nil->next != nil){
		struct point currentPoint = {0};
		pop(&currentPoint, sizeof(currentPoint));

		for(i = 0;i < 4;i++){
			if((currentPoint.y + dif[i].y) * c + (currentPoint.x + dif[i].x) < 0 || r * c <= (currentPoint.y + dif[i].y) * c + (currentPoint.x + dif[i].x)){

			}
			else if(square[(currentPoint.y + dif[i].y) * c + (currentPoint.x + dif[i].x)] == -1){
				if((currentPoint.x + dif[i].x) == c || (currentPoint.x + dif[i].x) == -1){
					
				}
				else{
					struct point pointP = {0};
					pointP.x = currentPoint.x + dif[i].x;
					pointP.y = currentPoint.y + dif[i].y;
					backInsert(&pointP,sizeof(pointP));
					square[(currentPoint.y + dif[i].y) * c + (currentPoint.x + dif[i].x)] = square[(currentPoint.y * c) + currentPoint.x] + 1;
					count = square[(currentPoint.y + dif[i].y) * c + (currentPoint.x + dif[i].x)];
					// printf("%d\n",(((currentPoint.y + dif[i].y) * c)));
					// printf("%d\n",((currentPoint.x + dif[i].x)));
					// printf("\n");
				}
			}
			
		}
		
	}
	printf("%d\n",count);
	
	free(nil);
	free(square);
	return 0;
}

Measured memory_bytes: 66560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	while (N != 0) {
		int R = 1;
		int L = 0;
		int ans = 0;
		while (R < N) {
			int cur = (R - L + 1) * (R + L) / 2;
			if (N == cur) {
				ans++;
				R++;
			}
			else if (N < cur) {
				L++;
			}
			else {
				R++;
			}
		}
		cout << ans << endl;

		cin >> N;
	}
	return 0;
}



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



int main(){
    int Alp[30] = {0};
    string w;
    cin >> w;
    rep(i,w.size()){
        Alp[w[i]-'a']++;
    }
    rep(i,30){
        if(Alp[i]%2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

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

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for (int i = l; i <= r; i++) if (i % d == 0) ans += 1;
    print(ans);

    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


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

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

    vector<int> a(N); 
    vector<int> b(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
        b.at(i) = a.at(i);
    }
    int count = 0;
    sort(b.begin(), b.end());
    for (int i = 0; i < N; i++){
        if (b.at(i) != a.at(i)){
            count++;
        }
    }
    if (count == 0 || count == 2){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Map as MP
import Data.List
import Data.Tuple
import Data.Char
import Data.IORef
import Control.Monad

toTuple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
    in
        (a, b)

make es = VU.foldl' step MP.empty (VU.map swap es VU.++ es)
    where
        step m (f,t) =
            case MP.lookup f m of
                Just _ -> MP.adjust (t:) f m
                Nothing -> MP.insert f [t] m

del graph (f,t) =
    let
        graph' = MP.adjust (delete f) t graph
        graph'' = MP.adjust (delete t) f graph' 
    in
        graph''

dfs graph table v = do
    r <- VUM.read table (v-1)
    if r 
        then return 0
        else do
            VUM.write table (v-1) True
            table' <- VU.unsafeFreeze table
            let Just ns = MP.lookup v graph
            let ns' = delete v ns
            if (VU.and table')
                then return 1
                else if (Data.List.null ns')
                    then return 0
                    else do
                        res <- mapM (dfs graph table) ns'
                        return $ Data.List.sum res
                    
main = do
    (n,m) <- toTuple <$> B.getLine
    es <- VU.replicateM m (toTuple <$> B.getLine) 
    let graph = make es
    res <- newIORef (0 :: Int)
    forM_ [0..m-1] $ \i -> do
        tbl <- VUM.replicate n False
        let d = del graph (es VU.! i)
        solve <- dfs d tbl 1
        when (solve == 0) $ modifyIORef' res (+1)
    
    readIORef res >>= print

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

void solve(string, string);
int main(){
  int q; cin >> q;

  for(int i=0; i<q; i++){
    string s, t;  cin >> s >> t;
    solve(s, t);
  }

  return 0;
}

void solve(string s, string t){
  int m=s.length(), n=t.length();
  s = " " + s; t = " " + t;

  int dp[m+1][n+1];
  for(int i=0; i<=m; i++) dp[i][0]=0;
  for(int i=0; i<=n; i++) dp[0][i]=0;

  for(int i=1; i<=m; i++){
    for(int j=1; j<=n; j++){
      if(s[i]==t[j]){
        dp[i][j] = dp[i-1][j-1]+1;
      }
      else{
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  cout << dp[m][n] << endl;
}



Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  string acgt = "ACGT";
  
  int max = 0;
  int count = 0;
  
  for(int i = 0; i < s.length(); ++i){
    int j;
    bool hit = false;
    for(j = 0; j < acgt.length(); ++j){
      if(s[i] == acgt[j]){
        ++count;
        hit = true;
      }
    }
    if(!hit){
      if(count > max){
        max = count;
      }
      count = 0;
    }
  }
  
  if(count > max) max = count;
  
  cout << max << endl;
}

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

using namespace std;

int main(){
  string s;

  while(  cin >> s){
  string joi = "JOI",ioi = "IOI";
  int num_joi=0,num_ioi=0;

  for(int i=0;i < s.size()-2 ;i++) {
    string sub= s.substr(i,3) ;
    if(sub == joi) num_joi++;
    if(sub == ioi) num_ioi++;
  }

  cout << num_joi <<"\n" << num_ioi << "\n";
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  map<string,int> mp,mp2;
  string acgt[4]={"A","C","G","T"};
  mp[""]=1;
  rep(i,n){
    for(auto itr=mp.begin();itr!=mp.end();itr++){
      string s=itr->F;
      rep(k,4){
	string news=s+acgt[k];
	if(news[0]=='A' && news[1]=='G' && news[3]=='C') continue;
	if(news[0]=='A' && news[2]=='G' && news[3]=='C') continue;
	if(news[1]=='A' && news[2]=='G' && news[3]=='C') continue;
	if(news[1]=='G' && news[2]=='A' && news[3]=='C') continue;
	if(news[1]=='A' && news[2]=='C' && news[3]=='G') continue;
	//	cout<<news<<endl;
	if(news.size()==4){
	  news=news.substr(1,3);
	}
	//	cout<<news<<endl;
	if(news!="GAC" && news!="ACG" && news!="AGC"){
	  mp2[news]+=mp[s];
	  mp2[news]%=MOD;
	}
      }
    }
    mp.clear();
    mp=mp2;
    mp2.clear();
  }
  int ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans+=itr->S;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace ABC136
{
    class D
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            List<int> indexes = new List<int>();
            int[] ans = new int[S.Length];
            for (int i = 0; i < S.Length-1; i++)
            {
                if (S[i] == 'R'&& S[i + 1]=='L') { indexes.Add(i); }
            }
            int k = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i <= indexes[k]&&S[i]=='R') { ans[indexes[k] + ((indexes[k] - i) % 2)]++; }
                else if(S[i] == 'L') { ans[indexes[k] + ((i - indexes[k]) % 2)]++;}
                else if(i > indexes[k] && S[i] == 'R') { k++;i--; }
            }
            for (int i = 0; i < S.Length-1; i++)
            {
                Console.Write(ans[i] + " ");
            }
            Console.WriteLine(ans[S.Length - 1]);
        }
    }
}


Measured memory_bytes: 16224
#include<iostream>
using namespace std;
int main(){
	int n, m, a[100], cnt = 0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	if(cnt%(4*m)!=0) cnt = (cnt/(4*m)) + 1;
	else cnt/=(4*m);
	for(int i=0;i<n;i++){
		if(a[i]>=cnt){
			m--;
		}
	}
	if(m>0) cout<<"No"<<endl; 
	else cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
n = gets.to_i
s = gets

pattern = [{"SS"=>'S', "SW"=>'W', "WS"=>'W', "WW"=>'S'}, {"SS"=>'W', "SW"=>'S', "WS"=>'S', "WW"=>'W'}]
pt = (s[0] == 'o') ? 0 : 1

keys = ["SS", "SW", "WS", "WW"]
ok = false
4.times do |i|
  ans = keys[i].dup

  1.upto(n - 1) do |j|
    if s[j] == 'o'
      ans << pattern[0][ans[-2]+ans[-1]]
    else
      ans << pattern[1][ans[-2]+ans[-1]]
    end
  end

  if pattern[pt][keys[i]] == ans[n - 1] && ans[n] == ans[0]
    ok = true
    puts ans[0..(n - 1)]
    break
  end
end

puts (-1) unless ok

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

int n;
char s[100],s2[100];

int main()
{
    int i,ocr=0,poz=0;
    cin.get(s,15);
    if(s[0]!='A')
    {
        cout<<"WA";
        return 0;
    }
    n=strlen(s);
    for(i=2;i<n-1;i++)
        if(s[i]=='C')
            {
                ocr++;
                poz=i;
            }
    if(ocr>1 or ocr==0)
    {
        cout<<"WA";
        return 0;
    }
    s[0]='a';
    s[poz]='c';
    for(i=0;i<n;i++)
        s2[i]=tolower(s[i]);
    if(strcmp(s,s2)!=0)
    {
        cout<<"WA";
        return 0;
    }
    cout<<"AC";
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		int gram[] = new int[5001];
		Arrays.fill(gram, Integer.MAX_VALUE);
		int cnt = 0;
		for (int i = 0; i <= 25; i++) {
			for (int j = 0; j <= 48; j++) {
				for (int k = 0; k <= 10; k++) {
					int sum = i * 200 + j * 300 + k * 500;
					if (sum <= 5000) {
						double add = 0;
						int base = i / 5;
						int mod = i % 5;
						add = (380 * base * 5 * 0.8) + 380 * mod;

						base = j / 4;
						mod = j % 4;
						add += (550 * base * 4 * 0.85) + 550 * mod;
						base = k / 3;
						mod = k % 3;
						add += (850 * base * 3 * 0.88) + 850 * mod;
						gram[sum] = (int) Math.min(gram[sum], add);
					}
				}
			}
		}
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			System.out.println(gram[n]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

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

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17152
def lexicographical_order(a, b):
    if a > b:
        return 0
    elif a < b:
        return 1
    else:
        return 2

if __name__ == "__main__":
    n = int(input())
    taro_point, hanako_point = 0, 0
    for _ in range(n):
        taro_hand, hanako_hand = input().split()
        res = lexicographical_order(taro_hand, hanako_hand)

        if res == 0: 
            taro_point += 3
        elif res == 1:
            hanako_point += 3
        elif res == 2:
            taro_point += 1
            hanako_point += 1

    print(taro_point, hanako_point)


Measured memory_bytes: 5600
//
//  main.cpp
//  ABC163_B
//
//  Created by Kosei on R 2/04/19.
//  Copyright © Reiwa 2 Kosei. All rights reserved.
//

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
typedef long long ll;
signed main() {
    int n, m;
    int ans = 0;
    int a[10000] = {0};
    cin >> n >> m;
    rep(i, m) {
        cin >> a[i];
        ans += a[i];
    }
    if (ans <= n) {
        cout << n - ans << endl;
    } else {
        cout << -1 << endl;

    }
    r0
}


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

const int INF = 1e+8;
const int MAX_D = 201;
const int MAX_N = 201;

int D, N, T[MAX_D], A[MAX_N], B[MAX_N], C[MAX_N];

int main(){
	// 入力
	cin >> D >> N;
	for(int i=0 ; i < D ; i++ ) cin >> T[i];
	for(int i=0 ; i < N ; i++ ) cin >> A[i] >> B[i] >> C[i];
	
	// dp[d][k] := d日目で前の日に服kを着た時の派手さの差の絶対値の合計
	int dp[MAX_D][MAX_N];
	for(int d=0 ; d < D ; d++ ) fill(dp[d], dp[d] + MAX_N, -1);
	for(int i=0 ; i < N ; i++ ){
		if( A[i] <= T[0] && T[0] <= B[i] ){
			dp[0][i] = 0;
		}
	}
	
	for(int d=0 ; d < D-1 ; d++ ){
		for(int i=0 ; i < N ; i++ ){
			if( dp[d][i] == -1 ) continue;
			
			for(int j=0 ; j < N ; j++ ){
				if( A[j] <= T[d+1] && T[d+1] <= B[j] ){
					dp[d+1][j] = max(dp[d+1][j], dp[d][i] + abs(C[i] - C[j]));
				}
			}
		}
	}
	int ans = 0;
	for(int i=0 ; i < N ; i++ ){
		ans = max(ans, dp[D-1][i]);
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int n;
VI ss;

int main(void) {
	while (1) {
		ss.clear();
		cin >> n;
		if (n == 0) break;
		rep (i, n) {
			int s;
			cin >> s;
			ss.PB(s);
		}
		sort(ALL(ss));
		int sum = 0;
		REP (i, 1, ss.size() - 1) {
			sum += ss[i];
		}
		cout << sum / (n - 2) << endl;
	}
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>

int hyo[102][102];

int main(){

	int r, c;
	std::cin >> r >> c;

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			std::cin >> hyo[i][j];
		}
	}

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++)hyo[i][c] += hyo[i][j];
	}
	for (int i = 0; i <= c; i++){
		for (int j = 0; j < r; j++)hyo[r][i] += hyo[j][i];
	}

	for (int i = 0; i <= r; i++){
		for (int j = 0; j <= c; j++){
			if (j == c)std::cout << hyo[i][j] << std::endl;
			else std::cout << hyo[i][j] << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  cout << b * c / 2 << endl;
}

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

bool good(string s){
	string t(s.rbegin(),s.rend());
	return t == s;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	int n = s.size();
	if (good(s.substr(0,n/2)) && good(s.substr(n/2+1,n)) && good(s)){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
ll gcd(ll a2,ll b2){
	int t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}
int main() {

	int k;
	cin>>k;

	ll t=0;
	for(int i=1; i<k+1; i++){
		for(int j=1; j<k+1; j++){
			for(int l=1; l<k+1; l++){
				int s=gcd(i,j);
				t+=gcd(s,l);
			}
		}
	}
	cout<<t<<endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

int main() {
  cin.sync_with_stdio(false);

  /* ifstream cin("d.in"); */

  int t;
  cin >> t;
  for (; t; t--) {
    ll a, b;
    cin >> a >> b;
    ll target = a * b - 1;

    ll sqr_a;
    for (sqr_a = 1; sqr_a * sqr_a <= a; sqr_a++);
    sqr_a--;

    ll sqr_b;
    for (sqr_b = 1; sqr_b * sqr_b <= b; sqr_b++);
    sqr_b--;

    ll sqr = sqr_a * sqr_b;
    while ((sqr + 1) * (sqr + 1) <= target) {
      sqr++;
    }
    while (sqr * sqr > target) {
      sqr--;
    }

    ll ans = 2 * sqr;

    if (sqr == 0) {
      cout << 0 << '\n';
      continue;
    }

    ll other_sqr = target / sqr;
    if (other_sqr == sqr) {
      ans--;
    }

    ll other_a = target / a;
    if (other_a && (target / other_a) == a) {
      ans--;
    }

    ll other_b = target / b;
    if (other_b && (target / other_b) == b) {
      ans--;
    }

    cout << ans << '\n';
  }

  return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int f(int a, int b) {
  if (a > b) {
    int tmp = b;
    b = a;
    a = tmp;
  }
  if (b % a == 0) return 2 * (b / a) * a - a;
  return 2 * (b / a) * a + f(a, b % a);
}

signed main() {
  int N, X;
  cin >> N >> X;
  cout << N + f(N - X, X) << endl;
  return 0;
}


Measured memory_bytes: 256