akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Yuki
 */
public class Main {

	/*** ?????? */
	private final static double INTEREST = 1.05;

	/*** ??????????????? */
	private final static double REVALUATION = 1000;

	/*** ???????????\??????????????????????¨??????\?????? */
	private static BufferedReader br;

	/*** ??± */
	private static int weekNum;

	/*** ????????? */
	static {
		// ?¨??????\?????????
		br = new BufferedReader(new InputStreamReader(System.in));
		try {
			weekNum = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * ?????????????????????<br>
	 * ??????????????????????????????
	 *
	 * @param args
	 *            ??????????????°
	 */
	public static void main(String[] args) {

		// ????????????????????????
		System.out.println(getTotalDept());

	}

	/**
	 * ?????????????????????????????? ????????????????????±???????¨??????????????¨????????????????
	 *
	 * @return ???????????????
	 */
	private static int getTotalDept() {
		double debt = 100000 / REVALUATION;
		for (; weekNum > 0; weekNum--) {
			debt = Math.ceil(debt * INTEREST); // ????????????
		}
		return (int) (debt * REVALUATION);
	}

}

Measured memory_bytes: 16868
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int N, M, Q;
	scanf("%d %d %d", &N, &M ,&Q);
	int lr[1000][1000];
	rep(i, 0, N + 1) {
		rep(j, 0, N + 1) {
			lr[i][j] = 0;
		}
	}
	rep(i, 0, M) {
		int l, r;
		scanf("%d %d", &l, &r);
		++lr[l][r];
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[i][j] += lr[i][j - 1]; 
		}
	}
	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			lr[j][i] += lr[j - 1][i]; 
		}
	}
	rep(i, 0, Q) {
		int p, q;
		scanf("%d %d", &p, &q);
		cout << lr[q][q] - lr[p-1][q] - lr[q][p-1] + lr[p-1][p-1] << endl;
	}
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()
#define sign(x) ((x) >= 0 ? 1 : -1)

bool solve(){
    int L, N; cin >> L >> N;
    int power = 0;
    rep(i, N){
        int x, w; cin >> x >> w;
        power += x * w;
    }
    if(power == 0) cout << 0 << endl;
    else {
        cout << 1 << endl;
        cout << -1 * sign(power) << " " << abs(power) << endl;
    }
    
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

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

int main(){
	int m,n1,n2;
	cin >> m>>n1>>n2;
	while(m!=0||n1!=0||n2!=0){
	int p[m];
	for(int i = 0; i < m; i++){
		cin>>p[i];
	}
	int g = 0;
	for(int i = n1; i <= n2; i++){
		g = max(g,p[i-1]-p[i]);
	}
	for(int i = n2; i >= n1; i--){
		if(g==p[i-1]-p[i]){
			cout << i<<endl;
			break;
		}
	}
	cin >> m>>n1>>n2;
	}
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	long long A[16][16]; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> A[i][j]; 
		}
	}
	long long P[65536] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int k = 0; k < (1 << N); k++){
				if(((k >> i) & 1) && ((k >> j) & 1)) P[k] += A[i][j];
			}
		}
	}
	long long dp[65536] = {}; 
	for(int i = 1; i < (1 << N); i++) dp[i] = -1e18; 
	for(int bit = 1; bit < (1 << N); bit++){
		int now = bit; 
		while(1){
			dp[bit] = max(dp[bit], dp[now] + P[bit - now]); 
			now = (now - 1) & bit; if(now == bit) break; 
		}
	}
	cout << dp[(1 << N) - 1] << endl; 
}

Measured memory_bytes: 1280
#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;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int R=in();
    if(N<10){
        R=R+100*(10-N);
    }
    cout<<R<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

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

        if (a == b)
            Console.WriteLine(c);
        else if (a == c)
            Console.WriteLine(b);
        else
            Console.WriteLine(a);
    }
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


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

	int h,w, a,b;
	cin >>h >>w >>a >>b;
	
	cout << (h-a) * (w-b) <<"\n";

	return 0;
}




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

int gcd(int64_t a, int64_t b){
    if (b > a) return gcd(b, a);

    if(a % b == 0){
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main(){
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;

  int64_t l = C*D/gcd(C, D);

  int64_t div_by_C = B/C - (A-1)/C;
  int64_t div_by_D = B/D - (A-1)/D;
  int64_t div_by_l = B/l - (A-1)/l;

  cout << (B-A+1) - (div_by_C + div_by_D - div_by_l) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    int M;
    cin >> M;
    vector<string> T(M);
    for(int i = 0; i < M; i++) cin >> T[i];
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        int res = 0;
        for(int j = 0; j < N; j++){
            if(S[i] == S[j]) res++;
        }
        for(int j = 0; j < M; j++){
            if(S[i] == T[j]) res--;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000001
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define f0(s,a,b) for(lli s=a;s<b;s++)
#define f1(s,a,b) for(lli s=a;s<=b;s++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define T 100
#define print(x) cout<< #x <<"=" <<x<<"\n";


int main()
{
     fast
     lli n;
     cin>>n;
     lli a=n%10;
     n=n/10;
     lli c=n%10;
     n=n/10;
     lli b=n%10;
     if(a==7||b==7||c==7)
     {
          cout<<"Yes";
     }
     else
     {
          cout<<"No";
     }
     

     
}

Measured memory_bytes: 3648
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vector<pair<string, pair<int, int> > > data(N);
    rep(i, 0, N) {
        string a;
        int b;
        cin >> a;
        data[i].first = a;
        cin >> b;
        data[i].second.first = -b;
        data[i].second.second = i;
    }
    sort(data.begin(), data.end());
    rep(i, 0, N) {
        cout << data[i].second.second + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat


# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)
        for st in range(1<<n):
            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]



main()


Measured memory_bytes: 34024
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

x,y,A,B,C=get_i
P=get_i.sort!{|a,b| b<=>a}
Q=get_i.sort!{|a,b| b<=>a}
R=get_i.sort!{|a,b| b<=>a}
ans=[]
ans.push(P[0..x-1])
ans.push(Q[0..y-1])
ans.push(R)
puts ans.flatten!.sort!{|a,b| b<=>a}[0..x+y-1].inject(:+)

Measured memory_bytes: 32256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
String a=scan.next();
char b[]=new char[a.length()];
for(int i=0;i!=a.length();i++) {
	char c=a.charAt(i);
	if(i==3) {
		c='8';
	}
	b[i]=c;
}
for(int i=0;i!=a.length();i++) {
	System.out.print(b[i]);
}
System.out.println();
	}
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a){
    mint x=1;
    mint y=1;
    rep(i, a){
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}


int main(void){
    int n, a, b;
    cin>>n>>a>>b;
    mint ans=mint(2).pow(n);
    ans-=1;
    ans-=choose(n, a);
    ans-=choose(n, b);
    cout<<ans.x<<endl;
    return 0;
}

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

using namespace std;

int n, ans;

int main(int argc, char ** argv)
{
	cin >> n;
	for (int i = 1; i <= n; i += 2)
	{
		int sum = 0;
		for (int j = 1; j <= floor(sqrt(i)); j++)
			if (!(i%j))
				sum++;
		if (sum == 4)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [x, y, z] <- readInt
  putStrLn $ show z ++ " " ++ show x ++ " " ++ show y


Measured memory_bytes: 380
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

using lint = long long;
#define rep(i, n) for(lint i = 0; i < lint(n); i++)
#define repu(i, a, b, s) for(lint i = lint(a); i < lint(b); i += lint(s))
#define repd(i, a, b, s) for(lint i = lint(a); i > lint(b); i += lint(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint N, M;
    cin >> N >> M;

    vector<lint> a(N);
    vector<lint> b(M);

    for(auto &&it : a) {
        cin >> it;
    }

    for(auto &&it : b) {
        cin >> it;
    }

    vector<lint> c = convolution<998244353>(a, b);
    rep(i, N + M - 1) { cout << (i == 0 ? "" : " ") << c[i]; }
    cout << endl;
}

int main(int argc, char *argv[]) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 27264
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
double D[80]; int d;

double pop_n(){
  return (D[--d]);}
void push_n(double a) {
  D[d]=a; d++;
}

int main() {
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp != NULL) {
      double a,b;
      if ((tp[0] == '+') && (tp[1]==0)) {
        b = pop_n(); a = pop_n();
        push_n(a+b);
      }
      else if (tp[0] == '*') {
        b = pop_n(); a = pop_n();
        push_n(a*b);
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]-=D[--d];
      }
      else if (tp[0] == '/') {
        D[d-2]/=D[--d];
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",pop_n());
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int N;
int a[100010], b[100010], c[100010];

//DPテーブル
int dpA[100010], dpB[100010], dpC[100010];

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	
	dpA[0] = a[0]; dpB[0] = b[0]; dpC[0] = c[0];
	for (int i = 1; i < N; i++)
	{
		dpA[i] = max(dpB[i - 1] + a[i], dpC[i - 1] + a[i]);
		dpB[i] = max(dpA[i - 1] + b[i], dpC[i - 1] + b[i]);
		dpC[i] = max(dpA[i - 1] + c[i], dpB[i - 1] + c[i]);
	}

	cout << max(dpA[N - 1], max(dpB[N - 1], dpC[N - 1])) << endl;
}

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

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")

using namespace std;

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

    int N; string S; cin >> N >> S;
    int occurence = 0;
    size_t idx = S.find("ABC");
    while(idx != string::npos){
        occurence++;
        idx = S.find("ABC", idx+1);
    }
    cout << occurence << endl;
    return 0;
}

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

int main() {
	string s; cin >> s;
	size_t p = s.find("C");
	if (p == s.npos) puts("No");
	else if (s.substr(p).find("F") != s.npos) puts("Yes");
	else puts("No");
}

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

using namespace std;

int main(){
    vector<int>C,V;

    int N;
    int tmp;
    int max=0;

    cin>>N;

    for(int i=0;i<N;i++){
        cin>>tmp;
        V.push_back(tmp);
    }
    for(int i=0;i<N;i++){
        cin>>tmp;
        C.push_back(tmp);
    }
    for(int i=0;i<N;i++){
        if(V[i]>C[i])
            max +=(V[i]-C[i]);

    }

    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
l = []
l.append([0]*(w+2))
target = 0
count = 0
dirs = [[-1, 0], [1, 0], [0, -1], [0, 1]]
for i in range(h):
  temp = list(input())
  target += temp.count('#')
  l.append([0] + temp + [0])
l.append([0]*(w+2))
ans = []
for i in range(1, h+1):
  for j in range(1, w+1):
    if l[i][j] == '#':
      for dir in dirs:
        if l[i+dir[0]][j+dir[1]] == "#":
          count += 1
          break
    else:
      continue
    pass

if count == target:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int count(ll n, ll N){
  if(n > N)
    return 0;
  int ret = 0;
  string s = to_string(n);
  if(s.find('7')!=string::npos && s.find('5')!=string::npos &&s.find('3')!=string::npos )
    ret = 1;
  ret += count(n*10+7, N) + count(n*10+5, N) + count(n*10+3, N);
  return ret;
}

int main(){
  ll N;
  cin >> N;
  cout << count(0, N);
}



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

using namespace std;

void func_A(){
    
    int x;
    for (int i = 1; i <= 5; ++i) {
        cin >> x;
        if (x == 0) {
            cout << i;
            return;
        }
    }

}

void func_B() {}

void func_C() {}

int main()
{

    func_A();

    return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n;
    cin >> n;
    vi A (n), B (n);
    trav (a, A)
        cin >> a;
    trav (a, B)
        cin >> a;
    for (i = 0; next_permutation (all (A)); ++i);
    for (j = 0; next_permutation (all (B)); ++j);
    cout << abs (i - j) << '\n';

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 5/3/2020
 
 20:16-
 
 */

string S;
int N;

void solve() {
  int N=SZ(S);
  REP(i,N-1) if(S[i]==S[i+1]) {
    cout<<i+1<<" "<<i+2<<endl;
    return;
  }
  REP(i,N-2) if(S[i]==S[i+2]) {
    cout<<i+1<<" "<<i+3<<endl;
    return;
  }
  cout<<-1<<" "<<-1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 512
n = int(input())
s = []
t = []
for i in range(n):
    a, b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

# print(s, t, x)

idx = s.index(x)
# print(idx)
ans = sum(t) - sum(t[: idx + 1])

print(ans)


Measured memory_bytes: 3060
#pragma region include, macro
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double a, b;
	cin >> a >> b;
	cout << a / b << endl;
}

Measured memory_bytes: 256
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;

void input() {
  cin >> S;
}

void solve() {
  int a = stoi(S.substr(0, 2));
  int b = stoi(S.substr(2, 2));

  bool m_a = 1 <= a and a <= 12;
  bool m_b = 1 <= b and b <= 12;

  if (m_a and !m_b) {
    cout << "MMYY" << endl;
  }
  else if (!m_a and m_b) {
    cout << "YYMM" << endl;
  }
  else if (!m_a and !m_b) {
    cout << "NA" << endl;
  }
  else {
    cout << "AMBIGUOUS" << endl;
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, C, n=3, ans=1e9; cin >> N >> C; int D[C][C], c[N][N], moto[n][C]={};
REP(i, C){ REP(j, C){ cin >> D[i][j]; } }
REP(i, N){ REP(j, N){ cin >> c[i][j]; moto[((i+1)+(j+1))%3][c[i][j]-1]++; } }
REP(i, C){ REP(j, C){ if(i==j){ continue; } REP(k, C){ if(i==k||j==k){ continue; }
 int now=0;
 REP(x, C){ now=now+moto[0][x]*D[x][i]+moto[1][x]*D[x][j]+moto[2][x]*D[x][k]; } 
 ans=min(ans, now);
} } }
cout << ans << "\n";
}

Measured memory_bytes: 1280
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main()
{	
	int n;
	cin >> n;
	vector <int> count(1000, 0);
	for (int i = 1; i <= n; i++) {
		int t = i;
		while (t % 2 == 0) {
			if (t == 0) {
				break;
			}
			count[i]++;
			t /= 2;
		}
	}
	int num=0;
	int big=0;
	for (int i = 1; i <= n; i++) {
		num = count[i];
		if (num > big) {			big = num;
		}

	}
	int an=1;
	for (int i = 0; i < big; i++) {
		an *= 2;
	}
	cout << an << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこの,プロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します

Measured memory_bytes: 256
// atcoder/abc162/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

lli pow(lli n, int p)
{
  if (p == 0) return 1;
  if (p == 1) return n;
  lli m = pow(n, p / 2);
  (m *= m) %= mod;
  if (p%2) (m *= n) %= mod;
  return m;
}

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  const int N = 1e5 + 5;

  int n, k;
  while (cin >> n >> k) {
    static lli x[N];
    fill(x, x + N, 0);
    for (int i = k; i; --i) {
      x[i] = ::pow(k / i, n);
      for (lli j = i + i; j <= k; j += i) {
        x[i] -= x[j];
        x[i] = (x[i] + mod) % mod;
      }
    }

    lli sum = 0;
    for (int i = 0; i < N; ++i) {
      (sum += (x[i] * i) % mod) %= mod;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 4420
package main

import (
	"fmt"
	"strconv"
)

func reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	var s string
	fmt.Scan(&s)
	s = reverse(s)

	const m = 2019
	base := 1
	total := 0
	ans := 0
	dp := make(map[int]int)
	for i := 0; i < len(s); i++ {
		dp[total]++
		num, _ := strconv.Atoi(string(s[i]))
		total += num * base
		total %= m
		ans += dp[total] // sj - si = 0
		base = base * 10 % m
	}

	fmt.Println(ans)

}

Measured memory_bytes: 4472
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int k, x;
  cin >> k >> x;
  int l = max(-1000000, x-k+1);
  int r = min( 1000000, x+k-1);
  for (int i=l; i<=r; i++) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
s=int(input())

if s<3:
    print(0)
    exit()

ans=0
xx=0
tt=False
mod = 10**9+7 
n = 10**4 
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    xx+=1
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

for i in range(s//3):
    s-=3
    ans+=cmb(s+i,i)
    ans%=mod

print(ans)

Measured memory_bytes: 10316
#include "bits/stdc++.h"
using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	char a[n+1][n+1], b[m+1][m+1];

	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			cin >> a[i][j];
		}
	}

	for(int i=1;i<=m;i++) {
		for(int j=1;j<=m;j++) {
			cin >> b[i][j];
		}
	}


	for(int g=0; g <= n-m+1; g++) {
		for(int r=0; r <= n-m+1; r++) {
			bool flag = true;
			for(int i=1;i<=m;i++) {
				for(int j=1;j<=m;j++) {
					if(a[r+i][g+j] != b[i][j]) flag = false;
				}
			}
			if(flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
// ll x[100010], v[100010];
// ll sumR[100010];
// ll sumL[100010];
// ll maxL[100010];
// ll maxR[100010];
int main() {
  // 095d
  ll n; ll c; cin >> n >> c;
  vll x(n+4,0), v(n+4,0);
  rep(i,n) cin >> x[i+1] >> v[i+1];
  x[n+1] = c; 
  v[n+1] = 0;
  x[0] = v[0] = 0;
  vll maxR(n+4,0), maxL(n+4,0), sumR(n+4,0), sumL(n+4,0);
  rep(i, n+1) {
    sumR[i+1] = sumR[i] + v[i+1]-(x[i+1]-x[i]);
    maxR[i+1] = max(maxR[i], sumR[i+1]);
  }
  for (int i=n; i>=0; i--) {
    sumL[i] = sumL[i+1] + v[i]-(x[i+1]-x[i]);
    maxL[i] = max(maxL[i+1], sumL[i]);
  }
  ll ans = 0;
  for (int i=n+1; i>=0; i--) {
    ll cal = sumL[i] - (c-x[i]);
    if (i) cal += maxR[i-1];
    chmax(ans, cal);
  }
  rep(i, n+1) {
    ll cal = sumR[i] - x[i];
    if (i != n) cal += maxL[i+1];
    chmax(ans, cal);
  } 
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=INT_MAX;
struct segtree
{
    vector<int> node;
    vector<int> lazy;
    vector<bool> lflg;
    int n;
    segtree(int sz)
    {
        n=1;while(n<sz) n*=2;
        node.resize(2*n,0);
        lazy.resize(2*n,0);
        lflg.resize(2*n,false);
    }
    void lazyupdate(int k, int l, int r)
    {
        if(lflg[k])
        {
            node[k]+=(r-l+1)*lazy[k];
            push(lazy[k],k,l,r);
            lazy[k]=0;
            lflg[k]=false;
        }
    }
    void push(int v,int k,int l,int r)
    {
        if(r-l>0)
        {
            lazy[2*k]=lazy[2*k+1]=v;
            lflg[2*k]=lflg[2*k+1]=true;
        }
    }
    void update(int qa, int qb, int v, int k=1, int l=1,int r=-1)
    {
        if(r<0) r=n;
        lazyupdate(k, l, r);
        if(qb<l||r<qa) return;
        if(qa<=l&&r<=qb)
        {
            node[k]+=(r-l+1)*v;
            push(v,k,l,r);
        }
        else
        {
            int m=(l+r)/2;
            update(qa,qb,v,2*k,l,m);
            update(qa,qb,v,2*k+1,m+1,r);
            node[k]=node[2*k]+node[2*k+1];
        }
    }
    int get(int qa, int qb, int k=1, int l=1, int r=-1)
    {
        if(r<0) r=n;
        lazyupdate(k ,l, r);
        if(qb<l||r<qa) return 0;
        if(qa<=l&&r<=qb) return node[k];
        else
        {
            int m=(l+r)/2;
            int lv=get(qa, qb, 2*k, l, m);
            int rv=get(qa, qb, 2*k+1, m+1, r);
            return lv+rv;
        }
    }
};

int main()
{
    int n,q;
    scanf("%d %d",&n,&q);
    segtree tree(n);
    for(int i=0;i<q;i++){
        int c;
        scanf("%d",&c);
        if(c){
            int s,t;
            scanf("%d %d",&s,&t);
            cout<<tree.get(s,t)<<endl;
        }else{
            int x,y;
            scanf("%d %d",&x,&y);
            tree.update(x,x,y);
        }
    }
}


Measured memory_bytes: 4956
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    static void solve(Scanner in) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        int ans = 1;
        if (a != b)
            ans++;
        if (a != c && b != c)
            ans++;
        System.out.println(ans);

    }
}

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


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

int a, b, c;
a = n/100;
b = n/10-a*10;
c = n%100-b*10;

if (a ==1 ) a=9;
else if (a ==9 ) a=1;
if (b ==1 ) b=9;
else if (b ==9 ) b=1;
if (c ==1 ) c=9;
else if (c ==9 ) c=1;
  int ans =a*100+b*10+c ;
cout << ans << endl;
}

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

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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x.at(i) >> y.at(i);
    }
    auto dist = [&](int i, int j) {
        double dx = x.at(i) - x.at(j);
        double dy = y.at(i) - y.at(j);
        return sqrt(dx * dx + dy * dy);
    };
    vector<int> p(n);
    for (int j = 0; j < n; ++j) {
        p.at(j) = j;
    }
    double len = 0;
    do {
        for (int i = 0; i < n - 1; ++i) {
            len += dist(p.at(i), p.at(i + 1));
        }
    } while (next_permutation(p.begin(), p.end()));
    double ans = len / factorial(n);
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
rec = []
for i in range(N):
    x, y = map(int, input().split())
    rec.append((i, x, y))

recx = sorted(rec, key=lambda s: s[1])
recy = sorted(rec, key=lambda s: s[2])

G = []
for i in range(1, N):
    costx = min(abs(recx[i][1] - recx[i - 1][1]), abs(recx[i][2] - recx[i - 1][2]))
    costy = min(abs(recy[i][1] - recy[i - 1][1]), abs(recy[i][2] - recy[i - 1][2]))
    G.append((recx[i][0], recx[i - 1][0], costx))
    G.append((recy[i][0], recy[i - 1][0], costy))

rank = [0] * N
par = [i for i in range(N)]


def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] > rank[y]:
        par[y] = x
    else:
        par[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


def same(x, y):
    return find(x) == find(y)


G = sorted(G, key=lambda s: s[2])
num = 0
for e in G:
    if not same(e[0], e[1]):
        unite(e[0], e[1])
        num += e[2]

print(num)


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

int main(void){
  int N, count;
  cin >> N;
  vector<int> ans(N, 1);
  int cr[N][N];
  for(int i = 0; i < N; i++){
    cin >> count;
    for(int j = 0; j < N; j++){
      cr[i][j] = -1;
	}
    for(int j = 0; j < count; j++){
      int temp;
      cin >> temp;
      cin >> cr[i][temp - 1];
      
    }
  }
  int max = 0;
  for(int bit = 0; bit < (1<<N); ++bit){
    for(int j = 0; j < N; j++){
      ans[j] = 0;
      if(bit & (1<<j))ans[j] = 1;
      //cout << ans[j];
    }
    for(int k = 0; k < N; k++){
      for(int l = 0; l < N; l++){
        if(ans[k] == 1 && cr[k][l] == 1 && ans[l] == 0){
          ans[k] = -1;
          break;
        }
        else if(ans[k] == 1 && cr[k][l] == 0 && ans[l] == 1){
          ans[k] = -1;
          break;
        }
      }
    }
    count = 0;
    for(int n = 0; n < N; n++){
      if(ans[n] == 1) count++;
      if(ans[n] == -1) {
        count = 0;
        break;
      }
    }
    if(count > max) max = count;
    //cout << " " << count << endl;
  }
  cout << max;
}

Measured memory_bytes: 256
from itertools import product

RGB0 = [*map(int, input().split())]
K = int(input())

for K_cards in product(range(3), repeat=K):
  RGB = RGB0[:]
  if RGB[2] > RGB[1] > RGB[0]:
    print("Yes")
    exit()
  for i in range(K):
    RGB[K_cards[i]] *= 2
    if RGB[2] > RGB[1] > RGB[0]:
      print("Yes")
      exit()
print("No")

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

int main(){
    int a, work;
    int sum = 0;
    cin >> a;
    int b = a;
    for(int i = 1000000000; i > 0; i /= 10){
        if(b % i != a){
        work = b / i;
        sum += work;
        b = b - i * work;
        }
    }
    if(a % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
_, s = open(0).read().split()
left, right = [0], []
lw, re = 0, 0
for i in s:
  if i == 'W':
    lw += 1
  left += [lw]
for i in s[::-1]:
  if i == 'E':
    re += 1
  right += [re]
print(min(i + j for i, j in zip(left[:-1], right[-2::-1] + [0])))

Measured memory_bytes: 24648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(a > b)System.out.println(a - 1);
    else System.out.println(a);
  }
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    ll nx = 0, ny = 0, nt = 0;
    rep(i, n) {
        ll t, x, y; cin >> t >> x >> y;
        if((abs(nx - x) + abs(ny - y)) > (t - nt)) {
            cout << "No" << endl;
            return 0;
        }
        if((abs(nx - x) + abs(ny - y))%2 != (t - nt)%2) {
            cout << "No" << endl;
            return 0;
        }
        nx = x;
        ny = y;
        nt = t;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=1e9+7;
//
int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<endl;
	}else if(a+b>=k){
		cout<<a<<endl;
	}else{
		cout<<a-(k-a-b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3636
/*************************************************************************
     File Name: Atcoder2159.cpp
     ID: Liusiyu
     BLOG: http://blog.csdn.net/r_o_j 
     LANG: C++ 
     Mail: 779532360@qq.com 
     Created Time: 2017年01月17日 星期二 13时39分27秒
 ************************************************************************/
#include<bits/stdc++.h>
#define MEM(a,x) memset(a,x,sizeof(a))
#define MEMINF(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN=2e5 + 10;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
int n, k, l;
int color[3][MAXN];
vector<int> G[3][MAXN];
int city[MAXN];

void Dfs(int r, int c,int id) {
  stack<int> s;
  s.push(r);
  color[id][r] = c;
  while (!s.empty()) {
    LL u = s.top();
    s.pop();
    for (int i = 0; i < G[id][u].size(); ++i) {
      int v = G[id][u][i];
      if (color[id][v] == -1) {
        color[id][v] = c;
        s.push(v);
      }
    }
  }
}

void Deal(int id) {
  LL a = 1;
  for (int i = 1; i < n + 1; ++i) 
    color[id][i] = -1;
  for (int i = 1; i < n + 1; ++i) 
    if (color[id][i] == -1) 
      Dfs(i, a++, id);
}

int main() {
  cin >> n >> k >>l;
  for (int i = 0; i < k; ++i) {
    int s, t;
    cin >> s >> t;
    G[1][s].push_back(t);
    G[1][t].push_back(s);
  }
  for (int i = 0; i < l; ++i) {
    LL s, t;
    cin >> s >>t;
    G[2][s].push_back(t);
    G[2][t].push_back(s);
  }
  Deal(1);
  Deal(2);
  map<pair<int, int>, int>M;
  for (int i = 1; i < n + 1; ++i) {
    M[make_pair(color[1][i],color[2][i])]++;
  }
  for (int i = 1; i < n; ++i) {
    cout << M[make_pair(color[1][i],color[2][i])] << " ";
  }
  cout << M[make_pair(color[1][n],color[2][n])]<<endl;
}



Measured memory_bytes: 32556