akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, m, c, b[20] = {}, a[20][20] = { {} };
    cin >> n >> m >> c;
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < m;i++) {
            cin >> a[j][i];
        }
    }
    int x = 0;
    for (int j = 0; j < n;j++) {
        int y = c;
        for (int i = 0;i < m;i++) {
            y += a[j][i] * b[i];
        }
        if (y > 0) x++;
    }
    cout << x << endl;
}
   

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s, t = map(str, input().split())
ans = ''
for i in range(n):
    ans = ''.join([ans, s[i], t[i]])
print(ans)


Measured memory_bytes: 74860
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	int n;cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    vector<int> dp(n+10);
    dp[0] = 0; dp[1] = abs(a[1]-a[0]);
    rep(i,2,n){
        dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4020
def dfs(v, matrix, visited):
    visited[v] = True
    for i in range(n):
        if visited[i]:
            continue
        if not matrix[v][i]:
            continue
        dfs(i, matrix, visited)


n, m = map(int, input().split())
ab = [tuple(map(lambda x: (int(x) - 1), input().split())) for _ in range(m)]
matrix = [[False] * n for _ in range(n)]
for a, b in ab:
    matrix[a][b] = True
    matrix[b][a] = True
visited = [False] * n
ans = 0

for a, b in ab:
    matrix[a][b] = False
    matrix[b][a] = False
    for i in range(n):
        visited[i] = False
    dfs(0, matrix, visited)
    if not all(visited):
        ans += 1
    matrix[a][b] = True
    matrix[b][a] = True
print(ans)


Measured memory_bytes: 41052
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
using namespace std;
long long inf=100000000000007;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int to,cost;};
vector<edge> G[22];
vector<int> O[10];
char fi[1005][1005];
P sg[10];
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
pair<int,double> s[1005];
int c=0;
int n,k;
signed main(){
    bool bo[10][10]={false};
    int n,m;cin>>n>>m;
    int a,b;
    rep(i,m){
        cin>>a>>b;
        bo[a][b]=true;
        bo[b][a]=true;
    }
    vector<int> v(n);
    int c=0,d=0;
    iota(v.begin(),v.end(),1);
    int count=0;
    do{
        bool s=true;
        for(auto x:v){
            d=c;
            c=x;
            if(c!=0&&d!=0){
                if(!bo[c][d])s=false;
            }
        }
        if(s)count++;
        c=0;d=0;
    }while(next_permutation(v.begin()+1, v.end()) );
    cout<<count<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int x, y;
	cin >> x >> y;

	int ans = x + (y / 2);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  
  int count = 0;
  
  for (int i=min(A,B); i>=1; i--) {
    if (A%i == 0 && B%i == 0) {
      count++;
      if (count == K) {
        cout << i << endl;
        break;
      }
    }
  }
  
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
//----------------------------------------------------------------------
using namespace std;
int main(void) {
    int n; cin >> n;
    int m; cin >> m;
    vector<int> p(n);
    vector<int> mask(n);
    fill(p.begin(),p.end(),0);
    fill(mask.begin(),mask.end(),1);
    int penal= 0;
    int anse = 0;
    for(int i = 0; i < m; ++i) {
        int num; cin >> num;
        string s; cin >> s;
        if(s=="WA") {
            p[num-1]++;
        }
        if(s=="AC") {
            penal += p[num-1] * mask[num-1];
            anse += mask[num-1];
            mask[num-1] = 0;
        }
    }
    cout << anse << " " << penal << endl;
    return 0;
}



Measured memory_bytes: 1024
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();

    let mut V = VecDeque::new();

    for _ in 0..N{
        let c = buf_it.next().unwrap();
        match c{
            "insert" => {
                let n = buf_it.next().unwrap().parse::<usize>().unwrap();
                V.push_front(n);
            },
            "delete" => {
                let n = buf_it.next().unwrap().parse::<usize>().unwrap();
                let mut j = N+10;
                for (i,&v) in V.iter().enumerate(){
                    if n==v{
                        j = i;
                        break;
                    }
                }
                V.remove(j);
            },
            "deleteFirst" => {
                V.pop_front();
            },
            "deleteLast" => {
                V.pop_back();
            },
            _ => {}
        }
    }
    
    println!("{}",V.iter().map(|v| format!("{}",v)).collect::<Vec<_>>().join(" "));
}


Measured memory_bytes: 47916
#include<stdio.h>
int swap(int *A,int *B,int *C){
    int p1,p2;
    p1 = *A;
    *A = *B;
    *B = p1;
    p2 = *A;
    *A = *C;
    *C = p2;
    return 0;
}
int main(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    swap(&A,&B,&C);
    printf("%d %d %d\n",A,B,C);
    return 0;
}

Measured memory_bytes: 2152
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

// comb (前計算O(NlogMOD) クエリO(1))
const int MAX_N = 2000;
ll FACT[MAX_N + 1], IFACT[MAX_N + 1];

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

ll comb(ll n, ll r) {
    if (n < 0 || r < 0 || r > n)return 0;
    if (r > n / 2) r = n - r;
    return FACT[n] * IFACT[n - r] % MOD * IFACT[r] % MOD;
}

int main() {
    int N, K; input(N,K);
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i % MOD;
        IFACT[i] = powMod(FACT[i], MOD - 2, MOD);
    }
    FOR(i, 1, K + 1) {
        cout << (comb(K - 1, i - 1) % MOD) * comb(N - K + 1, i) % MOD << endl;
    }
    getchar(); getchar();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' '; cout << endl;
#define OUTP(a) cout << a.f << ' ' << a.s << endl;
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
#define get_lind(vec, val) (int)(lower_bound(all(vec), val) - vec.begin())
#define get_rind(vec, val) (int)(upper_bound(all(vec), val) - vec.begin())


using  namespace std;
map<ll, ll> num;
int main()
{
    int n; cin >> n;
    ll a[n];
    ll totalsum = 0;
    set<ll> nums;
    FOR(i, n, 0)
    {
        cin >> a[i];
        num[a[i]]++;
        nums.insert(a[i]);
    }
    for(auto e : nums)
    {
        totalsum += ((num[e] - 1) * num[e]) / 2;
    }
    FOR(i, n, 0)
    {
        cout << totalsum - num[a[i]] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 17024
import java.util.Scanner;

public class Main {
    static final int NUMBER = 1000000007;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        // 全体の場合の数（条件2, 3を無視）
        long ans = 1;
        for(int i=0; i<n; i++) {
            ans *= 10;
            ans %= NUMBER;
        }

        // 0が無い数列の個数
        long no0 = 1;
        for(int i=0; i<n; i++) {
            no0 *= 9;
            no0 %= NUMBER;
        }

        // 9が無い数列の個数
        long no9 = no0;

        // 0と9の両方が無い数列の個数
        long no09 = 1;
        for(int i=0; i<n; i++) {
            no09 *= 8;
            no09 %= NUMBER;
        }

        ans = ans - no0 - no9 + no09;
        while(ans < 0) {
            ans += NUMBER;
        }
        ans %= NUMBER;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define UNWORDS(vec, str) for(int i = 0; i < (vec).size(); ++i) cout << (i ? str : "") << (vec)[i]
#define UNLINES(vec) for(int i = 0; i < (vec).size(); ++i) cout << (vec)[i] << endl
#define RS resize
#define CLR clear
#define PB push_back
using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a and b and not c) cout << "Open" << endl;
	else if(not a and not b and c) cout << "Open" << endl;
	else cout << "Close" << endl;
	
	return 0;
}

Measured memory_bytes: 1156
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut vec = Vec::new();
    let mut zero = false;
    let mut left = 0;
    for i in 0..n {
        if !zero && s[i] == '0' {
            zero = true;
            left = i;
        }
        if zero && (s[i] == '1' || i == n-1) {
            vec.push((left, i));
            zero = false;
        }
    }

    if vec.len() <= k {
        println!("{}", n);
        return;
    }

    let mut ans = vec[k].0;
    let mut l = 1;
    while l + k <= vec.len() {
        if l + k < vec.len() {
            ans = max(ans, vec[l+k].0 - vec[l-1].1);
        } else {
            ans = max(ans, n - vec[l-1].1);
        }
        l += 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

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

int A[3];
int main()
{
	cin >> A[0] >> A[1] >> A[2];
	int min = A[0]+A[1]+A[2];
	for( int i = 0; i < 3; i++ ) {
		int cost1 = 0;
		for( int j = 0; j < 3; j++ ) {
			if( i == j ) continue;
			int cost2 = abs(A[i]-A[j]);
			for( int k = 0; k < 3; k++ ) {
				if( i == k || j == k ) continue;
				int cost3 = abs(A[j]-A[k]);
				if( cost1+cost2+cost3 < min ) {
					min = (cost1+cost2+cost3);
				}
			}
		}
	}
	cout << min << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((a==5 && b==5 && c==7)|| (a==5 && b==7 && c==5)|| (a==7 && b==5 && c==5)){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.*;
import java.lang.String;
import java.lang.System;
import java.lang.reflect.Array;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String c = "CODEFESTIVAL2016";
		String[] arrS = s.split("");
		String[] arrC = c.split("");
		int len = c.length();
		int count = 0;
		
		for (int i = 0; i < len; i++) {
			if (!arrS[i].equals(arrC[i])) {
				count++;
			}
		}
		
		System.out.println(count);
		
		
    }
}

Measured memory_bytes: 10192
//03
#include<iostream>
#include<algorithm>

using namespace std;

int nt;
int t[30];
int m[101];

int gd(int d){
  for(int i=0;i+d<=100;i++){
    if(t[i%nt]>m[d+i])return d+i;
  }
  return 999;
}

int main(){
  while(cin>>nt,nt){
    for(int i=0;i<nt;i++){
      cin>>t[i];
    }
    fill(m,m+101,24);
    int n;
    cin>>n;
    while(n--){
      int d,mm;
      cin>>d>>mm;
      m[d]=min(m[d],mm);
    }
    int cd=1;
    int nc=0;
    for(;;){
      int dl=gd(cd);
      if(dl==999)break;
      int ml=0,x;
      for(int i=1;i+cd<=dl;i++){
	int id=gd(i+cd);
	if(id>ml){
	  ml=id;
	  x=i+cd;
	}
      }
      cd=x;
      nc++;
    }
    cout<<nc<<endl;
  }
  return 0;
}

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

int main(){
  int A , B , C;
  cin >> A >> B >> C;
  if ((A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5)){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

X,K,D=(int(x) for x in input().rstrip('\n').split())
if X>0 and X-K*D>=0:
  print(X-K*D)
elif X<0 and X+K*D<=0:
  print(-X-K*D)
else:
  if X>0:
    x = X%D
    y=X//D
    if (K-y)%2==0:
      print(x)
    else:
      print(D-x)
  elif X<0:
    a = (-1)*X
    x = a%D
    y = a//D
    if (K-y)%2==0:
      print(x)
    else:
      print(D-x)
  else:
    if K%2==0:
      print(0)
    else:
      print(D)

Measured memory_bytes: 9168
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int M1 = sc.nextInt();
    int D1 = sc.nextInt();
    int M2 = sc.nextInt();
    int D2 = sc.nextInt();

    if(M1 != M2 && D2 != D1+1){
      System.out.println(1);
    }
    else{
      System.out.println(0);
    }
  }
}


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

int main() {
	string s;
	cin >> s;
	int sz = s.size();

	if (s[0] == '0' or s[sz - 1] == '1') {
		cout << -1 << "\n";
		return 0;
	}
	for (int i = 0; i < sz/2; ++i) {
		if (s[i] != s[sz - i - 2]) {
			cout << -1 << "\n";
			return 0;
		}
	}

	int root = 1, tok = 1, last = -1;
	for (int i = sz/2-1; i >= 0; --i) {
		if (s[i] == '1') {
			last = i;
			break;
		}
	}

	for (int i = sz/2-1; i >= 0; --i) {
		if (s[i] == '1') {
			// for (int j = last; j > i; --j) {
			// 	cout << root << " " << ++tok << "\n";
			// }
			// last = i;
			cout << root << " " << ++tok << "\n";
			root = tok;
		}
		else {
			cout << root << " " << ++tok << "\n";
		}
	}

	while (tok < sz) {
		cout << 1 << " " << ++tok << "\n";
	}

	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Linq;

public class AtCoder_156_A
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int n = line1[0];
        int r = line1[1];

        if (n >= 10)
        {
            Console.WriteLine(r);
        }
        else
        {
            Console.WriteLine(r + 100 * (10 - n));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack 
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <list>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  int sum=0;
  for(int i=0; i<m; i++){
      cin >> a[i];
      sum+=a[i];
  }
  cout << max(n-sum,-1) << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll solve(int* a, int n){
  ll cnt = 0;
  bool be = false;
  for(int i=0; i<n; i++){
    if(be){
      cnt += a[i] / 2;
      if(a[i] % 2) {
        be = false;
        cnt++;
      }
      else{
        if(a[i]) be = true;
        else be = false;
      }
    }
    else{
      cnt += a[i] / 2;
      if(a[i] % 2) be = true;
      else be = false;
    }
  }

  return cnt;
}

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];

  ll ans = solve(a, n);
  //reverse(a, a+n);
  ans = min(ans, solve(a, n));

  cout << ans << endl;
  
  return 0;
}


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

int main(){
	int n,m,x;
	cin>>n>>m>>x;

	vector<int> arr(n);
	for(int i = 0;i < m;i++){
		int t;
		cin>>t;
		arr[t-1] = 1;
	}

	for(int i = 1;i < x;i++) arr[i]+=arr[i-1];
	for(int i = x+1;i<n;i++) arr[i]+=arr[i-1];

	cout<<min(arr[x-1],arr[n-1]); 
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$array = array();
$array = explode(' ', trim(fgets(STDIN)));  # explodeで行全部を配列に取り込む。

$Sk = array();
for($k = -100; $k <= 100; $k++){
    $total = 0;
    for($i = 0; $i < $n; $i++){
        $total += ($k - $array[$i]) ** 2;
    }
    $Sk[$k] = $total;
}
print min($Sk);


Measured memory_bytes: 4728
#写経
#https://atcoder.jp/contests/abc171/submissions/14574647
from functools import reduce
def comb(n, max_k, mod):
    """
    (n,k) := n個からk個選ぶ組み合わせ
    k = 0~max_Kまでを計算して返す
    """
    res = [1]*(max_k+1)
    t = 1
    for i in range(max_k+1):
        res[i] *= t
        t *= n-i
        t %= mod

    n = reduce(lambda x,y: (x*y)%mod, range(1,max_k+1), 1)
    n = pow(n,-1, mod)

    for i in reversed(range(max_k+1)):
        res[i] *= n
        res[i] %= mod
        n *= i
        n %= mod
    return res

MOD = 10**9+7

def resolve():
    K = int(input())
    N = len(input())
    res = 0
    x = 1
    com = comb(N+K, K , MOD)

    for c in com:
        res += x*c
        res %= MOD
        x *= 25
        x %= MOD
    print(res)
resolve()

Measured memory_bytes: 49004
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//


int32_t main()
{
    io;
    int k, n;
    cin>>k>>n;
    vi inp(n);
    for(auto& x: inp) cin>>x;
    sort(inp.begin(), inp.end());
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, inp[i] - inp[i-1]);
    ans = max(ans, k - inp[n-1] + inp[0]);
    cout<<k - ans;
    return 0;
}

Measured memory_bytes: 4052
#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}
//x^n mod m (nが負の時は０)
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


int main(){
    int i,a,b,c,d;
    //入力
    cin>>a>>b>>c>>d;
    //処理
    int a_c=wtover(a,d),c_c=wtover(c,b);
    //出力
    c_c<=a_c?cout<<"Yes"<<endl:cout<<"No"<<endl;
}

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

		int N = sc.nextInt();
		int[] A = new int[N+1];
		for( int i=1; i<=N; i++ ){
			A[sc.nextInt()] = i;
		}
		for( int i=1; i<=N; i++ ){
			System.out.println(A[i]);
		}
	}
}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


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

int test=1;
//cin>>test;
while(test--)
{

	int n;
	cin>>n;
	set<string> s;
	string str;
	for(int i=0;i<n;i++)
	{
		cin>>str;
		s.insert(str);
	}

	cout<<s.size();
	
}
return 0;
}









Measured memory_bytes: 19252
n = int(input())
xlist = list(map(int, input().split()))
xsort = [x for x in sorted(xlist)]
xml, xmr = xsort[n // 2 - 1], xsort[n // 2]

for x in xlist:
  if x <= xml:
    print(xmr)
  else:
    print(xml)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    int f=0;
    int cnt=0;
    REP(i,n){
        switch(s[i]){
        case 'a':
            if(cnt<a+b){
                Yes(1);
                cnt++;
            }else{
                Yes(0);
            }
            break;
        case 'b':
            if(cnt<a+b && f<b){
                Yes(1);
                cnt++;
                f++;
            }else{
                Yes(0);
            }
            break;
        default:
            Yes(0);
        }
    }
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    char current_char = '0';
    int running = 0;
    int count = 0;
    for (char c : s) {
        if (running == 0 || current_char == c) {
            current_char = c;
            ++running;
        } else {
            --running;
            ++count;
        }
    }
    cout << 2*count << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
  char number[1001];
  int sum, i;

  while(1){
    scanf("%s", number);
    if(number[0] == '0' && number[1] == '\0')  break;
    sum = 0;
    for(i = 0; number[i] != '\0'; i++){
      sum += (number[i] - '0');
    }
    printf("%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 536
#include <cstdio>
#include <queue>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n) && n){
		queue<vector<int> >que;
		vector<int>vec;
		que.push(vec);
		for(int i=n;i>=1;i--){
			int ro=que.size();
			for(int j=0;j<ro;j++){
				vector<int>ss=que.front();
				que.pop();
				int rp=0;
				int ru=ss.size();
				for(int k=0;k<ru;k++){
					rp+=ss[k];
				}
				if(rp==n){
					que.push(ss);
				}
				else if(i==1){
					for(int e=rp+1;e<=n;e++){
						ss.push_back(1);
					}
					que.push(ss);
				}
				else{
				for(int e=rp;e<=n;e+=i){
					que.push(ss);
					ss.push_back(i);
				}
				}
			}
		}
		vector<vector<int> >v;
		while(!que.empty()){
			vector<int>d=que.front();
			que.pop();
			v.push_back(d);
		}
		sort(v.begin(),v.end());
		int w=v.size();
		for(int i=w-1;i>=0;i--){
			printf("%d",v[i][0]);
			for(int j=1;j<v[i].size();j++){
				printf(" %d",v[i][j]);
			}
			puts("");
		}
	}
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.in", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

void solve(std::istream &in, std::ostream &out) {
  int n, W;
  in >> n >> W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    in >> w[i] >> v[i];
  }
  vector<int64_t> dp(W + 1, -1);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = W - w[i]; j >= 0; --j) {
      if (dp[j] == -1) {
        continue;
      }
      if (w[i] + j <= W) {
        dp[w[i] + j] = max(dp[w[i] + j], dp[j] + v[i]);
      }
    }
  }
  int64_t a = *max_element(dp.begin(), dp.end());
  out << a << '\n';
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

    int W = scanner.nextInt();
    int H = scanner.nextInt();
    int N = scanner.nextInt();
    int left = 0, right = W, bottom = 0, top = H;
    for (int i = 0; i < N; i++) {
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      int a = scanner.nextInt();
      switch (a) {
        case 1:
          left = Math.max(left, x);
          break;
        case 2:
          right = Math.min(right, x);
          break;
        case 3:
          bottom = Math.max(bottom, y);
          break;
        case 4:
          top = Math.min(top, y);
          break;
      }
    }
    System.out.println(Math.max(right - left, 0) * Math.max(top - bottom, 0));
  }
}


Measured memory_bytes: 22612
n, m, k = map(int,input().split())
mod = 998244353
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
ff = [1 for i in range(n)]
for i in range(1,n):
    ff[i] = (ff[i-1]*(m-1))%mod
for i in range(1,k+1):
    ans = (ans+(cmb(n-1,i,mod)*ff[n-1-i])%mod)%mod
ans = (ans+ff[n-1])%mod
ans = (ans*m)%mod
print(ans)


Measured memory_bytes: 40652
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
# Kを無視した勝ち手のリスト
kachite = []
for i in range(N):
  if T[i] == 'r':
    kachite.append('p')
  elif T[i] == 's':
    kachite.append('r')
  else:
    kachite.append('s')

# 勝ち手リストを頭から見ていき、jとj-Kの勝ち手が同じ場合は変更する
for j in range(N):
  if j-K>=0:
    if kachite[j]==kachite[j-K] and kachite[j-K]!='':
      #K回前の勝ち手が同じ(得点が同じ)、かつ、空文字ではない場合
      kachite[j] = '' # K回前、K回後のいずれでもない手を出したことにする
# 最終得点を出力
rpoint = kachite.count('r')*R
spoint = kachite.count('s')*S
ppoint = kachite.count('p')*P
print(rpoint+spoint+ppoint)

Measured memory_bytes: 4212
#! python3
# coding:utf-8
 
def main():
    a,b,c,d = map(int,input().split())

    while (a>=0) and (c>=0):
        c = c - b
        if c <= 0:
            print("Yes")
            break
        a = a - d
        if a <= 0:
            print("No")
            break
if __name__ == "__main__":
    main() 

Measured memory_bytes: 9180
///
// File:  b.cpp
// Author: ymiyamoto
//
// Created on Thu Oct  5 17:56:06 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
static vector<string> array;

int32_t main()
{
  uint32_t N, L;
  cin >> N >> L;
  for (uint32_t i = 0; i < N; i++) {
    string str;
    cin >> str;
    array.push_back(str);
  }

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

  for (uint32_t i = 0; i < array.size(); i++) {
    cout << array[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
char s[15];
int len;
bool ok = true;
int main(){
	scanf("%s", s);
	len = strlen(s);
	for(int i = 0; i<len; i++) if(s[i] != (char)(i%2 ? 'i' : 'h')){
		ok = false;
	}
	puts(ok && len % 2 == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    int a=0,b=0;
    while(N>0){
        a+=N%10;
        if(N/10>0)b+=9;
        else b+=(N%10)-1;
        N/=10;
    }
    cout << max(a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class ProgramB
    {
        static void Main(string[] args)
        {var line = Console.ReadLine();
var data = line.Split(' ');
var a1 = int.Parse(data[0]); //first integer
var b1 = int.Parse(data[1]); //sec
          
          //string a=Console.ReadLine();int a1=int.Parse(a); string b=Console.ReadLine();int b1=int.Parse(b);
         Console.WriteLine(((a1-2*b1)<=0?0:a1-2*b1));
           /* string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] input_p = Console.ReadLine().Split(' ');
            int[] p = new int[n];
            for(int i = 0;i < n;i++)
                p[i] = int.Parse(input_p[i]);

            int count = 0;
            
            for(int i = 0;i < n;i++)
            {
                if(p[i] != i + 1)
                    count++;
            }

            if( count == 2 || count == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");*/
        }
    }


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 110 * 110;
bool dp[MAX];

int main(void) {
    dp[0] = true;
    int N;
    cin >> N;
    REP(i, N) {
        int b;
        cin >> b;
        RREP(i, MAX) if (dp[i]) dp[i + b] = true;
    }
    int ma = 0;
    REP(i, MAX) if (dp[i] && i % 10 != 0) ma = i;
    cout << ma << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    ll cnts = min(X, Y);
    ll cntb = max(X, Y) - cnts;
    ans = min(cnts * C * 2, (A + B) * cnts);
    if (X > Y) {
        ans += min((C * 2) * cntb, A * cntb);
    }
    else {
        ans += min((C * 2) * cntb, B * cntb);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var input = test.ConvertLongArray(test.ReadInput());
            
            Console.WriteLine(test.Lcm(input[0],input[1]));
        }

        /// <summary>
        /// 2つの数の最小公倍数を求める
        /// Gcdメソッドに依存。
        /// </summary>
        /// <returns>最小公倍数</returns>
        public long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        /// <summary>
        /// 2つの数の最大公約数を求める
        /// </summary>
        /// <returns>最大公約数</returns>
        public long Gcd(long a, long b)
        { 
            long r = 0;
            //大きさ比べて入れ替え
            if (a < b)
            {
                var temp = a;
                a = b;
                b = temp;
            }

            r = a % b;
            while (r > 0)
            {
                a = b;
                b = r;
                r = a % b;
            }

            return b;
        }

        

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }
    }
}


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

int main() {
    string input;
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> input;
        if (input == "AC") {
            ac++;
        }
        if (input == "WA") {
            wa++;
        }
        if (input == "TLE") {
            tle++;
        }
        if (input == "RE") {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 3224
#include<stdio.h>
#include<algorithm>
#include<utility>
#include<math.h>
int main()
{
	int n,y,r,t;
	std::pair<double,int>b[50];
	while(scanf("%d",&n),n)
	{
		scanf("%d",&y);
		for(int i=0;i<n;++i)
		{
			scanf("%d%d%d",&b[i].second,&r,&t);
			if(t-2)b[i].first=1+r/100.0*y;
			else b[i].first=pow(1+r/100.0,(double)y);
		}
		std::sort(b,b+n);
		printf("%d\n",b[n-1].second);
	}
	return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t POW(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (POW(x,y/2)*POW(x,y/2))%mod;
  else
    return ((((x%mod)*POW(x,y/2))%mod)*POW(x,y/2))%mod;
}
int main(){
int64_t N,K;
  cin>>N>>K;
  vector<int64_t>ans(K+1);
  for(int i=K;1<=i;i--){
  int64_t a=POW(K/i,N);
    for(int j=2;j<=K/i;j++){
    a=(a-ans.at(i*j)+mod)%mod;
    }ans.at(i)=a;
  
  }int64_t A=0;
  for(int i=1;i<=K;i++){
  A=(A+ans.at(i)*i)%mod;
  }cout<<A<<endl;
   return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  ll sum = 0;
  rep(i, n) {
    cin >> v.at(i);
    sum += v.at(i);
  }
  ll tmp = 0, res = sum;
  rep(i, n) {
    tmp += v.at(i);
    sum -= v.at(i);
    res = min(res, abs(tmp-sum));
  }
  cout << res << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
rate=[0]*10;cnt=0
lena=[0]*10
for i in range(n):
    if 1<=a[i]<=399:
        rate[0]=1
        lena[0]=1
    elif 400<=a[i]<=799:
        rate[1]=1
        lena[1]=1
    elif 800<=a[i]<=1199:
        rate[2]=1
        lena[2]=1
    elif 1200<=a[i]<=1599:
        rate[3]=1
        lena[3]=1
    elif 1600<=a[i]<=1999:
        rate[4]=1
        lena[4]=1
    elif 2000<=a[i]<=2399:
        rate[5]=1
        lena[5]=1
    elif 2400<=a[i]<=2799:
        rate[6]=1
        lena[6]=1
    elif 2800<=a[i]<=3199:
        rate[7]=1
        lena[7]=1
    else:
        cnt+=1
m=sum(rate)
if m==0:
    m=1
    print(m,cnt)
else:
    print(m,m+cnt)

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

int main(){
    int N;
    int s[102];
    int sums = 0;
    set<int> not10;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> s[i];
        sums += s[i];
        if(s[i] % 10 != 0){
            not10.insert(s[i]);
        }
    }

    if(sums % 10 != 0){
        cout << sums << endl;
    }
    else{
        if(not10.empty()){
            cout << 0 << endl;
        }
        else{
            cout << sums - *not10.begin() << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
s=0
for i in b:
    sa = bisect.bisect_left(a,i)
    sc = n-bisect.bisect_right(c,i)
    s += sa*sc
print(s)

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; ll C; cin >> N >> C;
    pair<ll, ll> sushi[N];
    rep(i, N){
        cin >> sushi[i].first >> sushi[i].second;
    }
    ll watch_val[N]; //watch_val[i]: 時計回りで,sushi[i]まで到達した時の価値の最大
    ll anti_watch_val[N];

    // watch_valの用意
    ll acc = sushi[0].second - sushi[0].first;
    watch_val[0] = max(0ll, acc);
    for(int i = 1; i < N; i++){
        acc += sushi[i].second - (sushi[i].first - sushi[i-1].first);
        watch_val[i] = max(watch_val[i-1], acc);
    }

    acc = sushi[N-1].second - (C - sushi[N-1].first);
    anti_watch_val[N-1] = max(0ll, acc);
    for(int i = N-2; i >= 0; i--){
        acc += sushi[i].second - (sushi[i+1].first - sushi[i].first);
        anti_watch_val[i] = max(anti_watch_val[i+1], acc);
    }
    //rep(i, N) cout << watch_val[i] << " "; cout << endl;
    //rep(i, N) cout << anti_watch_val[i] << " "; cout << endl;
    vector<ll> choice;
    choice.push_back(watch_val[N-1]);
    choice.push_back(anti_watch_val[0]);

    //時計回り -> 反時計回り
    for(int i = 0; i < N-1; i++){
        //iまで時計回りで行く
        choice.push_back(watch_val[i] - sushi[i].first + anti_watch_val[i+1]);
    }
    //反時計回り -> 時計回り
    for(int i = N-1; i > 0; i--){
        choice.push_back(anti_watch_val[i] - (C - sushi[i].first) + watch_val[i-1]);
    }

    //choiceの中で最大の値を出力
    ll ans = 0ll;
    rep(i, choice.size()) ans = max(ans, choice[i]);
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 5492
from collections import Counter
n = int(input())
l = ["".join(sorted(input())) for _ in range(n)]
lcnt = Counter(l)
ls = set(l)
ans = 0
for i in ls:
    #iC2を足していく
    ans += (lcnt[i]*(lcnt[i]-1))//2
print(ans)


Measured memory_bytes: 23340
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")

# reffer to: https://qiita.com/dn6049949/items/afa12d5d079f518de368
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.data = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

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

    # [l, r)
    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.data[l])
                l += 1

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


def main():
    N = I()
    A = LI()

    tree = SegmentTree(N, f=math.gcd)
    for i in range(N):
        tree.update(i, A[i])

    ans = 0
    for i in range(N):
        ans = max(ans, math.gcd(tree.query(0, i), tree.query(i + 1, N)))
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 93020