akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int dp[2005][2005];
int sum[2005][2005];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int s[n+1],t[m+1];
   rep(i,1,n+1)cin>>s[i];
   rep(i,1,m+1)cin>>t[i];
   dp[0][0]=1;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=m;j++)
       {
           if(s[i]==t[j])
           {
               (dp[i][j]=sum[i-1][j-1]+1)%=M;
           }
           (sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j] + M)%=M;

       }
   }
   int ans=0;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=m;j++)
        {ans+=dp[i][j];ans%=M;}
   }
   ans++;
   cout<<((ans+M)%M)<<endl;
}



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

int main(){
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	if((a*100+b*10+c)%4==0)
		cout << "YES\n";
	else
		cout << "NO\n";


	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	c := []rune(Scanner())
	fmt.Println(string(c[0] + 1))
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n; scanf("%d",&n);
   double res=pow(n/3.0,3); printf("%.12f\n",res);
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int count;
		int sum;

		sum = 0;
		while (sc.hasNext()) {
			count = 0;
			String str = sc.next();
			for (int i = 0; i < str.length(); i++) {
				if ('0' <= str.charAt(i) && str.charAt(i) <= '9') {
					count *= 10;
					count += str.charAt(i) - '0';
				} else {
					sum += count;
					count = 0;
				}
			}
			sum += count;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 12000
from collections import *

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

S = [0] * (N+1)

for i in range(N):
    S[i+1] = (S[i] + A[i]) % M

c = Counter()

ans = 0

for i in range(N+1):
    ans += c[S[i]]
    c[S[i]] += 1

print(ans)

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

int main() {
  int n,m,l;
  cin>>n>>m>>l;
  vector<vector<int > > A(n,vector<int>(m));
  vector<vector<int > > B(m,vector<int>(l));
  vector<vector<int64_t > > C(n,vector<int64_t>(l));
  
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>A.at(i).at(j);}}
  
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>B.at(i).at(j);}}
  
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
       C.at(i).at(j)+=A.at(i).at(k)*B.at(k).at(j);}}}
  
 // cout<<C.at(1).at(2)<<endl;
  
   for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      cout<<C.at(i).at(j);
      if(j<l-1){cout<<" ";}
       else{cout<<endl;}
    }}
  return 0;
}


Measured memory_bytes: 3288
X,Y,A,B,C = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),key=lambda x:-x)
q = sorted(list(map(int,input().split())),key=lambda x:-x)
r = sorted(list(map(int,input().split())),key=lambda x:-x)

pq = sorted(p[:X] + q[:Y])
# print(pq,r)
for i in range(min(X+Y,C)):
  if r[i] < pq[i]:
    break
else:
  i+=1
print(sum(r[:i] + pq[i:]))


Measured memory_bytes: 122084
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define maxn 1010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
const char mat4[4][5]={"aacd","bbcd","cdaa","cdbb"};
const char mat5[5][6]={"aabba","bcc.a","b..cb","a..cb","abbaa"};
const char mat6[6][7]={"aabcc.","b.b..c","baa..c","cc.aab","..cb.b","..cbaa"};
const char mat7[7][8]={"aa.bb.a",".cc..ca","b.dd.c.","b...d.b",".c..d.b","ac..cc.","a.bb.aa"};
char mat[maxn][maxn];
int n;
int main()
{
	n=read();
	if(n<=2){
		puts("-1"); return 0;
	}
	if(n==3){
		puts("aab\nb.b\nbaa");
		return 0;
	}
	memset(mat,'.',sizeof(mat));
	for(int i=0;i<=n-8;i+=4){
		for(int j=0;j<4;j++)
			for(int k=0;k<4;k++)
				mat[i+j][i+k]=mat4[j][k];
	}
	switch(n%4)
	{
		case 0:{
			for(int i=0;i<4;i++)
				for(int j=0;j<4;j++)
					mat[n-4+i][n-4+j]=mat4[i][j];
			break;
		}
		case 1:{
			for(int i=0;i<5;i++)
				for(int j=0;j<5;j++)
					mat[n-5+i][n-5+j]=mat5[i][j];
			break;
		}
		case 2:{
			for(int i=0;i<6;i++)
				for(int j=0;j<6;j++)
					mat[n-6+i][n-6+j]=mat6[i][j];
			break;
		}
		case 3:{
			for(int i=0;i<7;i++)
				for(int j=0;j<7;j++)
					mat[n-7+i][n-7+j]=mat7[i][j];
			break;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			putchar(mat[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 2176
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

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

fn print_answer(table: Vec<Vec<usize>>) {
  let n = table.len();
  let mut num_map = vec![-1; 4*n+10];
  let mut num_index = 1;

  println!("{}", n);
  for i in 0..n {
      for j in 0..n {
          if j >= 1 {
              print!(" ");
          }
          if num_map[table[i][j]] == -1 {
            num_map[table[i][j]] = num_index;
            num_index += 1;
          }
          print!("{}", num_map[table[i][j]]);
      }
      println!("");
  }
}

fn main() {
  input! {
    w: usize
  };

  if w <= 8 {
    let mut ans = vec![vec![0; w]; w];
    for i in 0..w {
      for j in 0..w {
        ans[i][j] = j;
      }
    }
    print_answer(ans);
    return
  }

  let n = (w+1) / 2;
  let n = if n % 2 == 1 { n + 1 } else { n };
  let mut ans = vec![vec![0; n]; n];
  for i in 0..n {
    for j in 0..n {
      let offset = (i/2)*2;
      ans[i][j] = (i%2)*n+(offset+j)%n;
      if w < 2*n && ans[i][j] == n*2-1 {
        ans[i][j] = ans[i-1][(j+1)%n]; 
      }
      if w < 2*n-1 && ans[i][j] == n*2-3 {
        ans[i][j] = ans[i-1][(j+1)%n];
      }
      if w < 2*n-2 && ans[i][j] == n*2-5 {
        ans[i][j] = ans[i-1][(j+1)%n];
      }
    }
  }

  print_answer(ans);
}


Measured memory_bytes: 7292
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 1000000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */

int n,q,com;
vector<int> parent(MAX);
vector<int> weight(MAX, 0);
vector<int> Rank(MAX, 0);

int root(int x){
    if(x == parent[x]) {
        return x;
    }
    else {
        int r = root(parent[x]);
        weight[x] += weight[parent[x]];
        return parent[x] = r;
    }
}

int calc_weight(int v) {
    root(v);
    return weight[v];
}

bool isSame(int x, int y) {
    return root(x) == root(y);
}

// weight(y) - weight(x) = z
bool relate(int x,int y, int z){

    // x, yについてrootと重み差分を補正
    //cout << "z : " << z << '\n';
    int w_x = calc_weight(x);
    int w_y = calc_weight(y);
    z += calc_weight(x);
    z -= calc_weight(y);
    //cout << "w_x : " << w_x << '\n';
    //cout << "w_y : " << w_y << '\n';
    //cout << "z : " << z << '\n';

    x = root(x); y = root(y);
    if (x == y) {
        return false;
    }
    // rank[x] >= rank[y] となるようにx, yをswap
    if (Rank[x] < Rank[y]) {
        swap(x, y);
        z = -z;
    }
    // y(root(y)) を x(root(x))の下にくっつける
    if (Rank[x] == Rank[y]) {
        Rank[x]++;
    }

    parent[y] = x;
    // xがyの親になるので, x yの差分をweight[y]に記録
    weight[y] = z;

    return true;

}

int diff(int x, int y) {
    return calc_weight(y) - calc_weight(x);
}

/* main */
int main(){

	scanf("%d %d",&n,&q);

	for(int i = 0; i < n; i++){
        parent[i] = i;
	}

    //cout << '\n';

    int x, y;
	for(int i = 0; i < q; i++){
		scanf("%d %d %d",&com,&x,&y);

		if(com == 1){
            if (!isSame(x, y)) {
                cout << '?' << '\n';
            }
            else {
                cout << diff(x, y) << '\n';
            }
        }
        else{
            int z; cin >> z;
            relate(x, y, z);
		}

    /*
        cout << "weight : ";
        for (int i = 0; i < n; i++) {
            int w = weight[i];
            cout << ' ' << w ;
        } cout << '\n';
        cout << "parent : ";
        for (int i = 0; i < n; i++) {
            int p = parent[i];
            cout << ' ' << p ;
        } cout << '\n';
        */


	}

	return 0;
}



Measured memory_bytes: 14280
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
  int a[4];
  int b[4];
  int i, j;

  while (cin >> a[0]) {
    for (i = 1; i < 4; i++) {
      cin >> a[i];
    }
    for (i = 0; i < 4; i++) {
      cin >> b[i];
    }         
    int hit = 0, blow = 0;
    for (i = 0; i < 4; i++) {
      for (j = 0; j < 4; j++) {
        if (i == j && a[i] == b[j]) {
          hit++;
        } else if (a[i] == b[j]) {
          blow++;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
//k_tourist
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll  i, j,n, a[mx];
	cin>>n;
	string s;
    cin>>s;

    ll cn=0;
    rep(i, 0, n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        cn++;
    }
	
    cout<<cn;
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e5+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};


void solve() {
	int n;
	cin>>n;
	vector<vi > v(n+1,vi (n,0));   


	rep(i,1,n+1){
		rep(j,1,n)
			cin>>v[i][j];
	}

	vi p(n+1,1);
	int cnt=0;

	while(1) {

        int f=0;
		vi vis(n+1,0);

		rep(i,1,n+1){

			if(vis[i]==0 && p[i]<n){		 

				int sval=v[i][p[i]];

				if(p[sval]<n &&	i==v[sval][p[sval]] && vis[sval]==0){

					if(f==0){
					 p[i]++;
					 p[sval]++;
					 vis[i]=1;
					 vis[sval]=1;
					 cnt++;
					 f=1;
				  }

				else{
					p[i]++;
					p[sval]++;
					vis[i]=1;
					vis[sval]=1;

				}
		 	  }
			}
		} 

			if(f==0) {
				break;
			}
		
	}
 
	int tc=0;
	rep(i,1,n+1){

		if(p[i]!=n)
		  tc=1;	
	}

	if(tc)
		cout<<-1<<endl;
	else
	  cout<<cnt<<endl;

}

int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	  
}



Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

char c;

int main(){
	while(cin>>c){
		if(c<'D')cout<<(char)(c+23);
		else cout<<(char)(c-3);
	}
	cout<<endl;
}

Measured memory_bytes: 0
import numpy as np
import itertools
n, d = map(int, input().split())
arr = np.zeros((n, d))
ans = 0
for i in range(n):
  arr[i] = np.array(input().split())
for i in list(itertools.combinations(arr, 2)):
  u = i[0] - i[1]
  d = str(np.linalg.norm(u))
  if d[-1]=='0':
    ans += 1
print(ans)

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    vector<string> name;
    vector<int> T;
    map<string, int> M;
    cin >> n;
    name.resize(n);
    T.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> name[i] >> T[i];
        M[name[i]] = i;
    }
    string str;
    cin >> str;
    int s = M[str];
    int ans = 0;
    for (int i = s + 1; i < n; i++) {
        ans += T[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, a[105], asum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        asum += a[i];
    }
    
    int min = 1e6, minnum;
    for (int i = 0; i < n; i++) {
        if (min > abs(asum - n * a[i])) {
            min = abs(asum - n * a[i]);
            minnum = i;
        }
    }
    
    cout << minnum << endl;
    
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];

int main() {
	megaRandom();
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) 
		scanf("%d", &a[i]);
	int last = -1, type = -1; // 0 decreasing, 1 increasing
	int cnt = 0;
	for(int i = 1; i <= n; i ++) {
		if(last == -1) {
			cnt ++;
			last = a[i];
		} else {
			if(type == -1) {
				if(last > a[i]) type = 0;
				if(last < a[i]) type = 1;
			} else {
				if(type == 0 && last < a[i]) {
					last = type = -1;
					i = i - 1;
					continue;
			 	}
			 	if(type == 1 && last > a[i]) {
			 		last = type = -1;
			 		i = i - 1;
			 		continue;
			 	}
			}
			last = a[i];
		}
	}
	printf("%d", cnt);
	return 0;         
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <array>

using namespace std;

#define forange(counter, end) forstep(counter, 0, end)
#define forstep(counter, begin, end) forstep_type(size_t, counter, begin, end)
#define forange_type(type, counter, end) forstep_type(type, counter, 0, end)
#define forstep_type(type, counter, begin, end) for (type counter = begin, forstep_type_end_##counter = end; counter < forstep_type_end_##counter; counter++)

const int D = 365;
const int C = 26;

array<int, C> contest;
array<array<int, C>, D> satisfaction;

int decr(const int c, const int last, const int now) {
	return contest[c] * (now - last);
}

int getScore(const array<int, C>& last, const int open, const int day) {

	int score = 0;

	forange(c, C)
	{
		if (c == open)
		{
			score += satisfaction[day][c];
		}
		else
		{
			score -= decr(c, last[c], day);
		}
	}

	return score;
}

int getScore(const array<int, D>& cont) {

	int score = 0;
	array<int, C> last;
	last.fill(-1);

	forange(d, D)
	{
		score += getScore(last, cont[d], d);
		last[cont[d]] = d;
	}

	return 1000000 + score;
}

struct Data {
	array<int, C> last;
	array<int, D> c;
	int score = 0;

	bool operator<(const Data& o) const {
		return score < o.score;
	}
};

array<int, D> think() {

	priority_queue<Data> qData;
	{
		Data first;
		first.last.fill(-1);

		qData.push(first);
	}

	const int BeamWidth = 200;

	forange(d, D)
	{
		decltype(qData) next;
		forange(w, BeamWidth)
		{
			if (qData.empty()) break;

			const auto top = qData.top();
			qData.pop();

			forange(c, C)
			{
				Data nextData = top;
				const int score = getScore(nextData.last, c, d);

				nextData.last[c] = d;
				nextData.c[d] = c;
				nextData.score += score;

				next.push(nextData);
			}

		}

		qData.swap(next);
	}

	const auto& top = qData.top();

	cerr << "score:" << getScore(top.c) << endl;

	return top.c;
}

int main() {

	int d;
	cin >> d;

	for (auto& c : contest)
	{
		cin >> c;
	}

	forange(d, D)
	{
		forange(s, C)
		{
			cin >> satisfaction[d][s];
		}
	}

	const auto ans = think();

	for (const auto& a : ans)
	{
		cout << (a + 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 31888
#include <bits/stdc++.h>
using namespace std;
long long n, a, b, f[200005], mod=1000000007;
long long umn(long long l, long long r){
	if(l>r) return 1;
	long long soll=l;
	for (int i=l+1; i<=r; i++){
		soll*=i; soll%=mod;
	}
	return soll;
}
long long fp(long long a, long long b){
	long long soll=1;
	while (b){
		if (b&1) soll*=a; soll%=mod; 
		a*=a; a%=mod; b>>=1;
	}
	return soll;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> a >> b; 
cout << ((fp(2, n) - umn(n-a+1, n)*fp(umn(1, a), mod-2) - umn(n-b+1, n)*fp(umn(1, b), mod-2) - 1)%mod+mod)%mod;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {  
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int a, b;
    int maxa = 0;
    int maxab = 0;
    REP(i, n){
        cin >> a >> b;
        if(maxa < a){
            maxa = a;
            maxab = b;
        }
    }
    cout << maxab + maxa << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>

using namespace std;

void swap(unsigned long long &a, unsigned long long &b)
{
    unsigned long long t = a;
    a = b;
    b = t;
}
int main()
{
    unsigned long long N,K;
    unsigned long long x;

    cin >> N >> K;

    unsigned long long min = N;
    x = N;

    unsigned long long sa = (x < K) ? (K - x) : (x - K);
    
    unsigned long long wari = N / K;
    
    min = N - (wari * K);

    sa = (min < K) ? (K - min) : (min - K);
    if (sa < min) {
        min = sa;
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    repi(i, N, 0)
    {
        cin >> A[i];
    }
    int num = 1;
    int cnt = 0;
    repi(i, N, 0)
    {
        num = A.at(num-1);
        cnt++;
        if (num == 2)
        {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin >> N >> L;
  vector<string> v(N);
  for(int i=0;i<N;i++){
   cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  for(s:v){
    cout << s;
  }
  cout << endl;
}

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;
my($n,$m)=split/ /,<>;
my@a=<>;
@a=(-1,@a,$n+1);
my@f=(0,1);
my$mod=1e9+7;
my$ans=1;
for(my$i=1;$i<=$m+1;$i++){
 my$l=$a[$i]-$a[$i-1]-1;
 for(my$j=@f;$j<$l+1;$j++){
  push@f,($f[$j-2]+$f[$j-1])%$mod;
 }
 $ans*=$f[$l];
 $ans%=$mod;
}
print$ans;


Measured memory_bytes: 20352
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
	class Book {
	public:
		long cost;
		long score[12];
	};
	long ans = -1;
	long n, m, x;
	Book books[12];

	// input
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> books[i].cost;
		for (int j = 0; j < m; j++) {
			cin >> books[i].score[j];
		}
	}

	// calc 本の組み合わせパターンをビット表現
	long ptn_max = 0;
	for (int i = 0; i < n; i++) {
		ptn_max |= (1 << i);
	}
	for (long ptn = 1; ptn <= ptn_max; ptn++) {
		long understand[12] = { 0 };	// 理解度
		long total = 0;					// 合計価格
		bool understand_ng = false;		// 目標未達
		for (int i = 0; i < n; i++) {
			if ( 0 != ( ptn & (1 << i) ) ) {
				total += books[i].cost;
				for (int j = 0; j < m; j++) {
					understand[j] += books[i].score[j];
				}
			}
		}
		for (int i = 0; i < m; i++) {
			if (understand[i] < x) {
				understand_ng = true;
				break;
			}
		}
		if (!understand_ng) {
			if (-1 != ans) {
				if (ans > total) {
					ans = total;
				}
			} else {
				ans = total;
			}
		}
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


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

int main() {
  int n, m, i, r = 0;
  cin >> n >> m;
  set<int> s[n];
  for (i = 0; i < n; i++){
    int k;
    cin >> k;
    for (int j = 0; j < k; j++){
      int a;
      cin >> a;
      s[i].insert(a);
    }
  }
  for(int j = 1; j <= m; j++){
    bool b = 1;
    for(i = 0; i < n; i++){
      if(s[i].count(j)){}
      else{
        b = 0;
        break;
      }
    }
    if(b)
      r++;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

int n, h, mx;
int a[1100], b[1100];
int dp[N];

void solve()
{
	cin >> h >> n;
	REP(i, n) {
		cin >> a[i] >> b[i];
		mx = max(mx, a[i]);
	}

	RREP(i, h + mx) {
		dp[i] = INF;
		REP(j, n) {			
			int k = i - a[j];
			if (k < 0) {
				dp[i] = min(dp[i], b[j]);
			}
			else {
				dp[i] = min(dp[i], dp[k] + b[j]);
			}
		}
	}
	int ans = INF;
	for (int i = h; i < h + mx; i++) ans = min(ans, dp[i]);
	cout << ans << endl;
}

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


Measured memory_bytes: 3708
#include <cstdio>

using namespace std;

const int mod = 1000000007;
char s[3000];

int dp[3000][3000];

int main() {
    int n, i, j;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n; i++) dp[0][i] = 1;
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] == '<') {
            int sum = 0;
            
            for (j = 0; j < n - i - 1; j++) {
                sum += dp[i][j];
                if (sum >= mod) sum -= mod;
                
                dp[i + 1][j] = sum;
            }
        } else {
            int sum = dp[i][n - i - 1];
            
            for (j = n - i - 2; j >= 0; j--) {
                dp[i + 1][j] = sum;
                
                sum += dp[i][j];
                if (sum >= mod) sum -= mod;
            }
        }
    }
    
    printf("%d\n", dp[n - 1][0]);
    
    return 0;
}


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

int main() {
  int h, w, s;
  cin >> h >> w >> s;
  vector<vector<char>> a(h, vector<char>(w));

  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      cin >> a[i][j];
    }
  }

  vector<vector<int>> ans(h, vector<int>(w));
  int num = 1;
  for(int i=0;i<h;i++) {
    vector<int> b;
    bool empty = true;
    b.emplace_back(-1);
    for(int j=0;j<w;j++) {
      if(a[i][j] == '#') {
        b.emplace_back(j);
        empty = false;
      }
    }
    b.pop_back();
    b.emplace_back(w-1);
    if(empty) {
      continue;
    }
    for(int j=0;j<b.size()-1;j++) {
      for(int k=b[j]+1;k<=b[j+1];k++) {
        ans[i][k] = num;
      }
      num++;
    }
  }

  for(int i=1;i<h;i++) {
    for(int j=0;j<w;j++) {
      if(ans[i][j] == 0) ans[i][j] = ans[i-1][j];
    }
  }

  for(int i=h-2;i>=0;i--) {
    for(int j=0;j<w;j++) {
      if(ans[i][j] == 0) ans[i][j] = ans[i+1][j];
    }
  }

  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
      cout << ans[i][j] << " "; 
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 1000000100;


ll H, W, A[80][80], B[80][80];
bool dp[80][80][26000];
ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

/*ll sum_bit(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add_bit(ll i, ll x)
{
	while (i <= 2 * N + 10)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

void init()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> B[i][j];
		}
	}
	ans = INF;
}

void output()
{
	cout << ans << endl;
}



void solve()
{
	dp[0][0][160 * 80 + A[0][0] - B[0][0]] = true;
	dp[0][0][160 * 80 + B[0][0] - A[0][0]] = true;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			for (int k = 1; k < 25900; k++)
			{
				ll add = abs(A[i][j] - B[i][j]);
				if (i > 0)
				{
					if (k >= add && dp[i - 1][j][k - add])
					{
						dp[i][j][k] = true;
					}
					if (k <= 25900 - add && dp[i - 1][j][k + add])
					{
						dp[i][j][k] = true;
					}
				}
				if (j > 0)
				{
					if (k >= add && dp[i][j - 1][k - add])
					{
						dp[i][j][k] = true;
					}
					if (k <= 25900 - add && dp[i][j - 1][k + add])
					{
						dp[i][j][k] = true;
					}
				}
			}
		}
	}
	for (int i = 0; i < 25900; i++)
	{
		if (dp[H - 1][W - 1][i])
		{
			ans = min(ans, (ll)abs(80 * 160 - i));
		}
	}
}

int main()
{
	init();

	solve();

	

	output();

	cin >> H;
}

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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

vector<vector<bool>> solve(vector<bool> x, vector<bool> y){
    if(x.size()==1){
        vector<vector<bool>> ans={x,y};
        return ans;
    }
    
    int pos=-1;
    for(int i=0; pos==-1; i++){
        if(x[i]!=y[i]) pos=i;
    }
    
    vector<bool> xd,yd;
    for(int i=0; i<x.size(); i++){
        if(i!=pos){
            xd.push_back(x[i]);
            yd.push_back(y[i]);
        }
    }
    vector<bool> c=xd;
    c[0]=!xd[0];
    auto ans1=solve(xd,c);
    auto ans2=solve(c,yd);
    
    vector<vector<bool>> ans(2*ans1.size());
    
    for(int i=0; i<ans1.size(); i++){
        for(int j=0; j<pos; j++){
            ans[i].push_back(ans1[i][j]);
        }
        ans[i].push_back(x[pos]);
        for(int j=pos; j<ans1[0].size(); j++){
            ans[i].push_back(ans1[i][j]);
        }
    }
    
    for(int i=0; i<ans1.size(); i++){
        for(int j=0; j<pos; j++){
            ans[i+ans1.size()].push_back(ans2[i][j]);
        }
        ans[i+ans1.size()].push_back(y[pos]);
        for(int j=pos; j<ans1[0].size(); j++){
            ans[i+ans1.size()].push_back(ans2[i][j]);
        }
    }
    
    return ans;
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,a,b;
    
    cin>>n>>a>>b;
    
    if(__builtin_popcount(a)%2==__builtin_popcount(b)%2){
        cout<<"NO";
        return 0;
    }
    
    vector<bool> x(n),y(n);
    for(int i=0; i<n; i++){
        x[i]=a&(1<<i);
        y[i]=b&(1<<i);
    }
    
    cout<<"YES\n";
    auto ans=solve(x,y);
    for(int i=0; i<ans.size(); i++){
        int val=0;
        for(int j=0; j<n; j++){
            val+=ans[i][j]*(1<<j);
        }
        cout<<val<<' ';
    }
    
    
}

Measured memory_bytes: 20192
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += b[i] - a[i];
        }

        long cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] < b[i]) {
                cnt += (b[i] - a[i] + 1) / 2;
            }
        }
        if (cnt <= sum) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 43996
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
lli solve(){
    lli n, cap;
    cin>>n>>cap;
    vll w(n), v(n);
    loop(i, 0, n)
        cin>>w[i]>>v[i];
    const lli N = 100005;
    vector<vll> dp(n+1, vll(N, 1e16));
    loop(i, 0, n+1)
        dp[i][0] = 0;
    loop(i, 1, n+1){
        loop(j, 1, N){
            if(j >= v[i-1]){
                lli pw = j - v[i-1];
                dp[i][j] = min(dp[i-1][j], dp[i-1][pw] + w[i-1]);
                if(dp[i][j] > cap)
                    dp[i][j] = min(dp[i-1][j], (long long)1e16);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    loopb(i, N-1, 0){
        if(dp[n][i] != 1e16){
            cout<<i<<"\n";
            return 0;
        }
    }
    cout<<0<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 83176
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
const int maxn=200000;
int a[maxn+5];
int b[maxn+5];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	
		for(int i=1;i<=n;i++){
			if(a[i]<=b[n/2]){
				printf("%d\n",b[n/2+1]); 
			}else{
				printf("%d\n",b[n/2]);
			}
		}
	
	return 0;
} 

Measured memory_bytes: 3712
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main()
{
    char a, b, c;
    cin >> a >> b >> c;
    
    int ans = (a - '0') + (b - '0') + (c - '0');
    cout << ans << endl;
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
s = list()
for i in range(D):
  s1 = list(map(int, input().split()))
  s.append(s1)
t = list()
for i in range(D):
  t.append(i%26)

def point(t, C, s):
  done = [0] * 26
  ans = 0
  for d in range(1, D+1):
    td = t[d-1]
    done[td] = d
    ans += s[d-1][td]
    for i in range(26):
      ans -= C[i]*(d-done[i])
  return ans

ans = 0
bettert = 0
for i in range(26):
  t[0] = i
  if(point(t, C, s) > ans):
    ans = point(t, C, s)
    bettert = i
    
print(bettert+1)
for i in range(1,D):
  print(t[i]+1)

Measured memory_bytes: 68260
#include <stdio.h>

int main()
{
    int r, c, i, j;
    int A[101][101] = {0};
    
    scanf("%d %d", &r, &c);
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d", &A[i][j]);
            A[i][c] += A[i][j];
            A[r][j] += A[i][j];
            A[r][c] += A[i][j];
        }
    }
    
    for(i=0; i<=r; i++){
        for(j=0; j<=c; j++){
            printf("%d", A[i][j]);
            if(j!=c) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
char in[1100000];
int to[1100000][27];
vector<int>g[1100000];
int segtree[1<<22];
int query(int a,int b,int c,int d,int e){
	if(d<a||b<c)return mod;
	if(c<=a&&b<=d)return segtree[e];
	return min(query(a,(a+b)/2,c,d,e*2),query((a+b)/2+1,b,c,d,e*2+1));
}
void update(int a,int b){
	a+=(1<<21);
	while(a){
		segtree[a]=min(segtree[a],b);
		a/=2;
	}
}
int rev[1100000];
int val[1100000];
int eu[2100000];
int fi[1100000];
int num;
int sz;
void dfs(int a){
	val[a]=num;
	rev[num++]=a;
	fi[a]=sz;
	eu[sz++]=val[a];
	for(int i=0;i<g[a].size();i++){
		dfs(g[a][i]);
		eu[sz++]=val[a];
	}
}
int h[1100000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int a;scanf("%d",&a);
	for(int i=0;i<27;i++)to[n][i]=-1;
		//printf("%d: %d %d %d\n",n,to[n][24],to[n][25],to[n][26]);
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<27;j++){
			if(in[i]>'a'+j){
				to[i][j]=-1;
				continue;
			}
			if(in[i]=='a'+j){
				to[i][j]=i+1;
			}else{
				if(to[i][j-1]!=-1&&to[to[i][j-1]][j-1]!=-1)to[i][j]=to[to[i][j-1]][j-1];
				//else if(to[i][26]!=-1)to[i][j]=to[to[i][26]][j];
				else to[i][j]=-1;
			}
		}
		for(int j=0;j<26;j++){
			if(to[i][j]==-1&&to[i][26]!=-1)to[i][j]=to[to[i][26]][j];
		}
		//printf("%d: %d %d %d\n",i,to[i][24],to[i][25],to[i][26]);
		if(~to[i][26]){
			h[i]=1;
			g[to[i][26]].push_back(i);
		}
	}
	for(int i=0;i<(1<<22);i++)segtree[i]=mod;
	for(int i=0;i<=n;i++){
		if(h[i]==0)g[n+1].push_back(i);
	}
 
	dfs(n+1);
	for(int i=0;i<sz;i++)update(i,eu[i]);
 
	while(a--){
		int p,q;scanf("%d%d",&p,&q);
		p--;
		int at=rev[query(0,(1<<21)-1,min(fi[p],fi[q]),max(fi[p],fi[q]),1)];
		//printf("%d %d: %d\n",p,q,at);
		if(at==p||at==q){
			printf("Yes\n");
		}else printf("No\n");
	}
}

Measured memory_bytes: 146688
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, long long M, vector<long long> a, vector<long long> b) {
  vi ans(N + 1, 0);

  REP(i, M) {
    ans[a[i]]++;
    ans[b[i]]++;
  }

  REP(i, N) { cout << ans[i + 1] << endl; }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  cin >> M;
  vector<long long> b(M - 1 + 1);
  vector<long long> a(M - 1 + 1);
  for (int i = 0; i <= M - 1; i++) {
    cin >> a[i];
    cin >> b[i];
  }
  solve(N, M, a, b);
  return 0;
}


Measured memory_bytes: 256
def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))


N, M = input_multiple_number()

listA = input_multiple_number_as_list()

hw = 0

for a in listA:
	hw += a

if hw > N:
	print(-1)
else:
	print(N-hw)


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> b(n-1);
    for(int i = 0; i < n-1; ++i){
        cin >> b[i];
    }
    
    vector<int> a(n);
    
    a[0] = b[0], a[n-1] = b[n-2];
    for(int i = 1; i <= n-2; ++i){
        a[i] = min(b[i-1], b[i]);
    }
    
    cout << accumulate(a.begin(), a.end(), 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	if(a<10 and b<10)
		cout << a*b << endl;
	else
		cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int math, eng, jap;

    while (scanf("%d", &n), n != 0) {
        for (int i = 0; i < n; i++) {
            char ch;
            
            scanf("%d %d %d", &math, &eng, &jap);

            if (math == 100 || eng == 100 || jap == 100) {
                ch = 'A';
            }
            else if (math + eng >= 180) {
                ch = 'A';
            }
            else if (math + eng + jap >= 240) {
                ch = 'A';
            }
            else if (math + eng + jap >= 210) {
                ch = 'B';
            }
            else if ((math + eng + jap >= 150) &&
                     (math >= 80 || eng >= 80)) {
                ch = 'B';
            }
            else {
                ch = 'C';
            }

            putchar(ch);
            putchar('\n');
        }
    }

    return 0;
}



Measured memory_bytes: 2140
n = int(input())
ans = [0]*n
c, s, f = [], [], []
for i in range(n - 1):
    ct, st, ft = list(map(int, input().split()))
    c.append(ct)
    s.append(st)
    f.append(ft)

for i in range(n - 1):
    time = 0
    for j in range(i, n - 1):
        if(s[j] < time):
            if(time % f[j] != 0):
                time += f[j] - time % f[j]
        else:
            time += s[j] - time
        time += c[j]
    ans[i] = time

for i in range(n):
    print(ans[i])


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

long long N, D;

int main(){
	cin >> N >> D;
	if(N%(2*D+1) == 0){
		cout << N/(2*D+1) << endl;
	} else {
		cout << N/(2*D+1) + 1<< endl;
	}


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 9999999999999999;

const long long MAX = 30000000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  long long X,Y;
  cin>>X>>Y;
  long long ans = 0;
  if((2*X-Y)%3 != 0){
    ans = 0;
    cout << 0 << endl;
    return 0;
  }
  else{
    COMinit();
    long long yy = (2*X-Y)/3;
    long long xx = (2*Y-X)/3;
    cout << COM((xx+yy),yy)%MOD << endl;
    return 0;
  }
}

Measured memory_bytes: 703360