akhauriyash/Code-Regression huggingface dataset:
class Modulo_Error(Exception):
    pass

class Modulo():
    def __init__(self,a,n):
        self.a=a%n
        self.n=n

    def __str__(self):
        return "{} (mod {})".format(self.a,self.n)

    #+,-
    def __pos__(self):
        return self

    def __neg__(self):
        return  Modulo(-self.a,self.n)

    #等号,不等号
    def __eq__(self,other):
        if isinstance(other,Modulo):
            return (self.a==other.a) and (self.n==other.n)
        elif isinstance(other,int):
            return (self-other).a==0

    def __neq__(self,other):
        return not(self==other)
    
    #加法
    def __add__(self,other):
        if isinstance(other,Modulo):
            if self.n!=other.n:
                raise Modulo_Error("異なる法同士の演算です.")
            return Modulo(self.a+other.a,self.n)
        elif isinstance(other,int):
            return Modulo(self.a+other,self.n)

    def __radd__(self,other):
        if isinstance(other,int):
            return Modulo(self.a+other,self.n)
        
    #減法
    def __sub__(self,other):
        return self+(-other)

    def __rsub__(self,other):
        if isinstance(other,int):
            return -self+other
        
    #乗法
    def __mul__(self,other):
        if isinstance(other,Modulo):
            if self.n!=other.n:
                raise Modulo_Error("異なる法同士の演算です.")
            return Modulo(self.a*other.a,self.n)
        elif isinstance(other,int):
            return Modulo(self.a*other,self.n)
        
    def __rmul__(self,other):
        if isinstance(other,int):
            return Modulo(self.a*other,self.n)
        
    #Modulo逆数
    def Modulo_Inverse(self):
        x0, y0, x1, y1 = 1, 0, 0, 1
        a,b=self.a,self.n
        while b != 0:
            q, a, b = a // b, b, a % b
            x0, x1 = x1, x0 - q * x1
            y0, y1 = y1, y0 - q * y1

        if a!=1:
            raise Modulo_Error("{}の逆数が存在しません".format(self))
        else:
            return Modulo(x0,self.n)
        
    #除法
    def __truediv__(self,other):
        return self*other.Modulo_Inverse()

    #累乗
    def __pow__(self,m):
        u=abs(m)

        r=Modulo(1,self.n)

        while u>0:
            if u%2==1:
                r*=self
            self*=self
            u=u>>1

        if m>=0:
            return r
        else:
            return r.Modulo_Inverse()

#-------------------------------------------------------------------------
M=10**9+7
n,a,b=map(int,input().split())
C=[Modulo(1,M)]*(b+1)

for k in range(1,b+1):
    C[k]=C[k-1]*Modulo(n-(k-1),M)/Modulo(k,M)

print((Modulo(2,M)**n-(C[a]+C[b])-1).a)


Measured memory_bytes: 89244
//basic c++ code is given here

#include<bits/stdc++.h>

using namespace std;


    int answer(int idx){


                return 0 ;

    }




    int main (  )
    {
      int n, k;


      cin >> n >> k ;

      int dp[n]={0};

      for(int i= 0 ; i< n ; i++){
        cin >> dp[i];
      }
        int l = sizeof(dp)/sizeof(dp[0]);
      sort(dp, dp+ l) ;

    int sum = 0 ;

    for(int i = 0 ;i< k ; i++){
        sum += dp[i];
    }
    cout << sum ;
    }


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();

        String[] vals = s.split(" ");
        String out = "APPROVED";
        for (int i = 0; i < vals.length; i++) {
            int x = Integer.parseInt(vals[i]);
            if (x % 2 == 0) {
                if (x % 3 != 0 && x % 5 != 0) {
                    out = "DENIED";
                    break;
                }
            }
        }
        System.out.println(out);
    }
}

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

int main() {
  ll x, ans = 0;
  cin >> x;
  ans += (x / 11) * 2;
  x %= 11;
  if (x == 0) {
    cout << ans << endl;
    return 0;
  } else if (x - 6 <= 0)
    ans += 1;
  else
    ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
a,b = gets.strip.split.map(&:to_i)
cnt = 0 
a.upto(b) do |i|
  s = i%10
  t = i/10000%10
  u = i/1000 % 10
  v = i/10%10
  cnt += 1 if s==t && u==v
end
puts cnt

Measured memory_bytes: 1788
#include <stdio.h>

int gcd(int,int);

int main(){
  int x,y;
  int answer;

  scanf("%d %d",&x,&y);
  answer = gcd(x,y);

  printf("%d\n",answer);
  return 0;
}

int gcd(int x,int y){
  int z;
  
  while (y > 0){
    z = x % y;
    x = y;
    y = z;
  }

  return x;
}



Measured memory_bytes: 2116
while line = gets
  a = line.chomp.split.map(&:to_i)
  b = gets.chomp.split.map(&:to_i)

  hit = 0

  a.length.times do |i|
    hit += 1 if a[i] == b[i]
  end

  blow = (a & b).length - hit

  puts "#{hit} #{blow}"
end

Measured memory_bytes: 8588
#include <stdio.h>

int main(int argc, char *argv[])
{
	int a, b;
	char op;
	while (1)
	{
		scanf("%d %c %d\n", &a, &op, &b);

		if (op == '?')
		{
			break;
		}
		else if (op == '+')
		{
			printf("%d\n", a + b);
		}
		else if (op == '-')
		{
			printf("%d\n", a - b);
		}
		else if (op == '*')
		{
			printf("%d\n", a * b);
		}
		else if (op == '/')
		{
			printf("%d\n", a / b);
		}
	}

	return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second

#define scn(a) scanf("%d",&a)
#define sccn(a,b) scanf("%d%d",&a,&b)
#define scccn(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scnl(a) scanf("%lld",&a)
#define sccnl(a,b) scanf("%lld%lld",&a,&b)
#define scccnl(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scnc(c) scanf(" %c",&c)

#define rep(i,n) for(int i = 0; i<n; ++i)
#define repab(i,a,b) for(int i = a; i<=b; ++i)
#define repba(i,b,a) for(int i = b-1; i>=a; --i)

#define printar(i,ar,n) for(int i = 1; i<=n; ++i) printf("%d ",ar[i]); puts("")

#define ms(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define pb(a) push_back(a)
#define pbp(a,b) push_back({a,b});

#define test(x) cout<<#x<<" "<<x<<endl

#define PI acos(-1)
#define MOD 1000000007
#define eps 0.00000001
#define inf 1<<30
#define MX 100005

int main(){
    double a,b,c;
    cin>>a>>b>>c;

    printf("%.0f\n",ceil(a/b)*c);
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k, n;
  cin >> n >> k;

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

  sort(all(p));

  ll ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3668
n = gets.to_i
num = gets.chomp.split.map(&:to_i)
num.unshift(0)
num.push(0)
#numの長さはn+2だよ
sum = 0
(n+1).times do |i|
  sum += (num[i+1]-num[i]).abs
end
for i in 1..n
  puts sum-(num[i]-num[i-1]).abs-(num[i+1]-num[i]).abs+(num[i+1]-num[i-1]).abs
end

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

int main(){
  int N;
  cin >> N;
  int d[110];
  for(int i = 0; i < N; i++){
    cin >> d[i];
  }
  
  int n[110] = {0};
  for(int i = 0; i < N; i++){
    n[d[i]]++;
  }
  
  int count = 0;
  for(int i = 1; i <= 100; i++){
    if(n[i] > 0){
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		Integer count = 0;

		if (c < a) {
			System.out.println(count);
			return;
		}
		
		if(a == b && b == c) {
			System.out.println(1);
			return;
		}

		while (true) {

			if (c % a == 0) {
				count++;
			}

			if (a == b) {
				System.out.println(count);
				return;
			}

			a++;
		}

	}

}


Measured memory_bytes: 26416
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Digits in Multiplication
 */

#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 */

const int MAX_D = 12;
const int INF = 1 << 30;

/* typedef */

typedef long long ll;

/* global variables */

ll tens[MAX_D];

/* subroutines */

inline int digs(ll n) {
  return upper_bound(tens, tens + MAX_D, n) - tens;
}

/* main */

int main() {
  tens[0] = 1;
  for (int i = 1; i < MAX_D; i++) tens[i] = tens[i - 1] * 10;

  ll n;
  cin >> n;

  int maxd = digs(n);
  for (ll p = 1; p * p <= n; p++)
    if (n % p == 0) maxd = digs(n / p);

  printf("%d\n", maxd);
  return 0;
}


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n,W;cin>>n>>W;
  vvi dp(110,vi(100100));
  repi(i,n) {
    int w,v;cin>>w>>v;
    rep(j,W+1) {
      if (w <= j) chmax(dp[i][j], dp[i-1][j-w] + v);
      chmax(dp[i][j], dp[i-1][j]);
    }
  }
  int ans = dp[n][W];
  cout << ans << endl;
}


Measured memory_bytes: 87424
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    int d,t,s; cin >> d >> t >> s;
    if (s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}    

Measured memory_bytes: 3632
import math

a,b,h,m = map(int,input().split())

h_x=a*math.cos(math.pi*2*(h+m/60)/12)
h_y=a*math.sin(math.pi*2*(h+m/60)/12)
m_x=b*math.cos(math.pi*2*m/60)
m_y=b*math.sin(math.pi*2*m/60)

l=math.sqrt((h_x-m_x)**2+(h_y-m_y)**2)
print(l)

Measured memory_bytes: 9572
#include<stdio.h>
#define N (x=(a*x+b)%c),++i
int main()
{
	int n,a,b,c,x,y,i;
	while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n)
	{
		i=0;
		while(n--)
		{
			scanf("%d",&y);
			while(y-x)if(N,i>10000)goto E;
			N;
		}
		printf("%d\n",i-1);
		continue;
E:puts("-1");while(n--)scanf("%*d");
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
 
int main(void){
  int i,j,temp,a[3];
   
  for(i=0;i<3;i++)  scanf("%d",&a[i]);
 
  for(i=0;i<2;i++){
    for(j=0;j<2-i;j++){
      if(a[j]>a[j+1]){
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
      }
    }
  }
  
  printf("%d %d %d\n",a[0],a[1],a[2]);

  return 0;
}

Measured memory_bytes: 596
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
res = 0
for i in range(n):
    if b[i] > a[i]:
        res += a[i]
        b[i] -= a[i]
        a[i] = 0
        if b[i] > a[i + 1]:
            res += a[i + 1]
            b[i] = 0
            a[i + 1] = 0
        else:
            res += b[i]
            a[i + 1] -= b[i]
    else:
        res += b[i]
        a[i] -= b[i]
    # print(a, b)/
print(res)

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


int main()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	cout<<h2*60+m2-(h1*60+m1+k)<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int N,M; cin>>N>>M;
  vector<vector<int>> v(M);
  rep(i,M) {
    int k; cin>>k;
    v[i].resize(k);
    rep(j,k) {
      cin>>v[i][j];
      --v[i][j];      // 0-origin
    }
  }
  vector<int> p(M);
  rep(i,M) cin>>p[i];

  int res = 0;
  // スイッチのon/offで，2^N通りの全探索
  for(int bit_switch=0; bit_switch<(1<<N); ++bit_switch) {
    bool all_on = true;
    rep(i,M) {
      // 電球iのbit列を生成
      int bit_light = 0;
      rep(j, v[i].size()) {
        bit_light |= (1<<v[i][j]);
      }

      // 電球iのbit列の中で実際にonになっているスイッチの数をカウント
      int cnt = 0;
      int bit_temp = bit_switch & bit_light;
      rep(j, N) {
        if(bit_temp & (1<<j)) ++cnt;
      }

      // 電球iが点灯しているか判定
      if(cnt%2 != p[i]) {
        all_on = false;
        break;
      }
    }
    // すべて電球がついている場合
    if(all_on)++res;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  int Num  = B / A;
  if(C <= Num) {
    printf("%d\n", C);
  } else {
    printf("%d\n", Num);
  }

  return 0;
}


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

int	main() {
	int N;
	cin >>N;
	vector<int> A(N+1, 0);
	for (int i=1; i*2<=N+1; i++) {
		A.at(i)=i;
		A.at((N/2)*2+1-i)=i;
	}
	vector<vector<int>> NN(0);
	for (int i=1; i<N; i++)
		for (int j=i+1; j<=N; j++)
			if (A.at(i)!=A.at(j))
				NN.push_back({i, j});
	cout <<NN.size() <<endl;
	for (int i=0; i<NN.size();i++)
		cout <<NN.at(i).at(0) <<' ' <<NN.at(i).at(1) <<endl;
	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    double n, m, l;
    cin >> n >> m >> l;
    cout << fixed << setprecision(10);
    cout << l*(m/n) << endl;
}


Measured memory_bytes: 3296
#!/usr/bin/python3
# -*- coding: utf-8 -*-
h = int(input())
w = int(input())
n = int(input())

if h > w:
    if n % h == 0:
        print(n // h)
    else:
        print(n // h + 1)
else:
    if n % w == 0:
        print(n // w)
    else:
        print(n // w + 1)

Measured memory_bytes: 2940
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        a: [u64;n],
    }

    if a.contains(&0) {
        println!("0");
        return;
    }

    let mut ans = 1u64;
    for i in a {
        let res = ans.checked_mul(i);
        if let Some(v) = res {
            ans = v;
        } else {
            println!("-1");
            return;
        }
    }

    if ans > 10u64.pow(18) {
        println!("-1");
        return;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4500
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,a[101],b[101],t,f;
int main(){
  cin>>n>>m;
  t=n;
  r(i,m)cin>>a[i]>>b[i];
  r(i,m){
    int res=1e9;
    r(j,m){
      if(b[j]>=t||(i&&b[j]>=t-1)){
        res=min(res,a[j]);
      }
    }
    if(res==1){
      cout<<i+1<<endl;
      return 0;
    }
    t=res;
  }
  cout<<"Impossible"<<endl;
}

Measured memory_bytes: 3092
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:17:33 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

A, B, C, D = na()
E = A + B
F = C + D

if E == F:
    print("Balanced")
elif E > F:
    print("Left")
elif E < F:
    print("Right")

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

int main(void){

  int a, b, sum;
  char  tmp[6], *token, *sep = " ";

  fgets(tmp, 6, stdin);
  token = strtok(tmp, sep);
  a = atoi(token);
  token = strtok(NULL, sep);
  b = atoi(token);

  sum = 0;
  if (a >= b) {
    sum += a;
    a--;
  }else{
    sum += b;
    b--;
  }
  if (a >= b) {
    sum += a;
    a--;
  }else{
    sum += b;
    b--;
  }

  printf("%d\n", sum);

  return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=3e5+10;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    int sum=0;
    sort(y,y+x);
    for (int i=1;i<x;i++)
    {
        sum+=y[i]-y[i-1];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int r; cin >> r; cout << r * r << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;

int n;
char s[MAXN+1];
char t[MAXN+1];

vector<int> a;
vector<int> b;

int solve() {
	b.clear(); if(t[0]=='1') b.PB(0); FOR(i,1,n) if(t[i]!=t[i-1]) b.PB(i); if(SZ(b)%2!=1) b.PB(n);
	int nextra=(SZ(b)+1)/2*2; a.clear(); REP(i,nextra) a.PB(0); if(s[0]=='1') a.PB(0); FOR(i,1,n) if(s[i]!=s[i-1]) a.PB(i); if(SZ(a)%2!=1) a.PB(n); REP(i,nextra) a.PB(n);
	//printf("a:"); REPSZ(i,a) printf(" %d",a[i]); puts("");
	//printf("b:"); REPSZ(i,b) printf(" %d",b[i]); puts("");
	int ret=INT_MAX;
	REPE(offset,SZ(a)-SZ(b)) if(offset%2==0) {
		int cur=0;
		REPSZ(i,a) if(i<offset) cur+=abs(a[i]-0); else if(i<offset+SZ(b)) cur+=abs(a[i]-b[i-offset]); else cur+=abs(a[i]-n);
		//printf("%d:",offset); REPSZ(i,b) printf(" %d",a[offset+i]); printf(" -> %d\n",cur);
		ret=min(ret,cur);
	}
	return ret;
}

void run() {
	scanf("%d",&n); scanf("%s",s); scanf("%s",t);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


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

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

  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << "\n";
  } else {
    cout << b - a << "\n";
  }
}


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

int main() {
  long long int l, r;
  cin >> l >> r;
  long long int res;
  long long int min = 2019;
  for(long long int i=l;i<r && i<l+2019;i++) {
    for(long long int j=i+1;j<=r && j<l+2019;j++) {
      res = ((i % 2019) * (j % 2019)) % 2019;
     if(res<min)
       min = res;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, k, a, b, ans;
int arr[105];

int main(){
    ios::sync_with_stdio(0);
    cin >> n >> k;
    forn(i,n) cin >> arr[i];
    
    ans = 0;

    forn(i,n){
        a = arr[i]*2;
        b = (k-arr[i])*2;

        ans += min(a,b);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef tuple<int, int, int, int> t4;
typedef pair<ll, ll> PL;
typedef long double ldouble;

int X[100010], Y[100010];
int W[100010];
int N, L, T;

void solve(){
	scanf("%d%d%d", &N, &L, &T);
	ll sum = 0;
	rep(i, N){
		scanf("%d%d", X+i, W+i);
		sum += X[i];
		sum += (W[i] == 1 ? 1 : -1) * T;
	}
	sum %= (ll)N * L;
	if(sum < 0)sum += (ll)N * L;
	rep(i, N){
		Y[i] = X[i] + (W[i] == 1 ? 1 : -1) * T;
		Y[i] %= L;
		if(Y[i] < 0)Y[i] += L;
	}
	sort(Y, Y+N);
	ll sum2 = 0;
	rep(i, N)sum2 += Y[i];
	ll t = sum - sum2;
	if(t < 0)t += (ll)N * L;
	t /= L;
	rep(i, N)printf("%d\n", Y[(i+t)%N]);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 2304
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else float('inf')
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

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

int main() {
    int N, W;
    cin >> N >> W;
    int weight[N], value[N];
    for(int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }
    long long int dp[N+1][W+1] = {};
    for(int i = 0; i < N; i++) {
        for(int sum_w = 0; sum_w <= W; sum_w++) {
            if(sum_w - weight[i] >= 0) {
                dp[i+1][sum_w] = max(dp[i+1][sum_w],
                 dp[i][sum_w - weight[i]] + value[i]);
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
#include <stdio.h>

long long val(long long x){
  long long sum = 0;
  while(x){
    sum += x%10;
    x /= 10;
  }
  return sum;
}

int main(){
  long long a, n, m, y, t, x, cnt = 0;
  scanf("%lld %lld %lld", &a, &n, &m);

  for ( y = 1; y <= 72; y++ ){
    x = 1;
    for ( t = 1; t <= n; t++ ){
      x *= (y+a);
    }
    if (x <= m && val(x) == y) cnt++;
  }

  printf("%lld\n", cnt);

  return 0;
}



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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    long long t = 0LL;
    for(int i = 0; i < n; ++i){
    	cin >> a[i];
    }
   // cout << "0 " ;
    int prev_max = a[0];
    for(int i = 1; i < n; ++i){
    	if(prev_max < a[i]){
    		prev_max = a[i];
    //		cout <<  "0 ";
    		continue;
    	}
    //	cout << (prev_max - a[i]) << " ";
    	t += prev_max - a[i];
    }

    //cout << '\n';
    cout << t;
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-6)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int n, a[1010];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  double maxi = 0;
  rep(i,n) REP(j,i+1,n) {
    double C = a[j], D = a[i];
    double A,B;
    int k = n-1;
    vector<int> ps;
    while( ps.size() < 2 ) {
      assert( k >= 0 );
      if( k != i && k != j ) ps.push_back(k);
      --k;
    }
    A = a[ps[0]];
    B = a[ps[1]];
    maxi = max(maxi,(A+B)/(C-D));
  }
  printf("%.10f\n",maxi);
  return 0;
}

Measured memory_bytes: 3256
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int> a (n);
 	 for(int i; i<n; i++) cin >> a[i];
  vector<int> b (n);
 	 for(int i; i<n; i++) cin >> b[i];
  vector<int> c (n-1);
  	for(int i; i<n-1; i++) cin >> c[i];
  int cnt = 0;
  for( int i; i<n; i++ ) {
  	cnt += b[ a[i] - 1 ];
  	if ( a[i]+1 == a[i+1] ) cnt += c[ a[i] - 1];
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    w = [wv[i][0] for i in range(N)]
    v = [wv[i][1] for i in range(N)]
    vdp = [[0 for _ in range(W+1)] for _ in range(N+1)]
    
    for i in range(N):
        for weight in range(W+1):
            # 品物iを（選べるなら）選ぶ
            if weight >= w[i]: vdp[i+1][weight] = max(vdp[i][weight - w[i]] + v[i], vdp[i][weight])
            # 品物iを選ばない
            vdp[i+1][weight] = max(vdp[i+1][weight], vdp[i][weight])
    print(vdp[N][W])

if __name__ == '__main__':
    main()

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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
// constexpr ll mod = 1e9 + 7;

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

    int ans=0;

    if(N>=2) ans += N*(N-1)/2;
    if(M>=2) ans += M*(M-1)/2;

    cout << ans << endl;

    return 0;
}


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

int main(){
    int n,i,j;
    cin >> n;
    vector<vector<int>> abc(n);
    for ( i = 0; i < n; i++)
    {   
        int a,b,c;
        cin >> a >> b >> c;
        abc[i].push_back(a);
        abc[i].push_back(b);
        abc[i].push_back(c);
    }

    vector<vector<int>> dp(n,vector<int>(3,0));

    for(i=0;i<3;i++)dp[0][i]=abc[0][i];

    for ( i = 1; i < n; i++)
    {
        for ( j = 0; j < 3; j++)
        {
            if(j==0){
                dp[i][0] = max(dp[i-1][1]+abc[i][j], dp[i-1][2]+abc[i][j]);
            }else if(j==1){
                dp[i][1] = max(dp[i-1][0]+abc[i][j], dp[i-1][2]+abc[i][j]);
            }else{
                dp[i][2] = max(dp[i-1][0]+abc[i][j], dp[i-1][1]+abc[i][j]);
            }   
        }
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
    
    
}

Measured memory_bytes: 11136
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
    string word;
    string longest = "";
    pair<int, string> frequent = make_pair(0, "");
    map<string, int> dictionary;

    while (cin >> word)
    {
        dictionary[word] += 1;

        if (dictionary[word] > frequent.first)
        {
            frequent = make_pair(dictionary[word], word);
        }
        if (word.size() > longest.size())
        {
            longest = word;
        }
    }
    cout << frequent.second << " " << longest << endl;
}


Measured memory_bytes: 3088
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    a,b = 0,1
    for i in range(n):
        q,x = LI()
        if q == 1:
            a *= x
            b *= x
        elif q == 2:
            a += x
            b += x
        else:
            a -= x
            b -= x
    B = b-a
    print(B-b,B)
    return


if __name__ == "__main__":
    solve()



Measured memory_bytes: 8172
#include <limits>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;

#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int n;
	int a[101];
	cin>>n;
	int i,j;
	for(i=0;i<n;i++)
	cin>>a[i];
	int m;
	cin>>m;
	int b,c;
	long long sum=0;
	for(j=0;j<m;j++){
		cin>>b>>c;
		//a[b-1]=c;
		for(i=0;i<n;i++){
			if(i==b-1){
				sum+=c;
			}else{
				sum+=a[i];
			}
			
		
	}
		cout<<sum<<endl;
		sum=0;
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Map<String, Integer> map = new HashMap<>();


        for (int i=0; i<n; i++){
            String s = sc.next();
            if (map.containsKey(s)){
                int tmp = (int)map.get(s);
                map.put(s, tmp+1);
            }else {
                map.put(s, 1);
            }
        }

//        System.out.print(map);

        List<String> list = new ArrayList<>();


        map = sortByValues(map);

//        System.out.print(map);

//        String maxStr = sortByValues(map)
//        int max = map.get(maxStr);
////        System.out.print(max);

//        for (String key: sortMapByValue(map).keySet()){
//            if (map.get(key)==max){
//                list.add(key);
//            }else {
//                break;
//            }
//        }

        int max = 0;
        for (int v: map.values()){
            max = Math.max(max, v);
        }

//        System.out.print(max);

//        System.out.print(map.keySet());


//        System.out.print(map.getClass());

        Collection<String> tmpStr = map.keySet();
        Collection<Integer> tmpInt = map.values();

        List<String> listStr = new ArrayList<>();
        List<Integer> listInt = new ArrayList<>();

        for (String str: map.keySet()){
            listStr.add(str);
        }

        for (Integer Int: map.values()){
            listInt.add(Int);
        }

//        System.out.print(listStr);
//        System.out.print(listInt);

        for (int i=0; i<listStr.size(); i++){
            if (listInt.get(i)==max){
                list.add(listStr.get(i));
            }else break;
        }
//        System.out.print(tmpInt.toArray());

//        for (String str: map.keySet()){
//            int tmp = map.get(str).intValue();
//            if (tmp==max) list.add(str);
//            else break;
//        }


        Collections.sort(list);
//        System.out.print(list);
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<list.size(); i++){
            sb.append(list.get(i)+"\n");
        }
        System.out.print(sb.toString());
//        System.out.print(sortByValues(map));
    }

    public static <K, V extends Comparable<V>> Map<K, V> sortByValues(final Map<K, V> map) {
        Comparator<K> valueComparator =
                new Comparator<K>() {
                    public int compare(K k1, K k2) {
                        int compare =
                                map.get(k2).compareTo(map.get(k1));
                        if (compare == 0)
                            return 1;
                        else
                            return compare;
                    }
                };

        Map<K, V> sortedByValues =
                new TreeMap<K, V>(valueComparator);
        sortedByValues.putAll(map);
        return sortedByValues;
    }
}


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

int main() {
  long long A, B, C, K;
  cin >> A >> B >> C >> K;
  
  if(K%2==0){
    cout << A-B << endl;
  }
  
  else if(K%2==1){
    cout << B-A << endl;
  }
  
  
}

Measured memory_bytes: 3632
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int> PII;
#define fi first
#define se second
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const long long res = 1000000000000000000;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    long long sum = 1;
    vector<long long>a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if(a[0] == 0) cout << 0 << endl;
    else{
        for(int i = 0; i < n; ++i){
            if(sum > res / a[i]){
                cout << -1 << endl;
                return 0;
            }
            sum = sum * a[i];
        }
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, sum = 0;
    cin >> A >> B;
    sum = A + B;
    if (sum >= 10) {
        cout << "error" << "\n";
    } else {
        cout << sum << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

vector<int>adj[nmax];
vector<int>vis(nmax,false);
int sz = 0;

void dfs(int u)
{
    sz++;
    vis[u]= true;
    for(int v:adj[u])
    {
        if(!vis[v])
            dfs(v);
    }
}

int main()
{
    optimizeIO();

    int n,m;
    cin>>n>>m;

    while(m--)
    {
        int a,b;
        cin>>a>>b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ans = 0;

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            sz = 0;
            dfs(i);
            ans = max(ans,sz);
        }
    }

    cout<<ans<<endl;


    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 21060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int n; cin >> n;
  vi p(n); rep(i,n) cin >> p.at(i);
  
  int ans = 0;
  repf(i,1,n-1) {
    int sum = p.at(i-1)+p.at(i)+p.at(i+1);
    int x = sum-max({p.at(i-1),p.at(i),p.at(i+1)})-min({p.at(i-1),p.at(i),p.at(i+1)});
    if(p.at(i)==x) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,l;
    cin>>n>>l;
    if(l<0&&l+n>1)
        cout<<(l+n+l-1)*n/2;
    if(l>=0)
        cout<<(l+1+l+n-1)*(n-1)/2;
    if(l<0&&l+n<=1)
        cout<<(l+l+n-2)*(n-1)/2;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[213456], uiop[213456];
signed main() {
	int n, a = 0, b = 0, c = 0, sum = 0, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a;
		if (h % 2 == 0) { test[a]++; }
		if (h % 2 == 1) { uiop[a]++; }
	}
	for (int h = 1; h <= 100000; h++) {
		if (sum <= test[h]) {
			b = h; sum = test[h];
		}
	}
	for (int h = 1; h <= 100000; h++) {
		if (ans <= uiop[h]) {
			c = h; ans = uiop[h];
		}
	}
	if (b != c) {
		cout << n - sum - ans<< endl;
	}
	else {
		sort(test, test + 100001);
		sort(uiop, uiop + 100001);
		cout <<  n - max(test[100000] + uiop[99999], test[99999] + uiop[100000]) << endl;
	}
}

Measured memory_bytes: 1792
result = 0
blue_num = int(input())
blue_list = []

for i in range(blue_num):
  blue_list.append(input())
  
red_num = int(input())
red_list = []

for i in range(red_num):
  red_list.append(input())
  
for key in set(blue_list + red_list):
  point = blue_list.count(key) - red_list.count(key)
  if result < point:
    result = point

print(result)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
mod=pow(10,9)+7
sa=[0]
tmp=0
for x in a:
  tmp+=x
  sa.append(tmp)
ans=0
for i in range(n-1):
  ans+=a[i]*(sa[n]-sa[i+1])
  ans%=mod
print(ans)

Measured memory_bytes: 110196
class Solution:

    def solve(self, S: str, Q: int, Query) -> int:

        S_list = list(S)
        R = []
        L = []

        num_reverse = 0
        for q in Query:
            if int(q[0]) == 1:
                num_reverse += 1
            else:
                if (num_reverse + int(q[1])) % 2 == 0:
                    R.append(q[2])
                else:
                    L.append(q[2])

        if num_reverse % 2 == 1:
            return ''.join(R[::-1] + S_list[::-1] + L)
        else:
            return ''.join(L[::-1] + S_list + R)


if __name__ == '__main__':

    # standard input
    S = input()
    Q = int(input())
    Query = []
    for _ in range(Q):
        Query.append(tuple(input().split()))

    # solve
    solution = Solution()
    print(solution.solve(S, Q, Query))


Measured memory_bytes: 25860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		if(A + B >= 10)
			System.out.println("error");
		else
			System.out.println((A + B));
	}
}


Measured memory_bytes: 21972
using System;
class T{
　static void Main(){
　　string[] l = Console.ReadLine().Split();
　　int N = int.Parse(l[0]);
　　int A = int.Parse(l[1]);
　　int B = int.Parse(l[2]);
　　Console.WriteLine(N*A>B?B:N*A); }　}

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

using namespace std;

int main()
{
	int A, B;
	
	cin >> A >> B;
	
	int sum = A + B;
	int sub = A - B;
	int multi = A * B;
	
	// 最大値を取得できる
	// C++11から複数引数も可能
	int answer = max({sum, sub, multi});
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 384
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	if(n==1){
		puts("Yes\n2");
		puts("1 1\n1 1");
		return 0;
	}

	int sum = 0;
	REP(k, 0, 1000){
		sum += k;
		if(sum-k!=n) continue;
		std::vector<V> ans(k, V(0));
		int cnt = 1;
		REP(i, 0, k) REP(j, i+1, k) {
			ans[i].push_back(cnt);
			ans[j].push_back(cnt);
			cnt++;
		}
		printf("Yes\n%ld\n", k);
		for(auto vec: ans){
			printf("%ld", vec.size());
			for(int x: vec) printf(" %d", x);
			puts("");
		}
		return 0;
	}
	puts("No");
	return 0;
}



Measured memory_bytes: 3200