akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);


}
int n;
vector<ll>v;
ll mem[(int)1e5 + 10];
ll solve(int i)
{
	if (i == n-1)return 0;
	ll& ret = mem[i];
	if (~ret)return ret;
	ret = solve(i + 1) + abs(v[i + 1] - v[i]);
	if (i + 2 < n)
		ret = min(ret, solve(i + 2) + abs(v[i + 2] - v[i]));
	return ret;
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		cin >> n;
	v = vector<ll>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	ex(solve(0));
}

Measured memory_bytes: 6528
N = int(input())

F = [int(input().replace(" ", ""), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	tmp2 = 0
	for j in range(N):
		tmp = (bin(i & F[j]).count('1'))
		tmp2 = tmp2 + P[j][tmp]
	profit = max(profit, tmp2)

print(profit)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

int a, b;

signed main () {
  cin >> a >> b;
  cout << max(a + b, max (a + a - 1, b + b - 1)) << endl;
  return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (S, T) = readLine()!!.split(" ")
    val (A, B) = readLine()!!.split(" ").map(String::toInt)
    val U = readLine()!!
    println(if (S == U) (A-1).toString()+" $B" else "$A "+(B-1).toString())
}

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

#define int long long

int H, W;
string s[100];

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < H; i++) {
        cout << s[i] << endl << s[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

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

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let csf = get!(usize, usize, usize; n-1);

    for i in 0..n - 1 {
        let mut t = 0;

        for &(c, s, f) in &csf[i..] {
            if t <= s {
                t = s;
            } else {
                t = s + (t - s + f - 1) / f * f;
            }

            t += c;
        }

        println!("{}", t);
    }
    println!("{}", 0);
}


Measured memory_bytes: 4352
import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))

    val Array(n, m) = in.readLine.split("\\s+").map(_.toInt)
    var prices = mutable.PriorityQueue(in.readLine.split("\\s+").map(_.toLong): _*)

    (1 to m).foreach { _ =>
      prices.enqueue(prices.dequeue() / 2)
    }

    System.out.println(prices.sum)
  }
}


Measured memory_bytes: 56908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n+5],b[n+5],c[n+5];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
     for(ll i=1;i<=n;i++)
    {
        cin>>b[i];
    }
     for(ll i=1;i<=n-1;i++)
    {
        cin>>c[i];
    }
    ll s=b[a[1]];
 // cout<<s;
     for(ll i=2;i<=n;i++)
    {
        if(a[i]==a[i-1]+1)
        {
        s=s+b[a[i]]+c[a[i]-1];
        }
        else{
        s=s+b[a[i]];
      //   cout<<s<<endl;
        }
    }
   cout<<s<<endl;
}

Measured memory_bytes: 384
A,B,M = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]

min_cost = 10 ** 6

for i in range(M):
  x,y,c = [int(s) for s in input().split()]
  if min_cost > a[x-1] + b[y-1] - c:
    min_cost = a[x-1] + b[y-1] - c
    
    
min_cost2 = min(a) + min(b)
print(min_cost) if min_cost < min_cost2 else print(min_cost2) 

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

#define rep(i,N) for(int i=0; i<(N); i++)
#define pb push_back

typedef long long ll;
typedef pair<int,int> P;
const ll mod=1e9+7;

ll N;
ll A[100005],B[100005];
ll ans1;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N+1){
	cin>>A[i];
}
rep(i,N){
	cin>>B[i];
}

rep(i,N){
	if(B[i]>=A[i]){
		ans1+=A[i];
		B[i]-=A[i];
	}
	else{
		ans1+=B[i];
		B[i]=0;
	}
	if(B[i]>=A[i+1]){
		ans1+=A[i+1];
		A[i+1]=0;
		B[i]-=A[i+1];
	}
	else{
		ans1+=B[i];
		A[i+1]-=B[i];
		B[i]=0;
	}

}

cout<<ans1<<endl;


}
	


Measured memory_bytes: 1920
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
using namespace std;
 

#define    int                   long long int 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1110111110111
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <long long int , pll>              //pair of ll and pair ll 
#define    sp(x)                    setprecision(x)
 

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    int a[n+1],dp[n+1];
    dp[0]=dp[1]=0;
    f(i,1,n)
        cin>>a[i];
    dp[2]=abs(a[2]-a[1]);
    // cout<<dp[1]<<" "<<dp[2]<<"  ";
    f(i,3,n)
    {
        dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
        // cout<<dp[i]<<"  ";
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n;
long long ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		if(i%3!=0&&i%5!=0)
			ans+=i;
	cout<<ans;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, t[100];

int main() {
	cin >> n;
	inc(i, n) { cin >> t[i]; }
	
	LL ans = 1;
	inc(i, n) { ans = lcm(ans, t[i]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int ans=0;
  int a[m];
  for(int i=0;i<m;i++)cin >> a[i];
  for(int i=0;i<n;i++){
    int q=0;
    for(int r=0;r<m;r++){
      int b;
      cin >> b;
      q+=a[r]*b;
    }
    if(q+c>0)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

const int MAX_N = 2 * 1e5;
int N, K, L;

struct union_find_tree {
	int par[MAX_N]; // 親
	int depth[MAX_N]; // 木の深さ

	// n要素で初期化
	void init(int n) {
		rep(i, 0, n) {
			par[i] = i;
			depth[i] = 0;
		}
	}

	// 木の根を求める
	int find(int x) {
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(depth[x] < depth[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K >> L;
	union_find_tree uft1, uft2;
	uft1.init(N);
	uft2.init(N);

	rep(i, 0, K) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		uft1.unite(p, q);
	}

	rep(i, 0, L) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		uft2.unite(r, s);
	}

	map<pair<int, int>, int> rsl;
	rep(i, 0, N) rsl[make_pair(uft1.find(i), uft2.find(i))]++;
	rep(i, 0, N) {
		cout << rsl[make_pair(uft1.find(i), uft2.find(i))];
		if(i == N - 1) cout << endl;
		else cout << " ";
	}

}



Measured memory_bytes: 15104
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vint ans;


void mainmain(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	ans = vint(n);
	rep(i,2){
		ans[0] = i;
		rep(j,2){
			ans[1] = j;
			bool ok = true;
			reep(k,1,n-1){
				if(s[k]=='o'){
					ans[k+1] = ans[k-1]^ans[k];
				}
				else{
					ans[k+1] = (1-ans[k-1])^ans[k];
				}
			}

			if(s[n-1]=='o'){
				if(ans[n-1]==0&&ans[0]!=ans[n-2]) ok=false;
				if(ans[n-1]==1&&ans[0]==ans[n-2]) ok=false;
			}
			else{
				if(ans[n-1]==0&&ans[0]==ans[n-2]) ok=false;
				if(ans[n-1]==1&&ans[0]!=ans[n-2]) ok=false;
			}

			if(s[0]=='o'){
				if(ans[0]==0&&ans[n-1]!=ans[1]) ok=false;
				if(ans[0]==1&&ans[n-1]==ans[1]) ok=false;
			}
			else{
				if(ans[0]==0&&ans[n-1]==ans[1]) ok=false;
				if(ans[0]==1&&ans[n-1]!=ans[1]) ok=false;
			}
			if(ok){
				rep(k,n){
					cout<<"SW"[ans[k]];
				}
				// cout<<s[n-1]<<" "<<ans[0]<<" "<<ans[n-2]<<endl;
				cout<<endl;
				return;
			}
		}
	}
	cout<<-1<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 976
from collections import deque
from itertools import chain

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
inf = float('inf')


def flatten(list_of_lists):
    return chain.from_iterable(list_of_lists)


def bfs(start, end):
    distance = [[inf for _ in range(W)] for _ in range(H)]
    queue = deque([(end, start)])
    distance[end][start] = 0

    while queue:
        y, x = queue.pop()
        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            if 0 <= nx < W and 0 <= ny < H and M[ny][nx] != '#' and distance[ny][nx] == inf:
                queue.appendleft((ny, nx))
                distance[ny][nx] = distance[y][x] + 1
    return distance


m = 0
for i in range(W):
    for j in range(H):
        if M[j][i] != "#":

            for length in list(flatten(bfs(i, j))):
                if length != inf and m < length:
                    m = length

print(m)


Measured memory_bytes: 48732
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
 
 
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    s=0
    for x in range(1,n):
        if a[x]<a[x-1]:
            s=s+a[x-1]-a[x]
            a[x]=a[x-1]
    print(s)


#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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

int main() {
  int w,a,b;
  cin>>w>>a>>b;
  if((a<=b && a+w>=b) || (b<=a && b+w>=a)) cout<<0<<endl;
  else cout<<min(abs(b-a-w),abs(a-b-w))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<string>
using namespace std;

const double PI  =3.141592653589793238463;
#define pb push_back
#define pf push_front
#define sz(v)  ((int)(v).size());
#define all(v) ((v).begin()),((v).end())
typedef unsigned long long ull;
typedef long long ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;

typedef pair<int,int> pi;
//2 7 3 4 9

void printVec(vul v1)
{
    for(int i=0; i<v1.size(); i++)
        cout<<v1[i]<<" ";
    cout<<endl;
}
ll rec(ll r,ll c){

if(r<=1 || c<=1){
    return 1;
}


return rec(r-1,c)+rec(r,c-1);
}

bool bin_search(ull  target, vul V){

ll low=0;
ll high=V.size()-1;
while(low<=high){
    ll mid=(low+high)/2;
    if(target==V[mid]){
        return true;
    }
    if(target <V[mid]){
        high=mid-1;
    }else{
    low=mid+1;
    }
}
return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
ll n,m,k;cin>>n>>m>>k;
vul a(n,0);
vul b(m,0);

for(ll i=0;i<n;i++){
cin>>a[i];
}
for(ll i=0;i<m;i++){
cin>>b[i];
}

vul A(n+1,0);
vul B(m+1,0);

for(ll i=0;i<n;i++){
A[i+1]=A[i]+a[i];
}
for(ll i=0;i<m;i++){
B[i+1]=B[i]+b[i];
}

ll books=0,A_books=0,B_books=0;
ull sum=0;

 vector<ull>::iterator lower,upper;
for(ull i=0;i<=n;i++){

ll t=k-A[i];
if(t < 0){
    continue;
}
 lower = lower_bound(B.begin(),B.end(),k-A[i]);
B_books=lower-B.begin();
if(B[B_books] >k-A[i] ||B_books>m){
    B_books--;
}
//B_books--;
sum=max(sum,B_books+i);

}
cout<<sum<<endl;
  return 0;
}


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

string s;
map<string,int> ans;

int main(){
	ans["SAT"] = 1;
	ans["FRI"] = 2;
	ans["THU"] = 3;
	ans["WED"] = 4;
	ans["TUE"] = 5;
	ans["MON"] = 6;
	ans["SUN"] = 7;
	cin >> s;
	cout << ans[s] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    a[0]--;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1])a[i]--;
        if(a[i]<a[i-1]){
            cout<<"No\n";return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 1024
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.864 #ループの時間制限
PROB=0.001 #突然変異の確率  
A=26 #アルファベットの数
START=time.time()
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    if (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]>0 or random()<PROB:
        T[d]=q

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 89672
n,k = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i)

sum = (1 + k) * k / 2
sum2 = sum - k

count = 0
(0..a_arr.length-1).each do |i|
  (0..a_arr.length-1).each do |j|
    if i < j then
      count += sum if a_arr[i] > a_arr[j]
    elsif i == j then
      next
    else
      count += sum2 if a_arr[i] > a_arr[j]
    end
  end
  count = count % (10 ** 9 + 7)
end

puts count


Measured memory_bytes: 2172
n = int(input())
cards = [[False for i in range(13)] for j in range(4)] #二次元配列を作る
pattern = ["S", "H", "C", "D"] #スート
for i in range(n):
    st, rank = input().split()
    cards[pattern.index(st)][int(rank)-1] = True #入力と表示を別にする
    
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5604
h, w, k = map(int, input().split())
maze = [input() for _ in range(h)]
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        count_kuro = 0
        for x in range(h):
            for y in range(w):
                if ((i >> x) & 1) == 0 and ((j >> y) & 1) == 0 and maze[x][y] == '#':
                    count_kuro += 1
        if count_kuro == k:
            ans += 1
print(ans)
        

    

        




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

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

int main() {
  string S;
  while (cin >> S) {
    ll res = 0;
    int p = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == 'W') {
        res += i - p;
        ++p;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;


int main()
{
	long double a, b;
	cin >> a >> b;
	cout << (ll)floor(a * b) << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char c;
  cin>>c;
  char ans[5]={'a','i','u', 'e','o'};
  string an="consonant";
  for(auto x:ans){
    if(x==c){
      an="vowel";
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
    string s;
    cin >> s;
    bool can = true;
    bool exist = false;
    rep(i,s.size()){
        if (i == 0) {
            if (s[i] != 'A')
            can = false;
        }
        else if (i >= 2 && i <= s.size()-2){
            if (s[i] == 'C' ) {
                if (exist) can = false;
                else exist = true;
            }
            if (s[i] != 'C' && isupper(s[i]))  can = false; 
        }
        else{
            if (isupper((s[i]))){
                //cout << "this" << endl;
                can = false;
            } 
        }
        //cout << i << endl;
        if (!can){
            cout  << "WA" << endl;
            return 0;
        }
    }
    if (exist && can) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;

}


Measured memory_bytes: 256
def main():
    orig, count, dist = [int(x) for x in input().split()]
    orig = abs(orig)
    q, mod = divmod(orig, dist)
    if q > count:
        return orig - dist * count
    else:
        if (count - q) % 2 == 0:
            return mod
        else:
            return abs(mod - dist)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9168
abc = list(map(int, input().split()))
cnt5 = 0
cnt7 = 0
for i in abc:
    if i == 5:
        cnt5 += 1
    elif i == 7:
        cnt7 += 1
if cnt5 == 2 and cnt7 == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
    ans = 0
    MOD = 10^9 + 7
    N = parseInt(readline())
    A = parseMap(split(readline()))
    af = 0
    for i in N:-1:2
        af += A[i]
        ans += ((A[i - 1] % MOD) * (af % MOD)) 
        ans %= MOD
    end
    println(ans)
end


main()


Measured memory_bytes: 193596
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 i = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
#define PREFIX "#" TOSTRING(__LINE__) "| "
#define debug(x) \
{ \
  std::cout << PREFIX << #x << " = " << x << std::endl; \
}

std::ostream& output_indent(std::ostream& os, int ind) {
  for(int i = 0; i < ind; i++) os << " ";
  return os;
}

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {
  return (os << "(" << p.first << ", " << p.second << ")");
}
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << "[";
  for(int i = 0;i < v.size();i++) os << v[i] << ", ";
  return (os << "]");
}
template<class T, class V> std::ostream& operator<<(std::ostream& os, const std::map<T, V>& v) {
  os << "{";
  for(auto p: v) os << p << ", ";
  return (os << "}");
}

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];

  auto func = [&](i64 K) {
    map<i64, i64> mp;
    mp[0] = 0;
    rep(i,1,N) {
      i64 b = A[i - 1];
      i64 a = A[i];
      if(b < a) {
        auto iter = mp.end();
        --iter;
        if(iter->second > 0) {
          mp[b] = 0;
        }
      }
      else {
        i64 j = a - 1;
        while(j >= 0) {
          auto iter = mp.upper_bound(j);
          --iter;
          i64 x = iter->second;
          if(x + 1 == K) {
            j = iter->first - 1;
            mp.erase(iter);
          }
          else {
            mp[j] = x + 1;
            mp[j + 1] = 0;
            break;
          }
        }
        if(j <= -1) {
          return false;
        }
        auto iter = mp.lower_bound(a);
        while(iter != mp.end()) {
          mp.erase(iter++);
        }
      }
    }
    return true;
  };

  i64 ok = N;
  i64 ng = 0;
  while(abs(ng - ok) > 1) {
    i64 m = (ok + ng) >> 1;
    if(func(m)) {
      ok = m;
    }
    else {
      ng = m;
    }
  }
  cout << ok << endl;
}


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

using i64 = long long;

const int N = 1e5 + 5;

vector<int> g[N];
i64 val[N];

int n, root;

void dfs(int u, int far = -1) {
	i64 sum(0), mx(0);
	for (auto v: g[u]) if (v != far) {
		dfs(v, u);
		mx = max(mx, val[v]);
		sum+= val[v]; }

	if (g[u].size() == 1)
		return;

	i64 up, down;
	down = sum - val[u];
	up = val[u] - down;

	if (down > sum - mx) throw 0;
	if (up < 0 || down < 0 || val[u] < up || val[u] < down || sum != 2 * down + up) throw 0;
	val[u] = up; }

int main() {
#ifdef HOME
	freopen("agc6c.in", "r", stdin);
	freopen("agc6c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> val[i];

	for (int a, b, i = 1; i < n; ++i) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a); }

	if (n == 2) {
		cout << (val[1] == val[2] ? "YES" : "NO") << endl;
		return 0; }

	for (int i = 1; i <= n; ++i) if (g[i].size() > 1) {
		root = i;
		break; }

	try {
		dfs(root); }
	catch (int e) {
		cout << "NO" << endl;
		return 0; }

	cout << (!val[root] ? "YES" : "NO") << endl;

	return 0; }


Measured memory_bytes: 13184
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

stack<int >S1;
stack<pair<int,int> >S2;
char ch;
int sum =0;

int main(){
	for(int i=0;cin >>ch;i++){
		if(ch=='\\')	S1.push(i);
		else if(ch=='/'&&S1.size()>0){
			int j = S1.top();
			S1.pop();
			sum += i-j;
			int a = i-j;
			while(S2.size()>0&&S2.top().first>j){
				a+=S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}
	
	vector<int>	ans;
	while(S2.size()>0){
		ans.push_back(S2.top().second);
		S2.pop();
	}	
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;

	return 0;
}




Measured memory_bytes: 3212
dic = {}
N,M = map(int,input().split())

dic1 = {}
for i in range(M):
    a,b = map(int,input().split())
    a,b = min(a,b),max(a,b)
    if b == N:
        dic[a]=0
    if a==1:
        dic1[b]=0
ans = False
for tmp in dic1:
    if tmp in dic:
        ans = True
        break
print("POSSIBLE" if ans else "IMPOSSIBLE")

Measured memory_bytes: 102380
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

struct edge {
	int from;
	int to;
	long long cost;
};
edge es[2000];
long long d[1000];
int num[1000];
int N,M;

long long INF = 1LL << 50;

bool shortest_path(int s);
//bool find_n_loop();

int main(){

	scanf("%d %d",&N,&M);

	for(int i=0;i<M;i++){
		int a,b;
		long long c;
		scanf("%d %d %lld",&a,&b,&c);
		struct edge e;
		e.from = a-1;
		e.to = b-1;
		e.cost = -1*c;
		es[i] = e;
	}


	if(shortest_path(0)){
		printf("inf\n");
	}else{
		//printf("%d\n",num[N-1]);

		printf("%lld\n",-d[N-1]);
	}
	/*
	for(int i=0;i<N;i++){
		printf("%lld\n",d[i]);
	}
	*/

	return 0;
}

//
bool shortest_path(int s){
	for(int i=0;i<N;i++) d[i] = INF;
	d[s] = 0;
	for(int j=0;j<N-1;j++){
		//bool update = false;
		for(int i=0;i<M;i++){
			edge e = es[i];
			if(d[e.from]!=INF && d[e.to] > d[e.from]+e.cost){
				d[e.to] = d[e.from]+e.cost;
				//update = true;
			}
		}
		//if(!update) break;
	}
	bool negative[1000];
	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}
	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if ((d[e.from] != INF && d[e.to] > d[e.from] + e.cost)) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
//			if (negative[e.from] == true) {
//					 negative[e.to] = true;
//			}
        }
    }
    return negative[N - 1];
}
//
/*
bool find_n_loop(){
	//for(int i=0;i<N;i++) d[i] = 0;

	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			edge e = es[j];
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i==N-1) return true;
			}
		}
	}
	return false;
}
*/


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

using namespace std;

char s[20];
int main() {

    scanf("%s", s);

    for (int i = 0; i < 4; ++i) {
        printf("%c", s[i]);
    }

    printf(" ");
    
    for (int i = 4; i < 12; ++i) {
        printf("%c", s[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) {
      string s;
      ll i,sum=0;
      cin>>s;
      ll n=s.length();
      for(i=0;i<n;i++)
        sum+=s[i]-'0';
      if(sum%9==0)
        cout<<"Yes";
      else
        cout<<"No";
    }
}


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

int n,A,B;
string a,b,tmp;

int main()
{
	cin>>a>>b;
	cin>>A>>B;
	cin>>tmp;
	if(tmp == a)
		--A;
	if(tmp == b)
		--B;
	cout<<A<<' '<<B<<endl;
	return 0;
}


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

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

  int n, a, b;
  cin >> n >> a >> b;

  int temp = n * a;

  if (temp <= b) {
    cout << temp << '\n';
  } else {
    cout << b << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd

N = int(input())
A = [int(a) for a in input().split(" ")]
if N==2:
    print(max(A))
else:
    left, right = [-1]*(N-1), [-1]*(N-1)
    lacc, racc = (A[0], A[-1])
    for i in range(N-1):
        lacc, racc = gcd(lacc, A[i]), gcd(racc, A[N-1-i])
        left[i], right[i] = lacc, racc
    ans = max(right[-1], left[-1])
    for l, r in zip(left[:-1], reversed(right[:-1])):
        ans = max(ans, gcd(l,r))
    print(ans)


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

#define int long long

#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)

signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d) << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
int n=sc.nextInt(); int []p=new int[n];
int m=sc.nextInt(); int []t=new int[m];
for(int i=0;i<m;i++)t[i]=sc.nextInt();
for(int i=0;i<m;i++){
	for(int j=0;j<n;j++){
		if(sc.nextInt()==t[i]){
			p[j]++;
		}else  p[t[i]-1]++;
	}
}
for(int i=0;i<n;i++)System.out.println(p[i]);
    }
}

Measured memory_bytes: 38020
#include<bits/stdc++.h>
using namespace std;
const int mx=123456;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n,s[mx],sum;
int main(){
    for(int i=0;i<3;i++){
        cin>>s[i];
    }
    sort(s,s+3);
    sum+=s[2]-s[0];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A[3];
    REP(i,3){
        cin >> A[i];
        cout << char(A[i][0]-32);
    }
    cout << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<ll, int> P;



int main(){
	ll n;
	int d[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			d[i][j] = 0;
		}
	}

	cin >> n;
	for(int i=1;i<=n;i++){
		string s = to_string(i);
		int top = s[0]-'0';
		int end = i%10;
		d[top][end]++;
	}

	ll ans = 0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ans += d[i][j]*d[j][i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_a() {
	ll n, m;
	ll x, y;
	//ll a, b, d;
	ll c;
	//char c;
	ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> s;

	ll d;
	rep(i, s.size()) {
		d = s[i] - '0';
		l_ans = (l_ans + d) % 9;
	}

	if (l_ans == 0) {
		s_ans = "Yes";
	}
	else {
		s_ans = "No";
	}


	cout << s_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}


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

const int MAX = 100000;
int main() {
	int N;
	cin >> N;
	int a[MAX];
	for (int i = 0;i < N;i ++) cin >> a[i];
	bool b[MAX]; // b[i]は既にi+1番目のボタンを押したか否か
	for (int i = 0;i < N;i ++) b[i] = false;
	int check = 0, ans = 0;
	while (!b[check]) { // 同じボタンに二度辿り着いた時点でループしてるから無限トレーニング
		if (check == 1) { // もしボタン2なら
			cout << ans;
			return 0;
		}
		b[check] = true; // ボタンを押した
		ans ++;
		check = a[check] - 1; // 次のボタンへgo!
	}
	cout << -1;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

ボタン1から次々押していってボタン2に辿り着ければ、その回数を出力すれば良い
では、辿り着かないときはどういう時か？
それは、同じボタンに戻ってきたとき
よって、一度押したボタンに戻ってきたら-1を出力すれば良いね
O(N)
*/

Measured memory_bytes: 768
MAX = 1000000007

def solve():
    N, M = [int(_) for _ in raw_input().split()]
    a = [None] * M
    for i in range(M):
        a[i] = int(raw_input())
    ok = [1] * (N+1)
    for i in range(M):
        ok[a[i]] = 0
    ret = [1] * (N+1)
    ret[N-1] = ok[N-1]
    for i in range (N-2,-1,-1):
        ret[i] = (ret[i+1] * ok[i+1] + ret[i+2] * ok[i+2]) % MAX
    print ret[0]

if __name__ == '__main__':
    solve()


Measured memory_bytes: 36764
#include <stdio.h>
 
int main(void)
{
  char b;
  
  scanf("%c", &b);
  
  if(b=='A'){
    printf("T");
  }else if(b=='T'){
    printf("A");
  }else if(b=='C'){
    printf("G");
  }else if(b=='G'){
    printf("C");
  }
    
  return 0;
  }

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
PI a[200200];
li res[200200];

int main() {
    cin >> n;
    rin{
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a, a + n);
    rep(i, n - 1) {
        res[a[i].S] = a[n - 1].F;
    }
    res[a[n - 1].S] = a[n - 2].F;

    rin{
        cout << res[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 6272
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int a = scan.nextInt();
     int b = scan.nextInt();
     int c = scan.nextInt();
     int x = 0;
     int y = 0;
     int z = 0;
     
     
     if( a == b){
         x = a;
         y = b;
         z = c;
         if(b >c){
             x = c;
             y = a;
             z = b;
         }
     }else if(b == c){
         x = a;
         y = b;
         z = c;
         if(a>b){
             x =b;
             y =c;
             z =a;
         }
     }else if(a == c){
         x = a;
         y = c;
         z = b;
         if(a>b){
             x =b;
             y =c;
             z =a;
         }
     }else if( a > b ) {
        x = b;
        y = a;
        z = c;
        if(a>c){
            x = b;
            y = c;
            z = a;
            if(b>c){
                x = c;
                y = b;
                z = a;
            }else if(a>b){
                    x = c;
                    y = a;
                    z = b;
                    if(a>b){
                        x = b;
                        y = c;
                        z = a;
                    }
            }
        }
     }else{
        x = a;
        y = b;
        z = c;
        if(b >c){
            x = a;
            y = c;
            z = b;
            if(a>c){
                x = c;
                y = a;
                z = b;
            }else if(b>a){
                x=c;
                y=b;
                z = a;
            }
        }
     }
     System.out.println(x+" "+ y +" "+z);
    }
}


Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
 
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}
//ll lcm(ll x, ll y) { return x/ll gcd(ll x, ll y)*y }

int main(){
  ll x ;
  cin >> x ;
  vector<ll> A(x);
  rep(i,x) cin >> A.at(i) ;
  sort(A.begin(),A.end());
  ll B = gcd (A.at(x-1),A.at(x-2));
  //rep(i,x) cout << A.at(i) ;
  for( int i = x-3 ; i >=0 ; i-- ){
    if(B >= A.at(i)) B = gcd(B,A.at(i)) ;
    else B = gcd(A.at(i),B) ;
  }
  cout << B << endl;
}

Measured memory_bytes: 1024