akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
char c[15];
int top=0;
int num;
int minN=10000;
int getnum(char c1,char c2,char c3)
{
    return 100*(c1-'0')+10*(c2-'0')+(c3-'0');
}

int abs(int a)
{
    if (a<0) return -a;
    return a;
}

int main()
{
    while (true)
    {
        scanf("%c",&c[top]);
        if (c[top]==EOF || c[top]=='\n' || c[top]==' ') break;
        top++;
    }
    for (int i=0; i<=top-3; ++i)
    {
        num=getnum(c[i],c[i+1],c[i+2]);
        num = abs(num-753);
        if (num<minN)
            minN=num;
    }
    cout<<minN<<endl;

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;

int bfs(vector<string> &s){
  int h = (int)s.size();
  int w = (int)s[0].size();
  
  vector<vector<int>> tr(h, vector<int>(w, -1));
  tr[0][0] = 1;
  queue<pair<int, int>> q;
  q.push({0, 0});
  
  pair<int, int> d[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
  
  while(!q.empty() && tr[h - 1][w - 1] == -1){
    pair<int, int> p = q.front();
    q.pop();
    
    for(auto e : d){
      int x = p.first + e.first;
      int y = p.second + e.second;
      if(x >= 0 && x < w && y >= 0 && y < h && tr[y][x] == -1 && s[y][x] != '#'){
        tr[y][x] = tr[p.second][p.first] + 1;
        q.push({x, y});
      }
    }
  }
  
  return tr[h - 1][w - 1];
}

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<string> s(H);
  for(int i = 0; i < H; i++) cin >> s[i];
  
  int b = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#') b++;
    }
  }
  
  int paint = bfs(s);
  if(paint == -1) cout << -1 << endl;
  else cout << H * W - paint - b << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if (weather.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (weather.equals("Cloudy")) {
            System.out.println("Rainy");
        } else if (weather.equals("Rainy")) {
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 22356
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		// GET INPUT
		
		int N = sc.nextInt();
		int[] ninzu = new int[100003];
		for(int i=0; i<N; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			ninzu[l]++;
			ninzu[r+1]--;
		}
		
		// GET INPUT END
		
		sc.close();

		for(int i=1; i<100003; i++) {
			ninzu[i] += ninzu[i-1];
		}
		for(int i=1; i<100003; i++) {
			ninzu[i] += ninzu[i-1];
		}
		
		System.out.println(ninzu[100002]);
	}

}

Measured memory_bytes: 25904
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int k;
	cin >> k;
	queue <ll> q;
	for(int i = 1; i < 10; i++) q.push(i);
	ll f;
	while(k--){
		f = q.front();
		q.pop();
		if(f%10 != 0){
			q.push(10*f + f%10 -1);
		}
		q.push(10*f + f%10);
		if(f%10 != 9){
			q.push(10*f + f%10 + 1);
		}
	}
	cout << f << endl;
	return 0;
}



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

using ll = long long;

bool isPalindrome(string s){ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = s.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) { 
        if (s[l++] != s[h--]) 
        {  
            return 0; 
        } 
    } 
    return (1); 
} 

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

    string s;
    cin >> s;

    ll n = s.size();

    string t = s.substr(0,(n-1)/2);
    string u = s.substr((n+1)/2,n-1);

    // cout << isPalindrome(s) << "\n"; 
    // cout << t << "\n";
    // cout << u << "\n";
    if(isPalindrome(s) && isPalindrome(t) && isPalindrome(u)){
    	cout << "Yes\n";
    }
    else{
    	cout << "No\n";
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {
        cin >> x ;
        cout << "Case" << " " << i << ": " << x << endl;
        
        if(x==0)
          break;
    }
}


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

int main(){
  int n;
  cin>>n;
  ll vec[n];
  int x=0,y=0;
  for(int i=0;i<n;i++){
    cin>>vec[i];
    if(vec[i]==0){
      x++;
    }
    if(vec[i]<0){
      y++;
    }
  }
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=abs(vec[i]);
  }
  if(x!=0||y%2==0){
    cout<<sum<<endl;
    return 0;
  }
  ll z=1e10;
  for(int i=0;i<n;i++){
    z=min(z,abs(vec[i]));
  }
  cout<<sum-2*z<<endl;
}

Measured memory_bytes: 4376
from collections import deque, Counter
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9 + 7
h, w = map(int, input().split())
n = int(input())

ans = 0

black = []
row = Counter()
column = Counter()
for _ in range(n):
    x, y = map(int, input().split())
    row[x] += 1
    column[y] += 1
    black.append((x, y))
row[h] += 1
column[w] += 1


def sqsum(x):
    return x*(x+1)*(2*x+1)//6


pre = -1
top = 0
bottom = h*w - n
area = []
for i in sorted(row.keys()):
    if i == pre+2:
        top += w
        bottom -= w
        area.append([-1, 1])
    elif i > pre+2:
        ans += (i-pre-2)*top*bottom + ((i-pre-2)*(i-pre-1)//2) * \
            w*(bottom-top) - sqsum(i-pre-2)*(w**2)
        ans %= mod
        top += (i-pre-1)*w
        bottom -= (i-pre-1)*w
        area.append([-1, i-pre-1])
    if i != h:
        top += w-row[i]
        bottom -= w-row[i]
        area.append([i])
    pre = i

R = len(area)

pre = -1
left = 0
right = h*w-n
area2 = []
for j in sorted(column.keys()):
    if j == pre+2:
        left += h
        right -= h
        area2.append([area[i][1] if area[i][0] == -1 else 1 for i in range(R)])
    elif j > pre+2:
        ans += (j-pre-2)*left*right + ((j-pre-2)*(j-pre-1)//2) * \
            h*(right-left) - sqsum(j-pre-2)*(h**2)
        ans %= mod
        left += (j-pre-1)*h
        right -= (j-pre-1)*h
        area2.append([(j-pre-1)*area[i][1] if area[i][0]
                      == -1 else (j-pre-1) for i in range(R)])
    if j != w:
        left += h-column[j]
        right -= h-column[j]
        tmp = []
        for i in range(R):
            if area[i][0] == -1:
                tmp.append(area[i][1])
            else:
                if (area[i][0], j) in black:
                    tmp.append(0)
                else:
                    tmp.append(1)
        area2.append(tmp)
    pre = j


C = len(area2)
area2 = [[area2[j][i] for j in range(C)] for i in range(R)]

vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]


def bfs(p, q):
    dist = [[10**5 for _ in range(C)] for __ in range(R)]
    visited = [[False for _ in range(C)] for __ in range(R)]
    dist[p][q] = 0
    visited[p][q] = True
    q = deque([(p, q)])
    while q:
        x, y = q.popleft()
        for dx, dy in vec:
            if 0 <= x+dx < R and 0 <= y+dy < C and area2[x+dx][y+dy] != 0:
                if not visited[x+dx][y+dy]:
                    dist[x+dx][y+dy] = dist[x][y] + 1
                    visited[x+dx][y+dy] = True
                    q.append((x+dx, y+dy))
    return dist


ans2 = 0

for x in range(R*C):
    i = x//C
    j = x % C
    if area2[i][j] == 0:
        continue
    d = bfs(i, j)
    for y in range(R*C):
        k = y//C
        l = y % C
        if area2[k][l] == 0:
            continue
        ans2 += area2[i][j]*area2[k][l]*d[k][l]
        ans2 %= mod

ans2 *= pow(2, mod-2, mod)

print((ans+ans2) % mod)


Measured memory_bytes: 135444
#include<bits/stdc++.h>
#define Re register
#define LL long long
using namespace std;

const int N=41;
int n;
LL Ans;
char str[N][N];
LL f[N][N][N],F[N][N][N];

int main()
{
	scanf("%d",&n);
	n*=2;
	for(Re int i=1;i<=n;i++)
	{
		scanf("%s",str[i]+1);
	}
	for(Re int i=1;i<n;i++)
	{
		f[i][i][i]=1;
		for(Re int j=i+1;j<=n;j++)
		{
			if(str[i][j]=='1')
			{
				F[i][i][j]=1;
			}
		}
	}
	for(Re int i=3;i<n;i+=2)
	{
		for(Re int j=1;i+j<=n;j++)
		{
			Re int k=i+j-1;
			for(Re int L=j;L<=k;L+=2)
			{
				for(Re int R=k;R>L;R-=2)
				{
					LL sum=0;
					for(Re int t=R;t<=k;t++) sum+=F[j][L][t]*f[R][k][t];
					for(Re int t=L+1;t<R;t++) f[j][k][t]+=f[L+1][R-1][t]*sum;
				}
			}
			for(Re int a=j+1;a<k;a++)
			{
				for(Re int b=k+1;b<n;b++)
				{
					if(str[a][b]=='1')
					{
						F[j][k][b]+=f[j][k][a];
					}
				}
			}
		}
	}
	for(Re int i=1;i<n;i++)
	{
		if(str[n][i]=='1')
		{
			Ans+=f[1][n-1][i];
		}
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 4536
#include<iostream>
#include<utility>
#include<algorithm>
#include<queue>
using namespace std;
const int inf = 999999;
const int max_n = 1010;
typedef pair<int, int> P;


char grp[max_n][max_n];
int d[max_n][max_n];
int m, n, k;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
	
	
	int bfs(P, P);
	P search(int );
	
	cin >> m >> n >> k;
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			char c;
			cin >> c;
			grp[i][j] = c;		
		}
	}
	
	P prev = search(0);
	int total = 0;
	for(int i = 1; i <= k; i++){
		P next = search(i);
		total += bfs(prev, next);
		prev = next;
	}
	
	cout << total << endl; 
	
	return 0;
} 

P search(int i){
	char c;
	if(i == 0)
		c = 'S';
	else
		c = i + '0';
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(grp[i][j] == c){
				P p(i, j);
				return p;
			}
		}
	}
	// 找不到的情况 
}

int bfs(P p1, P p2){
	fill(d[0], d[0] + max_n * max_n, inf);
	d[p1.first][p1.second] = 0;
	queue<P> qu;
	qu.push(p1);
	while(!qu.empty()){
		P tp = qu.front();
		if(tp == p2) break;
		qu.pop();
		for(int i = 0; i < 4; i++){
			int nx = tp.first + dx[i];
			int ny = tp.second + dy[i];
			if(nx >= 0 && ny >= 0 && nx < m && ny < n){
				if(grp[nx][ny] != 'X' && d[nx][ny] == inf){
					d[nx][ny] = d[tp.first][tp.second] + 1;
					P np(nx, ny);
					qu.push(np); 
				}
			}
		}
	}
	return d[p2.first][p2.second];
}


Measured memory_bytes: 8060
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
#include<vector>

using namespace std;



int main()
{
    int n;
    const long long waru = 1000000007;
    cin >> n;

    vector<long long> a(n);
    long long ans=0;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    for (int i = 0; i < n; i++) {
        //for (int j = i+1; j < n; j++) {
        //    ans += (a[i] * a[j]) % waru;

        //    ans = ans % waru;
        //}
        sum -= a[i];
        ans += (a[i] * (sum % waru)) % waru;
        ans %= waru;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4776
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 4010;
const int ZERO = 2005;
const int MOD = 1e9+7;

int a[MAXN][MAXN] = {0};

int fpow( int a, int b ) {
	if( !b ) return 1;
	int rtn = fpow(a,b/2);
	rtn = int((ll)rtn * rtn % MOD);
	if( b & 1 ) rtn = int((ll)rtn * a % MOD);
	return rtn;
}
int inv( int a ) {
	return fpow(a,MOD-2);
}

int fac[8010], ifac[8010];
void prelude() {
	fac[0] = 1;
	for( int i = 1; i < 8010; ++i ) fac[i] = int((ll)fac[i-1] * i % MOD);
	ifac[8009] = inv(fac[8009]);
	for( int i = 8008; i >= 0; --i ) ifac[i] = int((ll)ifac[i+1] * (i+1) % MOD);
}

int C( int a, int b ) {
	return int((ll)fac[a] * ifac[a-b] % MOD * ifac[b] % MOD);
}

int main() {
	prelude();
	int n; scanf( "%d", &n );
	int ans = 0;
	for( int i = 0; i < n; ++i ) {
		int x, y; scanf( "%d%d", &x, &y );
		--a[ZERO+x][ZERO+y];
		++a[ZERO-x][ZERO-y];
		// printf( "C(%d, %d) = %d\n", x+x+y+y, x+x, C(x+x+y+y, x+x) );
		ans = (ans - C(x+x+y+y, x+x) + MOD) % MOD;
	}
	for( int i = 0; i < MAXN; ++i )
		for( int j = 0; j < MAXN; ++j ) {
			int end = -a[i][j];
			a[i][j] = max(a[i][j], 0);
			if( i ) a[i][j] = (a[i][j] + a[i-1][j]) % MOD;
			if( j ) a[i][j] = (a[i][j] + a[i][j-1]) % MOD;
			if( end > 0 ) ans = int((ans + (ll)a[i][j] * end) % MOD);
			// if( a[i][j] && i < ZERO+3 && j < ZERO+3 ) printf( "a[%d][%d] = %d\n", i, j, a[i][j] );
		}
	ans = int((ll)ans * inv(2) % MOD);
	printf( "%d\n", ans );
	return 0;
}


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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10;
set <int> fin;
int n, m, u, v, ans, t[maxn];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        t[i] = 1;
    fin.insert (0);
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        u--;
        v--;
        if (fin.find (u) != fin.end())
        {
            if (t[u] == 1)
                fin.erase (u);
            fin.insert (v);
        }
        t[u]--;
        t[v]++;
    }
    cout << fin.size();
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>	
		#include <stdio.h>
		#include <string>
		typedef long long int ll; 

        using namespace std;
         int main(){
           string S;
           cin >> S; 
           int N = S.size(); 
           ll P = 1000*1000*1000+7; 
           
           //int i = S.at(2) - '0';
           // int j = S.at(5) - '0';
           vector<vector<ll>> A(N+2, vector<ll>(13));
           // A[i][j]= (右から読んでいってi番目までの和がjになる場合の数)
           
           ll a = 1;
           A.at(0).at(0)=1; 
           
           for(int i=1; i<=N; i++){
             if(S.at(N-i)=='?'){   
               for(int j=0; j<13; j++ ){
                 for(int k=0; k<10; k++){
                   A.at(i).at(j) += A.at(i-1).at((260 + j-a*k )%13); 
                 }
                 A[i][j] = A[i][j]%P; 
               }
             }else{
               ll x = S.at(N-i)-'0';  
               for(int j=0; j<13; j++){
                A.at(i).at(j) = A.at(i-1).at((260 + j-a*x )%13);
               }
             }
             a=(a*10)%13; 
           }// for ends
           cout<< A.at(N).at(5) <<endl; 
         }

Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;

long long MOD = 1e9 + 7;

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

    long long n, m;
    cin >> n >> m;

    //vector<long long> a(n, 0);
    priority_queue<double> q;
    for (size_t i = 0; i < n; i++)
    {
        double tmp;
        cin >> tmp;
        q.push(tmp);
    }
    for (size_t i = 0; i < m; i++)
    {
        double t = q.top();
        q.pop();
        t /= 2.0;
        q.push(t);
    }

    long long ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct edge {
    int src,to,id;

    edge(){};
    edge(int to, int id) : src(-1), to(to), id(id) {}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<edge>> G(N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v,i);
        G[v].emplace_back(u,i);
    }

    vector<int> idx(N);
    iota(all(idx),0);
    sort(all(idx),[&](int a, int b){return A[a] < A[b];});

    vector<int> check(N),color(N,-1),ans(M,1e9);
    rep(i,N) {
        int v = idx[i];
        if (check[v]) continue;
        for (auto &e : G[v]) {
            if (A[v] < A[e.to]) continue;
            if (A[v]==A[e.to]) {
                if (color[e.to]==-1) {
                    color[v] = 0;
                    color[e.to] = 1;
                } else color[v] = 1 - color[e.to];
                ans[e.id] = A[v];
                check[v] = check[e.to] = 1;
                break;
            } 
            color[v] = 1 - color[e.to];
            ans[e.id] = A[v];
            check[v] = 1;
            break; 
        }
        if (!check[v]) {
            cout << -1 << ln;
            return 0;
        }
    }

    rep(i,N) cout << (color[i] ? 'B' : 'W');
    cout << ln;
    rep(i,M) cout << ans[i] << ln;
}

Measured memory_bytes: 14592
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
    a = list(map(int,input().split()))
    eq = c
    for j in range(m):
        eq += a[j] * b[j]
    if eq > 0:
        count += 1
print(count)

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

namespace ConsoleApp15
{
    class Class26
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            var M = new long[5];
            M[0] = long.Parse(Console.ReadLine()); //A
            M[1]= long.Parse(Console.ReadLine());//B
            M[2]= long.Parse(Console.ReadLine());//C
            M[3]= long.Parse(Console.ReadLine());//D
            M[4]= long.Parse(Console.ReadLine());//E

            long min = M.Min();

            Console.WriteLine(4 + N / min + (N % min >= 1 ? 1 : 0));
        }
    }
}


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

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

    if ( n % 2 == 0 ) {
        cout << 0.5000000 << endl;
    }
    else {
        cout << float( n / 2  + 1 ) / float(n) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct edge{
    int u, v, cost;
    edge() {}
    edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
    bool operator<(const edge &e) {return this->cost < e.cost;}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> G(m);
    vvi graph(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        G[i] = edge(a-1, b-1, -c);
        graph[b-1].push_back(a-1);
    }
    vector<bool> used(n);
    used[n-1] = true;
    function<void(int)> dfs = [&](int i) {
        for(int ne:graph[i]) {
            if(!used[ne]) {
                used[ne] = true;
                dfs(ne);
            }
        }
    };
    dfs(n-1);
    sort(all(G));
    vi check(n, INT_MAX);
    check[0] = 0;
    rep(i, n*2) {
        bool change = false;
        rep(j, m) {
            edge &e = G[j];
            if(check[e.u] == INT_MAX) continue;
            if(chmin(check[e.v], check[e.u]+e.cost+p) and used[e.v]) change = true;
        }
        if(i > n-2 and change) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(-check[n-1], 0) << endl;
}

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

int n,m,Bridge=0,Count=0,Num[10005],Low[10005];
vector<int> g[10005];

void DFS(int u,int root)
{
    Num[u]=++Count;
    Low[u]=Count;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(Num[v]==0)
        {
            DFS(v,u);
            Low[u]=min(Low[u],Low[v]);
            if(Low[v]>=Num[v])
                Bridge++;
        }
        else
        if(v!=root)
            Low[u]=min(Low[u],Num[v]);
    }
}

int main()
{
    cin>>n>>m;
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        if(Num[i]==0)
            DFS(i,i);
    cout<<Bridge;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
using namespace std;
int stone(int ans[], int a[], int n, int k){
	if(a[0] > k)
		return 0;
	if(ans[k] != -1)
		return ans[k];
	int sol = 0;
	int j = 0;
	while(j < n && a[j] <= k)
		sol = sol | (stone(ans, a, n, k - a[j++]) ? 0 : 1);
	return ans[k] = sol;
}
int main(){
	int n, k, i;
	scanf("%d %d", &n, &k);
	int a[n];
	for(i = 0; i < n; i++)
		scanf("%d", a + i);
	int ans[k + 1];
	memset(ans, -1, sizeof(int) * (k + 1));
	printf("%s\n", stone(ans, a, n, k) ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 9844
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func cmpStrNum(a, b string) bool {
	if a == "---" {
		return true
	}
	if len(a) < len(b) {
		return true
	} else if len(a) > len(b) {
		return false
	}
	return a < b
}

func main() {
	line := nextLine()

	spl := intSprit(line)

	N := spl[0]

	a := intSprit(nextLine())
	tb := []int{2, 5, 5, 4, 5, 6, 3, 7, 6}

	dp := make([]string, 100000)
	for i := 1; i < len(dp); i++ {
		dp[i] = "---"
	}
	dp[0] = ""

	for i := 0; i <= N; i++ {
		if dp[i] == "---" {
			continue
		}
		for _, v := range a {
			if cmpStrNum(dp[i+tb[v-1]], dp[i]+strconv.Itoa(v)) {
				dp[i+tb[v-1]] = dp[i] + fmt.Sprint(v)
			}
		}
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 130752
X,Y = map(int,input().split())

MOD = 10**9 + 7
FAC = [1]
INV = [1]
for i in range(1,X+Y+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

def nCr(n,r):
  return FAC[n]*INV[n-r]*INV[r]

a = (2*X-Y)/3
b = (2*Y-X)/3
if a>=0 and b>=0 and a.is_integer() and b.is_integer():
  print(nCr(int(a)+int(b),min(int(a),int(b)))%MOD)
else:
  print(0)


Measured memory_bytes: 136128
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
tmp1 = list(A.items())
tmp1.sort()
if len(tmp1) == 1 and tmp1[0][0] == 0 or len(tmp1) == 2 and tmp1[0][0] == 0 and tmp1[1][1] == N // 3 * 2 and tmp1[0][1] == N // 3 or len(tmp1) == 3 and (tmp1[0][0] ^ tmp1[1][0] ^ tmp1[2][0]) == 0 and tmp1[0][1] == tmp1[1][1] == tmp1[2][1] == N // 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 21028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] tmp = sc.nextLine().split(" ");
		int n = Integer.parseInt(tmp[0]);
		int m = Integer.parseInt(tmp[1]);
		int[] l = new int[m];
		int[] r = new int[m];
		for(int i=0; i<m; i++) {
			tmp = sc.nextLine().split(" ");
			l[i] = Integer.parseInt(tmp[0]);
			r[i] = Integer.parseInt(tmp[1]);
		}
		sc.close();

		int lmax = 0;
		int rmin = 1000000;
		for(int i=0; i<m; i++) {
			if (l[i] > lmax) lmax = l[i];
			if (r[i] < rmin) rmin = r[i];
		}
		System.out.println(lmax <= rmin ? rmin-lmax+1 : 0);
	}
}


Measured memory_bytes: 110668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T,U; int A,B; cin >> S >> T >> A >> B >> 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;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }

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

	if (N == 100000)
		cout << 9 + 900 + 90000 << endl;
	else if (N / 10000 > 0)
		cout << 9 + 900 + N - 9999 << endl;
	else if (N / 1000 > 0)
		cout << 9 + 900 << endl;
	else if (N / 100 > 0)
		cout << 9 + N - 99 << endl;
	else if (N / 10 > 0)
		cout << 9 << endl;
	else
		cout << N;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, a[99][99];
int main() {
	while(scanf("%d", &n), n) {
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) scanf("%d", &a[i][j]);
		}
		bool flag = false;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(!flag) {
					bool ok = true;
					for(int k = 0; k < n; k++) {
						if(j != k && a[i][j] > a[i][k]) ok = false;
						if(i != k && a[i][j] < a[k][j]) ok = false;
					}
					if(ok) printf("%d\n", a[i][j]), flag = true;
				}
			}
		}
		if(!flag) printf("0\n");
	}
}

Measured memory_bytes: 2620
#include "bits/stdc++.h"
#pragma GCC optimize("O3")
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin() , v.end()
#define pb push_back
#define eb emplace_back
#define MAX 1000006
#define MIN -100006
typedef long long  ll;
const ll MOD = 1e9 + 7;
using namespace std;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ;return x ;}
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";



int main(int argc, char const *argv[])
{
	fast
	cout.precision(0);
	cout<<fixed;
	ll n , m,k ,pt(0),ct(0) ,x,y; 
	ll t =1; 
	cin>>n;
	cout<<(n%2) + (n/2);

}	

Measured memory_bytes: 256
n = gets.chomp.to_i
x = gets.chomp
ans = 0
(n - 1).times do |i|
  l = x[0..i].split("").uniq
  r = x[(i+1)..-1].split("").uniq
  s = 0
  l.each do |e|
    s += 1if r.include?(e)
  end
  ans = [ans, s].max
end
puts ans

Measured memory_bytes: 3836
#include <cassert>
#include <iostream>
#include <string>
#include <list>
#include <vector>

class TDllist
{
    std::list<int> FList;
public:
    void Insert(int X)
    {
        // FList.push_front(X);
        FList.insert(FList.begin(), X);
    }
    void Delete(int X)
    {
        for(std::list<int>::iterator It = FList.begin();
            It != FList.end();
            ++It)
        {
            if(*It == X){
                FList.erase(It);
                return;
            }
        }
    }
    void DeleteFirst()
    {
        // FList.pop_front();
        FList.erase(FList.begin());
    }
    void DeleteLast()
    {
        FList.pop_back();
    }
    void Show()const
    {
        std::list<int>::const_iterator It = FList.begin();
        std::cout << *It;
        for(++It; It != FList.end(); ++It)
        {
            std::cout << " " << *It;
        }
        std::cout << std::endl;
    }
};

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    TDllist List;
    int n, X;
    std::cin >> n;
    std::string Command;
    for(int i = 0; i < n; ++i){
        // std::string Command;
        std::cin >> Command;
        if(Command == "insert"){
            // int X;
            std::cin >> X;
            List.Insert(X);
        }else
        if(Command == "delete"){
            // int X;
            std::cin >> X;
            List.Delete(X);
        }else
        if(Command == "deleteFirst")
        {
            List.DeleteFirst();
        }else
        if(Command == "deleteLast")
        {
            List.DeleteLast();
        }else{
            assert(false);
        }
    }
    List.Show();
    return 0;
}

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

string S;

int main(){
	cin >> S;
	long long s = 0;
	long long e = S.size() - 1;
	long long ans = 0;
	
	while(s < e) {
		if(S[s] == S[e]){
			s++;
			e--;
			continue;
		}
		if(S[s] == 'x'){
			ans++;
			s++;
			continue;
		}
		if(S[e] == 'x'){
			ans++;
			e--;
			continue;
		}
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
"use strict"
function Main(input) {

    var input = input.split("\n");

    const N = Number(input[0].split(" ")[0]);
    const K = Number(input[0].split(" ")[1]);
    const H = input[1].split(" ").map(Number);

    // 必殺技(K回) > モンスター(N体) は即抜け
    if (K >= N) {
        //出力
        console.log(0);
        return;
    }

    const sortDesc = H.sort(function (a, b) {
        return b - a;
    });

    let answer = 0;
    for (let i = K; i < N; i++) {
        answer += sortDesc[i];
    }

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str = null;
			String[] strArr = null;
			StringBuilder sb = new StringBuilder();
			while(true){
				str = br.readLine();
				if(str.equals("0")){
					break;
				}

				strArr = str.split("");
				long sum = 0;
				int len = str.length();
				for(int i=0;i<len;i++){
					sum += Integer.parseInt(strArr[i+1]);
				}

				sb.append(sum).append("\n");
			}

			System.out.print(sb.toString());

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null) {
					br.close();
				}
			} catch (IOException ioe) {
			}

		}
	}
}

Measured memory_bytes: 19332
#include <iostream>
#include <cstdio>
using namespace std;
int N, M, A, B, C, D, x1, x2, y1, y2;
const int inf = 1001000100;
int K[32][32]={};


int main() {
  scanf("%d%d", &N, &M);

  for (int i=1; i<N+1; i++)
    for (int j=1; j<N+1; j++)
      K[i][j] = inf;
  
  for (int i=0; i<M; ++i){
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    //cerr << "read " << A << " " << B << " " << C << " " << D << endl;
    K[A][B] = C;
    K[B][A] = D;
  }

  scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
  
  for (int k=1; k<N+1; k++){
    for (int i=1; i<N+1; i++){
      for (int j=1; j<N+1; j++){
	if (K[i][j] > K[i][k] + K[k][j])
	  K[i][j] = K[i][k] + K[k][j];
	//cout << K[i][j] << " ";
      }
      //cout << endl;
    }
  }

 
  cout << y1 - y2 - K[x1][x2] -K[x2][x1] << endl;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll h,w;cin>>h>>w;
	string s[h];
	rep(i,0,h)cin>>s[i];
	ll ans=0,a[h][w];
	rep(i,0,h)rep(j,0,sz(s[i])){
		if(s[i][j]=='#')a[i][j]=0;
		else a[i][j]=1;
	}
	ll b[h][w],c[h][w];
	rep(i,0,h){
		ll val=0;
		rep(j,0,w){
			if(a[i][j])val++;
			else val=0;
			b[i][j]=val;
		}
		ll mx=0;
		for(ll j=w-1;j>=0;--j){
			if(a[i][j])b[i][j]=max(mx,b[i][j]),mx=b[i][j];
			else b[i][j]=0,mx=0;
		}
	}
	rep(j,0,w){
		ll val=0;
		rep(i,0,h){
			if(a[i][j])val++;
			else val=0;
			c[i][j]=val;
		}
		ll mx=0;
		for(ll i=h-1;i>=0;--i){
			if(a[i][j])c[i][j]=max(mx,c[i][j]),mx=c[i][j];
			else c[i][j]=0,mx=0;
		}
	}
	rep(i,0,h)rep(j,0,w){
		if(a[i][j])ans=max(ans,b[i][j]+c[i][j]-1);
	}
	cout<<ans;
	return 0;
	
}



Measured memory_bytes: 98304
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        bool plus = false;
        bool multi = false;

        if(a * b == 15)
        {
            Console.WriteLine('*');
        }
        else if(a + b == 15)
        {
            Console.WriteLine('+');
        }
        else
        {
            Console.WriteLine('x');
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int a;
		int b;
		if(n == 1){
			System.out.println("Hello World");
		} else {
			a = saori.saori_hayami();
			b = saori.saori_hayami();
			System.out.println(a+b);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

c = []
d = []
for _ in range(m):
    cc, dd = map(int, input().split())
    c.append(cc)
    d.append(dd)

for aa, bb in zip(a, b):
    l = 2 * 10 ** 8
    num = 1
    for i, (cc, dd) in enumerate(zip(c, d)):
        dis = abs(aa - cc) + abs(bb - dd)
        if dis < l:
            l = dis
            num = i + 1
    print(num)

Measured memory_bytes: 3064
n,m=map(int,input().split())
x=1
if m%n==0:
    print(m//n)
else:
    for i in range(1,int(m**0.5)+1):
        if m%i==0 and i*n<=m:
            x=max(x,i)
        if m%(m//i)==0 and (m//i)*n<=m:
            x=max(x,m//i)
    print(x)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<int> a(N), b(N);
	for (int i=0; i<N; i++)
		cin>>a[i];
	for (int i=0; i<N; i++)
		cin>>b[i];
	reverse(b.begin(),b.end());
	for (int i=0; i<N; i++) {
		if(a[i]!=b[i]) continue;
		bool ok=false;
		for (int j=0; j<N; j++) {
			if(i==j) continue;
			if(a[i]!=b[j] && a[j]!=b[i]) {
				swap(b[i],b[j]); ok=true; break;
			}
		}
		if(!ok) {
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	for (auto x : b)
		cout<<x<<" ";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m, k; cin >> n >> m >> k;
  int check;
  for(int i = 0; i <= n; ++i){
    for(int j = 0; j <= m; ++j){
      check = (n - i) * j + (m - j) * i; 
      if(check == k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
readlines.each do |l|
  xa,ya,xb,yb,xc,yc,xd,yd = l.split.map(&:to_f)
  puts ((xa==xb && yc==yd) || (xc==xd && ya==yb)) || ((ya-yb)/(xa-xb) * (yc-yd)/(xc-xd) == -1) ? "YES" : "NO" 
end

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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, int> pli;

const int mn = 5005;
const int maxlog = 19;

int n;
struct node{
    int h,w;
    bool operator < (const node &p) const{
        return h+w<p.w+p.h;
    }
}p[mn];

ll d[mn];

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].h,&p[i].w);
    }
    sort(p+1,p+n+1);
    memset(d,-1,sizeof d);
    d[0]=0;
    for(int i=1;i<=n;i++){
        for(int j=n-1;j>=0;j--){
            if (d[j]==-1) continue;
            if (d[j]<=p[i].h){
                if (d[j+1]==-1) d[j+1]=1e18;
                d[j+1]=min(d[j]+p[i].w,d[j+1]);
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++) {
        if (d[i]==-1) {
            ans=i-1;
            break;
        }
        ans=i;
        //printf("%d %lld\n",i,d[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-


def get_input() -> int:
    """
    標準入力の取得

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    求解処理.

    Args:\n
        N (int): 整数（N <= 999）
    """
    """
    Nの1桁目で場合分け.
    """
    result = str()
    first_place = N % 10
    if first_place in [2, 4, 5, 7, 9]:
        result = "hon"
    elif first_place in [0, 1, 6, 8]:
        result = "pon"
    else:
        result = "bon"

    # 求解処理
    print(result)


if __name__ == "__main__":
    N = get_input()
    main(N)


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>

using namespace std;
using ll = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

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

  bool same(int x, int y) {
    x = find(x), y = find(y);
    return x == y;
  }
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main()
{
  // 整数の入力
  ll N,M;
  cin >> N >> M;
  UnionFind uf(N);
  for(int i = 0;i < M;i++){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a,b);
  }
  set<ll> unique_groups;
  int max_group_size = 0;
  for(int i = 0;i < N;i++){
    max_group_size = max(max_group_size, uf.size(i));
  }
  cout << max_group_size << endl;
 return 0;
}


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

int main (void) {
	char s[16];
	int iRetValue=0, tama=0;

	memset (&s[0], 0, sizeof (s));
//	scanf ("%s%s%s", &s[0], &s[1], &s[2]);
	iRetValue = scanf ("%s", &s[0]);

	for (int ii=0; ii < 3; ii++) {
		if (s[ii] == '1') {
			tama++;
		}
	}

	printf ("%d", tama);

	return 0;
}


Measured memory_bytes: 128
import sys
#input = sys.stdin.buffer.readline
from collections import Counter

def main():
    N,P = map(int,input().split())
    s = input()
    l = len(s)
    ans = 0
    if 10%P == 0:
        for i,st in enumerate(s[::-1]):
            num = int(st)
            if num%P == 0:
                ans += l-i
    else:
        rest = [0]
        t = 1
        for st in s[::-1]:
            num = int(st)%P
            rest.append(num*t%P)
            t = t*10%P
            
        for i in range(l):
            rest[i+1] += rest[i]

        for i in range(l):
            rest[i+1] %= P
            
        c = Counter(rest)
        c = list(c.values())
        for num in c:
            ans += num*(num-1)//2
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 12140
#include <iostream>

using namespace std;

int main(){
    string S,T;
    cin >> S;
    cin >> T;
    string temp = S;
    temp += S;

    for(int i = 0; i < temp.size(); i++){
        if(temp[i] == T[0]){
            bool flag = true;
            for(int n = 0; n < T.size(); n++){
                if(temp[i+n] != T[n]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

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

  ll N; cin >> N;
  string X; cin >> X;

  vector<ll> f(N + 10, 0);
  f[0] = 0;
  f[1] = 1;
  f[2] = 1;
  for (ll i = 3; i <= N; i++) {
    ll temp = i;
    ll p = 0;
    for (ll j = 0; j < N; j++) {
      p += (temp % 2);
      temp /= 2;
      if (temp == 0) break;
    }
    f[i] = f[(i % p)] + 1;
  }
  
  ll cnt = 0;
  for (ll i = 0; i < N; i++) {
    ll d = (X[i] - '0');
    cnt += d;
  }


  vector<vector<ll>> r_x(N + 10, vector<ll>(3, 0)); // 0 1 2
  vector<vector<ll>> r_2(N + 10, vector<ll>(3, 0));

  r_2[0][0] = 1;
  r_2[0][1] = 1;
  r_2[0][2] = 1;

  for (ll i = 1; i < N; i++) {
    r_2[i][2] = (r_2[i-1][2] * 2) % (cnt + 1);
    if (cnt > 1) {
      r_2[i][0] = (r_2[i-1][0] * 2) % (cnt - 1);
    }
  }


  ll d = X[N - 1] - '0';

  if (cnt <= 1) {
    r_x[0][0] = 0;
    r_x[0][2] = d;
  } else {
    r_x[0][0] = d % (cnt - 1);
    r_x[0][2] = d % (cnt + 1);
  }
  for (ll i = 1; i < N; i++) {
    d = X[N - 1 - i] - '0';
    r_x[i][2] = (r_x[i-1][2] + d * r_2[i][2]) % (cnt + 1);
    if (cnt > 1) {
      r_x[i][0] = (r_x[i-1][0] + d * r_2[i][0]) % (cnt - 1);
    }
  }

  for (ll i = 0; i < N; i++) {
    d = X[i] - '0';
    if (d == 1) {
      if (cnt == 1) {
        cout << 0 << '\n';
      } else {
        ll cnt_temp = cnt - 1;
        ll r = (r_x[N - 1][0] - r_2[N - 1 - i][0] + cnt_temp) % cnt_temp;
        cout << (f[r % cnt_temp] + 1) << '\n';
      }
    } else {
      ll cnt_temp = cnt + 1;
      ll r = (r_x[N - 1][2] + r_2[N - 1 - i][2] + cnt_temp) % cnt_temp;
      cout << (f[r % cnt_temp] + 1) << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 26816
//44
#include<iostream>

using namespace std;

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    bool f=false;
    while(m--){
      int p;
      cin>>p;
      f|=p==1;
    }
    cout<<fixed<<(f?0:n/2.)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
ant = [int(input()) for _ in range(5)]

minidx = 0
minval = 124
i = 0
for a in ant:
    while 10 < a:
        a %= 10
        if a == 0:
            a = 10
    if a < minval:
        minidx = i
        minval = a
    i += 1

ans = 0
for i in range(5):
    if i == minidx:
        continue
    fact = 10
    while fact - ant[i] < 0:
        fact += 10
    ans += fact

ans += ant[minidx]
print(ans)

Measured memory_bytes: 38256