akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=3000005;
const int mod=1000000007;

int ans,sum,s1,s2,s;
int x[10],y[10],fac[N],inv[N];

void add(int &x,int y){
	(y>=mod)?y-=mod:0;
	(y<0)?y+=mod:0;
	x+=y;
	(x>=mod)?x-=mod:0;
	(x<0)?x+=mod:0;
}

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s; 
}

void init(){
	int i;
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (i=2;i<=N-5;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-5]=quickpow(fac[N-5],mod-2);
	for (i=N-6;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int x,int y){
	if (x<y) return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int calc(int x1,int y1,int x2,int y2){
	int s=0,i,j;
	//for (i=x1;i<=x2;i++)
	//	for (j=y1;j<=y2;j++) add(s,C(i+j,j));
	s=(C(x2+1+y2+1,y2+1)+C(x1+y1,y1)-C(x1+y2+1,y2+1)-C(x2+1+y1,y1))%mod;
	(s<0)?s+=mod:0;
	return s;
}

int main(){
	int i;
	for (i=1;i<=6;i++) scanf("%d",&x[i]);
	for (i=1;i<=6;i++) scanf("%d",&y[i]);
	init();
	for (i=x[3];i<=x[4];i++){
		s1=calc(i-x[2],y[4]-y[2],i-x[1],y[4]-y[1]);
		s2=calc(x[5]-i,y[5]-y[4]-1,x[6]-i,y[6]-y[4]-1);
		s=1ll*s1*s2%mod;
		add(sum,s);
		add(ans,-1ll*s*(x[4]-i)%mod);
		s1=calc(i-x[2],y[3]-1-y[2],i-x[1],y[3]-y[1]-1);
		s2=calc(x[5]-i,y[5]-y[3],x[6]-i,y[6]-y[3]);
		s=1ll*s1*s2%mod; 
		//add(sum,s);
		add(ans,-1ll*s*(i-x[3])%mod);
	}
	for (i=y[3];i<=y[4];i++){
		s1=calc(x[3]-1-x[2],i-y[2],x[3]-1-x[1],i-y[1]);
		s2=calc(x[5]-x[3],y[5]-i,x[6]-x[3],y[6]-i);
		s=1ll*s1*s2%mod;
		//add(sum,s);
		add(ans,-1ll*s*(i-y[3])%mod);
		s1=calc(x[4]-x[2],i-y[2],x[4]-x[1],i-y[1]);
		s2=calc(x[5]-1-x[4],y[5]-i,x[6]-x[4]-1,y[6]-i);
		s=1ll*s1*s2%mod;
		add(sum,s);
		add(ans,-1ll*s*(y[4]-i)%mod);
	}
	add(ans,1ll*sum*(y[4]-y[3]+x[4]-x[3]+1)%mod);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		arr[i] += arr[i-1];
	}	
	ll mdf = 1000000000000000000;
	for(int i=1;i<n;i++)
	{
		ll p1 = arr[i], p2 = arr[n] - arr[i];
		ll df = abs(p1 - p2);
		mdf = min(mdf, df);
	}	
	cout<<mdf<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector< tuple< string,int,int > > d;
	for(int i=0;i<n;++i){
		string s;
		int a;
		cin >> s >> a;
		d.push_back(make_tuple(s,-a,i+1));
	}
	sort(d.begin(),d.end());
	for(auto x:d){
		cout << get<2>(x) << endl;
	}
}


Measured memory_bytes: 256
/**
 *   created: 07 September 2019  17:28:19
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


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

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
    optimizeIO();
    int tt=1;
    //cin>>tt;
    while(tt--){
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        int res = 0;
        rep(i,1,n){
            if(s[i]==s[i-1])
                res++;
        }
        cout<<min(n-1,res+k*2);
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<vector<int>> F(N,vector<int>(10,0));
	for (int i=0; i<N; i++)
		for (int j=0; j<10; j++)
			cin>>F[i][j];
	vector<vector<int>> P(N,vector<int>(11,0));
	for (int i=0; i<N; i++)
		for (int j=0; j<11; j++)
			cin>>P[i][j];
	int ans=INT_MIN;
	for (int bt=1; bt<(1<<10); bt++) {
		vector<int> ct(N,0);
		for (int i=0; i<10; i++)
			if(bt&(1<<i))
				for (int j=0; j<N; j++)
					ct[j]+=F[j][i];
		int ret=0;
		for (int i=0; i<N; i++)
			ret+=P[i][ct[i]];
		ans=max(ans,ret);
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main() {
  intmax_t a, b, x;
  scanf("%jd %jd %jd", &a, &b, &x);

  intmax_t res = b/x + 1;
  if (a > 0) res -= (a-1)/x + 1;
  printf("%jd\n", res);
}

Measured memory_bytes: 128
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x: i64 = sc.read();
    println!("{}", if x >= 30 { "Yes" } else { "No" });
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2120
import sys
input = sys.stdin.readline
N,W= map(int,input().split())
ans=[0 for e in range(W+1)] 
for i in range(N):
 w,v=map(int,input().split())
 for j in range(w,W+1)[::-1]:
  ans[j]=max(ans[j-w]+v,ans[j])
print(max(ans))

Measured memory_bytes: 44784
<?php
$times = [];
for ($i = 0; $i < 5; $i++) {
	$times[] = trim(fgets(STDIN));
}

$allOnePlaces = [];
$onesPlaces = [];
for ($i = 0; $i < 5; $i++) {
    $allOnePlaces[] = $times[$i] % 10;
  	if ($times[$i] % 10 === 0) {
    	continue;
    }
	$onesPlaces[] = $times[$i] % 10;
}
$minOnesPlaces = min($onesPlaces);

$minOnesPlacesTime = array_keys($allOnePlaces, $minOnesPlaces, true);

$result = 0;
for ($i = 0; $i < 5; $i++) {
    if ($i === $minOnesPlacesTime[0]) {
    	$result += $times[$i];
        continue;
    }
	$result += ceil($times[$i] / 10) * 10;
}

echo $result, PHP_EOL;

Measured memory_bytes: 4604
class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

import math

n = int(input())
seg = SegmentTree(n, math.gcd)

A = list(map(int,input().split()))
for i in range(n):
    seg.update(i, A[i])

ans = 1
for i in range(n):
    tmp = A[i]
    seg.update(i, A[i-1])
    ans = max(ans, seg.query(0,n))
    seg.update(i, tmp)
    
print(ans)

Measured memory_bytes: 86380
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int health = sc.nextInt();
		int attack = sc.nextInt();
		sc.close();
		if(health%attack == 0) {
			System.out.println(health/attack);
		}else {
		System.out.println(health/attack+1);
		}
	}
	}




Measured memory_bytes: 23764
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  string num;
  map<char,string> data;
  data['0'] = "* = ****";
  data['1'] = "* =* ***";
  data['2'] = "* =** **";
  data['3'] = "* =*** *";
  data['4'] = "* =**** ";
  data['5'] = " *= ****";
  data['6'] = " *=* ***";
  data['7'] = " *=** **";
  data['8'] = " *=*** *";
  data['9'] = " *=**** ";
  bool f=false;
  while(cin>>num){
    if(f){
      cout<<endl;
    }else{
      f = true;
    }
    while(num.size()!=5) num.insert(0,"0");
    vector<string> soroban;
    REP(i,num.size()){
      soroban.push_back(data[num[i]]);
    }
    REP(y,soroban[0].size()){
      REP(x,soroban.size()){
        cout<<soroban[x][y];
      }
      cout<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
s = gets.chomp
N = s.to_i
D = s.size
R=[3,5,7]

ans = (2 ... D).inject(0) do |t, n|
  s = []
  n.times{ s << R }
  t + R.product(*s).count{|values| values.uniq.size == 3 && values.inject(0){|s,v| s * 10 + v} <= N }
end
puts ans

Measured memory_bytes: 5628
#include<iostream>
#include<string>
using namespace std;
int main(){
string s,ss,tt[1000];
int i=0,j,l,m=0,n,cc[1000]={0};
while(cin>>s){
l=s.size();
if(m<l){m=l;ss=s;}
tt[i++]=s;
}
n=i;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)if(tt[i]==tt[j])cc[i]++;
for(m=0,i=0;i<n;i++){
if(m<cc[i]){m=cc[i];l=i;}
}
cout<<tt[l]<<" "<<ss<<endl;
return 0;
}

Measured memory_bytes: 1200
a, b, c, x, y = [int(i) for i in input().split()]

if a + b // 2 < c:
    c = a + b // 2

n = a * x + b * y
m = c * max(x, y) * 2

v = 0

if x > y:
    v = c * y * 2 + a * (x-y)
else:
    v = c * x * 2 + b * (y-x)

print(min(n, v, m))

Measured memory_bytes: 3064
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let A = read![i64; N];
    let win = A.into_iter().any(|a| a % 2 != 0);
    println!("{}", if win { "first" } else { "second" })
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

int main()
{
	int count = 0, allcount = 0, flag = 1;
	string S;
	cin >> S;

	if (S[0] == 'A') {
		for (int i = 2; i < S.size() - 1; ++i) {
			if (S[i] == 'C') ++count;
		}
		for (int i = 0; i < S.size(); ++i) {
			if (S[i] == 'C') ++allcount;
		}
		if (count == 1 && count == allcount) {
			flag = 0;
			for (int i = 1; i < S.size(); ++i) {
				
				if (S[i] == 'C' || (S[i] >= 97 && S[i] <= 122)) {

				}
				else {
					flag = 1;
				}
			}
		}
	}

	if (flag == 0) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(fst) (int)(fst).size()
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(fst) fst.begin(), fst.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s ;
    forn(i, sz(s)) cout << "x";
    cout << "\n";
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    vector<bool> good(n,true); 
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(h[a-1]==h[b-1]){
            good[a-1]=false;
            good[b-1]=false;
        }
        else if(h[a-1]>h[b-1]){
            good[b-1]=false;
        }
        else if(h[b-1]>h[a-1]){
            good[a-1]=false;
        }
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(good[i]==true) count++;
    }
    cout<<count<<endl;

}

Measured memory_bytes: 3708
import collections

N = int(input())
S = [input() for _ in range(N)]
S.sort()
#print(S)
ans = collections.Counter(S)
values, cnt = zip(*ans.most_common())
#print(values)
#print(cnt)
max_count = cnt[0]
for i in range(len(cnt)):
    if max_count > cnt[i]:
        break
    print(values[i])

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

ll dp[3001][3001];
int main(){
    string s,t;
    cin >> s;
    cin >> t;

    int m = s.length();
    int n = t.length();

    rep(i,m){
        rep(j,n){
            if(s[i] == t[j])
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);
        }
    }

    string ans = "";
    int i = (int)s.size(),j=(int)t.size();
    while(i>0 && j>0){
        
        if (dp[i][j] == dp[i-1][j]) 
            --i;
        
        else if(dp[i][j] == dp[i][j-1])
            --j;

        else {
            ans = s[i-1] + ans; 
            --i, --j;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 70656
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

n = ni()
ab = [tuple(li()) for _ in range(n)]

que = []
for ai, bi in ab:
    heappush(que, [-ai-bi, ai, bi])
    
cnt = 0
tak = 0
aok = 0
while que:
    sm, ai, bi = heappop(que)
    if cnt % 2 == 0:
        tak += ai
    else:
        aok += bi
        
    cnt += 1
        
print(tak-aok)

Measured memory_bytes: 29996
def f(a,b):
	if a==b:
		d=0
		ret = a
	elif a < b:
		d = b//a
		if b%a == 0:
			ret = a*(2*d -1)
		else:
			ret = 2*a*d + f(a,b%a)
	else:
		d = a//b
		if a%b == 0:
			ret = b*(2*d -1)
		else:
			ret = 2*b*d + f(a%b,b)
	#print(a,b,d,ret)
	return ret


N,X = map(int,input().split(" "))

print(N+f(N-X,X))

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int count=0;
  for(int i=0;i<1000;i++){
    int v[3]={i/100,(i/10)%10,i%10};
    int d=0;
    for(int j=0;j<n;j++){
      if(s[j]=='0'+v[d]){
        d++;
      }
      if(d==3){
        count++;
        break;
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int N, M;
bool graph[50][50];
bool visited[50];

void dfs(int v) {
    visited[v] = true;
    rep(i, N) {
        if (graph[v][i] == false) continue;
        if (visited[i] == true) continue;
        dfs(i);
    }
}


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    int a[M], b[M];
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }
    int ans = 0;
    rep(i, M) {
        graph[a[i]][b[i]] = false;
        graph[b[i]][a[i]] = false;
        rep(j, 50) visited[j] = false;
        dfs(0);
        bool bridge = false;
        rep(j, N) if(visited[j] == false) bridge = true;
        if (bridge) ans++;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int a, b; cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}

Measured memory_bytes: 3620
S = input()
l = len(S)
A = {'A', 'C', 'G', 'T'}
ans = 0
for i in range(l):
    for j in range(l):
        if i + j > l:
            continue
        flag = True
        for s in S[i:l-j]:
            if s not in A:
                flag = False
                break
        if flag:
            ans = max(ans, len(S[i:l-j]))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

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

mint dp[2010];
int main() {
  int n;
  cin >> n;
  dp[0] = 1;
  for(int i = 1;i<=n;i++){
    for(int j = 0;j<=i-3;j++){
      dp[i]+=dp[j];
    }
  }
  cout<<dp[n].x<<endl;
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int T,A;

int main(){
    scanf("%d%d", &T, &A);
    if(T<=5){
        printf("0");
    }else {
        printf("%d", T >= 13 ? A : A / 2);
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
L=list(S)
A=len(L)
S=[]
for i in range(A):
  if (ord(L[i])+N)>90:
    S.append(chr(ord(L[i])+N-26))
  else:
    S.append(chr(ord(L[i])+N))
    
print(''.join(S))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int X, Y, A, B, C;
int a[N], b[N], c[N];
ll sumA[N], sumB[N], sumC[N];
vector<int> vec;

void solve()
{
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    for (int i = 1; i <= A; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= B; ++i)
        scanf("%d", &b[i]);
    for (int i = 1; i <= C; ++i)
        scanf("%d", &c[i]);
    sort(a + 1, a + A + 1, greater<int>());
    sort(b + 1, b + B + 1, greater<int>());
    sort(c + 1, c + C + 1, greater<int>());
    for (int i = 1; i <= X; ++i)
        vec.push_back(a[i]);
    for (int i = 1; i <= Y; ++i)
        vec.push_back(b[i]);
    int sz = vec.size();
    int now = 1;
    while (sz < X + Y)
    {
        vec.push_back(c[now]);
        now++;
        sz = vec.size();
    }
    ll ans = accumulate(vec.begin(), vec.end(), 0LL);
    sort(vec.begin(), vec.end());
    for (int i = now, j = 0; i <= C, j < vec.size(); ++i, ++j)
    {
        if (c[i] > vec[j])
        {
            ans -= vec[j];
            ans += c[i];
        }
    }
    cout << ans << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 7544
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

	int n;
	cin >> n;

	int extra = -1;

	if(n&1) {
		cout << 0;
		return 0;
	}

	n /= 2;

	int fives = 0;
	int temp = 5;

	while(n/temp > 0) {
		fives += n/temp;
		temp *= 5;
	}

	cout << fives;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 2e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

vector<int> P;
vector<int> tot;

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>k>>q;

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

    vector<int> val;

    for(int i=1;i<=n;i++)
        val.push_back(A[i]);

    sort(val.begin(),val.end());

    val.erase(unique(val.begin(),val.end()),val.end());

    for(int i=0;i<val.size();i++){

        cur = val[i];
        tot.clear();
        P.clear();

        for(int i=1;i<=n;i++){
            if(A[i]>=cur)P.push_back(A[i]);
            else {
                sort(P.begin(),P.end());

                m = P.size();

                for(int i=0;i<m-k+1;i++)
                    tot.push_back(P[i]);
                P.clear();
            }
        }
        sort(P.begin(),P.end());
        m = P.size();
        for(int i=0;i<m-k+1;i++)
            tot.push_back(P[i]);

        sort(tot.begin(),tot.end());

        if((int)tot.size()<q)break;

        mn = min(mn,tot[q-1]-cur);
    }

    cout<<mn<<"\n";

    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long  ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[9] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const ll dy[9] = {0, 1, 1, 1, 0, -1, -1, -1, 0};

signed main()
{   
    gearup;
    ll h,w,n; cin >> h >> w >> n;
    map<pair<int,int>,int> mp;
    rep(i,n){
        int a,b; cin >> a >> b;
        rep(j,9){
            int nx = b+dx[j];
            int ny = a+dy[j];
            if(nx >= w || nx <= 1)continue;
            if(ny >= h || ny <= 1)continue;
            mp[pair<int,int>(ny,nx)]++;
        }
    }

    vl num(10);
    num[0] = (w-2)*(h-2);
    for(auto m:mp){
        num[m.second]++;
        num[0]--;
    }
    rep(i,10)out(num[i]);
}


Measured memory_bytes: 56576
// AtCoder140150c.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <vector>
#include <cmath>


//https://kenkoooo.com/atcoder/#/table/

using namespace std;

void func147c()
{
    int n;
    cin >> n;


    vector<vector<int>> a(n, vector<int>(n));
    //証言を-1で初期化
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            a[i][j] = -1;
        }
    }

    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp; //証言の数
        for (int j = 0; j < temp; ++j) {
            int x, y;
            cin >> x; //n番目の人
            --x; //vector 扱いやすくするために1引く
            cin >> y; //証言0か1
            a[i][x] = y;
        }
    }

    /*
    証言の組み合わせを全通り探索
    全員正直者から始め、成立しないなら正直者を減らしていく
    正直者・不親切な人は１と０で表せるので
    2進数11111・・・で始め、1ずつ減らしていけば全通り探索できるはず
    成立し次第その人数を出力して終わり
    */

    int bin = pow(2, n) - 1;
    vector<int> honest(n); //正直者の組み合わせ
    while (bin > 0) {
        //証言ベクター更新
        int temp = bin;
        for (int i = 0; i < n; ++i) {
            int temp2 = pow(2, n - 1 - i);
            if (temp / temp2 > 0) honest[i] = 1;
            else honest[i] = 0;
            temp %= temp2;
        }


        /*
        cout << bin << "\n";
        for (int i = 0; i < n; ++i) {
            cout << honest[i] << " ";
        }
        cout << "\n\n";
        */

        //証言を調べる
        //ただし、不親切な人と仮定してる人は飛ばす
        int judge;
        for (int i = 0; i < n; ++i) {
            judge = 1;
            if (honest[i] == 0) continue; //不親切は飛ばす
            for (int j = 0; j < n; ++j) {

                //cout << "i j a[i][j]:" << i << " " << j << " " << a[i][j] << "\n";

                int temp = a[i][j]; //証言を取り出す
                if (temp == -1) continue; //-1は証言なしとして飛ばす
                if (temp != honest[j]) {//証言に食い違いが出たら間違いなのでbreak
                    //cout << "食い違い発生　証言：" << temp << " 仮定:" << honest[j] << "\n";
                    judge = 0;
                    break;
                }
            }
            if (judge == 0) break;
        }

        if (judge == 1) break; //judge==1ならbreak
        --bin; //judge==0なら--bin、正直者の組み合わせを変えてもう一回
    }

    int ans = 0;
    for (int i = n; i > 0; --i) {
        int temp = pow(2, i - 1);
        if (bin / temp > 0) ++ans;
        bin %= temp;
    }

    cout << ans;


}



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



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

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[0]=0;
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1) sum+=M[i][p[i]];
    }
    return sum;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;cin>>e;
            M[i][j]=e==-1?INFTY:e;
        }
    }
    cout<<prim()<<endl;
    return 0;
}



Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
  int n,r,x,y;
  scanf("%d%d",&n,&r);
  if(n<=10)
  { x=100*(10-n);
   y=x+r;
    printf("%d\n",y);
  }
  else
   printf("%d\n",r); 
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a > b)
    cout << "a > b" << endl;
  else if(a < b)
    cout << "a < b" << endl;
  else
    cout << "a == b" <<	endl;
  return 0;
}

Measured memory_bytes: 1156
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t,a;
  cin >> n >> t >> a;
  int x,y,j=100000000,ans;
  for(int i=1; i<=n; i++) {
    cin >> x;
	int y = (t*1000-x*6)-a*1000;
    y = abs(y);
	if(j > y) {
      j = y;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
  int a, b, i;
  char s[100];
  scanf("%d%d", &a, &b);
  scanf("%s", &s);
  int flag = 0;
  for(i = 0; i < a; i++){
    if(s[i] < '0' || '9' < s[i]) flag = 1;
  }
  if(s[a] != '-') flag = 1;
  for(i = a + 1; i < a + b + 1; i++){
    if(s[i] < '0' || '9' < s[i]) flag = 1;
  }
  
  if(flag) printf("No\n");
  else printf("Yes\n");
  return 0;
}

Measured memory_bytes: 128
def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c = [int(x) for x in input().rstrip().split(" ")]

    max_num = max([a, b, c]) if (sum([a, b, c]) + max([a, b, c])) % 2 == 0 else max([a, b, c]) + 1

    print(int((max_num * 3 - sum([a, b, c])) / 2))




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61564
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????????????????£?????????
"""
turns = int(input().strip())
hanako = 0
tarou = 0
for i in range(turns) :
   tcard, hcard = input().strip().split()

   if tcard == hcard :
       hanako += 1
       tarou += 1
   elif tcard > hcard :
       tarou += 3
   else:
       hanako += 3

print("{0} {1}".format(tarou,hanako))

Measured memory_bytes: 7624
import math
import sys
from collections import Counter

import time

N = int(input())
Ns = N


def create_sosu(n, max, Nso):
    for i in range(2, max+1):
        if n % i == 0:
            while n % i == 0:
                n = n // i
                Nso.append(i)
            return create_sosu(n, int(math.sqrt(n)), Nso)

    # 最後まで来た場合 = その値が素数の場合
    # ただし1は素数ではない
    if n != 1:
        Nso.append(n)
    return Nso


def execute_answer(n, kv):
    # 設問の操作をしていきます
    x = 0
    count = 0
    xcount = 0
    while n > 1 and x <= len(kv):
        for x in kv.keys():
            for y in range(1, kv[x]+1, +1):
                if n % (x**y) == 0:
                    count = count+1
                    n = n//(x**y)
                    xcount = xcount+y
                else:
                    break
    print(count)


def main():

    # Nが1の場合にはそのまま終了
    if N == 1:
        print(0)
        return

    # Nが1以外の場合
    # 素数一覧を作成する
    Nso = create_sosu(N, int(math.sqrt(N)), [])
    execute_answer(Ns, Counter(Nso))


main()


Measured memory_bytes: 9488
h,w = map(int,input().split())
c = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j],c[i][k]+c[k][j])
ans = 0
for i in a:
    for j in i:
        if j != -1:
            ans += c[j][1]
print(ans)

Measured memory_bytes: 3316
program main
  implicit none
  integer :: n, i
  character(3) :: s, t
  read(*, *) n
  write(s, "(i3)") n
  t(:) = s(:)
  do i = 1, 3
    if (s(i:i) == "1") then
      t(i:i) = "9"
    else if (s(i:i) == "9") then
      t(i:i) = "1"
    end if
  end do
  write(*, "(a)") t
end program main


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 00:45:38
*/

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


int main(){
    int r,g,b;
    cin >> r >> g >> b;
    if( (10*g+b)%4 == 0 ) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define N 105
using namespace std;
typedef pair<int,int> P;
int n,m,a;
P ans[N];

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=1;i<=m;i++)
      ans[i].first=0,ans[i].second=i;
    for(int i=0;i<n;i++)
      for(int j=1;j<=m;j++)
	cin>>a,ans[j].first+=a;
    for(int i=1;i<=m;i++)
      for(int j=1;j<m;j++)
	if(ans[j].first<ans[j+1].first)
	  swap(ans[j],ans[j+1]);
    for(int i=1;i<=m;i++){
      if(i!=1)cout<<' ';
      cout<<ans[i].second;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
  int debt = 100000, n, i, j;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    debt = debt * 1.05 + 999;
    debt = (debt/1000) * 1000;
  }
  
  printf("%d\n", debt);
  
  return 0;
}

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

int main()
{
    long long N;
    cin >> N;
    long long minstep = N - 1;
    for (long long i = 2; i < sqrt(N) + 1; i++)
    {
        if (N % i == 0)
        {
            if (minstep > i + N / i)
            {
                minstep = i + N / i - 2;
            }
        }
    }
    cout << minstep << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> imos(n+1,0);
    for (int i = 0; i < m; ++i) {
        int l,r;
        cin >> l >> r;
        imos[l-1]++;
        imos[r]--;
    }
    for (int i = 0; i < n; ++i) {
        imos[i+1] += imos[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(imos[i] == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,0,3){
    if(s[i]=='R') ans++;
  }
  if(ans>=2&&s[1]=='S') cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
	int i,n,k,c;
  	scanf("%d",&n);
  c=0;
  	for(i=1;i<=n;i++){
    	scanf("%d",&k);
      	if(i%2==1&&k%2==1){
        	c++;
        }
    }
  printf("%d\n",c);
}



Measured memory_bytes: 1732
#include<stdio.h>
int main(){
  int K,S;
  scanf("%d%d",&K,&S);
  int i,j;
  int count=0;
  for(i=0;i<=K;i++){
    for(j=0;j<=K;j++){
        if(S-i-j<=K&&S-i-j>=0){
          count++;
      }
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from fractions import gcd
from functools import reduce


MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    common_multi = reduce(lambda x, y: x * y // gcd(x, y), A)
    print(sum(map(lambda x: common_multi // x, A)) % MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6228
#!/usr/bin/env python3
import sys
import queue

def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    # initialize count
    count = [0] * N
    for j in range(Q):
        count[p[j]-1] += x[j]
    # initialize tree vertice adjacency list
    adj_list = [ [] for i in range(N) ]
    for i in range(N-1):
        u, v = a[i] - 1, b[i] - 1
        adj_list[u] += [v]
        adj_list[v] += [u]
    # BFS from root, which is 0-th node
    explored = [False] * N
    myqueue = queue.Queue()
    explored[0] = True
    myqueue.put(0)
    while(not myqueue.empty()):
        u = myqueue.get()
        for v in adj_list[u]:
            if explored[v] == False:
                myqueue.put(v)
                explored[v] = True
                count[v] += count[u]
    print(' '.join([str(i) for i in count]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]" 
    x = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 122020
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
ll H, h, m, s, p;

bool check() {
	ll byou = 60 * H * s, hun = 60 * m * p * H + s * H, ji = 3600 * p * h + 60 * p * m + s;
	if (hun == ji) return false;
	ll diff1 = hun - byou, diff2 = byou - ji;
	if (diff1 < 0) diff1 += 3600 * p * H;
	if (diff2 < 0) diff2 += 3600 * p * H;
	return diff1 == diff2;
}

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

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

	while (cin >> H >> h >> m >> s , H) {
		p = 119 * H - 1;
		s *= p;

		while (1) {
			//cout << h << " " << m << " " << s << endl;
			if (check()) {
				ll g = gcd(s, p);
				cout << h << " " << m << " " << s / g << " " << p / g << endl;
				break;
			}

			s++;
			if (s / p == 60) s = 0 , m++;
			if (m == 60) m = 0 , h++;
			if (h == H) h = 0 ;
		}
	}

}

Measured memory_bytes: 3128
#include<stdio.h>
typedef struct{
  int value;
  char moji;
}card;
 
int main(){
  int i,j,n,minj;
 
  card num[36],suit[36],temp;
  
  scanf("%d",&n);
for(i=0;i<n;i++){
  scanf(" %c%d",&num[i].moji,&num[i].value);
  suit[i].moji = num[i].moji;
 suit[i].value = num[i].value;
  }
 
/*bubble sort */
 for(i=0;i<n;i++){
   for(j = n-1;j>i;j--){
     if(num[j].value < num[j-1].value){
       temp = num[j];
       num[j] = num[j-1];
       num[j-1] = temp;
    }
   }
 }

for(i=0;i<n-1;i++){
   printf("%c%d ",num[i].moji,num[i].value);
 }
 printf("%c%d\nStable\n",num[i].moji,num[i].value);

/* selection sort */

 for(i=0;i<n-1;i++){
   minj = i;
   for(j=i;j<=n-1;j++){
     if(suit[j].value < suit[minj].value) minj = j;
   }
     temp = suit[i];
     suit[i]=suit[minj];
     suit[minj]=temp;
 }

 for(i=0;i<n-1;i++){
   printf("%c%d ",suit[i].moji,suit[i].value);
 }
 printf("%c%d\n",suit[i].moji,suit[i].value);
 
 for(i=0;i<n;i++){
   if(suit[i].moji != num[i].moji) {
    printf("Not stable\n");
     break;}
 }
 if(i == n)printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
def integer_cards(cards, params)
  remain_card_count = cards.size
  card_count = cards.each_with_object(Hash.new { |h, k| h[k] = 0 }) { |i, h| h[i] += 1 }
  params.each do |count, num|
    cards << num
    card_count[num] += count
  end

  cards.uniq!
  cards.sort_by! { |n| n * -1 }
  sum = 0
  cards.each do |num|
    break if remain_card_count < 0
    count = card_count[num]
    sum += [remain_card_count, count].min * num
    remain_card_count -= count
  end

  sum
end

n, m = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i)
params = []
m.times do 
  params << gets.split.map(&:to_i)
end

puts integer_cards(cards, params)

Measured memory_bytes: 44420