akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
#include <map>
#include <vector>
#include <string>
#include <tuple>
#include <set>

using namespace std;

class Solver {
};

int main() {
	int n, t, s;
	cin >> n >> t >> s;
	vector<int> as(n);
	vector<int> bs(n);
	for (int i = 0; i < n; i++) {
		cin >> as[i];
		cin >> bs[i];
	}

	vector<int>dp(t + 1, 0);
	int res = 0;
	for (int i = 0; i < n; i++) {
		vector<int>next(t + 1, 0);
		for (int j = 0; j <= t; j++) {
			next[j] = max(next[j], dp[j]);
			int next_time = j + bs[i];
			if (j<s && next_time>s)next_time = s + bs[i];
			if (next_time <= t) {
				next[next_time] = max(next[next_time], dp[j] + as[i]);
				res = max(res,next[next_time]);
			}
		}
		dp = next;
	}

	cout << res << endl;
}


Measured memory_bytes: 3208
const main = (input) => {
    const args = input.split(' ');
    const N = parseInt(args[0], 10),
          A = parseInt(args[1], 10),
          B = parseInt(args[2], 10);

    const nums = Array.from(new Array(N), (v, i) => ++i).filter((i) => {
        var n = i.toString().split('').reduce((p, c) => p + parseInt(c), 0);
        return (n >= A && n <= B);
    });

    console.log(nums.reduce((p, c) => p + c, 0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9968
#include <bits/stdc++.h>
#define  ren(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) ren(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    li n,ans=1.;
    cin>>n;
    ren(i,1,n+1) ans=(ans*i)%1000000007;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       
        if(a < b){
            System.out.printf("a < b\n");
        }
        else if(a > b){
            System.out.printf("a > b\n");
        }
        else {
            System.out.printf("a == b\n");
        }
    }
}



Measured memory_bytes: 26084
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ull unsigned long long 
const ll mod = 1e9 + 7;
int main()
{
  ll n,k;
  cin>>n>>k;
  ll dp[n+1][k+1];
  memset(dp,0,sizeof(dp));
  ll arr[n+1];
  for(int i=1;i<=n;++i)
  cin>>arr[i];
  dp[0][0]=1;
  for(int i=1;i<=n;++i)
  {
    ll pre=0;
    for(int j=0;j<=k;++j)
    {
      pre += dp[i-1][j];
      if(j-arr[i]-1>=0) pre -= dp[i-1][j-arr[i]-1];
      pre = (pre + mod)%mod;
      dp[i][j] = pre;
    }
  }
  cout<<dp[n][k];
}

Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int x = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I') x++;
        else if(s[i] == 'D') x--;
        if(x > ans) ans = x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int w , h , n , x , y , a , x1 , x2 , y1 , y2;
    cin >> w >> h >> n;
    x1 = 0;
    x2 = w;
    y1 = 0;
    y2 = h;
    while ( n -- ) {
        cin >> x >> y >> a;
        if ( a == 1 ) {
            x1 = max( x1 , x );
        } else if ( a == 2 ) {
            x2 = min( x2 , x );
        } else if ( a == 3 ) {
            y1 = max( y1 , y );
        } else {
            y2 = min( y2 , y );
        }
    }
    cout << max( 0 , ( x2 - x1 ) ) * max( 0 , ( y2 - y1 ) );
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int N;
    cin >> N;
    int H[N];
    rep(i, 0, N) cin >> H[i];

    int max_v = H[0], rsl = 1;
    rep(i, 1, N) {
        if(max_v <= H[i]) rsl += 1;
        chmax(max_v, H[i]);
    }
    cout << rsl << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
//#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    REPS(a, N) {
        ans += N / a;
        if (N % a == 0)
            ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,H,W;
    cin>>N>>H>>W;
    
    int cnt=0;
    rep(i,N){
        int a,b; cin>>a>>b;
        if(a>=H&&b>=W) cnt++;
    }
    cout1(cnt)
}

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

int main(){
  int K,X;
  cin >> K >> X;
  vector <int> v;
  v.push_back(X);
  for(int i=1;i<K;i++){
    v.push_back(X+i);
  }
  for(int i=1;i<K;i++){
    v.push_back(X-i);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    cout << v.at(i);
    if(i==v.size()-1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 256
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        dist = sum(map(lambda v1, v2: (v1 - v2) ** 2, x[i], x[j]))
        if math.sqrt(dist) == int(math.sqrt(dist)):
            ans += 1

print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  int mx=0, mxsec=0;
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
    if(vec.at(i) > mx) mx = vec.at(i);
    else mxsec = max(mxsec, vec.at(i));
  }
  if(mx == mxsec){
    for(int i=0; i<n; ++i){
      cout << mx << endl;
    }
  }
  else{
    for(int i=0; i<n; ++i){
      if(vec.at(i) == mx) cout << mxsec << endl;
      else cout << mx << endl;
    }
  }
}

Measured memory_bytes: 2432
c,d[4010]={1};main(t,j){for(;t+=(j=getchar())>10?c+=j%3,1:-1;d[c<t?t:c-t]=0)for(j=c;j;d[j--]%=998244353)d[j]+=d[j-1];printf("%d",d[c]);}

Measured memory_bytes: 128
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

typedef vector<double> vd;

const int LOSE = 1;
const int BACK = 2;

int main() {
	int N, T, L, B;
	while(cin >> N >> T >> L >> B, N) {
		vi field(N+1);
		vector<vd> dp(T+3, vd(N+1));

		int tmp;
		REP(i, L) {
			cin >> tmp;
			field[tmp] = LOSE;
		}
		REP(i, B) {
			cin >> tmp;
			field[tmp] = BACK;
		}

		dp[0][0] = 1;
		FOR(i, 1, T) {
			FOR(j, 0, N-1) {
				FOR(d, 1, 6) {
					int np = j+d;
					if(np > N) {
						np = 2*N-np;
					}
					if(field[np] == LOSE) {
						dp[i+1][np] += dp[i-1][j]/6.0;
					} else if(field[np] == BACK) {
						dp[i][0] += dp[i-1][j]/6.0;
					} else {
						dp[i][np] += dp[i-1][j]/6.0;
					}
				}
			}
			dp[i][N] += dp[i-1][N];
		}

		printf("%.6f\n", dp[T][N]);
	}

	return 0;
}

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

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

  int ans = r*r;
  cout << ans << endl;
  return 0;
}


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

struct UnionFind {
    vector<int> data;
    UnionFind(int n) { data.assign(n, -1); }

    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return true;
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x) {
        return (data[x]<0 ? x : data[x]=root(data[x]));
    }

    int size(int x) {
        return -data[root(x)];
    }
};

int main() {
  lint N, M;
  cin >> N >> M;

  UnionFind uf(N);
  for(lint i=0; i<M; i++) {
    lint A, B;
    cin >> A >> B;
    A--, B--;
    uf.unite(A, B);
  }
  lint ans = 0;
  for(lint i=0; i<N; i++) {
    ans = max((lint)uf.size(i), ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
def choice_contest(c, data_day, last, day, contest):
    contest -= 1
    #print(last)
    last = [i + 1 for i in last]
    # 今回開催するコンテストのlastを0にする
    last[contest] = 0
    #print(len(last))
    #print(last)
    # 不満度の計算
    d_satis = sum([last[i] * c[i] for i in range(26)])
    # i日目にcontestを選んだ場合の
    return [int(data_day[contest]) - d_satis, last]

def main():
    d = int(input())
    c = list(map(int,input().split()))
    data = [input().split() for _ in range(d)]
    last = [0] * 26
    ans = 0
    for i in range(d):
        s, last = choice_contest(c, data[i], last, i, contest = int(input()))
        ans += s
        print(ans)
    return 0

if __name__ == "__main__":
    main()

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = 0;
    bool ans2 = false;
    // if(x == y || y == -x + h)
        ans = w * h / 2;
    // else
        // ans = max(x * h, y * w);
    if(x == w / 2 && y == h / 2) ans2 = true;
    cout << ans << ' ' << ans2 << endl;
}

Measured memory_bytes: 256
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    L = []

    for i in range(X):
        for j in range(min(Y, K // (i + 1) + 1)):
            for k in range(min(Z, K // (i + 1) // (j + 1) + 1)):
                L.append(A[i] + B[j] + C[k])

    L.sort(reverse=True)

    for i in range(K):
        print(L[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 80804
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
   val N=readLine()!!.toInt()

   val S=(1..N).map {readLine()!!.toInt()}
   val allc=S.fold(0){sum,ele -> sum+ele}

   println(if(allc%10==0) {allc-(S.filter{(allc-it) %10!=0}.min()?:allc)} else {allc})
  }
}


Measured memory_bytes: 33488
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

/*各位の和　
int sum = 0;
for(int i = 0; i <= 5; i++){
   sum += n%10;
   n /= 10;  
}
*/

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll a,b,k;
  cin>>a>>b>>k;
  if(b-a+1<=k*2){
    rep(i,b-a+1)print(a+i);
  }
  else
  {
    rep(i,k)print(a+i)
    rep(i,k)print(b-k+i+1)
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int n,x;
   cin>>n>>x;
   vector<int>a(n);
   for(int i=0;i<n;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   int ans=0;
   for(int i=0;i<n;i++){
      if(x>=a[i] && (x==a[i] || i<n-1)){
         x-=a[i];
         ans++;
      }
      
   }
   cout<<ans<<endl;
}

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

int main() {
	int s, w; cin >> s >> w;
	if (w >= s) cout <<  "unsafe" << endl;
	else cout <<  "safe" << endl;
	return 0;
}


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

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

        String s = sc.next();
        String t = sc.next();

        char[] s_char = s.toCharArray();
        char[] t_char = t.toCharArray();

        Arrays.sort(s_char);
        Arrays.sort(t_char);

        String sorted_s = new String(s_char);
        String sorted_t = new String(t_char);
        sorted_t = new StringBuilder(sorted_t).reverse().toString();

        if (sorted_s.compareTo(sorted_t) < 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, M, a, b, c;
vector<lP>v[1000];
ll g[1000], res;

int main() {
	cin >> N >> M;
	for (int i = 0; i != M; ++i) {
		cin >> a >> b >> c;
		v[a - 1].push_back(mkp(b - 1, c));
	}
	for (int i = 0; i != N; ++i) {
		g[i] = -0xe869120e869120;
	}
	g[0] = 0;
	for (int h = 0; h != N; ++h) {
		for (int i = 0; i != N; ++i) {
			for (int j = 0; j != v[i].size(); ++j) {
				g[v[i][j].first] = max(g[v[i][j].first], g[i] + v[i][j].second);
			}
		}
	}
	res = g[N - 1];
	for (int h = 0; h != N; ++h) {
		for (int i = 0; i != N; ++i) {
			for (int j = 0; j != v[i].size(); ++j) {
				g[v[i][j].first] = max(g[v[i][j].first], g[i] + v[i][j].second);
			}
		}
	}
	if (res != g[N - 1])
		cout << "inf" << endl;
	else
		cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	vector<int> coins;
	for (int i = 1; i * i <= 300; ++i)
		coins.push_back(i * i);

	int dp[33][333];
	clear(dp, 0);
	dp[0][0] = 1;
	for (int i = 0; i < coins.size(); ++i)
		for (int j = 0; j <= 300; ++j)
			for (int k = 0; k * coins[i] <= j; ++k)
				dp[i + 1][j] += dp[i][j - k * coins[i]];

	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", dp[coins.size()][n]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int a[MAXN];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        a[i] -= i;
    }
    sort(a + 1, a + n + 1);
    int b = a[(n + 1) / 2];
    long long ans = 0;
    for(int i = 1; i <= n; i++)
        ans += abs(a[i] - b);
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n);
  for (int i = 0; i < s.size();) {
    char t = s[i];
    int j = i + 1, cnt = 1;
    while (1) {
      if (t != s[j] || j >= s.size()) {
        if (t == 'R') {
          a[j - 1] += (cnt + 1)/2;
          a[j] += cnt/2;
        }
        else {
          a[i - 1] += cnt/2;
          a[i] += (cnt + 1)/2;
        }
        i = j;
        break;
      }
      cnt++;
      j++;
    }
  }
  for (int i = 0; i < a.size() - 1; i++) {
    cout << a[i] << " ";
  }
  cout << a[a.size() - 1] << endl;
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<bool>> black(H, vector<bool>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char c;
            cin >> c;
            if (c == '.') {
                black[i][j] = false;
            } else {
                black[i][j] = true;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {
            // check
            int count = 0;
            for (int r = 0; r < H; ++r) {
                for (int c = 0; c < W; ++c) {
                    if (black[r][c] && ((1 << r) & i) && ((1 << c) & j)) {
                        ++count;
                    }
                }
            }
            if (count == K) {
                ++ans;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ans,sum;
int main(){
    cin>>a>>b>>c;
    if((a!=5 && a!=7) || (b!=5 && b!=7) || (c!=5 && c!=7)){
        cout<<"NO"<<endl;
        return 0;
    }
    if(a==5) ans++;
    else sum++;
    if(b==5) ans++;
    else sum++;
    if(c==5) ans++;
    else sum++;
    if(ans==2&&sum==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	map<int , int>mp ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		mp[x]++ ;
	}
	int cnt = n , prv = 0 ;
	int ans = 0 ;
	for(auto &i : mp)
	{
		if(cnt == n/2 && n%2 == 0)
			ans += (i.first - prv) ;
		prv = i.first ;
		cnt -= i.second ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 3200
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math
sys.setrecursionlimit(300000)


def solve(R):
    ret = R * 2 * math.pi
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    solve(R)

if __name__ == '__main__':
    main()



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

#define ll long long

int N;
ll C[202020];
ll mo=1000000007;

void solve() {
    int i, j, k, l, r, x, y;
    string s;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> C[i];
    sort(C, C + N);
    reverse(C, C + N);
    ll p = 1, q = 1;
    for (int i = 0; i < N; ++i) {
        q = q * 2 % mo;
    }
    ll sum = 1, ret = 0;
    for (int i = 0; i < N; ++i) {
        q = q * (mo + 1) / 2 % mo;
		(ret+=(C[i]*sum)%mo*q)%=mo;
		sum=(sum*2+p)%mo;
		p=p*2%mo;
    }
    cout<<ret*p%mo<<endl;
}


int main() {
    solve();
}

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

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> pena(N,0);
    vector<ll> ok(N,0);
    ll res1=0;
    ll res2=0;
    for (int i = 0; i < M; i++)
    {
        ll p;
        string status;
        cin >> p >> status;--p;
        if(status=="AC"){
            if(!ok[p]){
                ++res1;res2+=pena[p];ok[p]=true;
            }
        }
        else pena[p]++;
    }
    cout<<res1<<" "<<res2;
    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 600005;
int n, p[13][MX], fin[13][MX], res[MX];
string t;

void go (int i, int m) {
	vector<vi> a(3, vi(m));

	forn (j, 3 * m) a[j / m][j % m] = j;

	fin[i][0] = 3 * m - 1;

	forn (j, t.size()) {
		if (t[j] == 'S') {
			swap(a[1], a[2]);
		} else {
			vi aux(3);
			forn (k, 3) aux[k] = a[k][fin[i - 1][j]];
			forn (k, 3) a[(k + 1) % 3][fin[i - 1][j]] = aux[k];
		}

		fin[i][j + 1] = a[2][fin[i - 1][j + 1]];
	}

	forn (j, 3 * m) p[i][j] = a[j / m][p[i - 1][j % m]];
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> t;

	iota(p[0], p[0] + 3, 0);

	fin[0][0] = 2;
	forn (i, t.size()) {
		swap(p[0][1], p[0][2]);
		if (t[i] == 'R') swap(p[0][0], p[0][1]);
		fin[0][i + 1] = p[0][2];
	}

	int m = 3;
	for (int i = 1; i < n; i++, m *= 3)
		go(i, m);

	forn (i, m) res[p[n - 1][i]] = i;

	forn (i, m) cout << res[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 20164
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	string S;
	cin >> S;
	int size = S.size();
	int a = 0;
	int z = 0;
	for (int i = 0; i < size; i++) {
		if (S[i] == 'A') {
			a = i;
			break;
		}
	}
	for (int j = size - 1; j > -1; j--) {
		if (S[j] == 'Z') {
			z = j;
			break;
		}
	}
	cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define ll long long

int main () {
  ll a, b, c;
  cin >> a >> b >> c;
  ll aa = abs(b * c * (a / 2 - (a - a / 2)));
  ll bb = abs(c * a * (b / 2 - (b - b / 2)));
  ll cc = abs(a * b * (c / 2 - (c - c / 2)));
  cout << min(aa, min(bb, cc)) << endl;
}


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

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

//#define int ll

class CSccPuzzle {
public:

void solve(std::istream& cin, std::ostream& cout) {
    ll N, M;
    cin >> N >> M;
    ll t = min(M/2, N);
    M -= 2*t;
    error(t, M);
    cout << t + M/4 << endl;
}


};


#undef int
int main() {


	CSccPuzzle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
NX = input()
NX = NX.split(' ')
N = int(NX[0])
x = int(NX[1])
A = input()
A = list(map(int, A.split(' ')))
sorted_a = sorted(A)
s = 0

cum_sum = [0] * (len(sorted_a))
for i, a in enumerate(sorted_a):
    s = s + a
    cum_sum[i] = s

checker = True
for i, s in enumerate(cum_sum):
    if s == x:
        print(i+1)
        checker = False
        break
    elif s >= x:
        print(i)
        checker = False
        break

if checker:
    print(i)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{   
    int a;
    int x = 100;
    scanf("%d", &a);
    for (; a > 0; a--) {
        x = ceil((float)x * 1.05);
    }
    printf("%d\n", x * 1000);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long md;
long long dp[3010][3010];
long long C[3010][3010];
long long g[3010][3010];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long powd(long long x,long long y,long long p){
	long long res=1;
	while(y){
		if(y&1) res=res*x%p;
		x=x*x%p;
		y>>=1;
	}
	return res;
}
void Add(long long &x,long long y){
	(x+=y)%=md;
}
int n;
long long solve(int x){
	long long res=0;
	for(int i=0;i<=n;i++)
		Add(res,dp[x][i]*g[n-x][i]%md);
	res=res*C[n][x]%md*powd(2,powd(2,n-x,md-1))%md;
	return res;
}
int main(){
	scanf("%d%lld",&n,&md);
	C[0][0]=C[1][0]=C[1][1]=1;
	for(int i=2;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=n;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%md;
	}
	for(int i=0;i<=n;i++){
		g[i][0]=1,g[i][1]=powd(2,i);
		for(int j=2;j<=n;j++)
			g[i][j]=g[i][j-1]*g[i][1]%md;
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j>0) Add(dp[i][j],dp[i-1][j-1]);
			Add(dp[i][j],dp[i-1][j]*(j+1));
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++){
		if(i&1)
			Add(ans,md-solve(i));
		else
			Add(ans,solve(i));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 212352
from collections import deque
N,M = list(map(int,input().split()))
K = []
for i in range(M):
    A = list(map(int,input().split()))
    K.append(A)
p = list(map(int,input().split()))
ans = 0
for i in range(1 << N):
    f = True
    for j in range(M):
        s = 0
        for k in K[j][1:]:
            s += (i >> (k - 1)) & 1
        if s % 2 != p[j]:
            f = False
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int main(){
	while(true){
		int H;
		cin>>H;
		if(H==0) break;
		int a[10][5];
		rep(i,H) rep(j,5) cin>>a[H-1-i][j];
		int ans=0;
		while(true){
			bool update=false;
			rep(i,H){
				if(a[i][2]==-1) continue;
				int l=2,r=2;
				while(l>0){
					if(a[i][l-1]==a[i][2]) l--;
					else break;
				}
				while(r<4){
					if(a[i][r+1]==a[i][2]) r++;
					else break;
				}
				if(r-l+1>=3){
					update=true;
					ans+=a[i][2]*(r-l+1);
					for(int j=l;j<=r;j++) a[i][j]=-1;
				}
			}
			if(!update) break;
			rep(i,5){
				vector<int> vc;
				rep(j,H){
					if(a[j][i]!=-1) vc.pb(a[j][i]);
				}
				rep(j,vc.size()) a[j][i]=vc[j];
				for(int j=vc.size();j<H;j++) a[j][i]=-1;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1216
using System;
class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        string[] inputlist = input.Split(' ');
        int A = int.Parse(inputlist[0]);
        int B = int.Parse(inputlist[1]);
        int C = int.Parse(inputlist[2]);

        if (A + B+ C >= 22)
        {
            Console.Write("bust");

        }
        else
        {
            Console.Write("win");
        }
    }
}

Measured memory_bytes: 13140
def subImage(x,y,M,A):
    C = []
    for i in range(M):
        C.append(A[x+i][y:y+M])
    return C
    
def containIm(N,M,A,B):
    judge = 0    
    for x in range(N-M+1):
        for y in range(N-M+1):
            C = subImage(x,y,M,A)
            if C == B:
                judge = 1
                return judge
    return judge
    

# 入力
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

judge = containIm(N,M,A,B)
if judge == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b,x;
    cin >> a >> b >> x;
    //処理
    //出力
    if(a<=x && x<= a+b) cout << "YES" << ENT;
  	else cout << "NO" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
X = int(input())
if 400 <= X <= 599:
  print(8)
elif 600 <= X <= 799:
  print(7)
elif 800 <= X <= 999:
  print(6)
elif 1000 <= X <= 1199:
  print(5)
elif 1200 <= X <= 1399:
  print(4)
elif 1400 <= X <= 1599:
  print(3)
elif 1600 <= X <= 1799:
  print(2)
else:
  print(1)

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int nr = count(s.begin(), s.end(), 'R');
    int nb = n - nr;
    if (nr > nb) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    double ans=0;
    while(t--)
    {
        double n;
        string s;
        cin>>n>>s;
        if(s =="BTC")
        {
            ans+= ((380000)*n);
        }
        else
            ans+=n;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3)
		if (s[i] == t[i])
			ans++;
	cout << ans << endl;
}

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

	solve();
}


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

int main(){
  int n;
  cin >> n;
  long l[n];
  rep(i,n)cin >> l[i];
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      for(int k=j;k<n;k++){
        if(i!=j && j!=k && k!=i && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
          if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j])ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		List<TreeSet<Integer>> list = new ArrayList<>();
		for (int i = 0; i < 10; i++) {
			list.add(new TreeSet<>());
		}
		for (int i = 0; i < n; i++) {
			int a = s.charAt(i) - '0';
			list.get(a).add(i);
		}

		int ans = 0;
		for (int i = 0; i < 1000; i++) {
			int x = i;
			int y = x % 10;
			Integer idx = list.get(y).ceiling(0);
			if (idx == null) {
				continue;
			}

			x /= 10;
			y = x % 10;
			idx = list.get(y).higher(idx);
			if (idx == null) {
				continue;
			}

			x /= 10;
			y = x % 10;
			idx = list.get(y).higher(idx);
			if (idx != null) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24696
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void) {
  int x;
  cin >> x;
  while(true){
    if(IsPrime(x)) {
      cout << x << endl;
      break;
    }
    x++;
  }
  
  
  
  
         
         
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cstdio>
#include <cmath>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int wa(int n){
	if(n == 0) return 0;
	else return n % 10 + wa(n / 10);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	if(n % wa(n) == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
using namespace std;

#define all(c) c.begin(),c.end()
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i,0,n)
#define MAX(x, y)  ((x > y)? x : y);
#define MIN(x, y)  ((x < y)? x : y);
#define dump(x)  cout << #x" = " << x << endl;
#define debug(x) cout << #x" = " << x << " (" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	int max = -100, min = 100;
	int ans = 0, min_cost = -1;
	REP(i, n) {
		cin >> a[i];
		max = MAX(max, a[i]);
		min = MIN(min, a[i]);
	}

	FOR(i, min, max + 1) {
		int total_cost = 0;
		REP(j, n) {
			total_cost += (a[j] - i) * (a[j] - i);
		}
		if (min_cost > total_cost || min_cost == -1) {
			min_cost = total_cost;
		}
	}

	cout << min_cost << endl;

	return 0;
}

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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;
vi arr(50);
int main(void){
    int n;
    cin>>n;
    loop(i,n)
    {
        cin>>arr[i];
    }

    int ans=0;
    loop(i,n)
    {
        range(j,i+1,n-1)
        {
            ans+=arr[i]*arr[j];
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
//int p=0;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
void dfs(vector<pair<int,int> >v[],int vis[],int node,int ans[])
{
    vis[node]=1;
   // p++;
    for(auto u : v[node])
    {
        if(!vis[u.ff])
        {
            if((u.ss)%2==0)
                ans[u.ff]=ans[node];
            else
                ans[u.ff]=!ans[node];
            dfs(v,vis,u.ff,ans);
        }
    }
}
int main()
{
    fast();
    int n;
    cin>>n;
    int x,y,w,i;
    //map<pair<int,int>,int>mp;
     int ans[n+1];
    ans[1]=0;
    vector<pair<int,int> >v[n+1];
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y>>w;
       // mp[{x,y}]=w;
       // mp[{y,x}]=w;
        v[x].pb({y,w});
        v[y].pb({x,w});
    }
    int vis[n+1]={0};
    dfs(v,vis,1,ans);
   // cout<<p<<endl;
    for(i=1;i<=n;i++)
        cout<<ans[i]<<endl;
}



Measured memory_bytes: 9344
N, M = map(int, raw_input().split())
A = [0]*M
B = [0]*M
C = [0]*M
d = []
for i in range(N):
  d.append([1000000]*N)
  d[i][i]=0
for i in range(M):
  a, b, c = map(int, raw_input().split())
  A[i] = a-1
  B[i] = b-1
  C[i] = c
  d[a-1][b-1] = c
  d[b-1][a-1] = c
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j] = min(d[i][j], d[i][k]+d[k][j])
      d[j][i] = d[i][j]
r = 0
for i in range(M):
  if d[A[i]][B[i]] < C[i]:
    r += 1
print r

Measured memory_bytes: 2936
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    
}

signed main()
{
    fast;

    string a,b;cin>>a>>b;

    int x = 0;

    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i]) x++;
    }
    cout<<x;


    return 0;
}

Measured memory_bytes: 3784
f = []

for i in range (5):
  f.append(int(input()))
  
time = 0
machi = []

for i in range (5):
  if f[i]%10 == 0:
    time += f[i]
  else:
    time += f[i] + (10-f[i]%10)
    machi.append(10-f[i]%10)
    
if len(machi) == 0:
  print(time)
else:
  print(time-max(machi))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
///////////////////////
int max(int a,int b)
{
	if(a>=b)return a;
	else return b;
}

int main()
{
	int N,count=0,max_c=0;
	float x[101]={},y[101]={};

	while(1)
	{
		count=0;
		max_c=0;

		s_1(N);
		if(N==0)break;
		rep(i,N)
		{
			scanf("%f,%f",&x[i],&y[i]);
		}
		for(double i=0;i<=10;i+=0.01)
		{
			for (double j=0; j<=10;j+=0.01)
			{
				count=0;
				rep(k,N)
				{
					if((i-x[k])*(i-x[k])+(j-y[k])*(j-y[k])<=1.01)count++;
				}
				max_c=max(max_c,count);
			}
		}
		debug(max_c);
	}
	return 0;
}

Measured memory_bytes: 1264
S = input()
def is_asynmetric(S):
  for i in range(len(S) // 2):
    if S[i] != S[-(i + 2)]:
      return True
  else:
    return False
if S[0] != '1' or S[-2:] != '10':
  print(-1)
elif is_asynmetric(S):
  print(-1)
else:
  print('1 2')
  edge = 2
  for i, s in enumerate(S[1:-1], 3):
    print(edge, i)
    edge = edge if s == '0' else i

Measured memory_bytes: 4652