akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAXN	55
#define MAXM	105
#define P	1000000007
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXM], f[MAXN][MAXM][MAXM];
int cnt[MAXN], smaller[MAXN];
void update(int &x, int y) {
	x = (x + y) % P;
}
int main() {
	int n, m;
	read(n), m = 2 * n - 1;
	for (int i = 1; i <= m; i++)
		read(a[i]);
	sort(a + 1, a + m + 1);
	for (int i = 2; i <= n; i++) {
		if (a[n - i + 1] != a[n - i + 2]) cnt[i] = smaller[i] = 1;
		if (a[n + i - 1] != a[n + i - 2]) cnt[i]++;
	}
	f[1][1][1] = 1;
	for (int i = 1; i < n; i++)
	for (int j = 1; j <= 2 * i - 1; j++)
	for (int k = 1; k <= j; k++) {
		int now = f[i][j][k];
		if (now == 0) continue;
		int goal = j + cnt[i + 1], last = k + smaller[i + 1];
		for (int q = 1; q <= goal; q++)
			if (q == last) update(f[i + 1][goal][q], now);
			else if (q < last) update(f[i + 1][goal - (last - q - 1)][q], now);
			else update(f[i + 1][goal - (q - last - 1)][last + 1], now);
	}
	int ans = 0;
	for (int i = 1; i <= m; i++)
	for (int j = 1; j <= i; j++)
		update(ans, f[n][i][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        Map<Integer, Integer> mapAns = new HashMap<Integer, Integer>();

        for(int i=1;i<=n;i++){
            int h = sc.nextInt();
            map.put(i, h);
            mapAns.put(i, 1);
        }
        for(int i=0;i<m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int ah = map.get(a);
            int bh = map.get(b);
            if(ah > bh){
                mapAns.put(b, 0);
            }else if(ah < bh){
                mapAns.put(a, 0);
            }else{
                mapAns.put(a, 0);
                mapAns.put(b, 0);
            }
        }
        sc.close();
        for(int ans : mapAns.values()){
            if(ans == 1){
                sum++;
            }
        }
        System.out.println(sum); 
    }
}


Measured memory_bytes: 76876
N = int(input())
A = sorted(map(int,input().split()),reverse = True)
answer = 0
i = 1
s = 0
answer = A[0]
if N == 2:
    anwer=A[0]
else:
    while True:
        s = (i+1)//2
        answer += A[s]
        i += 1
        if i == N-1:
            break
    
print(answer)

Measured memory_bytes: 104856
function main() {
  const arr = input[0].split(' ').map(num => parseInt(num, 10));
  const menseki = arr[0] * arr[1];
  const syuui = (arr[0] + arr[1]) * 2;
  console.log(menseki + ' ' + syuui);
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n')
  main();
});



Measured memory_bytes: 15560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[6];
  for(int i=1;i<=5;i++)
  cin>>a[i];
  int c;
  for(int i=1;i<=5;i++)
  {
   if(a[i]==0)
    c=i;
    }
    cout<<c;
    return 0;
   }

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

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs; 
typedef pair<int, int> pi;

#define ll long long;

int main (void)
{ 
    string str;
    cin >> str;
    if(str.back() != 's'){
    	cout << str << "s" << endl;
    }else if(str.back() = 's'){
    	cout << str << "es" << endl;
    }
	return 0;
}


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

int main() {
    string s;
    int k;
    cin >> s >> k;
    for (auto i = 0; i < (int)s.size(); i++) {
        int tmp = (26 - (s[i] - 'a')) % 26;
        if (i == (int)s.size() - 1 and k != 0) {
            cout << (char)((s[i] - 'a' + k) % 26 + 'a');
            continue;
        }
        if (tmp <= k) {
            k -= tmp;
            cout << (char)'a';
            continue;
        }
        cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 3684
# ABC_129 C

def stairs(n, a):
    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    for i in range(2, n+1):
        if i in a:
            continue
        dp[i] = dp[i-1] + dp[i-2]
            
    result = dp[n] % 1000000007

    print(result)

    
n, m = list(map(int, input().split()))
a = set(int(input()) for _ in range(m))


if __name__ == '__main__':
    stairs(n, a)

Measured memory_bytes: 460056
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a), __##i = (b); i < __##i; i += (s))
#define down(i, a, b, s) for (int i = (a), __##i = (b); __##i < i; i += (s))

const int maxn = 2e3 + 2;
const int mod = 1e9 + 7;

ll n, m, a[maxn], b[maxn], sum[maxn][maxn], dp[maxn][maxn];

ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }

int main(int argc, char const *argv[]) {
  // freopen("E.txt", "r", stdin);

  while (cin >> n >> m) {
    range(i, 0, n, 1) cin >> a[i];
    range(i, 0, m, 1) cin >> b[i];

    memset(dp, 0, sizeof(dp));
    memset(sum, 0, sizeof(sum));
    range(i, 0, n, 1) {
      range(j, 0, m, 1) {
        if (a[i] == b[j]) {
          dp[i][j] = 1;
          if (i >= 1 && j >= 1) dp[i][j] = add(dp[i][j], sum[i - 1][j - 1]);
        }
        sum[i][j] = dp[i][j];
        if (i >= 1) sum[i][j] = add(sum[i][j], sum[i - 1][j]);
        if (j >= 1) sum[i][j] = add(sum[i][j], sum[i][j - 1]);
        if (i >= 1 && j >= 1) sum[i][j] = sub(sum[i][j], sum[i - 1][j - 1]);
      }
    }
    cout << sum[n - 1][m - 1] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 62976
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 100500;
ll n;
ll a[N], b[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    forn(i, s.size() - 1) n += s[i] != s[i + 1];
    cout << n;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	static long long array[10000];
	long long t, i, j, n;
	long long sum =0;

	scanf("%lld\n", &n);

	for ( i = 0; i < n; i++) {
		scanf("%lld", &array[i]);

	}
	for ( i = 0; i < n-1; i++){
		for (j = n - 1; j > i; j--) {
			if (array[j] < array[j - 1]) {
				t = array[j]; array[j] = array[j - 1]; array[j - 1] = t;
			}
		}
	}
	for ( i = 0; i < n; i++) {
		sum += array[i];
	}

	
	printf("%lld %lld %lld\n", array[0], array[n - 1], sum);
}


Measured memory_bytes: 2124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s;

  cin >> s;

  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      if(s[i] == s[j] && i != j){
        puts("no");
        return 0;
      }
    }
  }

  puts("yes");
  
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    map<ll, ll> mp;
    for (ll i = 0; i < N; i++) {
        int a;
        cin >> a;
        ++mp[a];
    }

    ll sz = mp.size();
    if (sz == 1) {
        auto [a, b] = *mp.begin();
        if (a == 0) {
            prints()("Yes");
        }
        else {
            prints()("No");
        }
    }
    else if (sz == 2) {
        auto itr = mp.begin();
        int a1, b1, a2, b2;
        tie(a1, b1) = *itr;
        tie(a2, b2) = *next(itr);
        if (b1 > b2) {
            swap(a1, a2);
            swap(b1, b2);
        }
        if (b1 == N / 3 && b2 == N * 2 / 3 && a1 == 0) {
            prints()("Yes");
        }
        else {
            prints()("No");
        }
    }
    else if (sz == 3) {
        auto itr = mp.begin();
        int a1, b1, a2, b2, a3, b3;
        tie(a1, b1) = *itr;
        ++itr;
        tie(a2, b2) = *itr;
        ++itr;
        tie(a3, b3) = *itr;
        if (b1 == b2 && b2 == b3 && b3 == b1 && (a1 ^ a2 ^ a3) == 0) {
            prints()("Yes");
        }
        else {
            prints()("No");
        }
    }
    else {
        prints()("No");
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 8296
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val A = Array(N) { sc.next().toInt() }.sorted().reversed()
        val total = A.sum()

        if (A[M - 1] * 4 * M >= total) {
            pw.println("Yes")
        } else {
            pw.println("No")
        }
    }
}


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

int main() {
    int N, K; cin >> N >> K;
    int mx = (N-1)*(N-2)/2;
    if(K > mx){
        cout << -1 << endl;
    } else {
        int tuika = mx - K;
        cout << N-1 + tuika << endl;
        for (int i = 2; i <= N; i++){
            cout << 1 << " " << i << endl;
        }
        int cnt = 0;
        bool ok = false;
        for (int i = 2; i <= N-1; i++){
            for (int j = i+1; j <= N; j++){
                if(cnt == tuika){
                    ok = true;
                    break;
                }
                cout << i << " " << j << endl;
                cnt++;
            }
            if(ok)break;
        }
    }
    return 0;
}

Measured memory_bytes: 3616
import sys
def decode(s):
    x=""
    for c in s:
        if not (c==" " or c=="."):
            x+=chr(ord(c)+1)
        else:
            x+=c
    return x.replace(chr(ord("z")+1),"a")
for s in sys.stdin.readlines():
    for i in xrange(ord("z")-ord("a")+1):
        if "the" in s or "that" in s or "this" in s:
            print s[:-1]
            break
        s=decode(s)

Measured memory_bytes: 4212
// F
// DeP
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 3e3 + 5, P = 998244353;

int n, S;
int A[MAXN], f[MAXN][MAXN][3];

int main() {
    scanf("%d%d", &n, &S);
    for (int i = 1; i <= n; ++i) scanf("%d", A + i);
    f[0][0][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= S; ++j) {
            int d = f[i-1][j][0];
            f[i][j][0] = (f[i][j][0] + d) % P;
            d = (d + f[i-1][j][1]) % P;
            f[i][j][1] = (f[i][j][1] + d) % P;
            d = (d + f[i-1][j][2]) % P;
            f[i][j][2] = (f[i][j][2] + d) % P;
            if (j >= A[i]) {
                d = (f[i-1][j - A[i]][0] + f[i-1][j - A[i]][1]) % P;
                f[i][j][1] = (f[i][j][1] + d) % P, f[i][j][2] = (f[i][j][2] + d) % P;
            }
        }
    printf("%d\n", f[n][S][2]);
    return 0;
}

Measured memory_bytes: 105856
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
int main(){
	scanf("%lld",&n);
	int cnt=0;
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		if(i+1!=t)cnt++;
	}
	puts(cnt<=2?"YES":"NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b)
	{
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
	for (int i = a; i < b; ++i)
	{
		if (abs(b - i) == abs(a - i))
		{
			cout << i;
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	system("pause");
}

Measured memory_bytes: 504
#include <stdio.h>

int main(void)
{
  char Get[4];
  int Count = 0;
  int loop;
 
  scanf("%s", Get);
 
  for(loop=0; loop<3; loop++) {
    if('1' == Get[loop]) {
      Count++;
    }
  }
  
  printf("%d", Count);
  
  return 0;
}

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

int main(){
    int n;
    scanf("%d", &n);
    if(n % 2 == 0){
        printf("%f", (float)1/2);}
    else{
        float p = (float)((n+1)/2) / n;
        printf("%f", p);}
    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(llabs(a-b)<=t*(v-w))
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


int main() {

	int n;
	cin >> n;
	vector<ll> a(n + 1);
	rep(i, n + 1) cin >> a[i];
	vector<ll> b(n);
	rep(i, n) cin >> b[i];

	ll ans = 0;
	// 後ろから貪欲でいい
	for (int i = n  - 1; i >= 0; i--) {
		if (b[i] >= a[i + 1]) {
			ans += min(a[i], b[i] - a[i + 1]);
			a[i] = max(0LL, a[i] - (b[i] - a[i + 1]));
			ans += a[i + 1];
			a[i + 1] = 0;
		}
		else {
			ans += b[i];
			a[i + 1] -= b[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY 1
#define BLACK 2

int g_n, g_M[MAX][MAX];

int prim();

int main(){
  scanf("%d",&g_n);
  
  for(int i = 0; i < g_n; i++){
    for(int j = 0; j < g_n; j++){
      int e;
      scanf("%d",&e);
      if(e == -1) g_M[i][j] = INFTY;
      else g_M[i][j] = e;
    }
  }

  printf("%d\n",prim());
  
  return 0;
}

int prim(){
  int u, minv;
  int d[MAX], p[MAX], color[MAX];

  for(int i = 0; i < g_n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  
  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(int i = 0; i < g_n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(int v = 0; v < g_n; v++){
      if(color[v] != BLACK && g_M[u][v] != INFTY){
	if(d[v] > g_M[u][v]){
	  d[v] = g_M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(int i = 0; i < g_n; i++){
    if(p[i] != -1) sum += g_M[i][p[i]];
  }

  return sum;
}



Measured memory_bytes: 2108
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	i := sc.Text()

	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	s := nextStr()
	t := nextStr()

	if s == t[0:len(t)-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1756
S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  n;
    while(cin>>n,n){
        int num[1001],ta[1001],si[1001],su[1001];
        for(int i=0;i<n;i++)cin>>num[i]>>ta[i]>>si[i]>>su[i];
        cin>>num[1000]>>ta[1000]>>si[1000]>>su[1000];
        bool kawa=0;
        for(int i=0;i<n;i++){
            int sum=(ta[i]+su[i])*4+si[i]*9;
            if(ta[i]<=num[1000]&&si[i]<=ta[1000]&&su[i]<=si[1000]&&sum<=su[1000]){
                cout<<num[i]<<endl;
                kawa=1;
            }
        }
        if(!kawa)cout<<"NA\n";
    }
}

Measured memory_bytes: 1176
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int arr[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;

    cin>>n;

    for(int i = 0; i < n; i++){
        cin>>arr[i];
    }

    int curr = 1, cnt = 0;

    for(int i = 0; i < n; i++){
        if(arr[i] == curr){
            curr++;
            cnt++;
        }
    }

    (cnt == 0) ? cout<<-1<<endl : cout<<(n - cnt)<<endl;

    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
x,y = zip(*xy)

#import random
#N = 200000
#x = [random.randint(0,10**9) for i in range(N)]
#y = [random.randint(0,10**9) for i in range(N)]

def Prim(g,cost):
    h = []
    N = len(g.keys())
    visited = [False]*(N+1)
    visited[1] = True
    v = 1
    for nv in g[v]:
        heappush(h, (cost[(v,nv)], (v,nv)))
    res = []
    d = 0
    while True:
        c, (v,nv) = heappop(h)
        if visited[nv]:
            continue
        res.append((v,nv))
        d += c
        if len(res) == N-1:
            break
        visited[nv] = True
        for nnv in g[nv]:
            if not visited[nnv]:
                heappush(h, (cost[(nv,nnv)], (nv,nnv)))
    return res, d

xi = [(x,i+1) for i,x in enumerate(x)]
yi = [(y,i+1) for i,y in enumerate(y)]

xi.sort()
yi.sort()

diffx = [(x1-x0,i0,i1) for (x0,i0),(x1,i1) in zip(xi,xi[1:])]
diffy = [(y1-y0,i0,i1) for (y0,i0),(y1,i1) in zip(yi,yi[1:])]

g = defaultdict(set)
cost = defaultdict(lambda : 10**10)
for d,i0,i1 in diffx:
    g[i0].add(i1)
    g[i1].add(i0)
    cost[(i0,i1)] = min(cost[(i0,i1)],d)
    cost[(i1,i0)] = min(cost[(i0,i1)],d)
for d,i0,i1 in diffy:
    g[i0].add(i1)
    g[i1].add(i0)
    cost[(i0,i1)] = min(cost[(i0,i1)],d)
    cost[(i1,i0)] = min(cost[(i0,i1)],d)

res,ans = Prim(g,cost)
print(ans)



Measured memory_bytes: 228532
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;
const int MAX=(1<<15)+10;
bool is_prime[MAX];
void init() {
    rep(i,MAX) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<MAX;i++) if(is_prime[i]) {
        for(int j=i+i;j<MAX;j+=i) is_prime[j]=false;
    }
}
void solve() {
    int ans=0;
    rep(i,n) if(is_prime[i]) {
        if(is_prime[n-i]) {
            //cout<<i<<","<<n-i<<endl;
            if(i<=n-i) ans++;
        }
    }
    cout<<ans<<endl;
    
}
int main() {
    init();
    while(cin>>n) {
        if(!n) break;
        solve();
    }
    return 0;
}

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

using namespace std;

#define int long long
double pi = 3.14159265359;
signed main(){
	double deg;
	cin>>deg;
	double x = 0, y = 0;
	int count = 0;
	double dir = 90;
	while(true){
		dir += deg;
		
		double rad = dir * pi / 180.0;
		
		x += cos(rad); 
		y += sin(rad) ;
		count++;
		if(abs(x) < 0.000005 && abs(y) < 0.0000005){
			cout<<count<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4020
#include<stdio.h>
int main(){
  int h,a;
  scanf("%d %d",&h,&a);
  int sum=0,var;
  for(int i=0;i<a;i++){
    scanf("%d",&var);
    sum+=var;
  }
  if(sum>=h)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
mt=[]
high=[0,0,0]
for i in range(10):
    mt.append(int(input()))
    if  mt[i] > high[0]:
        high=[mt[i]]+high[:2]
    elif mt[i] > high[1]:
        high=[high[0]]+[mt[i]]+[high[1]]
    elif mt[i] > high[2]:
        high=high[:2]+[mt[i]]
print ('\n'.join(map(str,high)))

Measured memory_bytes: 7640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double> > vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#define all(x) x.begin(), x.end()
#define INF 1000000009
#define MOD 1000000007

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

	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int dp[200][200];

int main(){
	int D, N, max=0;
	int *T, *A, *B, *C;
	cin >> D >> N;
	T = new int[D];
	A = new int[N];
	B = new int[N];
	C = new int[N];

	rep(i, D) cin >> T[i];
	rep(i, N) cin >> A[i] >> B[i] >> C[i];

	rep(i, N) rep(j, D) dp[i][j] = -1;
	rep(i, N) if(A[i] <= T[D-1] && T[D-1] <= B[i]) dp[i][D-1] = 0;

	for(int d=D-2; d >= 0; d--){
		rep(i, N){
			if(dp[i][d+1] == -1) continue;
			rep(j, N){
				if(A[j] > T[d] || B[j] < T[d]) continue;
				dp[j][d] = dp[i][d+1] + fabs(C[j]-C[i]) > dp[j][d] ? dp[i][d+1] + fabs(C[j]-C[i]) : dp[j][d];
			}
		}
	}

	rep(i, N) max = max < dp[i][0] ? dp[i][0] : max;
	cout << max << endl;

	delete[] T;
	delete[] A;
	delete[] B;
	delete[] C;
	return 0;
}

Measured memory_bytes: 1352
#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<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

vector<int> x(1111);
//約数の個数
void calc(int N) {
	for (long long i = 2; i*i <= N; i++) {
		int m = 0;
		while (N%i == 0) { // 素数で割り切れなくなるまで割っていく
			m++;//割った個数を配列に足す
			N /= i;
		}
		if (0 != m) {
			x[i]+=m;
		}
		if (1 == N) {
			break;
		}
	}
	if (1 != N) {
		x[N]+=1;
	}
}

int main() {
	int N;
	cin >> N;
	mint ans = 1;
	for (int i = 1;i<=N;++i) {
		calc(i);
	}
	for (int i = 1; i <= N; ++i) {
		ans *= (x[i] + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#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<int,int>;

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 ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    int x;
    rep(i,5){
        cin >> x;
        if(x!=i+1){
            cout << i+1 << endl;
            return 0;
        }
    }


    return 0;
}

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

using namespace std;

int main () {
  
    int n, k;
    string s;
  
    cin >> n >> k >> s;
  
    for (int i=0; i< n; i++) {
      if (i == k-1) putchar( tolower(s[i]) );
      else cout << s[i];
    }
    
    return 0;

  
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func sumOfDegit(n int) int {
    var sum int
    for n > 0 {
        sum += n % 10
        n /= 10
    }
    return sum
}

func main() {
    var n, a, b, sum int
    fmt.Scan(&n, &a, &b)
    for i := 1; i < n+1; i++ {
        if v := sumOfDegit(i); a <= v && v <= b {
            sum += i
        }
    }
    fmt.Println(sum)
}

Measured memory_bytes: 512
import numpy as np
from numba import njit

n,k =map(int,input().split())
a= np.array(list(map(int,input().split())))

@njit(cache=True)
def light(n,a_list):
    outcome= np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        outcome[max(0,i-a_list[i])] += 1
        outcome[min(n,i+a_list[i]+1)] -= 1
    outcome = np.cumsum(outcome)[:-1]
    return outcome

for _ in range(k):
    if min(a) == n:
        break
    a = light(n,a)

[print(aa,end=' ') for aa in a]

Measured memory_bytes: 118800
#include <stdio.h>

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

#define NMAX 100000
#define KMAX 100000
#define WMAX 10000

int required_k(int w[], int n , long P, int kmax) {
/*
?????§??????????????°?????¨?????????????????????????????°??°k?????????
????????????kmax??\????????????????????´?????? kmax + 1 ?????????
*/
  int k = 1, sum = 0;

  REP(i, n) {
    if(w[i] > P) {
      return kmax + 1;
    } else {
      sum += w[i];
    }

    if(sum > P) {
      k += 1;
      sum = w[i];
      if(k > kmax) {
        return k;
      }
    }
  }

  if(sum > P) {
    k += 1;
  }

  return k;
}


int main(void) {
  int n, k;

  scanf("%d %d", &n, &k);

  int w[n];
  long Pmax = 0;
  REP(i, n) {
    scanf("%d", &w[i]);
    Pmax += w[i];
  }


  long left = 0, right = Pmax;
  long mid;
  int req_k;
  while(left + 1 < right) {
    mid = (left + right) / 2;
    req_k = required_k(w, n, mid, k);
    if(req_k > k) {
      left = mid;
    } else {
      right = mid;
    }
  }
  printf("%ld\n", right);


/*
  REP(i, 30) {
    printf("%d: %d\n", i, required_k(w, n, (long)i, k));
  }
*/

  return 0;
}

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

int main()
{
 long long int k,n,a[200001],i,d;
  
  scanf("%lld %lld",&k,&n);
  
  for(i=1;i<=n;i++)
  {
    scanf("%lld",&a[i]);
  }
  d=a[2]-a[1];
  for(i=2;i<n;i++)
  {
    if(d<(a[i+1]-a[i]))
    {
      d=a[i+1]-a[i];
    }
  }
  if(d<(a[1]+k-a[n]))
  {
    d=a[1]+k-a[n];
  }
  d=k-d;
  printf("%lld",d);
     
  
  return 0;
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd_m(int a, int b){
	if(a<b){int tmp = a;a=b;b=tmp;}
	if(b==0) return a;
	if(a%b==0) return b;
	else return gcd_m(b, a-b);
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N];
	int L[N+1];
	int R[N+1];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
  	int ans = 0;
	L[0] = 0;
	R[N] = 0;
	for (int i = 0; i < N; i++)
	{
		L[i+1] = gcd_m(L[i], A[i]);
		R[N-i-1] = gcd_m(R[N-i], A[N-i-1]);
	}
	for (int i = 0; i < N; i++)
	{
		int tmp = gcd_m(L[i], R[i+1]);
		ans = max(ans, tmp);
	}
	
	cout << ans << endl;	
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll n;
ll a[200009];
map<ll, ll> mp;

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

    cin >> n;
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, n) {
        if(mp.count(i - a[i])) ans += mp[i - a[i]];
        mp[i + a[i]]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

vint dx = {1,0,-1,0};
vint dy = {0,1,0,-1};

int h, w;
vector<string> field;
vector<vector<bool>> used;

ll dfs(int x, int y, char now, ll &n_b, ll &n_w) {
    used[y][x] = true;
    if (now == '.') n_w++;
    if (now == '#') n_b++;
    rep(i,4) {
        int n_x = x + dx[i], n_y = y + dy[i];
        if (n_x >= 0 && n_x < w && n_y >= 0 && n_y < h && !used[n_y][n_x]) {
            if (field[n_y][n_x] != now) {
                if (now == '.') dfs(n_x,n_y,'#',n_b,n_w);
                if (now == '#') dfs(n_x,n_y,'.',n_b,n_w);
            }
        }
    }
    return n_b * n_w;
}

int main() {
    cin >> h >> w;
    field.resize(h);
    rep(i,h) cin >> field[i];
    ll ans = 0;
    used.assign(h,vector<bool>(w,false));
    rep(i,h)rep(j,w) {
        if (field[i][j] == '#') {
            if (used[i][j]) continue;
            ll n_b = 0, n_w = 0;
            ans += dfs(j,i,'#',n_b,n_w);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15488
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
using namespace std;
int main()
{
	string a;
	cin >> a;
	int f, l;
	f = stoi(a.substr(0,2));
	l = stoi(a.substr(2,2));
	int ansf = 0, ansl = 0;
	if (1 <= f && f <= 12) {
		ansf = 1;
	}
	else if (0 <= f && f <= 19) {
		ansf = 2;
	}
	if (1 <= l && l <= 12) {
		ansl = 1;
	}
	else if (0 <= l && l <= 19) {
		ansl = 2;
	}

	if (ansf == 1 && ansl == 1) {
		cout << "AMBIGUOUS";
	}
	else if (ansf == 1) {
		cout << "MMYY";
	}
	else if (ansl == 1) {
		cout << "YYMM";
	}
	else {
		cout << "NA";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  
int a,b,c;
  int i = 0;
cin>>a>>b>>c;
  int j = a;
    
 while( j <= b ){
   if ( c % j == 0){
     i++;}
   j++;
 }
  cout<< i <<endl;
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}



  


int main() {
  ll n;
  cin >> n;
  auto pf = prime_factorize(n);
  ll res = 0;
  for (auto p : pf){
    ll e = p.second;
    ll tmp = 0,cur = 1;
    while (e >= cur){
      e -= cur++;
      ++tmp;
    }
      res += tmp;
  }
cout << res << endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 201;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
vector<bool> IsPrime;
void sieve(int max){
    if (max+1 > IsPrime.size()){     
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (int i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(int j=2; i*j<=max; ++j){
                IsPrime[i*j] = false; 
            }
        }
    }     
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    vector<ll> p(1000005,0);
    sieve(1002);
    vector<ll> pr;
    rep(i,1002){
        if (IsPrime[i]) pr.push_back(i);
    }
    for (ll k:a){
        ll m = k;
        for (ll s:pr){
            if (m%s == 0){
                p[s]++;
                while(m%s == 0){
                    m /= s;
                }
            }
        }
        if (m != 1) p[m]++;
    }
    bool ok = 1;
    for (ll u:p){
        if (u >= 2) ok = 0;
    }
    ll g = a[0];
    rep(i,n){
        g = gcd(g,a[i]);
    }
    if (ok) PRINT("pairwise coprime");
    else if (g == 1) PRINT("setwise coprime");
    else PRINT("not coprime");
}



Measured memory_bytes: 18768
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define MOD 1000000007

typedef long lint;
typedef pair<lint, lint> P;
typedef pair<P, lint> edge;

bool lessPair(const edge& l, const edge& r){return l.second < r.second;}

struct UnionFind {
  vector<lint> par;
  vector<lint> weight;

  UnionFind(int N, vector<lint> X) : par(N), weight(N) {
    for(int i = 0; i < N; i++) {
      par[i] = i;
      weight[i] = X[i];
    }
  }
  
  int root(lint x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(lint x, lint y) {
    lint rx = root(x);
    lint ry = root(y);
    if (rx == ry) return;
    weight[ry] = weight[rx] + weight[ry];
    par[rx] = ry;
  }

  bool same(lint x, lint y) {
    lint rx = root(x);
    lint ry = root(y);
    return rx == ry;
  }

  lint get_weight(lint x) {
    return weight[root(x)];
  }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint M; cin >> M;
    vector<lint> X(N);
    vector<edge> edges(M);
    vector<vector<P>> adj(N);
    
    REP(i, N) {
      lint x; cin >> x;
      X[i] = x;
    }

    REP(i, M) {
      lint a,b,y; cin >> a; cin >> b; cin >> y;
      edges[i] = edge(P(a-1, b-1), y);
      adj[a-1].push_back(P(b-1,y));
      adj[b-1].push_back(P(a-1,y));
    }

    sort(edges.begin(), edges.end(), lessPair);

    UnionFind uni(N, X);

    stack<edge> S;

    REP(i, M) {
      auto e = edges[i];
      auto a = e.first.first;
      auto b = e.first.second;
      auto y = e.second;

      if(!uni.same(a,b))  {
        if(uni.get_weight(a) + uni.get_weight(b) >= y) {
          S.push(e);
          //          PRINT("dif");
          //          PRINT(e.second);
          
        }
      } else if(uni.get_weight(a) >= y) {
        S.push(e);
        //        PRINT(e.second);
      }
      
            
         

      uni.unite(a,b);
    }

    vector<bool> flag(N, false);
    lint res = 0;

    while(!S.empty())  {
      edge e = S.top();
      S.pop();

      if(flag[e.first.first]) continue;
      flag[e.first.first] = true;

      queue<lint> Q;
      Q.push(e.first.first);
      while(!Q.empty()) {
        lint i = Q.front();
        Q.pop();
        
        REP(j, adj[i].size()) {
          lint m = adj[i][j].first;
          if(adj[i][j].second > e.second) continue;
          res++;
          if(flag[m]) continue;
          flag[m] = true;
          Q.push(m);
        }
      }
    }

    PRINT(M-res/2);
    return 0;
}


Measured memory_bytes: 14960
N = int(raw_input())
data = []
for i in range(N):
    v = map(int, raw_input().split())
    data.append(v)

cond = []
for x in range(100+1):
    for y in range(100+1):
        h = []
        for d in data:
            if d[2] != 0:
                h.append(d[2] + abs(d[0]-x) + abs(d[1]-y))
        if len(set(h)) == 1:
            cond.append((x, y, h[0]))

if len(cond) == 1:
    print cond[0][0], cond[0][1], cond[0][2]
else:
    for c in cond:
        res = []
        for d in data:
            if d[2] == 0:
                if c[2] - (abs(d[0]-c[0]) + abs(d[1]-c[1])) <= 0:
                    res.append(True)
                else:
                    res.append(False)
        if all(res):
            print c[0], c[1], c[2]
            exit(0)



Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
using Graph = vector<vector<ll> >;
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 ll INF = 1e18;


//入力
ll n,m;

//Warshall-floyd
ll dp[310][310];//dpテーブルには辺がないところにはINF、i==jには０を入れておく
void warshallfloyd(){
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
}



struct Edge{
    ll from,to,cost;
};


int main(){
    cin >> n >> m;
    vector<Edge> edge(m);
    rep(i,310)rep(j,310)dp[i][j]=INF;
    rep(i,310)dp[i][i]=0;

    //ワーシャルフロイドで全地点間最短距離を求める
    rep(i,m){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        edge[i].from=a;
        edge[i].to=b;
        edge[i].cost=c;
        dp[a][b]=c;
        dp[b][a]=c;
    }
    warshallfloyd();
    ll ans = 0;
    rep(i,m){
        ll a = edge[i].from;
        ll b = edge[i].to;
        ll c = edge[i].cost;
        if(dp[a][b]<c)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4344
#include<stdio.h>
#include<string.h>
int main(){
	int n,r,a,b,c,d;
	while(scanf("%d",&n)!=EOF){
		r=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n){
							r++;
						}
					}
				}
			}
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2576
#include<stdio.h>
int main()
{
    int i=0;
    char str[1199],str2[1199];
    fgets(str, 1199, stdin);
    while(str[i]!='\0')
    {
        if(str[i]>=97&&str[i]<=122)
        {
            str2[i] = str[i]-32;
        }
        else if(str[i]>=65&&str[i]<=90)
        {
            str2[i] = str[i]+32;
        }
        else
        {
            str2[i] = str[i];
        }
        i++;
    }
    str2[i] = '\0';
   printf("%s",str2);
    return 0;
}



Measured memory_bytes: 2056