akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        int l = i % 10, f = s[0] - '0';
        if (l == f) {
            ++ans;
        }
        if (l == 0) continue;
        for (int len = 0; len < 5; len++) {
            int cur = l;
            int mx = 1;
            for (int j = 0; j < len; j++) {
                cur *= 10;
                mx *= 10;
            }
            cur = cur * 10 + f;
            if (cur > n) continue;
            ans += min(mx, (n - cur) / 10 + 1);
        }
//        cout << ans << '\n';
    }
    cout << ans << '\n';
}


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

int main(){
	string s;
	cin >> s;
	if (s[0] == 'A') {
		int c = 0;
		for (int i = 1;i < s.size();i++) {
			if (s[i] <'a'||s[i] > 'z') {
				c++;
			}
		}
		if (c == 1) {
			int count = 0;
			for (int i = 2;i < s.size() - 1;i++) {
				if (s[i] == 'C') {
					count++;
				}
			}
			if (count == 1) {
				cout << "AC" << endl;
				return 0;
			}
		}
	}
	cout << "WA" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 100000
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main()
{   
    for(int T=read();T--;)
    {
        ll a=read(),b=read(),c=read(),d=read();
        if(a<b||d<b) {puts("No");continue;}
        ll g=gcd(b,d);
        ll mn=a-max(0LL,(a-c-1)/g*g);
        if(mn<b) puts("No");
        else puts("Yes");
    }    
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect
n,K = (int(i) for i in input().split())
v = [int(i) for i in input().split()]
ans = 0
for i in range(min(n,K)+1):
    for j in range(i+1):
        z = []
        for k in range(j): z.append(v[k])
        for k2 in range(i-j): z.append(v[-k2-1])
        z.sort()
        ans = max(ans,sum(z[min(bisect(z,0),K-i):]))
print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main{
  public static Scanner cin;
  public static HashMap<String,Integer> m;

  public static String reverse(String s){
    return new StringBuffer(s).reverse().toString();
  }

  public static void arrange(){
    String s=cin.nextLine();
    m=new HashMap<String,Integer>();
    int i=1;
    for(;i<s.length();i++){
      String s1=s.substring(0,i),s2=s.substring(i);
      m.put(s1+s2,1);
      m.put(reverse(s1)+s2,1);
      m.put(s1+reverse(s2),1);
      m.put(reverse(s1)+reverse(s2),1);
      m.put(s2+s1,1);
      m.put(reverse(s2)+s1,1);
      m.put(s2+reverse(s1),1);
      m.put(reverse(s2)+reverse(s1),1);
    }
    System.out.println(m.size());
  }

  public static void main(String []args){
    cin=new Scanner(System.in);
    int i=0,n=cin.nextInt();
    cin.nextLine();
    for(;i<n;i++)arrange();
  }
}

Measured memory_bytes: 13000
let rec fold_for a b v f = if a > b then v else fold_for (a+1) b (f a v) f
let () =
  Scanf.scanf "%d" @@ fun n ->
  let w = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  fold_for 0 (n-2) 10101010 (fun i v ->
    let s1 = fold_for 0 i 0 (fun i v -> v + w.(i)) in
    let s2 = fold_for (i+1) (n-1) 0 (fun i v -> v + w.(i)) in
    min v (abs (s1 - s2)))
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
#include<cstdio>
const int N=1e5+3,M=1e9+7;
inline int Mod(int a){return a<M?a:a-M;}
struct edge{int v,nxt;}g[N+N];
int n,head[N],k,f[N][2];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs(int u,int fa){
	int v;
	f[u][0]=f[u][1]=1;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs(v,u),f[u][0]=(long long)f[u][0]*(f[v][0]+f[v][1])%M,f[u][1]=(long long)f[u][1]*f[v][0]%M;
}
signed main(){
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs(1,0);
	printf("%d",Mod(f[1][0]+f[1][1]));
	return 0;
}

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

using namespace std;

int main()
{
    int N;

    cin >> N;

    int ans = 0;

    while (true)
    {
        if (N > 1000)
        {
            N = N - 1000;
        }

        if (N < 1000)
        {
            ans = 1000 - N;
            break;
        }

        if (N == 1000)
        {

            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") 
#pragma GCC optimize("unroll-loops") 
#pragma GCC optimize("fast-math")
  
#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
  
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
  
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i; 
    }
    return str;
}
  
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
  
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();   
    return 0;
}

const int MOD = 1e9 + 7;
int cnt1[65], cnt0[65];

void solve() {
    int n; 
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int num; 
        cin >> num;
        for (int j = 0; j < 60; ++j) {
            if ((num >> j) & 1) {
                cnt1[j]++;
            }
            else {
                cnt0[j]++;
            }
        }
    }
    int ans = 0;
    int p = 1;
    for (int i = 0; i < 64; ++i) {  
        // if (cnt1[i] == 0 || cnt0[i] == 0) continue;
        p %= MOD;
        ans = (ans + (p * cnt1[i] % MOD) * cnt0[i] % MOD) % MOD;
        p *= 2;
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};


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

    int N;
    cin >> N;
    CumulativeSum<int> cs(N);

    REP(i, N) {
        int a;
        cin >> a;
        cs.Add(i, a);
    }
    cs.Build();

    int ans = LLINF;
    for(int i = 0; i < N - 1; ++i) {
        int sunuke = cs.Query(0, i);
        int arai = cs.Query(i + 1, N - 1);
        int cand = abs(sunuke - arai);
        chmin(ans, cand);
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

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

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

const double PI=3.14159265358979323846;

// vars

ll N;
string S;

void input() {
    N = read<ll>();
    S = read<string>();
}

void solve() {
    if(S.substr(0, N / 2) == S.substr(N/2)){ write("Yes"); }
    else { write("No"); }
}

int main() {
    input();
    solve();
}



Measured memory_bytes: 256
N = int(input())
s = 'MARCH'
c = [0] * 5
for i in range(N):
    S = input()
    for j in range(5):
        if S[0] == s[j]:
            c[j] += 1

ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += c[i] * c[j] * c[k]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
#define Forr(i,j,k) for(int i=j;i>=k;--i)
#define ll long long 
using namespace std;
const int N = 2010, INF = 0x3f3f3f3f, Mod = 1e9 + 7;
template<class T>void read(T &x){
	x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while( isdigit(c))x=x*10+c-48,c=getchar();
}
inline void file(){
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
}
int n, k, fac[N * N], ifac[N * N];
ll qpow(ll a, ll b){
	ll ret=1;
	for(;b;b>>=1,a=a*a%Mod)if(b&1)ret=ret*a%Mod;
	return ret;
}
void init(){
	read(n), read(k);
	fac[0] = 1;
	For(i, 1, n * k)fac[i] = 1ll * fac[i - 1] * i % Mod;
	ifac[n * k] = qpow(fac[n * k], Mod - 2);
	Forr(i, n * k, 1)ifac[i - 1] = 1ll * ifac[i] * i % Mod;
}
inline ll C(int a, int b){
	if(a < 0 || b < 0 || a < b)return 0;
	return fac[a] * 1ll * ifac[b] % Mod * ifac[a - b] % Mod;
}
int dp[N][N];
void solve(){
	dp[0][0] = 1;
	For(i, 0, n)
		For(j, i, n){
			if(i) dp[i][j] = dp[i - 1][j];
			if(j) dp[i][j] = (dp[i][j] + dp[i][j - 1] * C(i + j * (k - 1) - 1, k - 2)) % Mod;
		}
	if(k != 1)
		printf("%lld\n", 1ll * dp[n][n] * fac[n] % Mod);
	else puts("1");
}
int main(){
	//file();
	init();
	solve();
	return 0;
}


Measured memory_bytes: 47488
H,W,K = map(int,input().split())
c = [input() for i in range(H)]

#for h in range(H):
#  for w in range(W):
#    if c[h][w] == '#':

h = len(c)
hl = []
for i in range(2 ** h):
 bit_set = []
 for j in range(h):
   if ((i >> j) & 1):
     bit_set.append(j)

 hl.append(bit_set)

wl = []
for i in range(2 ** W):
 bit_set = []
 for j in range(W):
   if ((i >> j) & 1):
     bit_set.append(j)
 wl.append(bit_set)


ans = 0
for w in wl:
  wll = []
  for ww in w:
    wll.append(ww)

  for h in hl:
    count = 0
    for i, cc in enumerate(c):
      if not i in h:
        for k, ccc in enumerate(cc):
          if not k in wll:
            if ccc == '#':
              count += 1

    if count == K:
      ans += 1


print(ans)

 

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<int> A(N), sum(N);
  rep(i, N) cin >> A[i];
  
  sort(all(A));
  
  sum[0] = A[0];
  rep(i, N-1) sum[i+1] = sum[i]+A[i+1];
  
  int k = N-2;
  while(2*sum[k] >= A[k+1]) {
    if(k == 0) {
      cout << N << endl;
      return 0;
    }
    k--;
  }
  cout << N-k-1 << endl;
  
}

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

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x < b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n)  { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

int n;
int a[N];

set <int> S[N];
queue <int> Q;

int Merge(int x, int y) {
    if (S[x].size() < S[y].size()) swap(x, y);
    for (set <int> :: iterator it = S[y].begin(); it != S[y].end(); ++it)
        S[x].insert(*it);
    return x;
}

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // LOCAL
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &a[i]);
    FOR(i, 1, n) {
        S[i].insert(a[i]);
        Q.push(i);
    }
    sort(a + 1, a + n + 1);
    LL ans = 0;
    FOR(i, 1, n) {
        int v = a[i], sz = 0;
        assert(Q.size());
        int p = Q.front(); Q.pop();
        sz = S[p].size();
        while (*S[p].begin() != v) {
            sz += S[Q.front()].size();
            p = Merge(p, Q.front());
            Q.pop();
        }
        S[p].erase(v);
        if (S[p].size() != 0) Q.push(p);
        ans += (sz - 1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 36700
lst = []
n, l = map(int, input().split())
lst = list(range(l, l+n))
if lst.count(0) == 1:
	ans = sum(lst)
elif max(lst) > 0:
	del lst[0]
	ans = sum(lst)
else:
	del lst[-1]
	ans = sum(lst)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public Integer nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        int q = 1;
        for (int i = 0; i < q; i++) {
            solver.solve(i + 1, in, out);
        }
        out.close();
    }

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[][] towns = new long[n][2];
            for (int i = 0; i < n; i++) {
                towns[i][0] = in.nextLong();
                towns[i][1] = in.nextLong();
            }
            long fac = 1;
            for (int i = 2; i <= n; i++) {
                fac *= i;
            }
            double sum = 0;
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    sum += Math.sqrt(Math.pow(towns[i][0] - towns[j][0], 2) + Math.pow(towns[i][1] - towns[j][1], 2));
                }
            }
            out.println(2 * ((double) fac / n) * sum / fac);
        }
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
#define MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

// テレンス「もしかしてACですかーッ!?」　ジョセフ「Yse! Yse! Yse! Oh~MyGod」

struct UnionFind{
  vector<int> par;
  UnionFind(int N):par(N){
    for(int i=0;i<N;i++) par[i]=i;
  }
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry) return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
  int size(int n){
    return -par[root(n)];
  }
};





int main() {
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind road(n),train(n);
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    road.unite(a-1,b-1);
    road.unite(b-1,a-1);
  }
  for(int i=0;i<l;i++){
    int a,b;
    cin>>a>>b;
    train.unite(a-1,b-1);
    train.unite(b-1,a-1);
  }
  map<P,int> M;
  for(int i=0;i<n;i++){
    P pa(road.root(i),train.root(i));
    M[pa]++;
  }
  for(int i=0;i<n;i++){
    P pa(road.root(i),train.root(i));
    cout<<M[pa]<<endl;
  }
}


Measured memory_bytes: 13568
from copy import copy

def getval():
    s = input()
    t = input()
    return s,t

def main(s,t):
    dp = ["" for i in range(len(t)+1)]
    for i in range(len(s)):
        temp = [""]
        for j in range(len(t)):
            prev = dp[j+1]
            last = temp[-1]
            if len(prev)>len(last):
                temp.append(prev)
            elif len(prev)<len(last):
                temp.append(last)
            elif s[i]==t[j]:
                temp.append("".join([dp[j],s[i]]))
            else:
                temp.append(prev)
        dp = copy(temp)
        
    print(dp[len(t)])
                    
if __name__=="__main__":
    s,t = getval()
    main(s,t)

Measured memory_bytes: 229288
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

LL cakes[1005][3];
LL sums[1005];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%lld%lld%lld", &cakes[i][0], &cakes[i][1], &cakes[i][2]);
    }
    LL choices[8][3] = {
        {1,1,1},
        {-1,1,1},
        {1,-1,1},
        {1,1,-1},
        {-1,-1,1},
        {-1,1,-1},
        {1,-1,-1},
        {-1,-1,-1},
    };
    LL ans = 0;
    for (int c = 0; c < 8; c++) {
        for (int i = 0; i < n; i++) {
            sums[i] = cakes[i][0] * choices[c][0] + cakes[i][1] * choices[c][1] + cakes[i][2] * choices[c][2];
        }
        LL tmp = 0;
        sort(sums, sums + n, [](LL a, LL b){return a > b;});
        for (int i = 0; i < m; i++) {
            tmp += sums[i];
        }
        ans = max(ans, tmp);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include <iostream>



#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll A,B;
    string res;


    cin >> A >> B;

    if( A <= 8 && B <= 8)res = "Yay!";
    else res = ":(";

    cout << res << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
    int n, q, i, j, k, l;
    cin>>n;
    int a[n+2];
    ll ans=0;
    map<int,int>mp;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        mp[a[i]]++;
        ans+=a[i];
    }
    cin>>q;
    while(q--)
    {
        int u, v;
        cin>>u>>v;
        ll tmp=(ll)u*mp[u];
        int tmp2=mp[u];
        mp[u]=0;
        mp[v]+=tmp2;
        ll tmp1=(ll)tmp2 * v;
        cout<<ans-tmp+tmp1<<endl;
        ans=ans-tmp+tmp1;
    }
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> dam(N);
  vector<ll> Rain(N);
  ll sum = 0;
  for (ll &e : dam) {
    cin >> e;
    sum += e;
  }
  for (int i = 0; i < N; i++) {
    if (i < 2) {
      ll s = 0;
      for (int j = 0; j < (N-1)/2; j++) s += dam[(i+1+j*2)%N];
      Rain[i] = sum-s*2;
    }
    else Rain[i] = Rain[i-2]+(dam[i-1]-dam[i-2])*2;
  }
  for (int i = 0; i < N; i++) {
    cout << Rain[i] << (i < N-1 ? " " : "\n");
  }
}

Measured memory_bytes: 2816
N,L = map(int,input().split())
if L > 0:
    print(int(N*(2*L+N-1)/2 - L))
elif L+N-1 < 0:
    print(int(N*(2*L+N-1)/2 - (L+N-1)))
else:
    print(int(N*(2*L+N-1)/2))

Measured memory_bytes: 3060
import scala.io.StdIn._
object Main extends App {
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val map = Array.fill(h){readLine.trim.toCharArray}
  val buildings = (0 until w).flatMap{x ⇒ (0 until h).collect{
    case y if map(y)(x) == 'B' ⇒ Coordinate(x, y)
  }}.toArray.sortBy(c ⇒ c.x + c.y)
  val building2 = buildings.sortBy(c ⇒ c.x - c.y)
  println(
    math.max(buildings.head.manhattanDistance(buildings.last), building2.head.manhattanDistance(building2.last))
  )
}

case class Coordinate(x: Int, y: Int) {
  def manhattanDistance(that: Coordinate): Int = math.abs(x - that.x) + math.abs(y - that.y)
}


Measured memory_bytes: 338232
N, M, C = map(int, raw_input().split())
B = map(int, raw_input().split())

answer = 0
for i in range(N):
    A = map(int, raw_input().split())
    sum = 0
    for j in range(M):
        sum += A[j] * B[j]
    if sum + C > 0:
       answer += 1

print(answer)

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

int main()
{
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++){
        if (n.at(i) == '1'){
            n.at(i) = '9';
        }else{
            n.at(i) = '1';
        }
    }

    for (int i = 0; i < 3; i++){
        cout << n.at(i);
    }
    cout << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	ll N,K;
	cin>>N>>K;
	ll ans=K;
	while(N-->1){
		ans*=(K-1);
	}
	ce(ans)
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int c,n,m; cin >> c >> n >> m;
    vector<int> dp(c+1);
    vector<int> s(n),p(n);
    for(int i=0;i<n;i++){
        cin >> s[i] >> p[i];
    }
    for(int i=0;i<n;i++){
        vector<int> ndp=dp;
        for(int j=0;j+s[i]<=c;j++){
            ndp[j+s[i]]=max(ndp[j+s[i]],dp[j]+p[i]);
        }
        swap(dp,ndp);
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",dp[c/i]*i);
    }
}


Measured memory_bytes: 3424
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, a[100005];
double m;
int main() {
	int i, k;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	m = a[n-1] / 2.0;
	k = lower_bound(a, a+n, m) - a;
	if(m-a[k-1]<=a[k]-m) printf("%d %d", a[n-1], a[k-1]);
	else printf("%d %d", a[n-1], a[k]);
	return 0;
}

Measured memory_bytes: 640
a, b = map(int, input().split())

a_before = a / 0.08

if int(a/0.08) == a/0.08:
    a_min = int(a/0.08)
    a_max = int((a+1)/0.08)
elif int((a+1)/0.08) == (a+1)/0.08:
    a_max = int((1+a)/0.08 - 1)
    a_min = int(a/0.08 + 1)
else:
    a_min = int(a/0.08 + 1)
    a_max = int((a+1) / 0.08)

b_min = int(b/0.1)
b_max = int((b+1)/0.1 - 1)

if a_min >= b_min:
    if a_min <= b_max:
        print(a_min)
    else:
        print(-1)
elif b_min > a_min:
    if b_min <= a_max:
        print(b_min)
    else:
        print(-1)


Measured memory_bytes: 3064
n,m = map(int, input().split())
scl = []
for _ in range(m):
    s,c = map(int, input().split())
    scl.append((s,c))

for i in range(0, 1000):
    si = str(i)
    if len(si) != n: continue
    for sc in scl:
        s,c = sc
        if si[s-1] != str(c):
            break
    else:
        print(i)
        exit()
else:
    print(-1)

Measured memory_bytes: 62600
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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

#define forn(i, a, n) for (int i = (a); i < (int)n; i++)
#define trav(x, arr) for (auto &x : arr)
#define sz(x) (int)x.size()
#define Matrix(m, h, w) = std::vector<vector<int>> m(h, vector<int> (w)); 
using ll = long long;

// benq
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;


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


    int n, k; cin >> n >> k;

    vector<int> dp(n+1, INT_MAX), h(n+1);

    forn(i, 0, n) cin >> h[i];

    dp[0] = 0;

    forn(i, 1, n) {

    	for (int j = 1; j <= k && i-j >= 0; j++) {

    		dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
    	}

    }

    cout << dp[n-1];

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int sz = 8010;
	string s;
	int x, y;
	cin >> s >> x >> y;
 
	vector<vector<int>> d(2, vector<int>(2*sz, 0));
	d[0][sz] = d[1][sz] = 1;
	int cnt = 0;
	int f = -1;
	s += "T";
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'F') {
			++cnt;
			continue;
		}
		if (f < 0) {
			d[0][sz + cnt] = 1;
			cnt = 0;
			f = 1;
			continue;
		}
 
		vector<int> t(2*sz, 0);
		for (int i = 0; i < 2*sz; ++i) {
			if (i - cnt >= 0) { t[i - cnt] |= d[f][i]; }
			if (i + cnt < 2*sz) { t[i + cnt] |= d[f][i]; }
		}
		d[f] = t;
		cnt = 0;
		f = 1 - f;
	}
	cout << (d[0][x + sz] & d[1][y + sz] ? "Yes" : "No") << "\n";
 
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}

const ll N = 2e5+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;

struct S{
	ll a, b, c;
};

S arr[N];

void testcase(){
	int n;
	cin>>n;
	
	for(int i = 1; i <= n; i++){
		cin>>arr[i].a>>arr[i].b>>arr[i].c;
	}
	
	ll dp[N][3];
	
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	
	for(int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i].a;
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i].b;
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + arr[i].c;
	}
	
	ll ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
	cout<<ans<<'\n';
	
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int x, y;
	cin >> x >> y;
	int tmp = x;
	int ans = 0;
	while (tmp <= y) {
		tmp *= 2;
		ans++;
	}
	print(ans);
}

Measured memory_bytes: 256
import sys

lines = sys.stdin.read().split('\n')
nt_text = lines[0].split(' ')
N = int(nt_text[0])
T = int(nt_text[1])

HIGHEST_COST = 1000

smallest_cost = HIGHEST_COST + 1
for i in range(1, N+1):
    ct_text = lines[i].split(' ')
    if int(ct_text[1]) <= T:
        smallest_cost = min(smallest_cost, int(ct_text[0]))

if smallest_cost > HIGHEST_COST:
    print('TLE')
else:
    print(smallest_cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, ii>  iii;
typedef pair<double, double>  iidb;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3300
#define offset 3000
#define ptr nodo*
const ll MOD=1e9+7;

using namespace std;
int arrpa[tam];
int peso[tam][tam];
int findpa(int num){if (arrpa[num]==num)return num;return arrpa[num]=findpa(arrpa[num]);}
int main()
{	
	forr(i,0,tam)arrpa[i]=i;
	int n;ll tot=0;
	cin>>n;
	forr(i,0,n)
	{
		forr(j,0,n){
			cin>>peso[i][j];	
			tot+=peso[i][j];
		}
	}
	bool invalid=0;

	set<ii> s;
	forr(k,0,n)
	{
		forr(i,0,n)
		{
			forr(j,0,n)
			{
				if (i==k|| j==k)continue;
				int ant=peso[i][j];
				peso[i][j]=min(peso[i][j],peso[i][k]+peso[k][j]);
				if (ant!=peso[i][j])
					invalid=1;
				else if (ant==peso[i][k]+peso[k][j])
					s.insert({min(i,j),max(i,j)});
			}
		}
	}
	for(auto par:s)
		tot-=2*peso[par.fi][par.se];
	
	if (invalid)
		cout<<"-1\n";
	else
	{
		cout<<tot/2<<endl;
	}
}		

Measured memory_bytes: 7912
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int N;
vector<ll> A;
ll K;

ll dp[70][2];

ll solve(int b, int less) {
  if (b < 0) return 0;
  ll& res = dp[b][less];
  if (res != -1) return res;
  res = 0;
  int now = (K >> b) & 1;
  for (int d = 0; d <= (less ? 1 : now); d++) {
    ll sum = 0;
    for (ll a : A) {
      sum += d ^ ((a >> b) & 1);
    }
    sum <<= b;
    sum += solve(b - 1, less || (d < now));
    res = max(res, sum);
  }
  return res;
}

int main() {
  while (cin >> N >> K) {
    A.resize(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(62, 0) << endl;
  }
  return 0;
}


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

using namespace std;

const int Maxn = 1e5+7;
const int MOD = 998244353;

int n, a[Maxn];

int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	sort(a+1, a+n+1);
	int ans = a[1];
	for(int i = 2; i <= n; ++i)
		ans = int(1ll*ans*__gcd(a[i], i-1)%MOD);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{	
	int a[10] = {};
	int i = 0;
	while (cin >> a[i]) {
		i++;
		if (i == 10)break;
	}
	int max;
	for (int j = 0; j < 3; j++) {
		max = j;
		for (int k = j + 1; k < 10; k++) {
			if (a[max] < a[k]) {
				max = k;
			}
		}
		cout << a[max] << endl;
		a[max] = 0;
	}
	return 0;
}


Measured memory_bytes: 3056
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long a, b, c;
    std::cin >> a >> b >> c;

    if (a == b && b != c || a == c && c != b || b == c && c != a) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Biscuit Generator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, t;
  scanf("%d%d%d", &a, &b, &t);

  printf("%d\n", t / a * b);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> p(M);
  vector<string> S(M);
  for (int i=0; i<M; i++){
    cin >> p.at(i) >> S.at(i);
  }
  int ac=0;
  int pena=0;
  
  vector<vector<string>> result(N, vector<string>(0));
  
  for (int i=0; i<M; i++){
    int pi=p.at(i);
    string si=S.at(i);
    result.at(pi-1).push_back(si);
  }
  
  for (int i=0; i<N; i++){
    if (result.at(i).size() != 0){
      int penai = 0;
      int aci = 0;
      for (int j=0; j<result.at(i).size(); j++){
        if(result.at(i).at(j) == "WA"){
          penai++;
        }
        
        else{
          aci++;
          break;
        }
      }
      if(aci==1){
        pena += penai;
        ac += aci;
      }
    }
  }
  cout << ac << " " << pena << endl;
}
  

Measured memory_bytes: 11520
import fractions
a,b,c,d=map(int,input().split())
x=abs(c-a)
y=abs(d-b)
if x==0 or y==0:
    print(0)
else:
    gcd=fractions.gcd(x,y)
    m=x//gcd
    n=y//gcd
    print((m+n-1)*gcd)


Measured memory_bytes: 5304
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n, m, k;
  cin >> n >> m >> k;
  lol a[n + 5] = {};
  lol b[m + 5] = {};
  reps(i, n){
    cin >> a[i];
    a[i] += a[i - 1];
  }
  reps(i, m){
    cin >> b[i];
    b[i] += b[i - 1];
  }
  int ans = 0;
  rep(i, n + 1){
    if(a[i] <= k){
      int low = 0, high = m + 1;
      while(high > low + 1){
	int mid = (low + high) / 2;
	if(b[mid] > k - a[i]){
	  high = mid;
	} else {
	  low = mid;
	}
      }
      //cout << low << " " << high << '\n';
      ans = max(ans, i + low);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int N = s.size();
    int left;
    int right;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A') {
            left = i;
            break;
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (s[i] == 'Z') {
            right = i;
            break;
        }
    }
    cout << right - left + 1 << endl;
}

Measured memory_bytes: 3756
//reversing numbers

#include<iostream>
using namespace std;

int main()
{
int a[100] ;
int n;

cin >> n;

for(int i = 0; i < n; i++)
{
cin >> a[i];
}
for(int j = 1; j <= n; j++)
{
cout << a[n-j] ;
if(j==n){break;}
cout<<" ";
}
cout << endl;

return 0;
}

Measured memory_bytes: 1160
n = int(input())
t = []
t.append([0,0,0])
for i in range(n):
    t.append(list(map(int,input().split())))
#print(t)
for i in range(1,n+1):
    time = t[i][0] - t[i-1][0]
    dist = abs(t[i][1] - t[i-1][1])+abs(t[i][2]-t[i-1][2])
    if (dist > time)or(time%2 != dist %2):
        print('No')
        exit()
print('Yes')


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

int main(){
    string s;
    cin >> s;
    
    int len;
    len = s.length();
    vector<bool> flag(4);
    rep(i, len){
        if(s.at(i) == 'N') flag.at(0) = true;
        if(s.at(i) == 'W') flag.at(1) = true;
        if(s.at(i) == 'S') flag.at(2) = true;
        if(s.at(i) == 'E') flag.at(3) = true;
    }
    string ans = "Yes";
    if(flag.at(0) || flag.at(2)){
        if(!(flag.at(0) && flag.at(2))) ans = "No";
    }
    if(flag.at(1) || flag.at(3)){
        if(!(flag.at(1) && flag.at(3))) ans = "No";
    }
    
    cout << ans << endl;
    return 0;
}

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

N, M = map(int, input().split())

# 1からある島への便があるかを保持
transit = [False] * N
# ある島からNへの便があるかを保持
transit2 = [False] * N

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        transit[b] = True
    if b == N:
        transit2[a] = True

for i in range(N):
    if transit[i] and transit2[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 6132
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b = LI()
if 1 <= a <= 9 and 1 <= b <= 9:
    print(a * b)
else:
    print(-1)

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

#define MOD 1000000007

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1], t[n+1];
    scanf("%s %s", s, t);
    lld ans;
    int x;
    if(s[0] == t[0]){
        ans = 3;
        x = 1;
    }else{
        ans = 6;
        x = 2;
    }
    while(s[x] != '\0'){
        if(s[x] == t[x]){
            if(s[x-1] == t[x-1]){
                ans *= 2LL;
                ans = ans % MOD;
            }else{
                ans *= 1LL;
                ans = ans % MOD;
            }
            x += 1;
        }else{
            if(s[x-1] == t[x-1]){
                ans *= 2LL;
                ans = ans % MOD;
            }else{
                ans *= 3LL;
                ans = ans % MOD;
            }
            x += 2;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128