akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<vector<P>>an(n);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a--){
            int x,y;cin>>x>>y;
            an[i].pb(mp(x,y));
        }
    }
    int maxm=-1;
    for(int bit=0;bit<(1<<n);bit++){
        bool abc=true;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                for(int j=0;j<siz(an[i]);j++)
                    if(((bit>>(an[i][j].fi-1))&1)!=an[i][j].se)//
                        abc=false;
            }
        }
        if(abc==true)
            chmax(maxm,counter(bit));
    }
    cout<<maxm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

using namespace std;

int main(){
  int N;
  int tmp;
  cin >> N;
  std::vector<int> X;
  for(int i=1;i<=N;i++){
    cin >> tmp;
    X.push_back(tmp);
  }
  std::vector<int> Y(X);
  std::sort(Y.begin(),Y.end());

  for(int i=1;i<=N;i++){
    if(X[i-1]<=Y[N/2-1]){
      cout << Y[N/2] <<endl;
    }else if(X[i-1] > Y[N/2-1]){
      cout << Y[N/2-1] <<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3828
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
#pragma endregion
#pragma endregion


int main() {
	lint n, m; cin >> n >> m;
	lint ans = 1;
	if (n == 1) {
		printf("%d\n", m);
		return 0;
	}
	for (int i = 1; i < m / n + 2; i++) {
		if (m % i == 0 && m / i >= n) {
			ans = i;
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int main(){
    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            ans++;
        }
    }
    cout<<ans<<endl;
    return(0);
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = [-1] + getList()
lista = [0 for i in range(N + 1)]

# 逆順に実施する
# 1からループ回さないと34行目でバグる
for i in range(1, N + 1)[::-1]:
    cnt = 0
    # 2 * i, 3 * i...について
    for j in range(2 * i, N + 1, i):
        cnt += lista[j]
    # もしcnt % 2とa[i]が合わなければb[i]にボールを置いて修正
    if cnt % 2 != A[i]:
        lista[i] = 1
ans = []
for i in range(N + 1):
    if lista[i] == 1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))

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

using namespace std;
long long mi[200005],ma[200005];
int main()
{
    long long n;
    cin>>n;
    for(long long i=0; i<n; i++){
        cin>>mi[i]>>ma[i];
    }
    sort(mi,mi+n);
    sort(ma,ma+n);
    if(n%2==0){
        long long l1=mi[n/2-1],r1=ma[n/2-1],l2=mi[n/2],r2=ma[n/2];
        cout<<l2-l1+r2-r1+(r1-l2)*2+1;
    }else{
        cout<<ma[n/2]-mi[n/2]+1;
    }
    return 0;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b;
      cin >> a >> b;
      
      if((a%2 == 1)&&(b%2 ==1 )){
        cout << "Odd" << endl;
      }
      
      else{
        cout << "Even" << endl;
      }
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int count = 0;
	for (int i = stoi(a); i <= stoi(b); i++) {
		string s = to_string(i);
		if (s[0] != s[4]) continue;
		if (s[1] != s[3]) continue;
		count++;
	}
	cout << count << endl;
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N2 = N/2;
		if(N%2 == 1) N2++;
		
		int[] B = new int[N2];
		for(int i=0;i<N;i++){
			int l = N - A[i] - 1;
			if(l%2 != 0) {
				Console.WriteLine(0);
				return;
			}
			B[l/2]++;
		}
		
		long mod = (long)1e9+7;
		long ret = 1;
		for(int i=0;i<N2;i++){
			if(i < N2 -1 && B[i] != 2){
				Console.WriteLine(0);
				return;
			}else if( N%2 == 0 && B[N2-1] !=2){
				Console.WriteLine(0);
				return;
			}else if( N%2 == 1 && B[N2-1] !=1){
				Console.WriteLine(0);
				return;
			}
			ret *= (long) B[i];
			if(ret >= mod) ret %= mod;
		}
		
		Console.WriteLine(ret);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

int main()
{
   long long k,n;
   cin>>k>>n;
   long long a[n],i,j;

   for(i=0;i<n;i++)
    cin>>a[i];


  long long count=0;

  count = a[n-1] - a[0];
     for(i=n-1;i>0;i--)
     {
        a[i] = a[i] - k;
        count = min(count , a[i-1]-a[i]);

     }




   cout<<count;
   
}
//ā 

/*100
82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91
*/

Measured memory_bytes: 1792
#!/usr/bin/env python
import numpy as np
N = int(input())
a = np.array([int(input()) for i in range(N)])
mod =998244353
sum_a = np.sum(a)
dp =  np.zeros((N+1,sum_a+1))
half_dp = np.zeros((N+1,sum_a//2+1))
dp[0][0], half_dp[0][0] = 1, 1

for i in range(1,N+1):
    dp[i,:] += dp[i-1,:]*2 % mod
    dp[i,a[i-1]:] +=  dp[i-1, :-a[i-1]] % mod
    half_dp[i,:] +=  half_dp[i-1,:] % mod
    half_dp[i,a[i-1]:] += half_dp[i-1,:-a[i-1]] % mod

all_combination = 3**N % mod
half_sum_a = (sum_a //2) if sum_a % 2 == 0 else (sum_a//2)+1 
p = np.sum(dp[N][half_sum_a:])
c = half_dp[N][half_sum_a] if sum_a % 2==0 else 0
print(int(all_combination - 3 * p + 3 * c) % mod)


Measured memory_bytes: 329380
r, c = list(map(int, input().split()))
answer = []

for i in range(r):
    val = list(map(int, input().split()))
    val.append(sum(val))
    answer.append(val)

sumLine = [0] * (c + 1)
for i in range(len(answer)):
    for j in range(c + 1):
        sumLine[j] += answer[i][j]

answer.append(sumLine)

[print(*answer[i]) for i in range(len(answer))]


Measured memory_bytes: 6232
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

ll n;
ll ans = 0;

void dfs(ll x, int a, int b, int c) {
	if (x > n)return;
	if (a && b && c)ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	int n;
	cin >> n;
	vector<string>s(n);
	map<string, int>blue;
	rep(i, n) {
		cin >> s[i];
		blue[s[i]]++;
	}
	int m;
	cin >> m;
	int ans = 0;
	vector<string>t(m);
	rep(i, m) {
		cin >> t[i];
		blue[t[i]]--;
	}
	rep(i, n) {
		ans = max(ans, blue[s[i]]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
color=[0]*9
ac=0
for i in range(N):
    rate=min(a[i]//400,8)
    color[rate]+=1
for i in range(8):
    if color[i]>=1:
        ac+=1
min_ans=max(ac,1)
max_ans=ac+color[8]
print(min_ans,max_ans)

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N;
    scanf("%lld", &N);
    vector<ll> A(N+1),B(N);
    REP(ll, i, 0, N+1) scanf("%lld", &A.at(i));
    REP(ll, i, 0, N) scanf("%lld", &B.at(i));

    ll ans = 0;
    ll power;

    if ( A.at(0) < B.at(0) ){
        ans += A.at(0);
        power = B.at(0) - A.at(0);
    }
    else{
        ans += B.at(0);
        power = 0;
    }
    REP( ll, i, 1, N ){
        if ( A.at(i) < B.at(i) + power  ){
            ans += A.at(i);
            if ( B.at(i) > B.at(i) + power - A.at(i) )
                power = B.at(i) + power - A.at(i);
            else power = B.at(i);
        }
        else{
            ans += B.at(i) + power;
            power = 0;
        }
    }
    if ( A.at(N) < power ){
        ans += A.at(N);
    }
    else{
        ans += power;
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n) {
		cin >> b[i];
	}
	ll res = 0;
	queue<int> q;
	Rep(i, n) {
		if (i == 0) {
			if (b[i] > b[i + 1] + b[n - 1]) {
				q.push(i);
			}
		} else if (i == n - 1) {
			if (b[i] > b[0] + b[i - 1]) {
				q.push(i);
			}
		} else {
			if (b[i] > b[i + 1] + b[i - 1]) {
				q.push(i);
			}
		}
	}
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		if (i == 0) {
			if (b[i] > b[i + 1] + b[n - 1]) {
				ll temp = b[i + 1] + b[n - 1];
				ll t = (b[i] - a[i]) / temp;
				if (t > 0) {
					res += t;
					b[i] -= t * temp;
					q.push(n - 1);
					q.push(i + 1);
				}
				
			}
		} else if (i == n - 1) {
			if (b[i] > b[0] + b[i - 1]) {
				ll temp = b[0] + b[i - 1];
				ll t = (b[i] - a[i]) / temp;
				if (t > 0) {
					res += t;
					b[i] -= t * temp;
					q.push(i - 1);
					q.push(0);
				}
				
			}
		} else {
			if (b[i] > b[i + 1] + b[i - 1]) {
				ll temp = b[i + 1] + b[i - 1];
				ll t = (b[i] - a[i]) / temp;
				if (t > 0) {
					res += t;
					b[i] -= t * temp;
					q.push(i - 1);
					q.push(i + 1);
				}
			}
		}
	}
	bool flag = true;
	REP(i, n) {
		if (a[i] != b[i]) {
			flag = false;
		}
	}
	if (flag) {
		put(res);
	} else {
		put(-1);
	}
	
	return 0;
}


Measured memory_bytes: 4224
/*
 © 2020-08-29 06:57:42 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const int N = 1e6 + 5;
lli gcd(lli a, lli b){
  return b ? gcd(b, a % b) : a;
}
lli p[N];
lli mp[N];
bool pairw = true;
void fac(lli x){
  set<lli> foo;
  while(x > 1){
    if(!foo.count(p[x])){
      mp[p[x]]++;
      if(mp[p[x]] > 1) pairw = false;
      foo.insert(p[x]);
    }
    x /= p[x];
  }
}
int main(){ _
  iota(all(p), 0);
  for(lli i = 2; i * i <= N; i++) if(p[i] == i) for(lli j = i * i; j < N; j += i) if(p[j] == j) p[j] = i;
  // fore(i, 0, N) if(!p[i]) primes.pb(i);
  // fore(i, 0, 20) cout << primes[i] << ' '; cout << ENDL;
  lli n; cin >> n;
  vector<lli> v(n);
  set<lli> st;
  lli x = 0;
  fore(i, 0, n){
    cin >> v[i];
    if(x) x = gcd(x, v[i]);
    else x = v[i];
    fac(v[i]);
  }
  if(pairw) cout << "pairwise coprime" << ENDL;
  else if(x == 1) cout << "setwise coprime" << ENDL;
  else cout << "not coprime" << ENDL;
  return 0;
}


Measured memory_bytes: 26760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			String map[][] = new String[H][W];

			String S;
			for (int i = 0; i < H; i++) {
				S = sc.next();
				for (int j = 0; j < W; j++) {
					map[i][j] = ".";
					if (S.charAt(j) == '#') {
						map[i][j] = "#";
					}
				}
			}

			int count;
			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < H; i++) {
				sb.setLength(0);
				for (int j = 0; j < W; j++) {
					if (map[i][j].equals(".")) {
						count = 0;
						if (i - 1 >= 0 && j - 1 >= 0 && map[i - 1][j - 1].equals("#")) {
							count++;
						}
						if (i - 1 >= 0 && map[i - 1][j].equals("#")) {
							count++;
						}
						if (i - 1 >= 0 && j + 1 < W && map[i - 1][j + 1].equals("#")) {
							count++;
						}
						if (j - 1 >= 0 && map[i][j - 1].equals("#")) {
							count++;
						}
						if (j + 1 < W && map[i][j + 1].equals("#")) {
							count++;
						}
						if (i + 1 < H && j - 1 >= 0 && map[i + 1][j - 1].equals("#")) {
							count++;
						}
						if (i + 1 < H && map[i + 1][j].equals("#")) {
							count++;
						}
						if (i + 1 < H && j + 1 < W && map[i + 1][j + 1].equals("#")) {
							count++;
						}
						sb.append(count);
					}else{
						sb.append("#");
					}
				}
				System.out.println(sb);
			}
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const unsigned long long BASE=233,INV=7204522363551799129;
const int MAXN=250100;
map<unsigned long long,int> Map;
char s[MAXN];
int n;
unsigned long long f[MAXN],X=1,Y,ans;
signed main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='+') f[i]=f[i-1]+X;
		if(s[i]=='-') f[i]=f[i-1]-X;
		if(s[i]=='<') f[i]=f[i-1],X=X*BASE;
		if(s[i]=='>') f[i]=f[i-1],X=X*INV;
		Map[f[i]]++;
	}
	X=1;
	for(int i=1;i<=n;i++)
	{
		ans=ans+Map[f[n]*X+Y];
		if(s[i]=='+') Y=Y+X;
		if(s[i]=='-') Y=Y-X;
		if(s[i]=='<') X=X*BASE;
		if(s[i]=='>') X=X*INV;
		Map[f[i]]--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 33664
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  string a, b;
  cin >> a >> b;
  int sita = 0;
  sita += b[b.size()-1] - '0';
  sita += (b[b.size()-2] - '0') * 10;
  int ue = stoi(b);

  ll res = 0;
  res += stoll(a) * sita / 100;
  res += stoll(a) * ue;

  cout << res << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a ;
}

int main(){
    int n, m, i;
    double total=0;
    scanf("%d %d",&n,&m);
    int a[n];
    for(i=0;i<n;i++){ scanf("%d",&a[i]); total += a[i]; }
    qsort(a,n,sizeof(int),compare_int);
    //printf("%d %d\n",total,a[m-1]);
    if(a[m-1]<total/(4.0*m)){ printf("No"); }
    else{ printf("Yes"); }
    return 0;
}

Measured memory_bytes: 128
def make_it?(ary,val)
  if ary.empty?
    return val==0
  end
  dp={}
  dp[0]=true
  ary.each{|v|
    _dp={}
    dp.each_key{|k|
      _dp[k+v]=true
      _dp[k-v]=true
    }
    dp=_dp
  }
  dp[val]
end

s=gets.chomp
s+=?T
x,y=gets.split.map(&:to_i)
x_ary=[]
y_ary=[]

d=0
x_dir=true
initial_forward=true
s.each_char{|c|
  if initial_forward
    if c==?F
      d+=1
      next
    else
      initial_forward=false
      x-=d
      d=0
    end
  end

  if c==?T
    if d>0
      ary=x_dir ? x_ary : y_ary
      ary << d
    end
    x_dir=!x_dir
    d=0
  else
    d+=1
  end
}

achievable=[[x_ary,x],[y_ary,y]].all?{|ary,val|
  make_it?(ary,val)
}
puts achievable ? "Yes" : "No"

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

string convert(string L, string R) {
    reverse(ALL(L));
    int n = min(L.size(), R.size());
    for_(i,0,n) if (L[i] != R[i]) return "#";
    reverse(ALL(L));
    if (L.size() < R.size()) return R.substr(L.size());
    return L.substr(0, L.size() - R.size());
}

int N;
string S[55];
lint C[55];

int main() {
    cin >> N;
    for_(i,0,N) cin >> S[i] >> C[i];

    struct State {
        int p;
        string T;
        lint cost;

        bool operator < (const State& o) const { return cost > o.cost; }
    };

    map<string, lint> memo[2];
    priority_queue<State> que;

    for_(i,0,N) {
        int m = S[i].size();
        string L = "";
        // cerr << "# " << S[i] << endl;
        for_(j,0,m) {
            string R = S[i].substr(j);
            string T = convert(L, R);
            if (T != "#") {
                int p = (L.size() < R.size() ? 1 : 0);
                que.push(State{p, T, C[i]});
                memo[p][T] = C[i];
                // cerr << L << " " << R << endl;
            }

            R = S[i].substr(j + 1);
            T = convert(L, R);
            if (T != "#") {
                int p = (L.size() < R.size() ? 1 : 0);
                que.push(State{p, T, C[i]});
                memo[p][T] = C[i];
                // cerr << L << " " << R << endl;
            }

            L += S[i][j];
        }
    //     cerr << "_____" << endl;
    }

    while (!que.empty()) {
        State s = que.top(); que.pop();

        if (s.T == "") {
            cout << s.cost << endl;
            return 0;
        }

        for_(i,0,N) {
            string L = (s.p == 0 ? s.T : S[i]);
            string R = (s.p == 1 ? s.T : S[i]);

            int p = (L.size() < R.size() ? 1 : 0);
            string T = convert(L, R);
            if (memo[p].count(T) == 0) memo[p][T] = 1LL << 60;
            if (memo[p][T] > s.cost + C[i]) {
                memo[p][T] = s.cost + C[i];
                que.push(State{p, T, s.cost + C[i]});
            }
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3684
#include<iostream>
#include<vector>
#include <cmath>
#include <map>

using namespace std;


int main() {
	int n;
	cin >> n;
	int a = int(n / 500);
	int tot = a * 1000;
	n -= a * 500;
	tot += int(n / 5) * 5;
	
	cout << tot << endl;

	return 0;
}

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

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    map<long long, int> freq;
    map<long long, int>::iterator it;
    for (int i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        it = freq.find(a);
        if (it != freq.end())
        {
            it->second += 1;
        }
        else
        {
            freq.insert(pair<long long, int>(a, 1));
        }
    }
    long long ans = 0;
    long long max = 0;

    for (auto x : freq)
    {
        if (4 <= x.second)
        {
            ans = x.first * x.first;
            max = x.first;
        }
        else if (2 <= x.second)
        {
            ans = max * x.first;
            max = x.first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>

int main(void)
{ 
	int a[3];
	int i,j,m;
	for(i=0;i<3;i++) scanf("%d",&a[i]);
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				m=a[i];
				a[i]=a[j];
				a[j]=m;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return 0;
}


Measured memory_bytes: 2668
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e6 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

ll dp[1005][1005],n,m;
//ll fun(int i,int j) {
//    if(i>=n||j>=m)return 0;
//    if(s[i][j]=='#')return 0;
//    if(i==n-1&&j==m-1)return 1ll;
//    if(dp[i][j]!=0)return dp[i][j];
//    ll r1=0ll,r2=0ll;
//    if(i+1<n) {
//        r1=fun(i+1,j);
//    }
//    if(j+1<m) {
//        r2=fun(i,j+1);
//    }
//    return dp[i][j]=(r1+r2)%M;
//}
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {

        cin>>n>>m;
        for(int i=0; i<n; ++i) {
            cin>>s[i];
        }
        dp[0][0]=1;
        for(int i=0; i<n; ++i) {
            for(int j=0; j<m; ++j) {
                if(s[i][j]=='#')continue;
                if(i+1<n) {
                    if(s[i+1][j]=='.')
                        dp[i+1][j]=(dp[i+1][j]+dp[i][j])%M;
                }
                if(j+1<m) {
                    if(s[i][j+1]=='.')
                        dp[i][j+1]=(dp[i][j+1]+dp[i][j])%M;
                }
            }
        }
        cout<<dp[n-1][m-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 13216
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  int k;
  cin >> k;
  
  int n = max({a,b,c});
  
  for(int i=0;i<k;i++){
    n = n * 2;
  }
  
  cout << a + b + c - max({a,b,c}) + n;
  
  return 0;
}


  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t gcd(int64_t a, int64_t b) {
    if (a < b) {
        return gcd(b, a);
    }

    if (b == 0) {
        return a;
    }

    return gcd(b, a % b);
}

main() {
    int64_t a, b;
    cin >> a >> b;

    auto g = gcd(a, b);

    int64_t ans = 1;
    for (int64_t p = 2; p * p <= g; ++p) {
        if (g % p == 0) {
            ++ans;
        }

        while (g % p == 0) {
            g /= p;
        }
    }

    if (g > 1) {
        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
#define ll long long
//#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS() 
#else
#define bug(...)
#define IOS() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const int maxn=500005;

signed main (){
  IOS();
  int N; cin>>N;
  int ans=iinf;
  REP1(i,N-1){
    string x=to_string(N-i), y=to_string(i);
    int cnt=0;
    REP(j,SZ(x)){
      cnt+=x[j]-'0';
    }
    REP(j,SZ(y)){
      cnt+=y[j]-'0';
    }
    ans=min(ans, cnt);
  }
  cout<<ans<<endl;
}/*
3 3 1
0 0 1
1 1 1
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	char str[100];
	int times[26];
	int result=0;
	for(int i=0;i<26;i++){
		times[i]=0;
	}
	scanf("%s",str);
	for(int i=0;i<strlen(str);i++){
		times[str[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		result+=times[i]%2==0?0:1;
	}
	printf(result>0?"No":"Yes");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vvll G(1000000, vll(0));
  vll v(1000000, 0);
  vll inn(1000000, 0);
  ll before = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N-1; j++){
      ll A;
      cin >> A; A--;
      ll B = i;
      if(A > B) swap(A, B);
      ll now = A * 1000 + B;
      if(j != 0){
        G.at(before).push_back(now);
        inn.at(now)++;
      }
      before = now;
    }
  }

  ll ans = -1;
  queue<ll> que;
  ll counter = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < i; j++){
      ll n = j * 1000 + i;
      if(inn.at(n) == 0){
        que.push(n);
        v.at(n) = 1;
        chmax(ans, v.at(n));
      }
    }
  }

  while(!que.empty()){
    ll n = que.front(); que.pop();
    counter++;
    for(int i = 0; i < G.at(n).size(); i++){
      ll next = G.at(n).at(i);
      inn.at(next)--;
      if(inn.at(next) > 0) continue;
      if(v.at(next) < v.at(n) + 1){
        v.at(next) = v.at(n) + 1;
        chmax(ans, v.at(next));
        que.push(next);
      }
    }
  }
  if(counter == N * (N-1) / 2) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 54912
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var s = sc.Next();

        Console.WriteLine($"{s[0]}{s.Length - 2}{s[s.Length - 1]}");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int H, W; cin >> H >> W;
    vector<string> A(H); for (auto &a : A) cin >> a;
    vector<string> R = A, B = A;
    for (int i = 0; i < H; i++) {
        R[i][0] = '#';
        for (int j = 1; j < W-1; j++) {
            (i % 2 ? R : B)[i][j] = '#';
        }
        B[i][W-1] = '#';
    }
    for (auto& s : R) cout << s << '\n';
    cout << '\n';
    for (auto& s : B) cout << s << '\n';
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
#define SIZE 1000010
//status unsolved
long long fac[SIZE],finv[SIZE],inv[SIZE];
long long MOD=mod;

void make() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long modpow(long long a, long long n ) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    long long  sum;
    cin>>sum;
    long long  end=sum/3;
    long long ans=0;
    make();
    for(long long k=1;k<=end ;k++){
        ans+=C((sum-3*k)+k-1,k-1);
        ans%=mod;
        //cout<<ans<<endl;
    }
    if(sum<3)ans=0;
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 27056
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => {
            get().parse::<$t>().unwrap()
        };
        () => {
            get!(i64)
        };
    }
    let n = get!();
    let mut ans = 0.0;
    for _ in 0..n {
        let m = get!(f64);
        let s = get();
        if s == "JPY" {
            ans += m;
        } else {
            ans += m * 380_000.0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n, k;
    cin >> n >> k;
    int div = (n-1)*(n-2)/2 - k;
    if (div >= 0){
        cout << (n-1) + div << endl;
        rep(i, n-1) cout << "1 " << i+2 << endl;
        for (int i = 2; i <= n; i++)
        {
            for (int j = i+1; j <= n; j++)
            {
                if(div != 0){
                    cout << i << " " << j << endl;
                    div--;
                }
            }            
        }
    } else {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start	

	int N, K;
	cin >> N >> K;

	cout << (N - K + 1) << endl;



ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
#include <iostream>

#define N 101
#define INF 1e+9

using namespace std;
int main(void){
	int n,m;
	while(cin>>n>>m,n||m){
		int cost[N][N],times[N][N];
		for(int i=1;i<=m;++i)for(int j=1;j<=m;++j){cost[i][j]=times[i][j]=INF;}
		for(int i=0,a,b,c,t;i<n;++i){
			cin>>a>>b>>c>>t;
			cost[a][b]=cost[b][a]=c;
			times[a][b]=times[b][a]=t;
		}
		int k;cin>>k;
		for(int i=0,p,q,r;i<k;++i){
			cin>>p>>q>>r;
			if(r){//time
				int d[N];
				for(int j=1;j<=m;++j) d[j]=INF;
				d[p]=0;
				bool f=false;
				for(;;){
					for(int j=1;j<=m;++j){//from
						for(int k=1;k<=m;++k){//to
							if(d[j]!=INF && d[j] + times[j][k] < d[k]){
								f=true;
								d[k] = d[j] + times[j][k];
							}
						}
					}
					if(f==false) break;
					f=false;
				}
				cout<<d[q]<<endl;
			}else{//cost
				int d[N];
				for(int j=1;j<=m;++j) d[j]=INF;
				d[p]=0;
				bool f=false;
				for(;;){
					for(int j=1;j<=m;++j){//from
						for(int k=1;k<=m;++k){//to
							if(d[j]!=INF && d[j] + cost[j][k] < d[k]){
								f=true;
								d[k] = d[j] + cost[j][k];
							}
						}
					}
					if(f==false) break;
					f=false;
				}
				cout<<d[q]<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int n;
int s[109];
int memo[101][10009];

int dfs(int cnt,int sum){
  int rec;
  if(memo[cnt][sum]!=-1)return memo[cnt][sum];
  if(cnt==n){
    if(sum%10==0)return 0;
    else return sum;
  }
  rec=max(dfs(cnt+1,sum),dfs(cnt+1,sum+s[cnt]));
  return memo[cnt][sum]=rec;
}

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  for(int i=0;i<n;i++)cin>>s[i];
  cout<<dfs(0,0)<<endl;
  return(0);
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

bool checkMatchcolor(int charindex, int colorindex, vector<int> &line, int *color){
	if(charindex == 0){
		if(color[colorindex] != line[charindex+1]) return false;
	}
	else if(charindex == line.size()-1){
		if(color[colorindex] != line[charindex-1]) return false;
	}
	else if(color[colorindex] != line[charindex+1] && color[colorindex] != line[charindex-1]) return false;
	return true;
}

void changeZero(vector<int> &line, int index){
	int target = line[index];
	for(int i = index; line[i] == 0 || line[i] == target; i--){
		line[i] = 0;
		if(!i) break;
	}
}

int main(){
	int n = 0;
	int color[][2] = {{0, 0}, {2, 3}, {1, 3}, {1, 2}};
	while(cin >> n && n != 0){
		vector<int> line;
		for(int i = 0; i < n; i++){
			int tmp = 0;
			cin >> tmp;
			line.push_back(tmp);
		}

		int minch = n;
		for(int i = 0; i < n; i++){ 
			for(int j = 0; j < 2; j++){
				vector<int> copyline = line;
				if(!checkMatchcolor(i, j, copyline, color[line[i]])) continue;
				copyline[i] = color[line[i]][j];
				int count = 1;
				for(int k = 0; k < n-1; k++){
					if(!copyline[k]) continue;
					int progress = 1;
					while(!copyline[k+progress] && k+progress<copyline.size()) progress++;
					if(copyline[k] != copyline[k+progress]){
						if(count >= 4){
							changeZero(copyline, k);
							k = -1;
						}
						count = 1;
					}
					else count++;
				}

				if(count >= 4){
					changeZero(copyline, n-1);
				}

				int chnum = 0;
				for(int k = 0; k < n; k++){
					if(copyline[k]) chnum++;
				}

				minch = minch > chnum ? chnum : minch;
			}
		}

		cout << minch << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
using namespace std;
 
int main()
{
	int ndata, b, f, r, v;
	int rm[4][3][10];
	
	for(int i = 0; i < 4 ; i++) {
		for(int j = 0; j < 3 ; j++)
			for (int k = 0; k < 10; k++)
				rm[i][j][k] = 0;
	}
	
	cin >> ndata;
	
	for (int i = 0; i < ndata; i++) {
		cin >> b >> f >> r >> v;
		rm[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4 ; i++) {
		for(int j = 0; j < 3 ; j++) {
			for (int k = 0; k < 10; k++)
				cout << ' ' << rm[i][j][k];
			cout << endl;
		}
		if(i!=3)
		cout << "####################" << endl;
    }
    return 0;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(c/a>(b)/a||b%a==0||c%a==0){
		cout<<"OK"<<endl;
	}else{
		cout<<"NG"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
typedef long long ll;
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)

int main() {
	int n, cou = 0;
	char color[100001];

	scanf("%d", &n);
	scanf("%s", color, 100000);

	FORR(0,n-1){
		if (color[i] != color[i + 1]) {
			cou++;
		}
	}
	printf("%d\n", cou+1);
	
	return 0;
}

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

namespace ABC126C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');//入力を受け取って
            int N = int.Parse(input[0]);//整数型の変数Nにデータをセット
            int K = int.Parse(input[1]);//整数型の変数Kにデータをセット

            double ans;
            double ans_All = 0.0D;
            double x = 0.5D;

            for (int i = 1; i <= N; i++)
            {
                int statement = i;
                int counter = 0;
                while (statement<K)
                {
                    statement *= 2;
                    counter++;
                }
                ans = Math.Pow(x, (double)counter);
                ans_All += ans;
            }
            ans_All = ans_All / (double)N;
            Console.WriteLine(ans_All);
        }
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dat[1<<10];
int memo[1<<10][1<<10];
int issafe(int mask, int succ){
  if(memo[mask][succ] >= 0) return memo[mask][succ];
  int& res = memo[mask][succ];
  if(succ && (~mask & succ) == succ) return res = 0;
  for(int bit=mask;bit;(bit-=(mask&-mask))&=mask){
	REP(i,10){
	  if(dat[bit]>>i&1){
		if(!issafe(mask^bit, succ|(1<<i))){
		  return res = 0;
		}
	  }
	}
  }
  return res = 1;
}

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

  int N;
  while(cin>>N,N){
	string S;
	cin >> S;
	fill(dat, dat+(1<<10), 0);
	fill((int*)memo, (int*)memo+(1<<20), -1);
	bool safe = true;
	int bit = 0;
	for(int i=0;i<N;++i){
	  if(S[i] == 'u'){
		bit = 0;
	  }
	  else{
		int a = S[i] - '0';
		if(bit>>a&1){
		  safe = false;
		  break;
		}
		dat[bit] |= 1<<a;
		bit |= 1<<a;
	  }
	}
	if(!safe){
	  cout << "UNSAFE" << endl;
	  continue;
	}
	cout << (issafe((1<<10)-1, 0)?"SAFE": "UNSAFE") << endl;
  }

  return 0;
}

Measured memory_bytes: 7212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int[] a = new int[4];
		for(int i = 0;i < 6;i++) {
			int c = scn.nextInt();
			a[c-1]++;
		}
		boolean ans = true;
		for(int i = 0;i < 4;i++) {
			if(a[i]==1 || a[i] == 2) {
			}else {
				ans = false;
			}
		}
		System.out.println(ans?"YES":"NO");
	}

}


Measured memory_bytes: 23124