akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    REP(i, 100){
        if(a <= i && i < b && c <= i && i < d){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rustメモ: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

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

fn calc_min_cost(cost:&mut Vec<Vec<i64>>){
    for _ in 0..10{
        for i0 in 0..10{
            for i1 in 0..10{
                for i2 in 0..10{
                    cost[i0][i2] = cmp::min(
                        cost[i0][i2],
                        cost[i0][i1]+cost[i1][i2]);
                }
            }
        }
    }
}

fn main(){
    let mut cost = Vec::new();
    let mut board = Vec::new();
    let input = read_ints();
    let (h,w) = (input[0],input[1]);
    let mut ans = 0;

    for _ in 0..10{
        cost.push(read_ints());
    }
    for _ in 0..h{
        board.push(read_ints());
    }
    calc_min_cost(&mut cost);

    for i in 0..h as usize{
        for j in 0..w as usize{
            if board[i][j] != -1 {
                ans += cost[board[i][j] as usize][1];
            }
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<ll> vec(4);
  vec[0] = a * c;
  vec[1] = a * d;
  vec[2] = b * c;
  vec[3] = b * d;
  sort(vec.begin(), vec.end());
  cout << vec[3] << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#define MAX (10000)
#define NIL (-1)
using namespace std;
struct Node{
    int parent;
    int left,right;
};
Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL)return;
    printf(" %d",u);
    preParse(T[u].left);
    preParse(T[u].right);
}
void inParse(int u){
    if(u==NIL)return;
    inParse(T[u].left);
    printf(" %d",u);
    inParse(T[u].right);
}
void postParse(int u){
    if(u==NIL)return;
    postParse(T[u].left);
    postParse(T[u].right);
    printf(" %d",u);
}
int main(void){
    int k,l,r;
    int d;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].parent=T[i].left=T[i].right=NIL;
    }
    for(int i=0;i<n;i++){
        cin>>k>>l>>r;
        T[k].left=l;
        T[k].right=r;
        if(l!=NIL)T[l].parent=k;
        if(r!=NIL)T[r].parent=k;
    }
    for(int i=0;i<n;i++)if(T[i].parent==NIL)d=i;
    printf("Preorder\n");
    preParse(d);
    printf("\n");
    printf("Inorder\n");
    inParse(d);
    printf("\n");
    printf("Postorder\n");
    postParse(d);
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main (){
int N , M;
cin >> N >> M;
int favourite[40]={0};
for(int i = 1; i < N+1; i++){
  int K ;
  cin >> K;
  for(int j = 0; j < K; j++) {
    int A;
    cin >> A;
    favourite[A]++;
}
}
int count = 0;
for(int i = 0; i <= M; i++){
  if(favourite[i] == N) count++;
}
cout << count << endl;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int A,B;
    priority_queue<pair<ll,int>> q;
    REP(i,N){
        cin>>A>>B;
        q.push(mp(A+B,A));
    }
    ll taka=0;
    ll ao=0;
    ll ans=0;
    pair<ll,int> p;
    REP(i,N){
        p=q.top();
        q.pop();
        if(i%2==0){
            ans+=p.second;
        }else{
            ans-=p.first-p.second;
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 5748
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e4 + 50;
const int mod = 996873654;
int main(){
	int M,D;
	cin>>M>>D;
	int ans=0;
	for(int i=1;i<=M;i++){
		for(int j=1;j<=D;j++){
			int d1=j%10,d2=j/10;
			if(d1>=2&&d2>=2&&d1*d2==i){
				ans++;
			}
		}
	}
	pfi(ans);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template <class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template <class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define Cin(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define VecIn(T,name,n) vector<T> name(n); for(auto &i:name)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template <class T>void out(T n) { cout << n << endl; }
template <class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
template <> void out(double a) { printf("%.20f\n", a); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	Cin(int, a, b);
	out(a <= b ? a : a - 1);
}

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

namespace toi2
{
    class Program
    {
        static void Main(string[] args)
        {
            string aCards = Console.ReadLine();
            int aSize = aCards.Length;
            int aCardNum = 0;

            string bCards = Console.ReadLine();
            int bSize = bCards.Length;
            int bCardNum = 0;

            string cCards = Console.ReadLine();
            int cSize = cCards.Length;
            int cCardNum = 0;

            string cardMoji = "a";

            string winner = "";

            while (true)
            {
                if ("a".Equals(cardMoji))
                {
                    if (aCardNum >= aSize)
                    {
                        winner = "A";
                        break;
                    }

                    cardMoji = aCards.Substring(aCardNum, 1);
                    aCardNum++;

                }
                else if ("b".Equals(cardMoji))
                {
                    if (bCardNum >= bSize)
                    {
                        winner = "B";
                        break;
                    }

                    cardMoji = bCards.Substring(bCardNum, 1);
                    bCardNum++;

                }
                else if ("c".Equals(cardMoji))
                {
                    if (cCardNum >= cSize)
                    {
                        winner = "C";
                        break;
                    }

                    cardMoji = cCards.Substring(cCardNum, 1);
                    cCardNum++;
                }
            }
            Console.WriteLine("{0}", winner);
        }
    }
}


Measured memory_bytes: 13140
N = input().split(' ')

A = input().split(' ')

val = True

for i in A:
  num = int(i)
  if num % 2 ==0:
    if num % 3 ==0 or num % 5 == 0:
      continue
    else:
      val = False
      break
      
if val == True:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n;
      cin>>n;
      if(n>=30)cout<<"Yes";
      else cout<<"No";
     }

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll l,r;
    cin >> l >> r;
    vector<int> v;
    v.push_back(l%2019);
    for(int i=1;i<=min(r-l,(ll)2018);i++){
        v.push_back((l+i)%2019);
    }
    int n = v.size();
    int ans = INF;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int s = (v[i]%2019) * (v[j]%2019) % 2019;
            ans = min(ans,s);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b,a%b)

def main():
    while 1:
        try:
            a = list(map(int, input().split()))
            b = gcd(a[0],a[1])
            c = a[0]/b*a[1]
            #d = [b,c]
            print('%d %d' % (b,c))
        except:
            break
            
main()          



Measured memory_bytes: 5600
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,count1=0,count2=0;
    char a[100020];
    cin>>a;
            for(j=0;j<strlen(a);j++)
            {
                if(j%2==1)
                {
                    if(a[j]=='1')
                        count1++;
                }
                else
                {
                    if(a[j]=='0')
                        count1++;
                }
            }
             for(j=0;j<strlen(a);j++)
            {
                if(j%2==1)
                {
                    if(a[j]=='0')
                        count2++;
                }
                else
                {
                    if(a[j]=='1')
                        count2++;
                }
            }
    if(count1>count2)
        cout<<count2;
    else
        cout<<count1;
    return 0;
}


Measured memory_bytes: 384
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
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);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && a!=c)	cout<<"Yes";
	else if(a==c && a!=b)	cout<<"Yes";
	else if(b==c && a!=b)	cout<<"Yes";
	else
		cout<<"No";	


}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template<class T> void printvec(vector<T> v){
    for (T t : v) cout << t << " ";
    cout << endl;
}

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
     vi v(n);
     REP(i,n) cin >> v[i];
     //sort(ALL(v));
     
     int ans = 100000;
     
     auto itl = v.begin();
     auto itr = v.begin();
     itr++;
     REP(i,n)
     {
         int l = accumulate(v.begin(),itl,0);
         int r = accumulate(itl,v.end(),0);
         
        // cout <<"l"<<l<<endl;
         //cout <<"r"<<r<<endl;
         ans = min(ans,abs(l-r));
         itl++;
         itr++;
     }
     
     cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define mod 1000000007
#define PI 3.1415926535897932384626433
#define se second
#define fi first
#define pb push_back
#define T true
#define F false
#define endl "\n"
typedef char ch;
typedef bool boll;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef set < string > sst;
typedef set < long long > sl;
typedef queue < long long > que;
typedef vector < long long > vec;
typedef map < long long, long long > mll;
typedef pair < long long, long long > pll;
typedef vector < pair < long long, long long > > vpl;
typedef pair < long long, unsigned long long > pul;

int main()
{
    fast;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a>0 && c>0){
        c-=b;
        if(c<=0){
            cout << "Yes";
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No";
            break;
        }
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int count=0;
  for (int i=0;i<n;i++){
    while (a[i]%2==0){
      a[i]=a[i]/2;
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import heapq
def main():
    N = int(input())
    A = list(map(int, input().split()))
    fl = [i for i in A[:N]]
    f = [sum(A[:N])]
    heapq.heapify(fl)
    ll = [-i for i in A[2*N:]]
    l = [sum(A[2*N:])]
    heapq.heapify(ll)
    for i in range(N):
        s = f[-1]
        if A[N+i] > fl[0]:
            s = s - fl[0] + A[N+i]
            heapq.heappushpop(fl, A[N+i])
        f.append(s)
        s = l[-1]
        if - A[2*N-1-i] > ll[0]:
            s = s + ll[0] + A[2*N-1-i]
            heapq.heappushpop(ll, -A[2*N-1-i])
        l.append(s)
    r = f[0] - l[-1]
    for i in range(N+1):
        r = max(r, f[i] - l[-1-i])
    return r
print(main())


Measured memory_bytes: 40336
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n; cin>>n;
	vint v;
	bool flag=false;
	int m;
	FOR(i,0,1000){
		if(i*(i-1)/2==n){
			flag=true;
			m=i;
		}
	}
	if(flag){
		co("Yes");
		co(m);
		vector<int> v[1000];
		int c=1;
		FOR(i,0,m){
			FOR(j,0,i){
				if(i!=j){
					v[i].PB(c);
					v[j].PB(c);
				}
				c++;
			}
		}
		FOR(i,0,m){
			cout<<m-1<<" ";
			for(auto j:v[i]){
				cout<<j<<" ";
			}
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using lint = long long;
constexpr int D = 19;

std::vector<lint> ds(D);

void init() {
    ds[0] = 1;
    for (int i = 1; i < D; ++i) {
        ds[i] = ds[i - 1] * 10;
    }
}

void solve() {
    lint x;
    std::cin >> x;

    lint ans = 0;
    for (int n = 1; n <= D; ++n) {
        std::function<void(int, lint, lint)> dfs =
            [&](int k, lint y, lint pat) {
                if (k <= 0) {
                    if (y != 0) return;
                    if (k == 0) pat *= 10;
                    ans += pat;
                    return;
                }

                lint p = ds[k] - 1;
                for (int d = -9; d <= 9; ++d) {
                    auto ny = y - d * p;
                    if (ny % 10 != 0) continue;

                    lint cnt = 0;
                    for (int x = 0; x <= 9; ++x) {
                        for (int y = (k == n - 1); y <= 9; ++y) {
                            if (x - y == d) ++cnt;
                        }
                    }

                    dfs(k - 2, ny / 10, pat * cnt);
                }
            };

        dfs(n - 1, x, 1);
    }

    std::cout << ans << std::endl;
}

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

    init();
    solve();

    return 0;
}


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

using namespace std;

int main() {
  int A = 0, B = 0, M = 0;

  cin >> A >> B >> M;
  int a_m = 0;
  vector<int> a;
  int a_min = 1000000;
  for (int i = 0; i < A; i++) {
    cin >> a_m;
    a_min = min(a_m, a_min);
    a.push_back(a_m);
  }
  int b_m = 0;
  vector<int> b;
  int b_min = 1000000;
  for (int i = 0; i < B; i++) {
    cin >> b_m;
    b_min = min(b_min, b_m);
    b.push_back(b_m);
  }
  int money_min = a_min + b_min;
  int x = 0;
  int y = 0;
  int money = 0;
  int point_x =0;
  int point_b =0;
  for (int i = 0; i < M; i++) {
    cin >> x >> y >> money;
    point_x = a.at(x-1);
    point_b = b.at(y-1);
    money_min = min(money_min, (point_x + point_b - money));
  }
    
  
  cout <<max(money_min,0) << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

static inline int charToInt(char c) {
  switch(c) {
  case 'A':
    return 0;
  case 'C':
    return 1;
  case 'G':
    return 2;
  case 'T':
    return 3;
  default:
    return -1;
  }  
}

static inline int strToInt(const string& str) {
  int total = charToInt(str[0]);
  int cur;
  for (int i = 1; i < str.length(); i++) {
    cur = charToInt(str[i]);
    total += pow(4, i) * (1 + cur);
//    total += pow(4, i) + pow(4, i) * cur;
  }  
//  cout << " " << total << endl;
  return total;
}

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

  vector<bool> dictionary(static_cast<size_t>(pow(4, 12)) + 4, false);
  string command, str;

  for (int i = 0; i < n; i++) {
    cin >> command >> str;
    if (command[0] == 'i') {
      dictionary[strToInt(str)] = true;
    } else {
        cout << (dictionary[strToInt(str)] ? "yes" : "no") << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4972
s = input()
n = len(s)

head_s = s[0:(n-1)//2]
tail_s = s[(n+3)//2-1:]
if s == s[::-1] and head_s == head_s[::-1] and tail_s == tail_s[::-1]:
    print('Yes')
else:
    print('No')

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


int main() {
    int h, hh, k, kk;
    int a, b, c, d;

    cin >> h >> hh;
    cin >> k >> kk;
    cin >> a >> b >> c >> d;

    int sum1 = h * a + hh * b + (h / 10) * c + (hh / 20) * d;
    int sum2 = k * a + kk * b + (k / 10) * c + (kk / 20) * d;

    if(sum1 > sum2) cout << "hiroshi" << endl;
    else if(sum2 > sum1) cout << "kenjiro" << endl;
    else cout << "even" << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)

int main() {
    ll H, W;
    cin >> H >> W;

    if(H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        cout << (H * W + 1) / 2 << endl;
    }

    return 0;
}

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

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

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

    vector<string> s(N);

    REP(i, N)
        cin >> s[i];
    
    sort(s.begin(), s.end());

    string len = "";

    REP(i, N)
        len += s[i];
    
    cout << len << endl;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

sndeq (_,y1) (_,y2) = y1 == y2
pair [a,b] = (a,b)

main = do
 [n,m] <- map read . words <$> getLine
 abs <- map (pair . map read . words) <$> replicateM n getLine
 cds <- map (pair . map read . words) <$> replicateM m getLine
 let icds = nubBy sndeq (zip [1..m] cds)
 mapM_ (print . checkpoint icds) abs

checkpoint icds (a,b) = fst $ minimumBy (closest (a,b)) icds

closest ab (_,cd1) (_,cd2) = compare (manhattan ab cd1) (manhattan ab cd2) 

manhattan (x1,y1) (x2,y2) = abs (x1-x2) + abs (y1-y2)

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	int ret = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ret += d[i] * d[j];
			}
		
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long int expon2(int n);

void seq_reflesh(long int K, unsigned short int *seq);

int main(void){
  long int N, K, i, score, mscore;//scoreがオーバー風呂しないかやや心配
  unsigned short int seq[30];
  int j, bits, m, first;

  scanf("%ld %ld", &N, &K);

  long int list[N][2];

  for(i = 0; i < N; i++){
    scanf("%ld %ld", &list[i][0], &list[i][1]);
  }

  //A_iは最大30ビット

  //立ってるビットの数　＋　1だけ候補がある（最大31
  

  first = 1;
  do{
    seq_reflesh(K, seq);
    score=0;
    //これをKとしてまずがんばる
    for(i=0; i<N;i++){
      if((K | list[i][0]) == K) score = score + list[i][1];
    }
    if(first || mscore < score){
      mscore = score;
    }
    //ここからKの下を取り崩す処理
    m = 0;
    while(seq[m]){
      m++;
    }//mは初めて0になる桁でとまる

    if(expon2(m) > K) break;
    else{
      while(!seq[m]) m++;//mが再び1になったら止まる
    }

    K = K - expon2(m);

    K = K | (expon2(m) - 1);

    first = 0;
  } while(1);

  printf("%ld\n", mscore);
  return 0;
}

long int expon2(int n){
  long int result=1;
  int i;
  for(i=0;i<n;i++) result = result * 2;
  return result;
}

void seq_reflesh(long int K, unsigned short int *seq){
  long int exp;
  int j;
  
  exp = expon2(30);
  //exp=2^30

  
  for(j=29;j>=0;j--){
    exp = exp / 2;
    if(exp & K) seq[j] = 1; //2^j and Kが0じゃなければ
    else seq[j] = 0;
  }
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll t[100005], a[100005];
ll mn[100005], mx[100005];
int main() {
	std::cin >> n;

	for (int i = 0; i < n; ++i)
		std::cin >> t[i];
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	for (int i = 0; i < n; ++i) {
		if (i == 0 || t[i] > t[i - 1]) {
			mn[i] = t[i];
			mx[i] = t[i];
		}
		else {
			mn[i] = 1LL;
			mx[i] = t[i];
		}
	}

	for (int i = n - 1; i >= 0; --i) {
		if (i == n - 1 || a[i] > a[i + 1]) {
			mn[i] = std::max(mn[i], a[i]);
			mx[i] = std::min(mx[i], a[i]);
		}
		else {
			mn[i] = std::max(mn[i], 1LL);
			mx[i] = std::min(mx[i], a[i]);
		}
	}

	ll ans = 1LL;
	for (int i = 0; i < n; ++i) {
		if (mn[i] > mx[i]) {
			std::cout << 0 << std::endl;
			return 0;
		}
		else {
			ans *= (mx[i] - mn[i] + 1);
			ans %= mod;
		}
	}

	std::cout << ans << std::endl;
	return 0;
}


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

#define pb push_back

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int x, n;
	cin >> x >> n;
	
	unordered_set<int> notOk;
	
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		notOk.insert(a);
	}
	
	int ret = INT_MAX;
	int diff = INT_MAX;
	for (int i = -1000; i <= 1000; i++) {
		if (!notOk.count(i)) {
			if (abs(x - i) < diff) {
				diff = abs(x - i);
				ret = i;
			}
		}
	}
	
	cout << ret << endl;
	
	return 0;
}

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

namespace AOJ_ICPC1 {

	class Program {
		static void Main(string[] args) {
			while (true) {
				string str = Console.ReadLine();
				if (str == "#") break;
				Console.WriteLine(result(str.ToCharArray()));
			}
		}
		const string RightChar = "yuiophjklnm";
		static int result(char[] chars) {
			int count = 0;
			bool isRight = RightChar.Contains(chars[0]);
			foreach (char c in chars.Skip(1)) {
				if (isRight != RightChar.Contains(c)) {
					count++;
					isRight = !isRight;
				}
			}
			return count;
		}
	}
}

Measured memory_bytes: 6292
#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 ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int c=0;
  rep(i,n){
    cin >> a.at(i);
    if(a.at(i)==0)c=-2000000000;
    else if(a.at(i)<0)c++;
  }
  if(c<0||c%2==0){
    ll ans=0;
    rep(i,n)
      ans+=max(a.at(i),-a.at(i));
    cout << ans << endl;
  }
  else{
    int mini=2000000000;
    rep(i,n)
      mini=min(mini,max(-a.at(i),a.at(i)));
    ll ans=0;
    rep(i,n)
      ans+=max(a.at(i),-a.at(i));
    ans-=2*mini;
    cout << ans << endl;
  }
}

Measured memory_bytes: 640
def BubbleSort(C, N):
    for i in range(N):
        for j in range(N - 1, i, -1):
            if C[j][1] < C[j - 1][1]:
                C[j], C[j - 1] = C[j - 1], C[j]
def SelectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i + 1, N):
            if C[j][1] < C[minj][1]:
                minj = j
        if i != minj:
            C[i], C[minj] = C[minj], C[i]
N = int(input())
A = input().split()
B = A[:]
C = A[:]
BubbleSort(B, N)
print(*B)
print("Stable")
SelectionSort(C, N)
print(*C)
print("Stable" if B == C else "Not stable")


Measured memory_bytes: 5612
#include <stdio.h>
#include <stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n][2];
    int c[n];
    for(int b=0;b<n;b++){
        scanf("%d",&a[b][0]);
        a[b][1]=b+1;
        c[a[b][0]-1]=a[b][1];
    }
    for(int d=0;d<n;d++){
        printf("%d\n",c[d]);
    }
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define mod 998244353
#define inf 0x3f
int ans=998244353;
int read() 
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
void fr() 
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main() 
{   int n=rd,m=rd;
    fo(i,1,n)
    {
    	int x=rd,y=rd;
    	if(y<=m)ans=min(ans,x);
	}
	if(ans==998244353)cout<<"TLE"<<endl;
	else cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
store = []

for i in range(N):
    c,s = map(int,input().split())
    store.append([c,s])

store.sort(key=lambda x:x[0])

cost = 0
for line in store:
    if M <= line[1]:
        cost += M*line[0]
        break
    else:
        cost += line[0]*line[1]
        M -= line[1]

print(cost)

Measured memory_bytes: 21224
#include <iostream>
#include <algorithm>

#define llong long long
#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a,b) (((a)-(b))>0?((a)-(b)):((b)-(a)))

using namespace std;

int main(){
	llong N,D; cin >> N >> D;
	D = D*D;	// D^2
	int cnt = 0;
	
	rep(i,0,N){
		llong x,y; cin >> x >> y;
		if( x*x+y*y <= D ) cnt++;
	}
	
	cout << cnt;
	
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n;
  while(n>0){
      x=n%10;
      if(x==7){
        cout<<"Yes"<<endl;
        return 0;
      }
    n/=10;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3600
def main():
    n, k, *a = map(int, open(0).read().split())

    cnt = [sum((x >> i) & 1 for x in a) for i in range(40)]
    bits = [0 if i > n - i else 1 for i in cnt]

    base = format(k, 'b')
    l = len(base)
    tmp = []

    if sum(2 ** i for i, b in enumerate(bits[:l]) if b == 1) > k:
        for i in range(l - 1, -1, -1):
            if int(base[-i - 1]) < bits[i]:
                bits[i] = 0
                tmp.append(sum(2 ** j for j, b in enumerate(bits[:l]) if b == 1))
    else:
        tmp.append(sum(2 ** j for j, b in enumerate(bits[:l]) if b == 1))

    ans = max(sum(i ^ x for x in a) for i in tmp if i <= k)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14508
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1e18;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y);
long long dp[20][20];

vector<long long>calc(vector<pair<int,int>>A) {
	int n = A.size();
	sort(A.begin(),A.end());
	for (int i = 0;i<n + 1;++i) {
		for (int j = 0;j<n + 1;++j) {
			dp[i][j] = INF;
		}
		dp[0][0] = 0;
		for (int l = 0;l<n;++l) {
			for (int r = l + 1;r<=n;++r) {
				{
					long long now = INF;
					for (int k = l;k<r;++k) {
						long long s = 0;
						for (int i = l;i<r;++i) {
							s += abs(A[i].first - A[k].first)*ll(A[i].second);
						}
						chmin(now, s);
					}
					rep(j, n) chmin(dp[r][j + 1], dp[l][j] + now);

				}
				{ 
					ll now = 0;
					for (int i = l; i < r; ++i) {
						now += abs(A[i].first)*ll(A[i].second);
					}
					rep(j, n + 1) chmin(dp[r][j], dp[l][j] + now);
				}
			}
		}
	}
	vector<long long>res(n + 1, INF); 
	rep(j, n + 1) res[j] = dp[n][j];
	return res;
}

int main() {
	int N;
	cin >> N;
	vector<int>X(N), Y(N), P(N);
	vector<long long >Ans(N + 1, INF);
	for (int n = 0;n<N; ++n) {
		cin >> X[n] >> Y[n] >> P[n];
	}
	for (int n = 0;n<(1<<N);++n) {
		vector<pair<int, int>>Ax,Ay;
		for (int m = 0;m<N;++m) {
			if (n>>m&1) {
				Ax.emplace_back(X[m],P[m]);
			}
			else {
				Ay.emplace_back(Y[m], P[m]);
			}
		}
		vector<long long> dx = calc(Ax); 
		vector<long long> dy = calc(Ay);
		for (int p = 0;p<dx.size();++p) {
			for (int q = 0;q<dy.size();++q) {
				Ans[p + q] = min(Ans[p + q], dx[p] + dy[q]);
			}
		}
	}
	for (int i = 0; i < N+1; ++i) {
		cout << Ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

#define int long long int

int MOD(int a){
	return a % (int)(1e9 + 7);
}

int fact(int n){
	int i, ans = 1;
	for(i = 1; i <= n; i++){
		ans = MOD(i * ans);
	}
	return ans;
}

signed main(){
	int N, M;
	scanf("%lld%lld", &N, &M);
	if(N > M + 1 || M > N + 1){
		printf("0\n");
	}
	else if(N == M){
		printf("%lld\n", MOD(2 * fact(N) * fact(M)));
	}
	else{
		printf("%lld\n", MOD(fact(N) * fact(M)));
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        boolean ans=(s.indexOf('7')>=0);
        if(ans) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 32472
#include <iostream>
#include <utility>
#include <queue>

int main(int argc, char const *argv[]){
	int n,q,t = 0;
	std::cin >> n >> q;
	std::queue< std::pair<std::string,int> > que;
	
	for (int i = 0; i < n; ++i){
		std::string nm;
		int tm;
		std::cin >> nm >> tm;
		que.push(make_pair(nm,tm));
	} 

	while(!que.empty()){
		std::pair<std::string,int> front = que.front();
		que.pop();
		if(front.second - q > 0){
			t += q;
			que.push(make_pair(front.first,front.second-q));
		}else{
			t += front.second;
			std::cout << front.first << " " << t << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 6324
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	for(int i=1;i<inf;i++) if(i*(i+1)/2>=n){
		n=i*(i+1)/2-n;
		string s=string(i,')')+string(i,'(');
		for(int j=0;j<n;j++) swap(s[i-j-1],s[i-j]);
		cout<<s<<endl;
		break;
	}
}


Measured memory_bytes: 3340
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,Q=MI()
    S=ST()
    cumsum = [0]*N
    for i in range(N-1):
        if S[i:i+2]=="AC":
            cumsum[i+1]+=1
        cumsum[i+1]+=cumsum[i]
    for _ in range(Q):
        l,r = MI()
        print(cumsum[r-1]-cumsum[l-1])
if __name__ == '__main__':
    main()

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

int main() {
    int l,r;
    cin >> l >> r;
    
    if(l%2019==0 || r%2019==0 || l/2019!=r/2019){
        cout << 0 << endl;
        return 0;
    }

    vector<int> a;
    int p=l%2019,q=r%2019;

    for(int i = p; i < q; i++){
       for(int j = i+1; j <=q; j++){
            int x=i*j;
            x %= 2019;
            a.push_back(x);
       } 
    }
    sort(a.begin(),a.end());
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 11452
<?php
list($n) = ints();
$cnt = 0;
$cntlb = $cntra = $cntlbra = 0;
for ($i = 0; $i < $n; ++$i) {
    list($s) = strs();
    $m = strlen($s);
    if ($s[0] === 'B' && $s[$m - 1] === 'A') ++$cntlbra;
    elseif ($s[0] === 'B') ++$cntlb;
    elseif ($s[$m - 1] === 'A') ++$cntra;
    for ($j = 0; $j < $m - 1; ++$j)
        if ($s[$j] === 'A' && $s[$j + 1] === 'B') ++$cnt;
}
if ($cntlbra > 0) {
    $cnt += $cntlbra - 1;
    if ($cntlb > 0) {
        ++$cnt;
        --$cntlb;
    }
    if ($cntra > 0) {
        ++$cnt;
        --$cntra;
    }
}
$cnt += min($cntlb, $cntra);
echo $cnt;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16228
A, B = map(int, input().split())
S = input()

if len(S) != A + B + 1:
    print('No')
    exit()

if S[A ] != '-':
    print('No')
    exit()

for i in range(A + B + 1):
    s = S[i]
    if s == '-' and i != A:
        print('No')
        exit()

print("Yes")




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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h);//aという配列にh数の要素　今回は4
  for(int i = 0; i < h; i++){
    cin >> a.at(i);
  }

  vector<bool> row(h,false);
  vector<bool> col(w,false);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a.at(i).at(j) == '#'){
        row.at(i) = true;
				col.at(j) = true;
      }
    }
  }
 for(int i = 0; i < h; i++){
   if(row.at(i)){
     for(int j = 0; j < w; j++){
       if(col[j]){
         cout << a.at(i).at(j);
       }
     }
     cout << endl;
   }
 }


}




Measured memory_bytes: 3572
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
	stack<int> stk;
	int a,b,x,num;
	string s;
	
	while (cin >> s){
		if(s[0] == '+' || s[0] == '-' || s[0] == '*'){
			a = stk.top(); stk.pop();
			b = stk.top(); stk.pop();
			if(s[0] == '+')
				stk.push(a+b);
			else if(s[0] == '-')
				stk.push(b-a);
			else if(s[0] == '*')
				stk.push(a*b);
		}else{
			stk.push(atoi(s.c_str()));
		}
	}
	cout << stk.top() << endl;
	
	return 0;
}

Measured memory_bytes: 3200
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    N = int_raw()
    As = [int_raw() for _ in range(N)]
    As2 = sorted(As)
    m1 = As2[-1]
    m2 = As2[-2]
    for a in As:
        if a ==m1:
            print(m2)
        else:
            print (m1)

main()


Measured memory_bytes: 59984