akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N,C;
	cin>>N>>C;
	
	vector<vector<int>> D(C,vector<int> (C));
	
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			cin>>D[i][j];
		}
	}
	
	vector<vector<int>> c(3,vector<int>(C,0));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int x;
			cin>>x;
			x--;
			c[(i+j+2)%3][x]++;
		}
	}
	
	int ans = Inf;
	
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			for(int k=0;k<C;k++){
				if(i==j||j==k||k==i)continue;
				
				int now = 0;
				for(int a=0;a<C;a++){
					now += c[0][a] * D[a][i];
				}
				for(int a=0;a<C;a++){
					now += c[1][a] * D[a][j];
				}
				for(int a=0;a<C;a++){
					now += c[2][a] * D[a][k];
				}
				
				ans = min(ans,now);
	
			}
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

def bfs(start):
    INF = 10 ** 9
    dist = [INF] * (H*W)
    dist[start] = 0
    q = deque([start])
    move_list = [-1, 1, W, -W]
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in move_list:
            w = v + move
            if grid[w] == '#':
                continue
            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)
    return dist[-(W+2)]

d = bfs(W+1)
T = grid.count("#")

if d == 10 ** 9:
  print("-1")
else:
  print(H*W - T - (d+1))

Measured memory_bytes: 9316
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>

using namespace std;

int n, k;
string data[10];
set<int> used;

int solve(){
  used.clear();
  string tmp;
  for(int i1=0;i1<n;++i1){
    tmp = data[i1];
    for(int i2=0;i2<n;++i2){
      if(i2 == i1) continue;
      tmp = data[i1] + data[i2];
      if(k>2){
	for(int i3=0;i3<n;++i3){
	  if(i3 == i1 || i3 == i2) continue;
	  tmp = data[i1] + data[i2] + data[i3];
	  if(k>3){
	    for(int i4=0;i4<n;++i4){
	      if(i4 == i1 || i4 == i2 || i4 == i3) continue;
	      tmp = data[i1] + data[i2] + data[i3] + data[i4];
	      used.insert(atoi(tmp.c_str()));
	    }
	  }else used.insert(atoi(tmp.c_str()));
	}
      }else used.insert(atoi(tmp.c_str()));
    }
  }
  return (int)used.size();
}

main(){
  while(cin >> n >> k && (n || k)){
    for(int i=0;i<n;++i){
      cin >> data[i];
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
ll a,b;
//ld ;
string s,t,u;
// char c;

int main() {
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s==u){
    cout << a-1 << ' ' << b << endl;
  }else{
    cout << a << ' ' << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[100010];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i-1]<a[i])a[i]--;
		if(a[i-1]>a[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
#include<string>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<iostream>

using namespace std;
int main(){
int M,D;
cin >> M >> D;
int cnt=0,a,b;
for(int i=22;i<=D;i++){
a=i/10; //十位 

b=i%10;//各位 
if(b<2) continue;
if(a*b <= M && a*b>=4) cnt++;
}
cout<< cnt<<endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>
using namespace std;
#define sz(x) ((int)(x).size())

int main() {
	long long a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	long long ans = min(b, c) * 2;
	b -= ans / 2;
	c -= ans / 2;
	long long ans2 = min(a, max(b, c));
	a -= ans2;
	c -= ans2;
	printf("%lld\n", ans + ans2 + (c > 0));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b;
    cin >> a >> b;
    if(b==1) {
        cout << 0 << endl;
        return 0;
    }
    cout << (b-1+a-2)/(a-1) << endl;
}

Measured memory_bytes: 256
//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll n, ans, x;
string s;

int main(){
	fast_io;
	
	cin >> s;
	n = s.size();
	for(ll i = 0; i < (1ll << (n - 1)); i++){
		x = 0;
		for(ll j = 0; j < n; j++){
			x = (x * 10) + (s[j] - '0');
			if((i >> j) & 1) ans += x, x = 0;
		}
		ans += x;
	}
	cout << ans;
	
	return 0;
}

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

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

	cin >> n;

	for(int i = 0;i < n;++i){
		a.push_back(1);
		cin >> a[i];
	}

	sort(a.begin(),a.end());

	cout << a[n-1] - a[0] <<endl;



}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define INF 1e10

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <iostream>
#include <set>
#include <map>


using namespace std;

int prim[1230] = { 2,3 };

void prime(void)
{
	int tally = 2;
	int i, j, flag;
	for (i = 5; i<1010; i += 2)
	{
		for (j = 0, flag = 1; prim[j] * prim[j] <= i; j++)
			if (i%prim[j] == 0)
				flag = 0;
		if (flag)
		{
			prim[tally] = i;
			tally++;
		}

	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input1.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);

	prime();

	int n;
	while (cin >> n)
	{
		int so[1010];
		for (int a = 0; a <= n; a++)
			so[a] = 1;
		for (int a = 2; a <= n; a++)
		{
			int tmp = a;
			int b = 0;
			while (prim[b] <= a)
			{
				if (tmp%prim[b] == 0)
				{
					so[prim[b]]++;
					tmp /= prim[b];
					b = 0;
				}
				else
					b++;
			}

		}
		long long res = 1;
		for (int a = 2; a <= n; a++)
		{
			res *= so[a];
			res %= 1000000007;
		}
		cout << res << endl;
	}

	return 0;
}

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b <= c*d){
		cout << c*d << endl;
	}
	else{
		cout << a*b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long r = sc.nextInt();
		long d = sc.nextInt();
		long x = sc.nextInt();

		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			pr.println(x);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

using namespace std;

const int N = 205;
const int M = 5000005;
const int inf = 1e9;

struct Edge {
  int v, w, next;
} g[M];

int cnt = 0, head[N], st, ed, dis[N], cur[N];

void init() {
  memset(head, -1, sizeof(head));
  cnt = 0;
}

void addedge(int u, int v, int w = 1) {
  g[cnt].v = v, g[cnt].w = w, g[cnt].next = head[u], head[u] = cnt++;
  g[cnt].v = u, g[cnt].w = 0, g[cnt].next = head[v], head[v] = cnt++;
}

bool bfs() {
  memset(dis, -1, sizeof(dis));
  dis[st] = 0;
  queue<int> q;
  q.push(st);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; ~i; i = g[i].next) {
      int v = g[i].v, w = g[i].w;
      if (w && dis[v] == -1) {
        dis[v] = dis[u] + 1;
        q.push(v);
        if (v == ed) return true;
      }
    }
  }
  return false;
}

int dfs(int u, int limit) {
  if (u == ed) return limit;
  int ans = 0;
  for (int& i = cur[u]; ~i; i = g[i].next) {
    int v = g[i].v, w = g[i].w;
    if (w && dis[v] == dis[u] + 1) {
      int t = dfs(v, min(limit - ans, w));
      g[i].w -= t;
      g[i ^ 1].w += t;
      ans += t;
      if (ans == limit) break;
    }
  }
  if (!ans) dis[u] = -1;
  return ans;
}

int dinic(int n) {
  int ans = 0;
  while (bfs()) {
    for (int i = 1; i <= n; i++) cur[i] = head[i];
    ans += dfs(st, inf);
  }
  return ans;
}

int main(int argc, const char* argv[]) { 
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  init();
  st = n + m + 1, ed = n + m + 2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < m; j++) {
      if (a[i][j] != '.') {
        if (a[i][j] == 'S') {
          addedge(st, i + 1, 100000);
          addedge(st, j + n + 1, 100000);
        } else if (a[i][j] == 'T') {
          addedge(i + 1, ed, 100000);
          addedge(j + n + 1, ed, 100000);
        } else {
          addedge(i + 1, j + n + 1, 1);
          addedge(j + n + 1, i + 1, 1);
        }
      }
    }
  }
  int mx = dinic(n + m + 2);
  cout << (mx >= 100000 ? -1 : mx) << endl;
  return 0; 
}


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


int main() {
	int x; cin >> x;
	bool f = true;
	while (f) {
		bool f1 = true;
		for (int i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				f1 = false;
				break;
			}
		}
		if (f1) {
			f = false;
		}
		else {
			x++;
		}
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 10;
int n, m, k, A[maxn], B[maxn];
signed main(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i){
        cin >> A[i]; A[i] += A[i - 1];
    }
    for(int i = 1; i <= m; ++i){
        cin >> B[i]; B[i] += B[i - 1];
    }
    int ans = 0;
    int pa = 1, pb = 1;
    while (pb <= m && B[pb] <= k) pb ++;
    ans = --pb;
    for(pa = 1 ; A[pa] <= k && pa <= n; ++pa){
        while (A[pa] + B[pb] > k) pb --;
        ans = max(ans, pa + pb);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6672
#include"bits/stdc++.h"

using namespace std;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int ans = 0;

	for (int i = 0; i < 1000000; i++) {
		if (Y*i + Z*(i + 1) <= X) {
			ans = i;
		}
		else {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, p, q, ans;
vector<int> x, y;
int cost[60];

bool che(int a, int b)
{
    return p == a && q == b;
}
void solve(int X)
{
    rep(i, n)
    {
        if (i == X)
            continue;
        int dx = x[X] - x[i], dy = y[X] - y[i];
        if (che(dx, dy))
            cost[i] = 0;
    }
}

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

    cin >> n;
    x.resize(n), y.resize(n);
    rep(i, n) cin >> x[i] >> y[i];
    ans = INF;
    rep(i, n)
    {
        rep(j, n)
        {
            int dx = x[i] - x[j], dy = y[i] - y[j];
            p = dx, q = dy;
            rep(k, n) cost[k] = INF;
            rep(k, n)
            {
                if (cost[k] == INF)
                    cost[k] = 1;
                solve(k);
            }
            int tmp = 0;
            rep(i, n) tmp += cost[i];
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=10;
    int ara[12];
    for(int i=0;i<n;i++)
    {
        cin>>ara[i];
    }
    sort(ara,ara+n);
        for(int i=n-1;i>=7;i--)
    {
        cout<<ara[i]<<endl;
    }
    return 0;

}

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

// 2つの整数の場合
long long GetLeastCommonMultiple(long long a, long long b) {
	long long m = a;
	long long n = b;
	long long temp;
	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return a / n * b;
}

ll func(ll x, ll c, ll d) {
	ll canC = x / c;
	ll canD = x / d;
	ll lcm = GetLeastCommonMultiple(c, d);
	ll canCandD = x / lcm;
	return x - canC - canD + canCandD;
}

int main() {

	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << func(b, c, d) - func(a - 1, c, d) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;

int n, a[N], b[N];

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

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    
    int j = 0, bef = -1;
    for (int i = 0; i < n; i++) {
        if (bef != a[i]) j = 0; 
        if (a[i] == b[i]) {
            for (; j < n; j++) {
                if (a[j] != a[i] && b[j] != a[i]) {
                    swap(b[i], b[j]);
                    break;
                }
            }
            if (a[i] == b[i]) {
                cout << "No";
                return 0;
            }
        }
        bef = a[i];
    }
    cout << "Yes\n";
    for (int i = 0; i < n; i++) {
        if (i) cout << ' ';
        cout << b[i];
    }
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
cin >> s;
if (s.at(2)==s.at(3) && s.at(4)==s.at(5))
{
    cout << "Yes" <<endl;
}
else
{
    cout << "No" <<endl;
}


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,t,ans;
vector<pair<long long,long long> >ab0,ab;
vector<vector<long long> >dp;
vector<long long>sum;
inline bool cmp0(pair<long long,long long>a,pair<long long,long long>b) {
	return a.second<b.second;
}
inline bool cmp(pair<long long,long long>a,pair<long long,long long>b) {
	return a.first*(b.second+1)>b.first*(a.second+1);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>t;
	for(long long i=0;i<n;i++) {
		long long a,b;
		cin>>a>>b;
		if(a==0) ab0.push_back(make_pair(a,b));
		else ab.push_back(make_pair(a,b));
	}
	sort(ab0.begin(),ab0.end(),cmp0);
	sum.resize(ab0.size()+1,0);
	for(long long i=0;i<ab0.size();i++) sum[i+1]=sum[i]+ab0[i].second+1;
	sort(ab.begin(),ab.end(),cmp);
	dp.resize(ab.size()+1,vector<long long>(40,2e9));
	dp[0][0]=0;
	for(long long i=0;i<dp.size()-1;i++)
		for(long long j=0;j<39;j++) {
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+1+ab[i].first*(dp[i][j]+1)+ab[i].second);
		}
	for(long long i=0;i<40;i++)
		if(dp[dp.size()-1][i]<=t)
			for(long long j=sum.size()-1;j>=0;j--)
				if(dp[dp.size()-1][i]+sum[j]<=t) {
					ans=max(ans,i+j);
					break;
				}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 74348
package main

import "fmt"

func gcd(a, b int) int {
	if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}

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

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	xs := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	ans := diff(xs[0], x)
	for _, v := range xs {
		ans = gcd(ans, diff(v, x))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  map<ll,ll> cnti;
  map<ll,ll> cntj;
  for(ll i=0;i<n;i++) {
    cnti[a[i]+i]++;
    cntj[i-a[i]]++;
  }
  ll ans=0;
  for(auto p:cnti) {
    ans+=p.second*cntj[p.first];
  }
  cout << ans << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int d,t,s;
    cin >> d >> t >> s;
  	float tt;
  	tt = (float)d/s;
  	if(tt<=t)
      cout <<"Yes";
  	else
      cout<<"No";
    return 0;
}

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

using pii = pair<int, int>;
constexpr int INF = 1e9;

struct edge {
    int to, cost, id;
};

using edges = vector<edge>;
using graph = vector<edges>;

struct state {
    int v, id;
    pii cost;
    bool operator<(state const& s) const {
        return cost > s.cost;
    }
};

int main() {
    int N, T;
    cin >> N >> T;
    map<string, int> id;
    string A, B;
    cin >> A >> B;
    id[A] = 0;
    id[B] = 1;
    graph g(1000001);
    int now = 0;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        vector<int> idx(a);
        for(int j=0; j<a; ++j) {
            string s;
            cin >> s;
            if(id.count(s) == 0) {
                id[s] = id.size()-1;
            }
            idx[j] = id[s];
        }
        g.resize(id.size());
        for(int j=0; j<a-1; ++j) {
            int t;
            cin >> t;
            g[idx[j]].push_back(edge{idx[j+1], t, now});
            g[idx[j+1]].push_back(edge{idx[j], t, now});
            now++;
        }
        now++;
    }
    vector<pii> d(100001, make_pair(INF, INF));
    priority_queue<state> que;
    que.push(state{0, -1, make_pair(0, 0)});
    pii res = make_pair(INF, INF);
    while(!que.empty()) {
        state now = que.top();
        que.pop();
        if(now.id != -1 && d[now.id] < now.cost) {
            continue;
        }
        if(now.v == 1) {
            res = now.cost;
            break;
        }
        for(auto& e : g[now.v]) {
            int cost = e.cost;
            bool trans = false;
            if(now.id != -1 && abs(now.id - e.id) != 1) {
                cost += T;
                trans = true;
            }
            auto next = make_pair(now.cost.first + cost, now.cost.second + trans);
            if(d[e.id] > next) {
                d[e.id] = next;
                que.push(state{e.to, e.id, next});
            }
        }
    }

    if(res.first == INF) {
        cout << -1 << endl;
    } else {
        cout << res.first << ' ' << res.second << endl;
    }
}


Measured memory_bytes: 38244
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()

def main():
    N = I()
    s = S()
    Left = ""

    countO = 0
    for x in s:
        if x==")" and countO == 0:
            Left = "("+Left
        elif x==")":
            countO -= 1
        elif x=="(":
            countO += 1
    return(Left+s+")"*countO)


if __name__ == "__main__":
    print(main())

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

const int M = 1000005;

int main(){
  int N;
  cin >> N;
  multiset<int> A;
  rep(i,N){
    int a;
    cin >> a;
    A.insert(a);
  }
  vector<int> B(M);
  for(int j : A){
    if(B[j]>1){
      continue;
    }
    for(int i=j;i<M;i+=j){
      B[i]++;
    }
  }
  int C=0;
  for(int i : A){
    if(B[i]==1) C++;
  }
  cout << C << endl;
}

Measured memory_bytes: 16404
# -*- coding:utf-8 -*-
X = int(input())

sosu_list = [2]

for num in range(3,X+1,2):
    if all(num%sosu != 0 for sosu in sosu_list):
        sosu_list.append(num)

if X == sosu_list[-1]:
    print(X)
else:
    if X % 2 ==0:
        X+=1
    while True:
        if all(X%sosu != 0 for sosu in sosu_list):
            print(X)
            break
        X += 2


Measured memory_bytes: 69092
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(d>=abs(a-c)||abs(a-b)<=d&&abs(b-c)<=d){
  cout<<"Yes"<<endl;
  
  }
  else{
  cout<<"No"<<endl;
  }

}


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

namespace ABC130_1
{
    class B
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var sum = 0;
            var res = 1;
            for (int i = 1; i < a[0] + 1; i++)
            {
                sum += l[i - 1];
                if (a[1] < sum) break;
                res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(A==7 || B==7 || C==7){
			if(A==7){
				if(B==5 && C==5){
				System.out.println("YES");
				}else{
				System.out.println("NO");
				}
			}else if(B==7){
				if(C==5 && A==5){
				System.out.println("YES");
				}else{
				System.out.println("NO");
				}
			}else if(C==7){
			 if(A==5 && B==5){
			  System.out.println("YES");
			 }else{
			  System.out.println("NO");
			 }
            }else{
			}
		}else{
		System.out.println("NO");
		}
    	sc.close();
	}

}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

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

const double PI = 3.14159265358979;

struct Edge{ ll to, cost; };
void solve()
{
  ll n, m, l, r, d;
  cin >> n >> m;
  vector< vector<Edge> > G(n, vector<Edge>());
  for(int i = 0; i < m; ++i)
  {
    cin >> l >> r >> d;
    l--; r--;
    G[l].emplace_back(Edge{r, d});
    G[r].emplace_back(Edge{l, -d});
  }

  const ll INF = 1LL << 60;
  vector<bool> seen(n, false);
  vector<ll> dist(n, INF);
  for(int i = 0; i < n; ++i)
  {
    if (seen[i] == false)
    {
      // BFS(i);
      queue<ll> que;
      que.push(i);
      while(!que.empty())
      {
        int now = que.front();
        que.pop();
        if (seen[now]) continue;
        seen[now] = true;
        for(const auto& e : G[now])
        {
          if (dist[e.to] == INF)
          {
            dist[e.to] = dist[now] + e.cost;
          }
          else if (dist[e.to] != dist[now] + e.cost)
          {
            cout << "No";
            return;
          }
          que.push(e.to);
        }
      }
    }
  }
  cout << "Yes";
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, sum=0, in;
vector<int> S;
bool f = true;

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> in;
		S.push_back(in);
		sum += in;
	}
	sort(S.begin(), S.end());
	if((sum%10) == 0){

		for(int i = 0; i < N && f; i++){
			if(S[i] % 10 != 0){
				cout << sum - S[i] << endl;
				f = false;
				break;
			}
		}
		if(f){
			cout << 0 << endl;
		}

	}else{
		cout << sum << endl;
	}

  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

	int ans=0,sum=0;
	for (int i = 0; i < n-1; ++i){
		if(a[i]>=a[i+1]){
			sum++;
		}else{
			ans=max(ans,sum);
			sum=0;
		}
	}

	ans=max(ans,sum);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
using namespace std;

char maze[20][20];
int h, w;

int search(int a, int b){
	int dist1[4] = {1, 0, -1, 0};
	int dist2[4] = {0, 1, 0, -1};
	int reached[20][20];
	for (int i = 0; i < 20; i++){
		for (int j = 0; j < 20; j++){
			reached[i][j] = -1;
		}
	}
	queue<pair<pair<int, int>, int> > que;
	que.push(make_pair(make_pair(a, b), 0));
	reached[a][b] = 0;

	while(!que.empty()){
		int nowx = que.front().first.first, nowy = que.front().first.second, coun = que.front().second;
		que.pop();
		for (int i = 0; i < 4; i++){
			int x = nowx+dist1[i], y = nowy+dist2[i];
			if (x >= 0 && x < h){
				if (y >= 0 && y < w){
					if (maze[x][y] == '.'){
						if (reached[x][y] == -1){
							reached[x][y] = coun+1;
							que.push(make_pair(make_pair(x, y), coun+1));
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 20; i++){
		for (int j = 0; j < 20; j++){
			ans = max(ans, reached[i][j]);
		}
	}
	return ans;
}


int main(){
	int ans = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			cin >> maze[i][j];
		}
	}
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (maze[i][j] == '.'){
				ans = max(search(i, j), ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10 ** 9 + 7


def main():
    n, m = map(int, readline().split())
    # a = readlines()
    As = set(map(int, readlines()))
    # diff_a = [a[i+1] - a[i] for i in range(m - 1)]
    # if 1 in diff_a:
    #     print(0)
    #     return
 
    p1, p2 = 1, 1
    if 1 in As:
        p1 = 0

    for i in range(2, n + 1):
        if i in As:
            p1, p2 = 0, p1
        else:
            p1, p2 = (p1 + p2) % MOD, p1

    print(p1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16796
#include <bits/stdc++.h>
using namespace std;
char s1[105],s2[105];
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>s1[i];
	for (int i=1;i<=n;i++)  cin>>s2[i];
	for (int i=1;i<=n;i++)  cout<<s1[i]<<s2[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import bisect
sys.setrecursionlimit(10**6)

N=int(input())
A=[0]+list(map(int,input().split()))

E=[[] for i in range(N+1)]
for i in range(N-1):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[0]*(N+1)
USE[1]=1
ANS=[0]*(N+1)
DP=[]

def dfs(x):
    pos=bisect.bisect_left(DP,A[x])
    
    if pos<len(DP):
        changepos=pos
        old=DP[pos]
        
        DP[pos]=A[x]
    else:
        changepos=pos
        old=-1
        
        DP.append(A[x])

    ANS[x]=len(DP)

    for to in E[x]:
        if USE[to]==0:
            USE[to]=1
            dfs(to)

    if old==-1:
        DP.pop()
    else:
        DP[changepos]=old

dfs(1)

print(*ANS[1:])

Measured memory_bytes: 224568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;
int dp[310][310][310];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m), x(m);
	vector<PP> p(m);
	rep(i, m) {
		cin >> l[i] >> r[i] >> x[i];
		p[i].first = r[i];
		p[i].second.first = l[i];
		p[i].second.second = x[i];
	}
	sort(all(p));
	rep(i, m) {
		r[i] = p[i].first;
		l[i] = p[i].second.first;
		x[i] = p[i].second.second;
	}
	int idx = 0;
	dp[0][0][0] = 1;
	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				dp[i + 1][j][k] += dp[i][j][k];
				dp[i + 1][j][k] %= mod;
				dp[i + 1][i][k] += dp[i][j][k];
				dp[i + 1][i][k] %= mod;
				dp[i + 1][i][j] += dp[i][j][k];
				dp[i + 1][i][j] %= mod;
			}
		}
		while (idx < m && r[idx] == i + 1) {
			rep(j, n) {
				rep(k, n) {
					if (x[idx] == 1) {
						if (j >= l[idx]) dp[i + 1][j][k] = 0;
					}
					else if (x[idx] == 2) {
						if (k >= l[idx] || l[idx] > j) dp[i + 1][j][k] = 0;
					}
					else {
						if (l[idx] > k) dp[i + 1][j][k] = 0;
					}
				}
			}
			idx++;
		}
	}
	/*rep(j, n) {
		rep(k, n) {
			cerr << dp[3][j][k] << ' ';
		}
		cerr << endl;
	}*/
	int ans = 0;
	rep(j, n) {
		rep(k, n) {
			ans += dp[n][j][k];
			ans %= mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 226816
def solve(h1, m1, h2, m2, k):
    res = (h2 - h1) * 60 + (m2 - m1) - k
    return res


def main():
    h1, m1, h2, m2, k = map(int, input().split())
    res = solve(h1, m1, h2, m2, k)
    print(res)


def test():
    assert solve(10, 0, 15, 0, 30) == 270
    assert solve(10, 0, 12, 0, 120) == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9188
#include<stdio.h>

int main()
{
  int m, f, b;

  scanf( "%d %d %d", &m, &f, &b );

  if( m >= b ) printf( "0\n" );
  else if( m + f < b ) printf( "NA\n" );
  else printf( "%d\n", b - m );

  return 0;

}

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

int main(){
  int H, W;
  cin >> H >> W;
  rep(i, W+2){
    cout << "#";
  }
  cout << endl;
  rep(i, H){
    string s;
    cin >> s;
    cout << "#" + s + "#" << endl;
  }
  rep(i, W+2){
    cout << "#";
  }
  cout << endl;
  
}

Measured memory_bytes: 256
main(a,b,c,p,q,r,s,i,j){for(;scanf("%d%d%d",&a,&b,&c),a;){
if(!c)a==1&&b<0?printf("1 0 %d %d\n",a,b):printf("%d %d 1 0\n",a,b);
else{
	for(r=1;r*r<=a;r++)if(a%r==0)for(p=a/r,s=1;s*s<=abs(c);s++)if(c%s==0)for(j=0;j<2;j++,s=c/s)for(i=0;i<2;i++,s=-s)if(q=c/s,p*s+q*r==b)
		{p==r&&q<s?printf("%d %d %d %d\n",r,s,p,q):printf("%d %d %d %d\n",p,q,r,s);goto next;}
	puts("Impossible");
}next:;}exit(0);}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC150();
void ABC151();
void ABC152();
void ABC153();
void ABC155();
void ABC156();
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC150();
}

int kaizyou(int x){
    if(x==1){
        return 1;
    }else{
        return x*kaizyou(x-1);
    }
}

void ABC150(){
    int n,a=0,b=0;
    cin>>n;
    vector<int> p(n),q(n),a1(n),a2(n);
    for(i=0;i<n;i++){
        cin>>p[i];
        a1[i]=p[i];
        a2[i]=p[i];
    }
    for(i=0;i<n;i++){
        cin>>q[i];
    }
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    j=0;
    while(a1.size()!=1){
        for(i=0;i<n-j;i++){
            if(p[j]==a1[i]){
                a+=i*kaizyou(n-j-1);
                a1.erase(a1.begin()+i);
                break;
            }
        }
        j++;
    }
    j=0;
    while(a2.size()!=1){
        for(i=0;i<n-j;i++){
            if(q[j]==a2[i]){
                b+=i*kaizyou(n-j-1);
                a2.erase(a2.begin()+i);
                break;
            }
        }
        j++;
    }
    cerr<<"a:"<<a<<" b:"<<b<<endl;
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
/**
 *      purpose : AtCoder Petrozavodsk Contest 001 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-25 19:12:49
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 X, Y; cin >> X >> Y;

    if (X == Y){
        print(-1); return 0;
    }
    else if (X > Y && X % Y == 0){
        print(-1); return 0;
    }
    else if (X < Y){
        print(X); return 0;
    }
    else if (X > Y){
        int64 temp = X;
        while (1){
            if (X % Y == 0){
                X += temp;
            }
            else {
                print(X); return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
solve :: Int -> Int -> Int -> String
solve n a b = show maxNum ++ " " ++ show minNum
  where maxNum = min a b
        minNum = max 0 $ (a + b) - n

main :: IO ()
main = do
  [n, a, b] <- map read . words <$> getLine
  putStrLn $ solve n a b

Measured memory_bytes: 508
import itertools
N,M = map(int,input().split())
edges = {tuple(map(int,input().split())) for i in range(M)}
ans = 0
for i in itertools.permutations(range(2,N+1),N-1):
    l = [1]+list(i)
    ans += all(tuple(sorted(edge)) in edges for edge in zip(l,l[1:]))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

	//3<=n<=20
	int n = 0;
	cin >> n;

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

	//for (int i = 0; i < n; i++){
	//	cout << p[i] << endl;
	//}

	int count = 0;

	for (int i = 1; i < n - 1; i++){
		if (p[i - 1] < p[i] && p[i] < p[i + 1]){
			count++;
		}else if (p[i - 1] > p[i] && p[i] > p[i + 1]){
			count++;
		}
	}

	cout << count << endl;

	//system("pause");
	return 0;
}

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

cond = []
for i in range(1, N):
    if i*i >= N:
        break
    if N % i == 0:
         cond.append((i, N//i))
# print(cond)

ans = set()
for a,b in cond:
    m = a+1
    if N//m == N%m:
        ans.add(m)
    m = b+1
    if N//m == N%m:
        ans.add(m)

    x = a
    if N%x == 0 and N//x > 1 and x < N//x-1:
        ans.add(N//x - 1)
    x = b
    if N%x == 0 and N//x > 1 and x < N//x-1:
        ans.add(N//x - 1)
    # print(a,b,ans)
# print(ans)
a = sum(list(ans))
print(a)


Measured memory_bytes: 40668
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Measured memory_bytes: 19556
#include <iostream>
using namespace std;
int main() {
    int count[26] = {};
    char c;
    while (cin >> c) {
        if ( ! isalpha(c)) continue;
        if (isupper(c)) c = tolower(c);
        count[c - 'a'] ++;
    }
    for (int i=0; i<26; ++i) {
        cout << char('a' + i) << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1140
h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]

x = [[0 for _ in range(w)] for _ in range(h)]
y = [[0 for _ in range(w)] for _ in range(h)]

#横軸
for i in range(h):
    index = []
    l = []
    flag = True
    for j in range(w):
        if s[i][j] == "#":
            x[i][j] = -1
            flag = False
            if len(l) != 0:
                index.append(l)
                l = []
        else:
            flag = True
        if flag:
            l.append(j)
        if j == w - 1:
          if len(l) != 0:
              index.append(l)
    for j in index:
        for m in j:
            x[i][m] = len(j)

#縦軸
for j in range(w):
    index = []
    l = []
    flag = True
    for i in range(h):
        if s[i][j] == "#":
            y[i][j] = -1
            flag = False
            if len(l) != 0:
                index.append(l)
                l = []
        else:
            flag = True
        if flag:
            l.append(i)
        if i == h - 1:
          if len(l) != 0:
              index.append(l)
    for i in index:
        for m in i:
            y[m][j] = len(i)

ans=0

for i in range(h):
    for j in range(w):
        ans = max(ans,x[i][j] + y[i][j] - 1)

print(ans)

Measured memory_bytes: 254728
#include<bits/stdc++.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
struct dpair{
	long long x;
	long long y;
	int quant;
};
int main(void){
	int i,j,k,M,N,H,W,K;
	cin >> N;
	long long x[N];
	long long y[N];
	for(i=0;i<N;i++){
		cin >> x[i] >> y[i];
	}
	dpair dpairs[(N*(N+1))/2];
	bool flag=false;
	int paircount = 0;
	for(i=0;i<N-1;i++){//全パターン調べられそうなので、調べる。x小→x大、yも同様、の順
		for(j=i+1;j<N;j++){
			flag=false; 
			for(k=0;k<paircount;k++){
				if((dpairs[k].x==(x[j]-x[i])&&dpairs[k].y==(y[j]-y[i]))||(dpairs[k].x==(-1)*(x[j]-x[i])&&dpairs[k].y==(-1)*(y[j]-y[i]))){//過去にあったペア、逆方向も考慮
					dpairs[k].quant+=1;
					flag=true;
					break;
				}
			}
			if(flag==false){//過去になかった。
				dpairs[paircount].x=(x[j]-x[i]);
				dpairs[paircount].y=(y[j]-y[i]);
				dpairs[paircount].quant=1;
				paircount +=1;
			}
		}
	}
	int maxcount=0;
	for(i=0;i<paircount;i++){
		maxcount = max(maxcount,dpairs[i].quant);
	}
	cout << (N-maxcount);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans[1000006], n, m, k;
int main() {
    cin >> n >> m >> k;
    for (int i = 0; i <= n; i ++)
        for (int j = 0; j <= m; j ++) {
            ans[i * m + j * n - 2 * i * j] = 1;
        }
    cout << (ans[k] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 4096
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {
    var params = input[0].split(' ');
    var n = parseInt(params[0], 10);
    var m = parseInt(params[1], 10);
    var k = parseInt(params[2], 10);

    var feasible = false;
    for (var i = 0; i <= n; i++) {
        for (var j = 0; j <= m; j++) {
            if (j * (n - i) + i * (m - j) == k) {
                feasible = true;
                break;
            }
        }
    }

    if (feasible) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }

    return 0;
}



Measured memory_bytes: 7500
#include <stdio.h>
#include <math.h>
 
int main(void){
	int n,a,b,c;
	
	scanf("%d %d %d",&n,&a,&b);
	
	if(1<= n && n <=20 && 1<= a && a <=100 && 1<= b && b <=2000){
		
		c = a*n;
		
		if(c<b){
			printf("%d\n",c);
		}else{
			printf("%d\n",b);
		}
	}
	return 0;
}

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

int n;
vector<int> g[100005];

int DFS(int u,int root)
{
    int rs=0;
    for(int i=0;i<g[u].size();i++)
        if(g[u][i]!=root)
            rs^=DFS(g[u][i],u)+1;
    return rs;
}

int main()
{
    cin>>n;
    int u,v;
    for(int i=1;i<n;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(DFS(1,-1)>0)
        cout<<"Alice";
    else
        cout<<"Bob";
}


Measured memory_bytes: 11904
#include <stdio.h>

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

int main(void){
    int n,m,x;
    scanf("%d %d %d", &n,&m,&x);
    int c[12];
    int a[12][12];
    int ans = 100000007;
    for(int i = 0; i<n; i++){
        scanf("%d",&c[i]);
        for(int j = 0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int bit = 0; bit<(1<<n); bit++){
        int s[12];
        int t = 0;
        for(int i = 0; i<m; i++){
            s[i] = 0;
        }
        for(int i = 0; i<n; i++){
            if(bit & (1<<i)){
                t += c[i];
                for(int j = 0; j<m; j++){
                    s[j] += a[i][j];
                }
            }
        }
        int flag = 1;
        for(int i = 0; i<m; i++){
            if(s[i]<x){
                flag = 0;
            }
        }
        if(flag){
            ans = min(ans,t);
        }
    }
    if(ans==100000007){
        printf("%d\n",-1);
        return 0;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> v(n, 0);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  ll w=0, h=0;
  for(int i=0;i<n-1;i++){
    if (v[i] == v[i+1]){
      if (w > h){
        h = v[i];
      }else{
        w = v[i];
      }
      i++;
    }
  }
  cout << w * h << endl;
  return 0;
}

Measured memory_bytes: 1024
//ABC084C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	long long int x, y;
	cin >> x >> y;
	long long int count = 1;
	while(1){
		if(2*x <= y){
			x *= 2;
			count++;
		}else{
			cout << count << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100001
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector <int> v;
set <int> s,sro;
set <int> ::iterator it;
int ans[1000010];
int main()
{
	int n;
	cin >> n;
	int a[n+5];
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	a[n+1]=0;
	ans[0]=0;
	for(int i=1;i<=n+1;i++)
	{
		ans[i]=ans[i-1]+abs(a[i]-a[i-1]);
		//printf("%d %d\n",i,ans[i]);
	}
	int x;
	for(int i=1;i<=n;i++)
	{
		x=ans[n+1];
		//printf("x%d\n",x);
		x=x-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
		//printf("%d %d %d %d\n",a[i],a[i-1],a[i+1],x);
		x=x+abs(a[i+1]-a[i-1]);
		cout << x << endl;
	}
}

Measured memory_bytes: 2048
#!/usr/bin/python
# -*- coding: utf-8 -*-

S = input()

if S == "hi":
    print('Yes')
elif S == "hihi":
    print('Yes')
elif S == "hihihi":
    print('Yes')
elif S == "hihihihi":
    print('Yes')
elif S == "hihihihihi":
    print('Yes')
else:
    print("No")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  int N, K;
  cin >> N >> K;
  cout << (int) (log(N) / log(K) + 1) << endl;
}

Measured memory_bytes: 3764
#include<iostream>

using namespace std;

int main(void) {
	int n;
	bool flag = false;

	cin >> n;

	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 14; j++) {
			if (4 * i + 7 * j == n) {
				flag = true;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

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

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    int N = Cin();
    vector<char> S(N), T(N);
    for (int i = 0; i < N; ++i) cin >> S[i];
    for (int i = 0; i < N; ++i) cin >> T[i];
    for (int i = 0; i < N; ++i) cout << S[i] << T[i];
    cout << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

fn main() {
    let k: i64 = read();
    let x: i64 = read();
    if k * 500 < x {
        println!("{}", "No");
    } else {
        println!("{}", "Yes");
    }
}


Measured memory_bytes: 4352
ai = lambda: list(map(int, input().split()))
ai_ = lambda: [int(x) - 1 for x in input().split()]

n, m = ai()


def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k
    d = 1
    for k in range(1, b+1):
        d = d * k
    return r // d


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

ans = 1
f = factorize(m)
for p,num in f:
    ans *= nCb(num+n-1,num)
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 3064
/*
 * @Date         : 2020-08-10 15:25:18
 * @Author       : ssyze
 * @Description  :
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    vector<int> a(n);
    for (auto& x : a) cin >> x;
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 2; i < a.size(); i++) {
        ans += a[i / 2];
    }
    cout << ans + a[0] << endl;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define FI first
#define SE second
using namespace std;

int n,m,a,b,ans;
pair<int,int> arr[100005];
priority_queue<int> PQ;

int main(){
	scanf("%d%d",&n,&m);
	for(int i =0;i<n;i++){
		scanf("%d%d",&a,&b);
		arr[i] = {a,b};
	}
	sort(arr,arr+n);
	int id = 0;
	for(int i =1;i<=m;i++){
		while(id<n && arr[id].FI==i){
			PQ.push(arr[id].SE);
			id++;
		}
		if(PQ.empty()) continue;
		ans+= PQ.top();
		PQ.pop();
	}
	
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
	int ans = 0;
	string s,t;
	cin >> s >> t;

	

	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])
			ans++;
	}



	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,a,b,l,m;
	cin>>x>>a>>b;
	l=a-x;
	if(l<0)
	l=0-l;
	m=b-x;
	if(m<0)
	m=0-m;
	if(l<m)
	printf("A\n");
	if(m<l)
	printf("B\n");
	return 0;
}


Measured memory_bytes: 256