akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, M, K;
list<int>edge[3001];
int dis[3001];
priority_queue<int, vector<int>, greater<int>>Q;
bool flag[3001];
int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M >> K;
	for (int i = 1; i <= N; i++)dis[i] = INT_MAX;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		edge[a].push_back(c * 10000 + b);
		edge[b].push_back(c * 10000 + a);
	}
	for (int i = 0; i < K; i++) {
		int a;
		cin >> a;
		dis[a] = 0;
		Q.push(a);
	}
	while (!Q.empty()) {
		int current = Q.top() % 10000;
		int far = Q.top() / 10000;
		Q.pop();
		if (flag[current])continue;
		flag[current]=true;
		for (auto i : edge[current]) {
			if (dis[i % 10000] > far + i / 10000) {
				dis[i % 10000] = far + i / 10000;
				Q.push(dis[i % 10000] * 10000 + i % 10000);
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		for (auto j : edge[i]) {
			if (abs(dis[i] - dis[j % 10000]) >= j / 10000) {
				ans = max(ans, max(dis[i], dis[i % 10000]));
			}
			else {
				ans = max(ans, max(dis[i], dis[i % 10000]) + (j / 10000 - abs(dis[i] - dis[j % 10000]) + 1) / 2);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9500
#include <iostream>
using namespace std;
 
int main() {
    double w;
    while (cin >> w) {
        if (w <= 48.00) {
            cout << "light fly" << endl;
        } else if (48.00 < w && w <= 51.00) {
            cout << "fly" << endl;
        } else if (51.00 < w && w <= 54.00) {
            cout << "bantam" << endl;
        } else if (54.00 < w && w <= 57.00) {
            cout << "feather" << endl;
        } else if (57.00 < w && w <= 60.00) {
            cout << "light" << endl;
        } else if (60.00 < w && w <= 64.00) {
            cout << "light welter" << endl;
        } else if (64.00 < w && w <= 69.00) {
            cout << "welter" << endl;
        } else if (69.00 < w && w <= 75.00) {
            cout << "light middle" << endl;
        } else if (75.00 < w && w <= 81.00) {
            cout << "middle" << endl;
        } else if (81.00 < w && w <= 91.00) {
            cout << "light heavy" << endl;
        } else { 
            cout << "heavy" << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 3068
package main

import "fmt"

type dice struct {
	o, tw, th, fo, fi, s int
}

func (Dice dice) rot(D string) dice {
	for _, d := range D {
		switch d {
		case 'N':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.tw, Dice.s, Dice.o, Dice.fi
		case 'E':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.fo, Dice.o, Dice.s, Dice.th
		case 'W':
			Dice.o, Dice.th, Dice.fo, Dice.s = Dice.th, Dice.s, Dice.o, Dice.fo
		case 'S':
			Dice.o, Dice.tw, Dice.fi, Dice.s = Dice.fi, Dice.o, Dice.s, Dice.tw
		case 'R':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.th, Dice.fi, Dice.tw, Dice.fo
		case 'L':
			Dice.tw, Dice.th, Dice.fo, Dice.fi = Dice.fo, Dice.tw, Dice.fi, Dice.th
		}
	}
	return Dice
}

func main() {
	var Dice1, Dice2 dice
	var cnt int
	fmt.Scan(&Dice1.o, &Dice1.tw, &Dice1.th, &Dice1.fo, &Dice1.fi, &Dice1.s)
	fmt.Scan(&Dice2.o, &Dice2.tw, &Dice2.th, &Dice2.fo, &Dice2.fi, &Dice2.s)
	rotdice := map[int]dice{
		1: Dice2,
		2: Dice2.rot("N"),
		3: Dice2.rot("W"),
		4: Dice2.rot("E"),
		5: Dice2.rot("S"),
		6: Dice2.rot("N").rot("N"),
	}
	for i := 1; i <= 6; i++ {
		Dice2 = rotdice[i]
		for {
			if Dice1 == Dice2 {
				fmt.Println("Yes")
				return
			}
			if cnt == 3 {
				cnt = 0
				break
			}
			Dice2 = Dice2.rot("R")
			cnt++
		}
	}
	fmt.Println("No")
}



Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int n;
    vector<int>a(201);
    cin>>n;
    rep(i,n)cin>>a.at(i);
    int sum =0;
  
  while(true){
      bool b= false;

      rep(i,n){
          if(a.at(i)%2!=0)b=true;
      }
      if(b)break;
      rep(i,n){
          a.at(i)/=2;
      }
      sum++;
  }
cout<<sum<<endl;
   
}


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

int main() {
    int A, B, C, D, X;
    char op1 = '+', op2 = '+', op3 = '+';
    cin >> X;
    D = X % 10;
    X /= 10;
    C = X % 10;
    X /= 10;
    B = X % 10;
    X /= 10;
    A = X;

    bool can = false;
    int l, m, n;
    int sum;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                sum = A + B + C + D;
                if (i == 1) {
                    sum -= 2 * B;
                }
                if (j == 1) {
                    sum -= 2 * C;
                }
                if (k == 1) {
                    sum -= 2 * D;
                }
                if (sum == 7) {
                    l = i;
                    m = j;
                    n = k;
                    can = true;
                    break;
                }
            }
            if (can) {
                break;
            }
        }
        if (can) {
            break;
        }
    }

    if (l == 1) {
        op1 = '-';
    }
    if (m == 1) {
        op2 = '-';
    }
    if (n == 1) {
        op3 = '-';
    }
    cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b, c;
  readf("%s %s %s\n", &a, &b, &c);
  if (a == b) {
    c.writeln;
  } else if (a == c) {
    b.writeln;
  } else {
    a.writeln;
  }
}


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

long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}

long Combination(long n, long r, long mod) {
  long answer = 1;
  if (n-r < r) {
    r = n-r;
  }
  for (long i = 1; i <= r; i++) {
    answer *= n+1-i;
    answer %= mod;
    answer *= modpow(i,mod-2,mod);
    answer %= mod;
  }
  return answer;
}

int main(void) {

  long n,a,b;
  scanf("%ld %ld %ld", &n, &a, &b);
  long mod = pow(10,9)+7;
  long all = modpow(2,n,mod);
  long minus = Combination(n,a,mod)+Combination(n,b,mod)+1;
  minus %= mod;
  long answer = all+mod-minus;
  answer %= mod;
  printf("%ld\n", answer);

  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int d = (int)log10(n);
    set<int> st = {3,5,7};
    for(int i=0; i<d; i++){
        int s = st.size();
        auto itr = st.begin();
        for(int i=0; i<s; i++){
            st.insert((*itr)*10 + 3);
            st.insert((*itr)*10 + 5);
            st.insert((*itr)*10 + 7);
            itr++;
        }
    }
    int ans = 0;
    for(auto itr = st.begin(); itr != st.end(); itr++){
        vector<bool> judge(10, false);
        int a = *itr;
        if(a > n){
           break;
        }
        while(a > 0){
            judge.at(a%10) = true;
            a /= 10;
        }
        if(judge.at(3) == false || judge.at(5) == false || judge.at(7) == false){
            continue;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int length;
    char *A,*B,*C;
    scanf("%d",&length);
    A=(char *)malloc(sizeof(char)*length);
    B=(char *)malloc(sizeof(char)*length);
    C=(char *)malloc(sizeof(char)*length);
    scanf("%s",A);
    scanf("%s",B);
    scanf("%s",C);
    int count1=0,count2=0;
    int i;
    for(i=0;i<length;i++){
        if(A[i]==B[i]&&B[i]==C[i]){
            count1++;
        }
        else if(A[i]==B[i]&&B[i]!=C[i]){
            count2++;
        }
        else if(A[i]==C[i]&&B[i]!=C[i]){
            count2++;
        }
        else if(C[i]==B[i]&&A[i]!=C[i]){
            count2++;
        }
    }
    //printf("%d %d\n",count1,count2);
    printf("%d",count2+2*(length-count1-count2));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
    public:
    vector<int> d;
    DisjointSet(int size) : d(size, -1) {};

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool same(int x, int y) { return find(x) == find(y); }
    bool unite (int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    int size(int x) { return -d[find(x)]; }
};

/* global variables */
/* function */
/* main */
int main(){
    int N, M, K, u, v;
    cin >> N >> M >> K;
    DisjointSet ds = DisjointSet(N);
    vector<int> deg(N);
    for (int i = 0; i < M; i++) {
        scanf("%d %d", &u, &v);
        u--; v--;
        deg[u]++;
        deg[v]++;
        ds.unite(u, v);
    }

    vector<vector<int> > block(N, vector<int>());
    for (int i = 0; i < K; i++) {
        scanf("%d %d", &u, &v);
        u--; v--;
        block[u].push_back(v);
        block[v].push_back(u);
    }

    for (int i = 0; i < N; i++) {
        int cnt = 0;
        for (int b : block[i]) { if (ds.same(i, b)) cnt++; }
        cout << ds.size(i) - deg[i] - cnt - 1 << (i == (N - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 6784
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        
        int S = scan.nextInt();
        int h = S/3600;
        int m = (S-3600*h)/60;
        int s = S%60;
        System.out.println(h+":"+m+":"+s);
    }
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
int read();
int n, m;
long long x[200005], k;
int a[200005], nx[200005];
int res[200005], vis[200005], st[200005], top;
int main() {
    n = read();
    for (int i = 1; i <= n; ++i) x[i] = read(), nx[i] = i;
    for (int i = n; i >= 1; --i) x[i] -= x[i - 1];
    m = read(), scanf("%lld", &k);
    for (int i = 1; i <= m; ++i) a[i] = read();
    for (int j = 1; j <= m; ++j) swap(nx[a[j]], nx[a[j] + 1]);

    for (int i = 1, j; i <= n; ++i) {
        if (vis[i]) continue;
        st[top = vis[i] = 1] = i, j = nx[i];
        while (j != i) st[++top] = j, j = nx[j], vis[j] = 1;
        for (j = 1; j <= top; ++j) res[st[j]] = st[(j + k - 1) % top + 1];
    }
    long long t = 0;
    for (int i = 1; i <= n; ++i) t += x[res[i]], printf("%lld.0\n", t);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

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

int main(){
  int n, T;
  cin >> n >> T;
  vector<int> c(n);
  vector<int> t(n);
  for (int i=0 ; i<n ; i++)
    cin >> c.at(i) >> t.at(i);
  
  for (int i=0 ; i<n ; i++){
    if (t.at(i) > T)
      c.at(i) = -1;
  }
  
  sort(c.begin(), c.end());
  
  int ans, judge = 0;
  for (int i=0 ; i<n ; i++){
    if (c.at(i) > 0){
      judge = 1;
      ans = c.at(i);
      break;
    }
  }
  
  if (judge == 1)
    cout << ans << endl;
  else
    cout << "TLE" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;

const int MAX=1e6+5;

int main() {
  int L,R,d;
  cin>>L>>R>>d;
  cout<<R/d-(L-1)/d<<endl;
  return 0;  
}

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

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

        public static void Solve()
        {
            var hw = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var h = hw[0];
            var w = hw[1];
            var grid = new string[h];
            var skipH = new Dictionary<int, int>();
            var skipW = new Dictionary<int, int>();
            for (var i = 0; i < h; i++)
            {
                grid[i] = Console.ReadLine();
            }
            for (var i = 0; i < h; i++)
            {
                if (grid[i].Count(x => x == '#') == 0) skipH[i] = 1;
            }
            for (var i = 0; i < w; i++)
            {
                if (grid.Count(x => x[i] == '#') == 0) skipW[i] = 1;
            }
            for (var i = 0; i < h; i++)
            {
                for (var j = 0; j < w; j++)
                {
                    if (!skipH.ContainsKey(i) && !skipW.ContainsKey(j)) Console.Write(grid[i][j]);
                }
                Console.Write("\n");
            }
        }
    }
}


Measured memory_bytes: 13524
#include <stdio.h>

int main() {
	int a[3]={1,0,0};
	char b[2][2], c[2];
	char str[3][2]={"A","B","C"};
	int i = 0;
	
	// Cup Change
	while( scanf("%s,%s", &b[0], &b[1])!=EOF) {
		c[0] = a[ b[0][0] - 'A' ];
		c[1] = a[ b[1][0] - 'A' ];
		
		// change
		a[ b[1][0] - 'A' ] = c[0];
		a[ b[0][0] - 'A' ] = c[1];
	}
	
	// print Alphabet of Cup with coin
	for(i=0; i<3; i++) {
		if (a[i]) printf("%s\n", str[i]);
	}

	return 0;
}

Measured memory_bytes: 0
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(A),
    get_number(B),
    get_number(C),
    get_number(D),
    get_number(E),
    get_number(K),
    (E - A > K) -> writeln(":(") ; writeln("Yay!").


Measured memory_bytes: 8032
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
bool vis[100005];
void dfs(int u){
    vis[u] = 1;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }    
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        dfs(i);
        ans++;
    }
    printf("%d\n", ans-1);
}

Measured memory_bytes: 9884
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int x;
    cin>>x;

    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

using namespace std;
# define rep(i, a, b) for(int i = a; i < (b); ++i)
# define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s[s.size()-1]=='s'){
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int n,m; cin >> n>>m;
  int s[m][20];
  int p[m];
  int k[m];
  rep(i,0,m){
    cin>>k[i];
    rep(j,0,k[i]){
      cin>>s[i][j];
    }
  }

  rep(i,0,m) cin>>p[i];

  int ans=0;
  //各組み合わせ
  for(int tmp=0;tmp<(1<<n);tmp++){
    bitset<11> cho(tmp);

    bool al=true;
    //各電球
    for(int i=0;i<m;i++){
      int on=0;
      //その電球に繋がるスイッチ
      for(int ki=0;ki<k[i];ki++){
        if(cho.test(s[i][ki]-1)) on++;
      }

      if((on%2)!=p[i]){
        al=false;
      }  
    }

    if(al) ans++;
  }

  cout<<ans<<endl;
}

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

int main(){
  int n,a[n],col[8]={0},red=0; cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<400)col[0]=1;
    else if(a[i]<800)col[1]=1;
    else if(a[i]<1200)col[2]=1;
    else if(a[i]<1600)col[3]=1;
    else if(a[i]<2000)col[4]=1;
    else if(a[i]<2400)col[5]=1;
    else if(a[i]<2800)col[6]=1;
    else if(a[i]<3200)col[7]=1;
    else red++;
  }
  int minans=0;
  for(int i=0;i<8;i++)minans+=col[i];
  cout<<(minans==0 ? 1 : minans)<<" "<<minans+red<<endl;
}

Measured memory_bytes: 256
// abc136_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int N, K;
vector<int> A;

bool check(int x){

    vector<P> nums(N);
    REP(i, N){
        nums[i].first = A[i] % x;
        nums[i].second = x - nums[i].first;
    }
    sort(ALL(nums));

    vector<ll> cumsum1(N+1), cumsum2(N+1);

    REP(i, N){
        cumsum1[i+1] = cumsum1[i] + nums[i].first;
        cumsum2[i+1] = cumsum2[i] + nums[i].second;
    }

    ll mn = INF;
    REP(i, N){
        if (cumsum1[i+1] == cumsum2[N] - cumsum2[i+1]) {
            mn = min(mn, cumsum1[i+1]);
        }
    }

    return mn <= K;
}

vector<ll> get_divisors(ll n){
    vector<ll> res;
    for (int i = 1; i * i < n; i++){
        if (n % i == 0){
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }
    sort(ALL(res));
    return res;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> K;
    A = vector<int>(N);
    REP(i, N) cin >> A[i];

    ll sm = accumulate(ALL(A), 0);
    auto divisors = get_divisors(sm);

    REP_REV(i, divisors.size()){
        ll d = divisors[i];

        if (check(d)){
            print(d);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
n,C=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
d=[[0]*(10**5+1) for i in range(C+1)]
for u in stc:
    s,t,c=u
    if d[c][s]==-1:
        d[c][s]=0
        if d[c][t]==1:
            d[c][t]=0
        else:
            d[c][t]=-1
    else:
        d[c][s]=1
        if d[c][t]==1:
            d[c][t]=0
        else:
            d[c][t]=-1
for i in range(1,C+1):
    for j in range(10**5):
        if d[i][j+1]==1:
            d[i][j]+=1
            d[i][j+1]=0
data=[0]*(10**5+1)
for j in range(1,C+1):
    data[0]+=d[j][0]
for i in range(1,10**5+1):
    for j in range(1,C+1):
        data[i]+=d[j][i]
    data[i]+=data[i-1]
print(max(data))

Measured memory_bytes: 87896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
using VI = vector<int>;

constexpr ll INF = 1000000007;

int main() {
    ll x;
    cin >> x;
    ll t = 100;
    int ans = 0;
    while (true) {
        if (t >= x) {
            break;
        }
        t += t * 0.01;
        ans++;
    }
    cout << ans <<"\n";
    return 0;
}

Measured memory_bytes: 3640
MOD = 10 ** 9 + 7
S = input()
if S[-1] == '?':
  dp = [1,1,1,1,1,1,1,1,1,1,0,0,0]
  dpsum = 10
else:
  dp = [0] * 13
  dp[int(S[-1])] = 1
  dpsum = 1

unitmod = 1
for i, c in enumerate(list(reversed(S))[1:]):
  ndp = [0] * 13
  ndpsum = 0
  unitmod = unitmod * 10 % 13
  if c == '?':
    s = set([1,2,3,4,5,6,7,8,9,10,11,12])
    tm = unitmod
    for _ in range(9):
      s.discard(tm)
      tm = (tm + unitmod) % 13
    for j in range(13):
      x = dpsum
      for e in s:
        x -= dp[(j-e) % 13]
        x %= MOD
      ndp[j] = x
      ndpsum += x
  else:
    mod = unitmod * int(c) % 13
    for j in range(13):
      x = dp[(j-mod) % 13]
      x %= MOD
      ndp[j] = x
      ndpsum += x
  dp = ndp
  dpsum = ndpsum % MOD
print(dp[5])

Measured memory_bytes: 49260
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vc<ll> a(n);
    ll ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    while(true)
    {
        sort(a.begin(),a.end());
        if(a[n-1]<n) break;
        ll cc=a[n-1]/n;
        a[n-1]-=cc*n;
        ans+=cc;
        //dbg(cc);
        for(int i=0;i<n-1;i++) a[i]+=cc;
    }
    print(ans);
}

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

public class Main {
    int H, W;
    boolean[][] map;
    void run() {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        map = new boolean[H + 2][W + 2];
        for (int h = 1; h <= H; h++) {
            String l = sc.next();
            for (int w = 1; w <= W; w++) {
                map[h][w] = l.charAt(w - 1) == '.';
            }
        }

        int ans = 0;
        for (int h = 1; h <= H; h++) for (int w = 1; w <= W; w++) {
            if (!map[h][w]) continue;
            ans = Math.max(ans, dijkstra(w, h));
        }
        System.out.println(ans);
    }
    int[] dx = {-1,0,1,0}, dy = {0, -1, 0, 1};
    int dijkstra(int sx, int sy) {
        boolean[][] visited = new boolean[H + 2][W + 2];
        LinkedList<Node> q = new LinkedList<>();
        visited[sy][sx] = true;
        q.addLast(new Node(sx, sy, 0));

        int ret = 0;
        while (!q.isEmpty()) {
            Node cur = q.removeFirst();
            ret = Math.max(ret, cur.c);

            for (int i = 0; i < 4; i++) {
                if (!map[cur.y + dy[i]][cur.x + dx[i]] || visited[cur.y + dy[i]][cur.x + dx[i]]) {
                    continue;
                }
                visited[cur.y + dy[i]][cur.x + dx[i]] = true;
                q.addLast(new Node(cur.x + dx[i], cur.y + dy[i], cur.c + 1));
            }
        }
        return ret;
    }

    class Node {
        int x, y, c;
        Node(int x, int y, int c) {
            this.x = x;
            this.y = y;
            this.c = c;
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

int main(){
    ll n;
    ll l=pow(10,15);
    cin >> n;
    for(int i=0; i<5; i++){
        ll k;
        cin >> k;
        l=min(l,k);
    }
    ll ans;
    if(n%l==0){
        cout << n/l+4 << endl;
    }
    else{
        cout << n/l + 5 << endl;
    }
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<queue>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,g[2010][2010],a[2010],vis[2010],in[2010];
int first[2010],cnte;
struct edge{
	int to,next;
}e[10010];
inline void add(int u,int v){
	e[++cnte]=(edge){v,first[u]};first[u]=cnte;in[v]++;
}
int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
void dfs(int u){
//	cout<<"dfs "<<u<<'\n';
	vis[u]=1;int i;
	for(i=1;i<=n;i++){
//		cout<<"	try "<<i<<" from "<<u<<' '<<g[u][i]<<'\n';
		if(!vis[i]&&!g[u][i]) add(u,i),dfs(i);
	}
}
struct gaygayquan{
	int val,id;
};
inline bool operator <(gaygayquan x,gaygayquan b){
	return x.val<b.val;
}
gaygayquan mp(int l,int r){
	return (gaygayquan){l,r};
}
priority_queue<gaygayquan>q;
int main(){
	memset(first,-1,sizeof(first));
	n=read();int i,j,v;gaygayquan gay;
	for(i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		for(j=1;j<i;j++){
			if(gcd(a[i],a[j])==1) g[i][j]=g[j][i]=1;
//			cout<<i<<' '<<j<<' '<<a[i]<<' '<<a[j]<<' '<<g[i][j]<<'\n';
		}
	}
	for(i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(i=1;i<=n;i++) if(!in[i]) q.push(mp(a[i],i));
	while(!q.empty()){
		gay=q.top();q.pop();
		printf("%d ",gay.val);
		for(i=first[gay.id];~i;i=e[i].next){
			v=e[i].to;in[v]--;
			if(in[v]==0) q.push(mp(a[v],v));
		}
	}
}


Measured memory_bytes: 16128
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    int n; cin>>n;
    double val=n*n;
    val=val*n;
    val=val/(27*1.0);
    cout<<fixed<<setprecision(10)<<val<<endl;
    
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e+5;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

void solve() {
    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<char>());

    int n = s.size(), m = t.size();
    if (n < m) {
        rep(i, n) {
            if (s[i] < t[i]) {
                cout << "Yes" << endl;
                return;
            }
            else if (s[i] > t[i]) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "Yes" << endl;
    }
    else {
        rep(i, m) {
            if (s[i] < t[i]) {
                cout << "Yes" << endl;
                return;
            }
            else if (s[i] > t[i]) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "No" << endl;
    }
}

int main() {
    solve();
	return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//---------------------------------------------
// priority queue
//---------------------------------------------
type pqi struct{ a, l, n int }

type priorityQueue []pqi

func (pq priorityQueue) Len() int            { return len(pq) }
func (pq priorityQueue) Swap(i, j int)       { pq[i], pq[j] = pq[j], pq[i] }
func (pq priorityQueue) Less(i, j int) bool  { return pq[i].a > pq[j].a }
func (pq *priorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqi)) }
func (pq *priorityQueue) Pop() interface{} {
	x := (*pq)[len(*pq)-1]
	*pq = (*pq)[0 : len(*pq)-1]
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K := getInt(), getInt()
	a := getInts(N)

	l := 0
	r := 1000001000
	for l+1 < r {
		m := (l + r) / 2
		cnt := 0
		for i := 0; i < N; i++ {
			cnt += (a[i]+m-1)/m - 1
		}
		// out(m, cnt)
		if K < cnt {
			l = m
		} else {
			r = m
		}
	}
	out(l + 1)
}


Measured memory_bytes: 5848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge {ll s,t,d;};
typedef vector<vector<Edge>> Graph;

ll sum(vi a){
  ll ret=0;
  for(ll i:a) ret+=i;
  return ret;
}

int main(){
  ll N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];

  if(N==1) {
    cout<<"YES"<<endl;
    return 0;
  }

  ll sm=sum(A);
  if(sm%(N*(N+1)/2)) {cout<<"NO"<<endl; return 0;}

  REP(i,N) {
    ll x=sm/(N*(N+1)/2)+A[i]-A[(i+1)%N];
    if(x<0||x%N) {cout<<"NO"<<endl; return 0;}
  }

  cout<<"YES"<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

class MergeTech {
public:
	vector<int> num;
	vector<int> group;
	vector<vector<int>> G;

	void init(int sz) {
		num.resize(sz, 0);
		group.resize(sz, 0);
		G.resize(sz, vector<int>(0, 0));

		for (int i = 0; i < sz; i++) { G[i].push_back(i); group[i] = i; }
	}
	bool unite(int u, int v) {
		u = group[u]; v = group[v];
		if (u == v) {
			if ((int)G[u].size() > num[u]) {
				num[u]++; return true;
			}
			else {
				return false;
			}
		}
		else {
			int Total1 = G[u].size() + G[v].size();
			int Total2 = num[u] + num[v];

			if (Total1 > Total2) {
				if (G[u].size() < G[v].size()) swap(u, v);
				for (int i = 0; i < G[v].size(); i++) {
					group[G[v][i]] = u;
					G[u].push_back(G[v][i]);
				}
				num[u] += num[v]; num[v] = 0; G[v].clear();
				num[u]++;
				return true;
			}
			else {
				return false;
			}
		}
	}
};

long long N, H, W, A[200009], B[200009], C[200009], Total;
vector<tuple<long long, long long, long long>> tup;
MergeTech UF;

int main() {
	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--;
		tup.push_back(make_tuple(C[i], A[i], B[i] + H));
	}
	sort(tup.begin(), tup.end());
	UF.init(H + W + 2);

	for (int i = tup.size() - 1; i >= 0; i--) {
		bool G = UF.unite(get<1>(tup[i]), get<2>(tup[i]));
		if (G == true) Total += 1LL * get<0>(tup[i]);
	}
	cout << Total << endl;
	return 0;
}

Measured memory_bytes: 22256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<vector<int>> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;


typedef queue<int> qi;
typedef queue<string> qs;


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


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

    ll M = 0;
    ll A = 0;
    ll R = 0;
    ll C = 0;
    ll H = 0;
    rep(i, n){
        string s;
        cin >> s;
        if(s[0] == 'M') M++;
        if(s[0] == 'A') A++;
        if(s[0] == 'R') R++;
        if(s[0] == 'C') C++;
        if(s[0] == 'H') H++;
    }

    vll mc = {M, A, R, C, H};

    ll ans = 0;
    repp(i, 0, 2) repp(j, i+1, 3) repp(k, j+1, 4){
        ans += mc[i] * mc[j] * mc[k];
    }

    cout << ans << endl;

    //rep(i, 5) cout << mc[i] << endl;

    //cout << M << A << R << C << H << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int main(){ 
  ll x;
  cin >>x;
  ll a=x/500;
  ll b=x%500;
  ll c=b/5;
  ll ans=a*1000+c*5;
  cout <<ans<<endl;
}
  
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	cout<<(n+1)*n/2<<endl;
	return 0;
}


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

typedef pair<int,int> pii;
typedef pair<pii,long long> piii;
vector<vector<long long>>d(501,vector<long long>(51,INF));
signed main(){
    int n,m;  cin>>n>>m;
    vector<vector<pii>>edge(n,vector<pii>());
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        --a,--b;
        edge[a].push_back(pii(b,c));
        edge[b].push_back(pii(a,c));
    }
    int v0,a,b,c; cin>>v0>>a>>b>>c;
    priority_queue<piii,vector<piii>,greater<piii>>que;
    d[0][v0]=0;
    que.push(piii(pii(0,0),v0));
    while(!que.empty()){
        piii now=que.top(); que.pop();
        int v=now.second;
        int _v=(v*a+b)%c;
        if(d[now.first.second][v]<now.first.first)continue;
        for(int i=0; i<edge[now.first.second].size();i++){
            pii next=edge[now.first.second][i];
            if(d[next.first][_v]<=now.first.first+next.second*v)continue;
            d[next.first][_v]=now.first.first+next.second*v;
            que.push(piii(pii(d[next.first][_v],next.first),_v));
        }
    }
    int ans=INF;
    rep(i,51)if(d[n-1][i]!=INF){
        vector<vector<long long>>_d(501,vector<long long>(51,INF));
        _d[n-1][i]=d[n-1][i];
        que.push(piii(pii(d[n-1][i],n-1),i));
        while(!que.empty()){
            piii now=que.top(); que.pop();
            int v=now.second;
            int _v=(v*a+b)%c;
            if(_d[now.first.second][v]<now.first.first)continue;
            for(int i=0; i<edge[now.first.second].size();i++){
                pii next=edge[now.first.second][i];
                if(_d[next.first][_v]<=now.first.first+next.second*v)continue;
                _d[next.first][_v]=now.first.first+next.second*v;
                que.push(piii(pii(_d[next.first][_v],next.first),_v));
            }
        }
        rep(i,51)ans=min(ans,_d[0][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    long long int x;
    cin>>x;
    long long int m=100;
    int ans=0;
    while(1){
        m+=m/100;
        ans++;
        if(m>=x){
            cout<<ans;
            return 0;
        }
    }

}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

int main() {

	ll N, K;
	cin >> N >> K;

	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	vector<ll> wa(N + 2 - K,0);
	vector<ll> abswa(N + 2 - K,0);

	repn(i, K) {
		wa[1] += a[i];
		abswa[1] += max(a[i],0);
	}

	for (ll i = 2; i <= N + 1 - K; i++) {
		wa[i] = wa[i - 1] - a[i - 1] + a[i + K - 1];
		abswa[i] = abswa[i - 1] - max(a[i - 1],0) + max(a[i + K - 1],0);
	}

	ll m = INF;
	repn(i, N + 1 - K) {
		m = min(m, abswa[i]-max(wa[i],0));
	}

	ll ans = -m;
	repn(i, N) ans += max(a[i],0);

	cout << ans;
	
	
	system("PAUSE");
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int c, i;
  
  if ( b /10 == 0 )
    c = a * 10 + b;
  else if ( b / 100 == 0 )
    c = a * 100 + b;
  else if ( b / 1000 == 0 )
    c = a * 1000 + b;
  
  while ( i * i < c ){
    i++;
  }
  
  if ( i * i == c )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
    int n, k, ans = 1;
    cin >> n >> k;
    for (int i = 0; i < n;i++){
        if(ans < k){
            ans *= 2;
        }
        else{
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

reds = []
for i in range(N):
    a, b = map(int, input().split())
    reds.append([a,b])
reds.sort(key=lambda x: x[1], reverse=True)

blues = []
for i in range(N):
    c, d = map(int, input().split())
    blues.append([c,d])
blues.sort()

flag = [False for i in range(N)]
ans = 0
for i in range(N):
    c, d = blues[i][0], blues[i][1]
    for j in range(N):
        if flag[j] == True:
            continue
        a, b = reds[j][0], reds[j][1]
        if c>a and d>b:
            flag[j] = True
            ans += 1
            break
print(ans)


Measured memory_bytes: 9108
N,M=map(int, input().split())
C = [ [0,0] for _ in range(N) ]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        C[p][1] = 1
    else:
        if C[p][1] == 0:
            C[p][0] += 1
ans = 0
pena = 0
for i in range(N):
    if C[i][1] == 1:
        ans += 1
        pena += C[i][0]
print(ans,pena)



Measured memory_bytes: 13172
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second                       
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(ll)(b); i++)       
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
/// ({ ... }) avoids some problems: http://kernelnewbies.org/FAQ/DoWhile0
/// In non-contest code it is probably better to use: do { ... } while(0)
#define TR(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {

    ll n;
    cin >> n;

    vector<double> v;
    FOR(i,0,n){
        double d;
        cin >> d;
        v.pb(d);
    }
    //sort
    sort(v.begin(),v.end());

    double sum = v[0];
    FOR(i,1,n){
        sum = (sum + v[i])/2;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int ans=1;
	for(int i=0;i<n;i++)
	{
		int temp1;
		int temp2;
		temp1 = ans*2;
		temp2 = ans+k;
		ans = min(temp1,temp2);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

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

typedef long long ll;

#define N 123456*2

bool isp[N+1];
int s[N+1]={};

int main(void) {
    int n;
    REP(i,N+1){
        isp[i]=1;
    }
    isp[0]=0;
    isp[1]=0;
    FOR(i,2,N/2){
        if (!isp[i]) continue;
        int k=2*i;
        while(k<=N){
            isp[k]=0;
            k+=i;
        }
    }
    FOR(i,1,N){
        s[i] = s[i-1] + isp[i];
    }
    while (cin>>n && n){
        cout << s[2*n] - s[n] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2364