akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ops;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ops.push_back(make_pair(a, 1));
    }
    for (int i = 0; i < m; ++i) {
        int b, c;
        cin >> b >> c;
        ops.push_back(make_pair(c, b));
    }
    sort(ops.begin(), ops.end(), [&](pair<int, int>& p1, pair<int, int>& p2) { return p1 > p2; });
    long long s = 0;
    int remaining = n;
    for (auto& op : ops) {
        if (remaining > 0) {
            int to_choose = min(remaining, op.second);
            remaining -= to_choose;
            s += (long long) to_choose * op.first;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

typedef long long int LL;
const int maxn = 20007; 
int n; 
int prime[maxn]; 
bool vis[maxn]; 
void pre(int lim = 10000) {  
    for(int cnt = 0,i = 2;i <= lim;++ i) { 
        if(!vis[i]) prime[++ cnt] = i; 
        for(int j = 1;j <= cnt && prime[j] * i <= lim;++ j) { 
            vis[i * prime[j]] = 1; 
            if(i % prime[j] == 0) break; 
        } 
    } 
} 
LL a[507][507]; 
LL gcd(LL x,LL y) { 
    return y == 0 ? x : gcd(y,x % y); 
} 
LL lcm(LL x,LL y) {
    return x / gcd(x,y) * y; 
} 
int main() { 
	int i,j,k;
    read(n);
    pre(); 
    if(n == 2) {
        putc('4');putc(' ');putc('7');putc('\n'); 
        print(23);putc(' '); print(10); putc('\n'); 
        return 0;  
    } 
    for(i=0;i<=n+1;i++)
    	for(j=0;j<=n+1;j++)
    		a[i][j]=1;
    for(i = 1;i <= n;++ i) 
        for(j = 1;j <= n;++ j) { 
            if((j & 1) == (i & 1)) { 
                a[i][j] = prime[(i + j) / 2] * prime[(i + n + 1 - j) / 2 + n];  
                a[i + 1][j] = lcm(a[i + 1][j],a[i][j]); 
                a[i - 1][j] = lcm(a[i - 1][j],a[i][j]); 
                a[i][j + 1] = lcm(a[i][j + 1],a[i][j]); 
                a[i][j - 1] = lcm(a[i][j - 1],a[i][j]); 
            } 
        } 
    for(i = 1;i <= n;++ i) 
        for(j = 1;j <= n;++ j) 
            if((i & 1) == (j & 1)); 
            else a[i][j] ++; 
    for(i = 1;i <= n;++ i) 
    {
    	for(j = 1;j <= n;++ j) 
            print(a[i][j]),putc(' '); 
        putc('\n');
    }    
    return 0; 
} 

Measured memory_bytes: 9216
#include<bits/stdc++.h>
int a[210],c[210],n;
using namespace std;
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)c[a[i]]++;
	sort(a+1,a+n+1);
	if(a[n]&1){
		for(int i=a[n]/2+1;i<=a[n];i++)if(c[i]<2)return puts("Impossible"),0;
		if(a[1]<=a[n]/2||(n>2&&a[3]==a[n]/2+1))puts("Impossible");
		else puts("Possible");
	}
	else{
		if(c[a[n]/2]<1)return puts("Impossible"),0;
		for(int i=a[n]/2+1;i<=a[n];i++)if(c[i]<2)return puts("Impossible"),0;
		if(a[1]<a[n]/2||a[2]==a[n]/2)puts("Impossible");
		else puts("Possible");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int x;
  cin >> x;
  int a, b;
  cin >> a >> b;

  cout << (x - a) % b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define N_MAX 100001
typedef pair<int,int> P;

int main(){
  int N,R,L;
  int d,t,x;
  int time[N_MAX]={0};
  int score[N_MAX]={0};
  cin >> N >> R >> L;
  priority_queue<P> que;
  for(int i=1;i<=N;i++){
    que.push(P(0,N-i));
  }
  int now = 0;
  for(int j=0;j<R;j++){
    cin >> d >> t >> x;
    P p1 = que.top();
    while(score[N-p1.second] != p1.first){
      que.pop();
      p1 = que.top();
    }
    time[N-p1.second] += t - now;
    now = t;
    score[d] += x;
    que.push(P(score[d],N-d));
  }
  P p1 = que.top();
  while(score[N-p1.second] != p1.first){
    que.pop();
    p1 = que.top();
  }
  time[N-p1.second] += L - now;
  priority_queue<P> que2;
  for(int i=1;i<=N;i++){
    que2.push(P(time[i],N-i));
  }
  p1 = que2.top();
  cout << N - p1.second << endl;
}

Measured memory_bytes: 11928
function main(input) {
  input=input.trim();
  const x = parseInt(input.split(" ")[0], 10);
  const a = parseInt(input.split(" ")[1], 10);
  const b = parseInt(input.split(" ")[2], 10);

  if(Math.abs(x-a)>Math.abs(x-b)){
    console.log("B");
  }else{
    console.log("A");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int freq[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k, a;
  cin >> n >> k;
  vector<int> vec;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    freq[a]++;
  }
  for (int i = 0; i < N; ++i) {
    if(freq[i])
      vec.push_back(freq[i]);
  }
  sort(vec.begin(), vec.end());
  ll total = 0;
  for (int i = 0; i < ((int)vec.size()) - k; ++i) {
    total += vec[i];
  }
  cout << total;
  return 0;
}


Measured memory_bytes: 2168
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef long long ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define Q_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

int main()
{
	int N, M;
	cin >> N >> M;
	
	vector<P> A(N);
	REP(i, N) cin >> A[i].first >> A[i].second;
	sort(A.begin(), A.end());
	
	ll remainNum = M;
	ll ans = 0;
	for (auto one : A) {
		ll buyNum = min(remainNum, one.second);
		ans += buyNum * one.first;
		remainNum -= buyNum;
		if (remainNum == 0) {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int n, m, q, max_score = 0;
vector<int> a, b, c, s, seq;

int getScore() {
	int score = 0;
	for (int i = 0; i < q; i++) {
		if (seq[b[i]-1] - seq[a[i]-1] == c[i]) {
			score += s[i];
		}
	}

	return score;
}

void gen(int ind, int val) {

	if (ind == seq.size()) {

		max_score = max(max_score, getScore());

		return;
	}

	for (int i = val; i <= m; i++) {
		seq[ind] = i;
		gen(ind+1, i);
	}
}

int main() {

	IOS

	cin >> n >> m >> q;

	a.resize(q);
	b.resize(q);
	c.resize(q);
	s.resize(q);
	seq.resize(n);

	for (int i = 0; i < q; i++)
		cin >> a[i] >> b[i] >> c[i] >> s[i];

	gen(0, 1);

	cout << max_score << endl;

	return 0;
}

Measured memory_bytes: 3616
//⣿⣿⣿⣿⣿⣿⠟⠋⠁⣀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿
//⣿⣿⣿⣿⠋⠁⠀⠀⠺⠿⢿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠻⣿
//⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⣤⠀⠀⠀⠀⠀⣤⣦⣄⠀⠀
//⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⠏⣿⣿⣿⣿⣿⣁⠀⠀⠀⠛⠙⠛⠋⠀⠀
//⡿⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⣰⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀
//⡇⠀⠀⠀⠀⠀⠀⠀⠸⠇⣼⣿⣿⣿⣿⣿⣷⣄⠘⢿⣿⣿⣿⣅⠀⠀⠀⠀⠀⠀⠀⠀
//⠁⠀⠀⠀⣴⣿⠀⣐⣣⣸⣿⣿⣿⣿⣿⠟⠛⠛⠀⠌⠻⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣶⣮⣽⣰⣿⡿⢿⣿⣿⣿⣿⣿⡀⢿⣤⠄⢠⣄⢹⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣿⣿⣿⣿⣿⡘⣿⣿⣿⣿⣿⣿⠿⣶⣶⣾⣿⣿⡆⢻⣿⣿⠃⢠⠖⠛⣛⣷⠀
//⠀⠀⢸⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣮⣝⡻⠿⠿⢃⣄⣭⡟⢀⡎⣰⡶⣪⣿⠀
//⠀⠀⠘⣿⣿⣿⠟⣛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿⢁⣾⣿⢿⣿⣿⠏⠀
//⠀⠀⠀⣻⣿⡟⠘⠿⠿⠎⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣵⣿⣿⠧⣷⠟⠁⠀⠀
//⡇⠀⠀⢹⣿⡧⠀⡀⠀⣀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⢰⣿⠀⠀⠀⠀
//⡇⠀⠀⠀⢻⢰⣿⣶⣿⡿⠿⢂⣿⣿⣿⣿⣿⣿⣿⢿⣻⣿⣿⣿⡏⠀⠀⠁⠀⠀⠀⠀
//⣷⠀⠀⠀⠀⠈⠿⠟⣁⣴⣾⣿⣿⠿⠿⣛⣋⣥⣶⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⡀ 
//
//⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣴⢟⣛⡀⠀⠀⣸⢿⣇⠀ 
//⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⢿⣮⣽⡇⠀⢠⡿⠶⣿⡄ 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define DEBUG false
#define debugf if (DEBUG) printf
#define MAXN 1000010
#define MAXM 900009
#define MAXLOGN 20
#define ALFA 256
#define MOD 998244353
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define PI 3.141592653589793238462643383279502884
#define FOR(x,n) for(int x=0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) for(int x=int(n)-1; (x)>=0; (x)--)
#define REP1(x,n) for(int x=(n); (x)>0; (x)--)
#define pb push_back
#define pf push_front
#define pr printf
#define sc(x) scanf(" %d", &x)
#define sc2(x, y) sc(x);sc(y)
#define sc3(x, y, z) sc2(x, y);sc(z)
#define scll(x) scanf(" %lld", &x)
#define sc2ll(x, y) scll(x);scll(y)
#define sc3ll(x, y, z) sc2ll(x, y);scll(z)
#define ff first
#define ss second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x,y) memset(&x, (y), sizeof(x))
#define LOWBIT(A) (A & -A)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector <int> vi;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef pair < pll, ll > plll;
template <class T>
	using ord_set = tree<T, null_type, less<T>, rb_tree_tag,
	tree_order_statistics_node_update>;

int main(){
    string s; cin >> s;
    int ret = 0;
    FOR(i, sz(s) / 2){
        if(s[i] != s[sz(s) - 1 - i])ret++;
    }
    pr("%d\n", ret);
	return 0;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Possible"
#define NO  "No"

using namespace std;

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

  int num;
  bool flag;

  num = numeric_limits<int>::max();
  flag = true;
  int a, b, c; cin >> a >> b >> c;
  num = min(num, a + b);
  num = min(num, c + b);
  num = min(num, a + c);
  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var c string
	fmt.Scan(&c)

	if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
		fmt.Println("vowel")
	} else {
		fmt.Println("consonant")
	}
}


Measured memory_bytes: 512
x = input()
t = int(x)
x2 = input()
n = list(map(int, x2.split(" ")))


def main():
  if 0 in n:
    print(0)
    return
  p = 1
  for v in range(t):
    p *= n[v]
    if (p > 10 **18):
      print("-1")
      return
  print(p)

main()


Measured memory_bytes: 23464
'use strict'
const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0])
    let temp = input[1].split(' ')
    const T = parseInt(temp[0])
    const A = parseInt(temp[1])
    let H = input[2].split(' ').map(i => {
        let j = parseInt(i)
        return Math.abs(A - (T - j * 0.006))
    })
    
    let min = 999999
    let index = 0
    H.forEach((v, i) => {
        if(v < min) {
            min = v
            index = i
        }
    })
    console.log(index + 1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

using namespace std;

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

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b;
    cin>>a>>b;

    ll ans = a*b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
n = gets.to_i
b = gets.split.map(&:to_i)
a = [b[0]]

if n == 2
  puts b[0] * 2
else
  (b.size-1).times do |i|
    if b[i] > b[i+1]
      a << b[i+1]
    else
      a << b[i]
    end
  end
  if a[-1] > b[-1]
    a << a[-1]
  else
    a << b[-1]
  end

  puts a.inject(&:+)
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main () {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << W * H / 2 << ' ';
  if(H / 2 == y && W / 2 == x)cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
const int INF = 2e9;
const ll INFLL = 4e18;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int a[upperlimit];
int n;
int cuts(int l){
	int ans=0;
	for(int i = 1; i <= n; i++) ans+=(a[i]/l);
	return ans;
}
int main() {
	int k,l=0,r=INF;
	sd(n);sd(k);
	for(int i = 1; i <= n; i++){sd(a[i]);a[i]--;}
	while(r-l>1){
		int mid=(l+r)>>1;
		if(cuts(mid)<=k) r=mid;
		else l=mid;
	}
	pd(r);
	return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
int Nx, My;
int WA[105000];
bool AC[105000];
int main() {
    cin >> Nx>> My;
    int WAn= 0;
    int ACn = 0;
    for(int i = 1; i <= Nx; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(My--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACn++;
            WAn += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACn << " " << WAn << endl;

    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define S second
#define F first
#define EPS (1e-7)
#define INF (1e9)
#define N 31
using namespace std;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
typedef pair<double,P1> P3;
typedef pair<P3,int> P4;

vector<P2> G[N];
int n,m,s,g;

double dijkstra(){
  double d[N][N][N];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<N;k++)
	d[i][j][k]=INF;
  priority_queue<P4,vector<P4>,greater<P4> > q;
  for(int i=0;i<G[s].size();i++){
    int nx=G[s][i].first,cost=G[s][i].second.first;
    d[s][nx][1]=cost;
    q.push(P4(P3(cost,P1(s,nx)),1));
  }
  while(!q.empty()){
    P4 t=q.top(); q.pop();
    int px=t.F.S.F,x=t.F.S.S,v=t.S;
    double cost=t.F.F;
    if(d[px][x][v]+EPS<cost)continue;
    if(x==g&&v==1)return cost;
    for(int i=0;i<G[x].size();i++){
      int nx=G[x][i].F,cost2=G[x][i].S.F;
      int lim=G[x][i].S.S;
      if(nx==px)continue;
      for(int j=-1;j<=1;j++){
	int nv=v+j;
	if(nv<1||30<nv||nv>lim)continue;
	double ncost=cost+1.0*cost2/nv;
	if(d[x][nx][nv]>ncost+EPS){
	  d[x][nx][nv]=ncost;
	  q.push(P4(P3(ncost,P1(x,nx)),nv));
	}
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    cin>>s>>g;
    s--,g--;
    int a,b,c,d;
    for(int i=0;i<m;i++){
      cin>>a>>b>>c>>d;
      a--,b--;
      G[a].push_back(P2(b,P1(c,d)));
      G[b].push_back(P2(a,P1(c,d)));
    }
    double r=dijkstra();
    if(r==-1)cout<<"unreachable"<<endl;
    else printf("%.5f\n",r);
    for(int i=0;i<n;i++)G[i].clear();
  }
  return 0;
}

Measured memory_bytes: 3808
import collections as col
n = int(input())
li = [col.Counter(list(input())) for _ in range(n)]

ans = ""
#c = col.Counter(li)
for i in range(26):
  tmp = 100
  for j in range(n):
    tmp = min(tmp,li[j][chr(ord("a")+i)])
  ans += chr(ord("a")+i)*tmp
  #print(li[0][chr(ord("a")+i)])
#print(li)
print(ans)

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



int main() 
{
  ll N,K; cin>>N>>K;
  long double ans=0;
  if(N>=K) {ans+=(long double)(N-K+1)/N;}
  //cout<<ans<<endl;
  for(ll i=1;i<=min(K-1,N);i++)
  {
    double hoge=1;
    ll score=i;
    for(ll j=0;score<K;j++)
    {
      score*=2;
      hoge/=2;
    }
    ans+=hoge/N;
    //cout<<ans<<endl;
  }
  cout<<fixed<<setprecision(15)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n,ans=0;cin>>n;
    vector<int> vec(3);
    string x;
    for(int i=0;i<n;i++){
        cin>>x;
        for(int j=0;j<x.size()-1;j++){
            if(x[j]=='A'&&x[j+1]=='B')ans++;
        }
        if(x[0]=='B'&&x[x.size()-1]=='A')vec[1]++;
        else if(x[0]=='B')vec[2]++;
        else if(x[x.size()-1]=='A')vec[0]++;
    }
    if(vec[0]==0&&vec[1]>0&&vec[2]==0){
        ans+=vec[1]-1;
    }
    else if(vec[0]==0&&vec[1]>0&&vec[2]>0){
        ans+=vec[1];
    }
    else if(vec[0]>0&&vec[1]==0&&vec[2]>0){
        ans+=min(vec[0],vec[2]);
    }
    else if(vec[0]>0&&vec[1]>0&&vec[2]==0){
        ans+=vec[1];
    }
    else if(vec[0]>0&&vec[1]>0&&vec[2]>0){
        ans+=vec[1]+1;
        ans+=min(vec[0]-1,vec[2]-1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cstring>                    
#include <sstream>
#include <numeric>
#include <assert.h>

using namespace std;

#define lop(i,n) for(int i=0 ;i<n ;i++)
#define VI    vector<int>
#define VLL    vector<ll>
#define VPI    vector<pair<int,int>>
#define VII    vector<VI>
#define all(v)    v.begin() , v.end()
#define SORT(v)    sort(all(v))
#define ll    long long
#define ull unsigned long long
#define scni(x)    scanf("%d",&x)           
#define scnll(x)    scanf("%lld",&x)        
#define scnd(x)    scanf("%lf",&x)          
#define prnti(x)    printf("%d\n",x)        
#define prntll(x)    printf("%lld",x)       
#define prntd(x)    printf("%.9lf",x)        
#define sz(x)  x.size()
#define pp push_back
#define P pair<int , int>
#define mp make_pair

const double EPS = 1e-9;
const double PI = 3.14159265359;

//  O( n * log(log(n)) )
vector<ll> primes;
void GeneratingPrimes(int top){
    vector<bool> p (top+1 , 1);
//    vector<ll> primes;
    p[0] = p[1] = 0;

    for(int i = 2; i <= sqrt(top) ; i++){
        if(p[i]){
            for(int j = i*i ; j <= top ; j+=i){
                p[j]=0;
            }
        }
    }
    lop(i , top+1)
        if(p[i])primes.push_back(i);
//    return primes;
}

ll gcd(ll a ,ll b){return (b==0)?a : gcd(b , a%b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a , b);}
void EXTgcd(ll a , ll b , ll & x0 , ll & y0){
    if(b==0){ x0 =1 , y0 = 0; return; }
    EXTgcd( b , a%b , x0 , y0 );
    ll x1 = y0;
    ll y1 = x0 - (a/b) * (y0);

	y1 = y1;
    x0 = x1;
    y0 = y1;
}

long long power(long long n, long long p , ll mod) {
    if (!p)
        return 1;
    long long ans = 1;
    while (p > 1) {
        if (p & 1)
            ans = (ans * n) % mod;
        n = (n * n) % mod;
        p /= 2;
    }
    return (ans * n) % mod;
}

double dist(double a , double b , double x, double y){ return sqrt( pow( a-x ,2) + pow( b-y ,2) ); }
double dist3(double a , double b , double c , double x , double y ,double z ){ return sqrt( pow( a-x ,2) + pow( b-y ,2) + pow( c-z ,2)); }

int xadd[9]= { 1 , -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 };
int yadd[9]= { 1 , -1 , 0 ,-1 ,  0 , 1 , 0 ,  1, -1 };

int xx[4]={0 , 1 , 0 , -1};
int yy[4]={1 , 0 , -1 , 0};

// string digits[]= {"1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011"};

#define no  { cout<<"NO\n";  }
#define yes { cout<<"YES\n"; }
#define _1  { cout<<"-1\n";  }

ll const N = 1e5 + 10;
ll const INF = 1e18;
ll const mod = 1000000007;

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

ll n, a[N][3], dp[N][3];


int main(){
	cin >> n;
	lop(i,n){
		lop(j,3)scnll(a[i][j]);
	}
	lop(i,3)dp[0][i] = a[0][i];

	for(int i=1; i<n; i++){
		lop(j,3){
			lop(k,3)if(k!=j)dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i][j]);
		}
	}

	ll ans=0;
	lop(i,3)ans=max(ans, dp[n-1][i]);
	cout << ans;
return 0;}

Measured memory_bytes: 4992
#include <stdio.h>
using namespace std ; 
int main() {
	int k, s;
	scanf("%d %d", &k, &s);
	int count = 0;
	
	for (int x = 0; x <= k; x++)
	{
		for (int y = 0; y <= k; y++)
		{
			for (int z = 0; z <= k; z++)
			{
				if (x + y + z == s)
				{
					count++;
				}
			}
			
		}
	}
	
	printf("%d \n", count);
	
}

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

inputs = input().split(' ')
N = int(inputs[0])

shop_dict = {}
shop_sort = {}
for i in range(N):
    inputs = input().split(' ')
    shop_dict[i] = (inputs[0], int(inputs[1]))
    if inputs[0] in shop_sort.keys():
        shop_sort[inputs[0]].append(int(inputs[1]))
    else:
        shop_sort[inputs[0]] = [int(inputs[1])]
    
for k in shop_sort.keys():
    shop_sort[k] = sorted(shop_sort[k], reverse=True)
names = sorted(shop_sort)

for n in names:
    for x in shop_sort[n]:
        key = [k for k, v in shop_dict.items() if v == (n, x)]
        print(key[0] + 1)

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

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


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int n, d1, d2, cnt;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "a", stdout);
    // #endif
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> d1 >> d2;
        if(cnt == 3)    break;
        if(d1 == d2)    cnt++;
        else    cnt = 0;
    }
    puts((cnt >= 3) ? "Yes" : "No");
    return 0;
}

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

#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int main(){
    ll a;
    cin >> a;
    for (ll i = -1000 ; i <= 1000 ; i++) {
        for (ll j = -1000 ; j <= 1000 ; j++) {
            ll p1 = pow(i,5);
            ll p2 = pow(j,5);
            if (p1 - p2 == a) {
                cout << i <<' '<<j << '\n';
                exit(0);
            }
        }
    }
}


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

typedef long long ll;

bool judgeK(int st, int end, string &S)
{
    for(int i=st; i<=end; i++)
    {
        if (S[i] != S[end-i])
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string S;
    cin >> S;

    int n = S.size();

    if(!judgeK(0, n-1, S))
    {
        cout << "No" << endl;
    }
    else if(!judgeK(0, (n-1)/2-1, S))
    {
        cout << "No" << endl;
    }
    else if(!judgeK((n+3)/2 + 1, n-1, S))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
alphabet = ["a", "b", "c", "d", "e", "f", "g",
    "h", "i", "j", "k", "l", "m", "n",
    "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = []
 
while n > 0
    ans << alphabet[n % 26 - 1]
    n -= 1 if n % 26 == 0
    n /= 26
end
     
puts ans.reverse.join("")

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

int n;
int g[3];
int a[8];

int rec(int k, vector<int>& v) {
  if (k == n) {
    int err = -30;
    int c[3] = {};
    for (int i = 0; i < n; ++i) {
      if (v[i] == 3) continue;
      c[v[i]] += a[i];
      err += 10;
    }
    
    for (int w = 0; w < 3; ++w) {
      if (c[w] == 0) return 1e9;
      err += abs(c[w] - g[w]);
    }
    return err;
  }
  
  int mn = 1e9;
  for (int w = 0; w < 4; ++w) {
    v.push_back(w);
    mn = min(mn, rec(k + 1, v));
    v.pop_back();
  }
  return mn;
}


int main() {
  cin >> n >> g[0] >> g[1] >> g[2];
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  vector<int> v;
  cout << rec(0, v) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    if(n >= 65 && n <= 90){
        cout << 1 << endl;
    }
    else if(n >= 97 && n <= 122){
        cout << 2 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}




Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main()
{
    int x,y,i;
for (i=1; i<=3000; i++)
     { 
        cin >> x >> y;
        if ( x == 0 && y == 0)
            break;
        else if (x > y)
            cout << y  << " " << x << endl;
        else 
            cout << x  << " " << y << endl;
     }
    

 


}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  int a[n][10];
  int p[n][11];

  rep(i, n) rep(j, 10) cin >> a[i][j];
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = -1e18;
  rep(bit, 1<<10) {
    bool ok = false;
    ll score = 0;

    rep(i, n) {
      int cnt = 0;
      rep(j, 10) if ((bit & (1<<j)) && a[i][j]) {
        ++cnt;
        ok = true;
      }
      score += p[i][cnt];
    }

    if (ok) chmax(ans, score);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
int n, x, m[111111];
int gcd(int a, int b){
	if(b == 0) return a;
	return gcd(b, a % b);
}
int main(){
	scanf("%d %d", &n, &x);
	for(int i = 1, a; i <= n; i++){
		scanf("%d", &a);
		m[i] = a - x;
		if(m[i] < 0) m[i] = -m[i];
	}
	int now = m[1];
	for(int i = 2; i <= n; i++)
	 	now = gcd(m[i], now);
	 printf("%d\n", now);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

string g[1000];
vector<string> _map;
int h = 0, w = 0, sum = 0;


//void rec(vector<string> _map, int y, int x, char cur) {// 参照渡し : const ,&
void rec(int y, int x, char cur) {// 参照渡し : const ,&
	// 現在マーク対象としている文字以外のセルなら戻る
	if (y<0 || x<0 || y>=h || x>=w || cur != _map[y][x]) {
		return;
	}
	// 後で重複してカウントしないようにマークしておk
	_map[y][x] = 'p';

	/*rec(_map, y-1,x, cur);
	rec(_map, y,x+1, cur);
	rec(_map, y+1,x, cur);
	rec(_map, y,x-1, cur);*/
	rec(y-1,x, cur);
	rec(y,x+1, cur);
	rec(y+1,x, cur);
	rec(y,x-1, cur);

	return;
}

void print(vector<string> v) {
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << flush;
		} cout << endl;
	}
}
int main()
{
	//ifstream cin("sampleA.txt");
	//ofstream ofs("sampleAO.txt");

	//int h = 0, w = 0;
	//vector<string> _map;//vector<char>

	while (cin >> h >> w) {
		if (h == 0 && w == 0) {
			break;
		}
		cin.ignore();
		// 初期化処理
		_map.clear();
		_map.resize(h);
		sum = 0;

		//rep(i, h) _map[i].resize(w);
		// 最初の1行以外は9文字しか読み込まれてない
		rep(i, h) {
			string tmp = "";
			getline(cin, tmp);
			//cin.ignore();
			_map[i] = tmp;
			//cin.ignore();
		}

		// debug
		//print(_map); return 0;

		rep(i, h) {
			rep(j, w) {
				if (_map[i][j] != 'p') {
					sum++;
					rec(i, j, _map[i][j]);
				}
			}
		}

		cout << sum << endl;

	}

	return 0;
}

Measured memory_bytes: 1860
S = input()
sp = len(S) - 1

ans = 0
for i in range(2 ** sp):
    plus = [""] * sp
    for j in range(sp):
        if ((i >> j) & 1):  # 下から数えてj番目が1かどうか
            plus[sp-1 - j] = "+"
    fml = ""
    for i in range(len(S)):
        if i == len(S) - 1:
            fml = fml + S[i]
        else:
            fml = fml + S[i] + plus[i]
    ans += eval(fml)
print(ans)

Measured memory_bytes: 3060
n,m = map(int,input().split())
island_1 = []
island_n = []
ans = "IMPOSSIBLE"

for i in range(m):
    AB = sorted(map(int,input().split()))
    
    if AB[0] == 1:
        island_1.append(AB[1])
        
    if AB[1] == n:
        island_n.append(AB[0])
        
island_1 = set(island_1)
island_n = set(island_n)
        
if len(island_1&island_n) > 0:
    ans = "POSSIBLE"
    
print(ans)

Measured memory_bytes: 21072
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

int main(){
    int L,N;
    string s;
    cin >> N >> L;
    vector<string> S;
    rep(i,N){
        cin >> s;
        S.push_back(s);
    }
    sort(S.begin(), S.end());
    rep(i,N){
        cout << S[i];
    }
    cout << "" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 9999999

int main(){
    int e;
    
    while(cin >> e,e){
        //x+y^2+z^3=e
        int ans = INF;
        
        for(int z = 0 ; z*z*z <= e ; z++){
            for(int y = 0 ; (y*y)+(z*z*z) <= e ; y++){
                ans = min(ans,e-y*y-z*z*z+y+z);
            }
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
# http://merom686.hatenablog.com/entry/20120914/1347615020 を参考にしました

import math

n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
s = [0]*n
a = 0

for i in range(n):
    x[i],y[i] = map(int,input().split())


def calcdis(p):
    d = 0
    for i in range(len(p)-1):
        a = int(p[i])
        b = int(p[i+1])
        d += math.sqrt(math.pow(x[a]-x[b],2)+math.pow(y[a]-y[b],2))

    return d


def listup(d,history,stuck):
    global a
    if (d != 0):
        for i in range(n):
            if (history[i]) : continue
            history[i] = 1
            stuck[d-1] = str(i)
            listup(d-1,history,stuck.copy())
            history[i] = 0
    else:
        a += calcdis("".join(stuck))



def main():
    listup(n,h,s)
    print(a / math.factorial(n))



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;

int n,fa[N],a[N],m,id[N];
int find(int x) {return x==fa[x]?x:fa[x]=find(fa[x]);}
bool b[N];
ll ans;

int tmp[N];
bool cmp(int x,int y) {return a[x]<a[y];}

int main()
{
	scanf("%d%d",&n,&m);
	if (m==n-1) {puts("0");return 0;}
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),fa[i]=i;
	for (int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);u++,v++;
		fa[find(u)]=find(v);
	}
	
	int cnt=0;
	for (int i=1;i<=n;i++) if (fa[i]==i) id[i]=i;
	for (int i=1;i<=n;i++) if (a[i]<a[id[find(i)]]) id[fa[i]]=i;
	for (int i=1;i<=n;i++) 
	{
		if (fa[i]==i) b[id[i]]=true,ans+=a[id[i]],cnt++;
		tmp[i]=i;
	}

	sort(tmp+1,tmp+n+1,cmp);
	for (int i=1;i<=n&&cnt<2*(n-1-m);i++) 
	if (!b[tmp[i]]) ans+=a[tmp[i]],++cnt;
	
	if (cnt<2*(n-1-m)) puts("Impossible");
	else printf("%lld\n",ans);
	return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    cin>>n;
    int t=n/100; n%=100;
    if(n<=5*t) cout<<1;
    else cout<<0;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){ 
  string S; cin>>S;
  string ans="ABC";
  if(S=="ABC") ans="ARC";
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          string S;
          cin >> S;

          bool ans=false;
          int count=0;

          if(S[0]=='A'){
                    REP(i,S.size()-3){
                              if(S[i+2]=='C'){
                                        count++;
                              }
                    }
                    if(count==1) ans=true;
          }

          int cnt=0;

          if(ans==true){
                    REP(i,S.size()){
                              for(char c='A';c<='Z';c++){
                                        if(S[i]==c) cnt++;
                              }
                    }
                    if(cnt==2){
                              cout << "AC" << endl;
                              exit(0);
                    }
                    else      cout << "WA" << endl;
          }else     cout << "WA" << endl;

          return 0;
}


Measured memory_bytes: 256
/*Anikash Chakraborty cpp*/
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define w(t) int t; cin>>t; while(t--)
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<long long>
#define MAX 100002
#define MOD 1000000007
#define ll long long
 
using namespace std;
ll bigmod(ll b, ll p, ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
bool vis[MAX];
vector<ll> adj[MAX];
void dfs(ll u)
{
    vis[u] = true;
    for(auto i:adj[u])
        if(!vis[i]) dfs(i);
}

int dp[MAX];
int solve(vi a,int n,int k){
    int dp[n+1];
    
    dp[0]=0;
      dp[1]=abs(a[0]-a[1]);
     
      for(int i=2;i<n;i++){
        dp[i]=INT_MAX;
        for(int j=i-1;j>=max(0,i-k);j--){
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
      }
     
      return dp[n-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        memset(dp,-1,sizeof dp);
    
        ll n,k;
        cin>>n>>k;
        vi a(n);

        REP(i,n) cin>>a[i];
        
        cout<<solve(a,n,k)<<endl;

        // REP(i,n) cout<<dp[i]<<" ";
        // cout<<endl;
        

    
    
 
}



Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    printf("%d %d %d %d\n", x2 + y1 - y2, y2 - (x1 - x2), x1 + y1 - y2, y1 - (x1 - x2));
}


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

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

    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int cnt = 0;
    REP(i, a + 1){
        REP(j, b + 1){
            REP(k, c + 1){
                if(i * 500 + j * 100 + k * 50 == x){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a = input()

    count = 0
    for i in a:
        if "7" in i:
            count +=1

    if count >0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10400
n=int(input())
lst=list(map(int, input().split()))
r=0
l=0
ans=0
Sum=lst[0]
xSum=lst[0]
while 1:
  ans+=r-l+1
  if(r==n-1):
    break
  r+=1
  Sum+=lst[r]
  xSum^=lst[r]
  if(Sum!=xSum):
    while(Sum!=xSum):
      Sum-=lst[l]
      xSum^=lst[l]
      l+=1
print(ans)

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n, m; cin >> n >> m;
	G g; g.resize(n+1);
	for(int i=0;i<m;i++){
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	map<int, int> mp;
	for(auto c: g[1]){
		mp[c]++;
	}
	for(auto c: g[n]){
		mp[c]++;
	}
	for(auto kv: mp){
		if(kv.second==2){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
vector<int> g[222222];
int cnt=0;
bool vis[222222];

void dfs(int v){
	if(v<n)cnt++;
	vis[v]=true;
	rep(i,g[v].size()){
		if(!vis[g[v][i]])dfs(g[v][i]);
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n){
		int k;
		cin>>k;
		rep(j,k){
			int a;
			cin>>a;
			a--;
			g[i].pb(a+n); g[a+n].pb(i);
		}
	}
	memset(vis,0,sizeof(vis));
	dfs(0);
	if(cnt==n)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int ma=0;
  cin>>s;
 if(s[0]=='R' && s[1]=='R' && s[2]=='R')
 cout<<3;
 else if((s[0]=='R' && s[1]=='R' && s[2]=='S')||(s[0]=='S' && s[1]=='R' && s[2]=='R'))
 cout<<2;
 else if((s[0]=='R' && s[1]=='S' && s[2]=='R')||(s[0]=='R' && s[1]=='S' && s[2]=='S')||(s[0]=='S' && s[1]=='R' && s[2]=='S')||(s[0]=='S' && s[1]=='S' && s[2]=='R'))
cout<<1;
else
cout<<0;

    
}

Measured memory_bytes: 3632
a,b,c,x,y = (int(i) for i in input().split())
if a+b > c*2:
  if x > y:
    print(c*min(x,y)*2 + (x-y) * min(a, c*2))
  else:
    print(c*min(x,y)*2 + (y-x) * min(b, c*2))
else:
  print(a*x + b*y)


Measured memory_bytes: 3060