akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int f[n][10];
    ll p[n][11];
    
    rep(i, n){
        rep(j, 10){
            cin >> f[i][j];
        }
    }
    rep(i, n){
        rep(j, 11){
            cin >> p[i][j];
        }
    }
    
    int cnt[n];
    
    ll res = -100000000000, tmp;
    for(int bit = 0; bit < (1 << 10); bit++){
        if(bit == 0)    continue;
        memset(cnt, 0, sizeof(cnt));
        rep(j, 10){
            if(bit & (1 << j)){
                rep(i, n){
                    if(f[i][j]){
                        cnt[i]++;
                    }
                }
            }
        }
        
        tmp = 0;
        rep(i, n){
            tmp += p[i][cnt[i]];
        }
        if(res < tmp)   res = tmp;
    }
    cout << res << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int a, b, c;
	int k;
	cin>>a>>b>>c;
	cin>>k;
	int cnt = 0;
	while(a>=b) {
		b = b*2;
		cnt++;
	}
	while(c<=b) {
		c = c*2;
		cnt++;
	}
	if(cnt <= k) finish("Yes");
	finish("No");
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3632
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.s = [1 for i in range(n)]
            
    def find(self, x):
        if x == self.p[x]:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, a, b):
        ap = self.find(a)
        bp = self.find(b)
        if ap != bp:
            mini = min(ap ,bp)
            maxi = max(ap, bp)
            self.p[maxi] = mini
            size = self.s[bp] + self.s[ap]
            self.s[bp] = size
            self.s[ap] = size
            return True
        else:
            return False
            
    def size(self, n):
        np = self.find(n)
        return self.s[np]
    
N, M =map(int, input().split())
a, b = [], []
for i in range(M):
    a_i, b_i = map(int, input().split())
    a.append(a_i -1)
    b.append(b_i - 1)
    
s = UnionFind(N)
 
ans = (N*(N-1)) // 2
anss = [ans]
    
for i in range(M):
    j = M - i - 1
    if s.find(a[j]) != s.find(b[j]):
        ans -= s.size(a[j]) * s.size(b[j])
        s.union(a[j], b[j])
    if i != M-1:
        anss.append(ans)
        
sort_ans = sorted(anss)
for i in range(len(sort_ans)):
    print(sort_ans[i])

Measured memory_bytes: 21692
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No") 

if __name__ == '__main__':
    main()



Measured memory_bytes: 5588
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

unsigned int N;
string S;
//vector<pair<int, int>> sp, sm;
struct p {
  int mv;
  int lv;
};
multiset<p> sp, sm;
bool operator <(const p&lhs, const p&rhs) {
  if (lhs.mv > rhs.mv) return true;
  if (lhs.mv == rhs.mv && lhs.lv > rhs.lv) return true;
  return false;
}

void ldiff(string, int &, int &);

int main()
{
  ll diff=0;
  ll depth=0;
  int s1, s2;
  p s; 
  unsigned int i;

  cin >> N;
  for (i=0; i<N; i++) {
    cin >> S;
    ldiff(S, s1, s2);
    s.lv = s1;
    s.mv = s2;
    diff += s.lv;
    if (s.lv>=0) {
      sp.emplace(s);
    } else {
      s.mv -= s.lv;
      s.lv = - s.lv;
      sm.emplace(s);
    }
  }

  if (diff != 0) {
    printf("No\n");
    return 0;
  }

  for (auto it=sp.begin(); it != sp.end(); it++) {
//    printf("%d %d\n", it->lv, it->mv);
    if (depth + it->mv < 0) {
      printf("No\n");
      return 0;
    }
    depth += it->lv;
  }

  depth = 0;
  for (auto it=sm.begin(); it != sm.end(); it++) {
//    printf("%d %d\n", it->lv, it->mv);
    if (depth + it->mv < 0) {
      printf("No\n");
      return 0;
    }
    depth += it->lv;
  }

  printf("Yes\n");

  return 0;
}
void ldiff(string s, int &ld, int &md) {
  int len=s.size();

  ld = 0; md = 0;
  for (int i=0; i< len; i++) {
    switch(s[i]) {
    case '(': ld++; break;
    case ')': ld--; break;
    }
    if (ld < md) md = ld;
  }
}
/*
  ���ʗ񂪂ł������
  �J�����ʂ̐��ƕ����ʂ̐�������
  �J�����ʂ�+1�A�����ʂ�-1�Ƃ��ĕ�����̓r���ŕ��ɂȂ�Ȃ�
  */


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

const int mod = 998244353;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);



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

vector <int> bi(35,0),b2(35,0),b0(35,0);

mint ans;
ll x;
ll xb; //xb^(2^0)*xb^(2^1)*..
xb=m;
ll p=998244353;
ll xans=1;
ans=0;

xb=m-1;
rep(i,19){
            b2[i]=xb;
            xb=(xb*xb)%p;
        }

x=n-k-1;
rep(i,19){
            bi[i]=(x>>i)&1;
            if(bi[i]==1){
                xans*=b2[i];
                xans=xans%p;
            }
        }


mint xans2,ml;
mint cc;
for(int i=k; i>-1 ; --i){
    if(i!=k){
        xans*=(m-1);
        xans=xans%p;
    }
        cc=c(n-1,i);
        xans2=cc*xans;
        ans+=xans2*m;
}

cout << ans << endl;





    

    return 0;
}

Measured memory_bytes: 6236
import sys
import itertools

n=int(sys.stdin.readline())
A = [int(i) for i in sys.stdin.readline().split()]
sys.stdin.readline()
AA=[]
for l in range(1,n+1):
    for i in itertools.combinations(A, l):
        AA.append(sum(i))

for i in sys.stdin.readline().split():
    if int(i) in AA:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43044
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::min;
fn main() {
    input! {
        n:usize,
        k:usize,
        vn:[i64;n],
    }
    let r = min(n, k);
    let mut ans = 0;
    for i in 0..r + 1 {
        for j in 0..(r + 1 - i) {
            let d = k - i - j;
            let mut now = 0;
            let mut s = vec![];
            for a in 0..i {
                now += vn[a];
                s.push(vn[a]);
            }
            for a in n - j..n {
                now += vn[a];
                s.push(vn[a]);
            }
            s.sort();
            for a in 0..d {
                if a >= s.len() {
                    break;
                }
                if s[a] >= 0 {
                    break;
                }
                now -= s[a];
            }
            ans = std::cmp::max(ans, now);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int M=scan.nextInt();
		int[][] root = new int[N][N];
		for(int i=0;i<M;i++){
			int a =scan.nextInt()-1;
			int b =scan.nextInt()-1;
			root[a][b]++;
			root[b][a]++;
		}

		for(int i=0;i<N;i++){
			int sum=0;
			for(int j=0;j<N;j++){
				sum+=root[i][j];
			}
			System.out.println(sum);
		}
	}

}


Measured memory_bytes: 23764
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split();
            int[] IntInput = new int[3];

            for (int i = 0; i < 3; i++)
            {
                IntInput[i] = int.Parse(input[i]);
            }
            if (IntInput[0]== IntInput[1]&& IntInput[0]== IntInput[2])
            {
                Console.WriteLine(1);
            }
            else if (IntInput[0]== IntInput[1]|| IntInput[0]== IntInput[2]|| IntInput[1]== IntInput[2])
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(3);
            }

        }
    }
}

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

int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    int cnt=0;
    for(int i=1;i<n;i++) {
        for(int j=0;j<i;j++) {
          	if(h[i]<h[j])break;
            if(j==i-1) cnt++;
        }
    }
    cout<<cnt+1<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

list0 = []
list1 = []
set1 = set()

td = []
for i in range(N):
    t, d = map(int, input().split())
    td.append((t, d))

td.sort(key=lambda x: (x[0], -x[1]))

for t, d in td:
    if t in set1:
        list0.append(d)
    else:
        set1.add(t)
        list1.append(d)

list0.sort(reverse=True)
list1.sort(reverse=True)

various = min(K, len(list1))
selected0 = []
selected1 = []
for i in range(various):
    selected1.append(list1.pop(0))
if K > various:
    for i in range(K - various):
        selected0.append(list0.pop(0))

sum0 = sum(selected0)
sum1 = sum(selected1)
ans = sum0 + sum1 + various ** 2
while list0 and list0[0] > selected1[-1]:
    sum0 += list0.pop(0)
    sum1 -= selected1.pop(-1)
    various -= 1
    tmp = sum0 + sum1 + various ** 2
    if tmp <= ans:
        break
    ans = tmp

print(ans)


Measured memory_bytes: 31240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define t int t; cin>>t; while(t--)
#define clear(a,x) memset(a,x,sizeof(a))
#define boost ios_base::sync_with_stdio(false)
#define show(a) for(int bm=0;bm<a.size();bm++)cout<<a[bm]<<" ";
#define sc1(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sc4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sc5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define pr1(x) printf("%d\n",x)
#define pr2(x,y) printf("%d %d\n",x,y)
#define pr3(x,y,z) printf("%d %d %d\n",x,y,z)
#define pr4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define pr5(a,b,c,d,e) printf("%d %d %d %d %d\n",a,b,c,d,e)
#define scl(x) scanf("%lld",&x)
#define prl(x) printf("%lld\n",x)
#define u(i,a,b) for(i=a;i<b;i++)
#define d(i,a,b) for(i=a;i>b;i--)
#define all(x) x.begin(),x.end() 
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(x,y) make_pair(x,y) 
#define ff first
#define ss second
#define mod 1000000007
int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1);
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>

int main(){
	int A;
	int B;
	int C;
	scanf("%d %d %d",&A,&B,&C);
	if(A==B&&B==C&&C==A){//&&でかつ
		printf("No");
	}else if(A!=B&&B==C){//ちゃんと等号は＝＝にしろ
		printf("Yes");
	}else if(B!=A&&A==C){
		printf("Yes");
	}else if(C!=A&&A==B){
		printf("Yes");
	}else if(C!=A&&C!=B&&A!=B){
		printf("No");
	}else{
		printf("error");
	}
	return 0;
	}
	

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

n,k = map(int,input().split())
A = list(map(int,input().split()))
# n = 2*10**5
# k = 40
# A = [0] * n

if k >= 41:
    print(*([n] * n))
else:
    for ii in range(k):
        B = [0] * (n+1)
        for i in range(n):
            B[max(0, i-A[i])] += 1
            B[min(n, i+A[i]+1)] -= 1
        for i in range(1,len(B)):
            B[i] += B[i-1]
        A = B[:n]
    print(*A)

Measured memory_bytes: 169044
//人数が少ないグループから作る。グループに人を入れるときは、番号が小さい人から入れる。
//↑の2つを守れば、重複なく列挙可能。あとは、愚直なDPをするだけで解けそうな雰囲気。
#include <iostream>
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n & 1) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;
int n, a, b, c, d;
int fact[1001];
int factInv[1001];
int dp[1001][1001];

//残りn人いて、今からm人グループを作る。
int dfs(int n, int m) {
	if (m == b + 1) { return (n == 0); }
	if (dp[n][m] != -1) return dp[n][m];
	
	int ret = dfs(n, m + 1);
	for (int x = c; x <= d && m * x <= n; x++) {
		int cnt = fact[n] * factInv[n - m * x] % mod * powmod(factInv[m], x, mod) % mod * factInv[x] % mod;
		ret += cnt * dfs(n - m * x, m + 1);
		ret %= mod;
	}
	return dp[n][m] = ret;
}

signed main() {
	int i, j;
	
	cin >> n >> a >> b >> c >> d;
	fact[0] = 1;
	for (i = 1; i <= n; i++) fact[i] = (i * fact[i - 1]) % mod;
	for (i = 0; i <= n; i++) factInv[i] = powmod(fact[i], mod - 2, mod);
	for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) dp[i][j] = -1;
	
	cout << dfs(n, a) << endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 1000000000000000
#define N 210000

vector<ll> a(N,INF);
vector<ll> ansl(N);
vector<ll> bango(N);
vector<ll> reached(N,0);
vector<vector<ll>> conn(N);


//探索するものを定義しておく,初期値設定の値に注意!!
//大きい順に並んでいて、自分より小さいものの最小のindexを見つける
//自分より大きいもの見つけたければ昇順のvectorに対して不等号逆にする
bool isOK(ll index, ll key){ 
    if (a.at(index) >= key) return true; 
    else return false;
}

ll binse(ll key, ll sizem){ //sizem番目まで二分探索
	ll left = -1;
	ll right = sizem;
	while (right-left>1){
		ll mid = left+(right-left)/2;
		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	return right; //自分より大きい、または小さいものの最小のindex、なければsizemを返す
}

void dfs(ll x){
	reached[x] = 1;
	ll len = conn[x].size();
	ll ind = binse(bango[x],N-1);
	ll former = a[ind];
	a[ind] = bango[x];
	ansl[x] = binse(INF/10,N-1);
	//cout << x << " " << ansl[x] << " " << ind << endl;
	if (len!=0){
		REP(i,len){
			if (reached[conn[x][i]]==0){
				dfs(conn[x][i]);
			}
		}
	}
	a[ind] = former;
}

int main(){
	ll n, x, u, v; cin >> n;
	REP(i,n){
		cin >> x;
		bango[i] = x;
	}
	REP(i,n-1){
		cin >> u >> v;
		conn[u-1].pb(v-1);
		conn[v-1].pb(u-1);
	}
	dfs(0);
	REP(i,n){
		cout << ansl[i] << endl;
	}
}

Measured memory_bytes: 41248
#include<cstdio>


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		int ans=0;

		for(int i=0;i<n;i++)
		{
			int l, r;
			scanf("%d%d", &l, &r);
			ans+=r-l+1;
		}
		printf("%d\n", ans);
	}

	return 0;
}


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

typedef pair<long, long> P;

int main(){
    long N;
    long A;
    P students[100002];

    cin >> N;
    for(long n=0;n<N;n++){
        cin >> A;
        students[n] = P(A, n+1);
    }
    sort(students, students+N);
    for(long n=0;n<N;n++){
        cout << students[n].second << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

bool has7(int x)
{
    string s = to_string(x);

    for (char c : s)
    {
        if (c == '7') return true;
    }

    return false;
}

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

    if (has7(n)) cout << "Yes";
    else cout << "No";
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  rep(i, 0, N) {
    cin >> v[i];
  }

  sort(All(v));

  rep(i, 0, N - 1) {
    int times = i+1;
    v[times] = (v[i] + v[times]) / 2.0;
    sort(v.begin()+times, v.end());
  }

  cout <<  v[N-1] << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
    int n,sum=0,i,j,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    int size=sizeof(a)/sizeof(a[0]);
    sort(a,a+size);
    for(i=0;i<n;i++){
       for(j=i+2;j<n;j++){
           for(k=i+1;k<j;k++){
               if((a[k]+a[j])>a[i]&&(a[i]+a[k])>a[j]&&(a[i]+a[j])>a[k])
               sum++;
           }
       }
    }
    cout<<sum<<endl;
}


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

int f(int a){
	int ans = 0;
	while(0 < a){
		ans += a%10;
		a /= 10;
	}

	return ans;
}

int main(){
	int ans = __INT_MAX__;
	int n;
	cin >> n;
	for(int a = 1; a <= n-1; a++){
		int b = n-a;
		ans = min(ans, f(a)+f(b));
	}

	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> N(n), P(n), Q(n);
    for(int i = 0; i < n; i++) N[i] = i + 1;
    for(int i = 0; i < n; i++) cin >> P[i];
    for(int i = 0; i < n; i++) cin >> Q[i];

    int pans, qans, cnt = 0;
    do {
        if(N == P) pans = cnt;
        if(N == Q) qans = cnt;
        cnt++; 
    } while(next_permutation(N.begin(), N.end()));
    cout << abs(pans - qans) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	T := fsc.Next()
	N := len(S)
	M := len(T)
	results := make([]string, 0)
	for i := 0; i < N; i++ {
		if i+M-1 >= N {
			break
		}

		ok := true
		for j := 0; j < M; j++ {
			if S[i+j] != '?' && S[i+j] != T[j] {
				ok = false
				break
			}
		}

		if ok {
			//pre
			tmp := S[:i]
			//mid
			tmp += T[:]
			//last
			tmp += S[i+M:]
			var res string
			for j := 0; j < len(tmp); j++ {
				if tmp[j] == '?' {
					res += "a"
				} else {
					res += string(tmp[j])
				}
			}
			results = append(results, res)
		}
	}
	sort.Strings(results)
	if len(results) == 0 {
		fmt.Println("UNRESTORABLE")
		return
	}
	fmt.Println(results[0])
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int a,b,k;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&k);
  for(int j=a;j<b+1;j++){
  if(j < a + k){
    printf("%d\n",j);
  }else{
  if(j > b-k)printf("%d\n",j);
  }
  }
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 25, M = 1010;

int n, m, res;
int dist[N][N];
PII q[M];
char g[N][N];

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

void bfs(int x, int y)
{
	memset(dist, -1, sizeof dist);
	
	int hh = 0, tt = -1;
	q[ ++ tt] = {x, y};
	dist[x][y] = 0;
	
	while (hh <= tt)
	{
		auto t = q[hh ++ ];
		
		for (int i = 0; i < 4; i ++ )
		{
			int tx = t.F + dx[i];
			int ty = t.S + dy[i];
			
			if (tx < 0 || ty < 0 || tx >= n || ty >= m) continue;
			if (g[tx][ty] == '#' || dist[tx][ty] != -1) continue;
			
			q[ ++ tt] = {tx, ty};
			int d = dist[t.F][t.S] + 1;
			res = max(res, d);
			dist[tx][ty] = d;
		}
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%s", g[i]);
	
	for (int i = 0; i < n; i ++ )
		for (int j = 0; j < m; j ++ )
			if (g[i][j] == '.')
				bfs(i, j);

	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
C = [list(map(int,input().split())) for _ in range(3)]
ind = 0
for j in range(1,3):
    if not(C[0][j]-C[0][j-1]==C[1][j]-C[1][j-1]==C[2][j]-C[2][j-1]):
        ind = 1
        break
if ind==1:
    print("No")
else:
    print("Yes")

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

// 最大公約数
#if __cplusplus < 201703L
template <typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) { return (b != 0) ? gcd(b, a % b) : abs(a); }
#endif
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
gcd(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = gcd(res, *first);
    return res;
}
template <typename T>
constexpr T gcd(initializer_list<T> t) { return gcd(t.begin(), t.end()); }

// 最小公倍数
#if __cplusplus < 201703L
template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) { return (a != 0 && b != 0) ? a / gcd(a, b) * b : 0; }
#endif
template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
lcm(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = lcm(res, *first);
    return res;
}
template <typename T>
constexpr T lcm(initializer_list<T> t) { return lcm(t.begin(), t.end()); }

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

    int n; cin >> n;
    vector<ll> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    cout << lcm(t.begin(), t.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[5], b[5];
    int time_needed = 0;
    for(int i = 0; i < 5; i++)
    {
        scanf("%d", &a[i]);
        time_needed += a[i];
        if(a[i] % 10 != 0)
            b[i] = a[i] % 10;
        else
            b[i] = 10;
    }
    for(int i = 0; i <5-1; i++)
    {
        for(int j = 0; j <5-1-i;j++)
        {
            if(b[j] > b[j+1])
            {
                int temp = b[j];
                b[j] = b[j+1];
                b[j+1] = temp;
            }
        }
    }
    for(int i = 5-1; i >= 1; i--)
    {
        time_needed += 10-b[i];
    }
    printf("%d", time_needed);
    return 0;
}


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

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

Measured memory_bytes: 3548
n = int(input())
s = list(input())

chuumoku = 1
for i in range(n):
    if chuumoku >= len(s):
        break

    if s[chuumoku] == s[chuumoku - 1]:
        s.pop(chuumoku)
    else:
        chuumoku += 1

print(len(s))


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

int main(){
  int n;
  cin >> n;
  map<string, int> x;
  rep(i, n){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    auto itr = x.find(s);
    if (itr != x.end()) itr->second++;
    else x[s] = 1;
  }
  ll ans = 0;
  for (auto itr = x.begin(); itr != x.end(); itr++){
    ll n = itr->second;
    ans += n*(n-1)/2;
  }
  cout << ans << endl;
  
  return 0;
}

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

# define M_PI           3.14159265358979323846  /* pi */

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    // 3.141592 / 90 * 360 / 12
    //h  0 = M_PI / 2 // 90

    long double radian = 0;
    long double pi = M_PI;
    radian = pi / (long double)180 * ((long double)h * (long double)30 + ((long double)m / 2));
    long double a_x = sin(radian) * (long double)a;
    long double a_y = cos(radian) * (long double)a;

    radian = pi / (long double)180  * (long double)m * (long double)6;
    long double b_x = sin(radian) * (long double)b;
    long double b_y = cos(radian) * (long double)b;

    /*cout << (double)(3 - h) * (double)30 << endl;
    cout << (double)(15 - m) * (double)6 << endl;
    cout << a_x << endl;
    cout << a_y << endl;
    cout << b_x << endl;
    cout << b_y << endl;*/
    cout << setprecision(15) << sqrtl(powl(abs(a_x - b_x),2) + powl(abs(a_y - b_y),2)) << endl;
    return 0;
}

Measured memory_bytes: 4104
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

use std::io::prelude::*;

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

fn main() {
    let n: usize = input();
    let x: i64 = input();
    let mut m: Vec<i64> =
        (0..n).map(|_| input()).collect();
    let mut s = m.clone();
    /*
    if s[0] > x {
        s[0] = x;
    }
    */

    for i in 0..s.len() - 1 {
        if s[i] + s[i + 1] > x {
            if s[i+1] >= s[i+1] + s[i] - x {
                s[i+1] -= s[i+1] + s[i] - x;
            } else {
                s[i] -= s[i+1] + s[i] - x - s[i+1];
                s[i+1] = 0;
            }
        }
    }
    let mut r = 0;
    for i in 0..s.len() {
        r += m[i] - s[i];
    }
    println!("{}", r);
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, m;
  std::cin >> n >> m;
  std::vector<std::map<int64_t, int64_t>>
  node(n, std::map<int64_t, int64_t>());

  for (int64_t i = 0; i < m; i++) {
    int64_t a, b, c;
    std::cin >> a >> b >> c;
    node[a - 1].insert({b - 1, -c});
  }

  std::vector<int64_t> d(n, 114514801919810);
  d[0] = 0;
  for (int64_t i = 0; i < n; i++) {
    for (int64_t j = 0; j < n; j++) {
      if (d[j] != 114514801919810) {
        for (const auto &k : node[j]) {
          d[k.first] = std::min(d[k.first], d[j] + k.second);
        }
      }
    }
  }
  const auto first = d.back();
  for (int64_t i = 0; i < n; i++) {
    for (int64_t j = 0; j < n; j++) {
      if (d[j] != 114514801919810) {
        for (const auto &k : node[j]) {
          d[k.first] = std::min(d[k.first], d[j] + k.second);
        }
      }
    }
  }
  const auto second = d.back();

  if (first != second) {
    std::cout << "inf" << std::endl;
  } else {
    std::cout << -first << std::endl;
  }
  return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;

    vector<lint> divs(0);
    for (lint x = 1; x * x <= N; x++) {
        if (N % x == 0) {
            divs.push_back(x);
            if (x * x != N) divs.push_back(N / x);
        }
    }
    sort(divs.begin(), divs.end());
    // dump(divs);

    lint ans = 0;
    for (lint r : divs) {
        lint m = N / r - 1;
        if (r < m) ans += m;
    }

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

Measured memory_bytes: 3744
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N, X, T;
    scanf("%lld", &N);
    scanf("%lld", &X);
    scanf("%lld", &T);

    ll ans = N / X + (N % X > 0 ? 1 : 0);
    printf("%lld\n", ans * T);
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c; cin>>a>>b>>c;
  int k; cin>>k;
  int ans=0;
  rep(i,k){
    if(a>max(b,c)){
      a*=2;
    }else if(b>max(a,c)){
      b*=2;
    }else{
      c*=2;
    }
  }
  cout<<a+b+c<<endl;

}


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

int main() { 
    string s;
    cin >> s;
    int a = 100100, z = 0;
    rep(i, s.size()){
        if(s[i] == 'A') a = min(i, a);
        if(s[i] == 'Z') z = max(i, z);
    }
    cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
    string p;
    getline(cin, s);
    getline(cin, p);
    
    s += s;

    for(int i=0;i<s.size();i++){
        if(s.substr(i, p.size())==p){
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum=0;
    for(int i=0;cin >> ch;i++){
        if(ch=='\\') S1.push(i);
        else if(ch=='/'&&S1.size()>0){
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i=0;i<ans.size();i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3180
# -*- coding:utf-8 -*-

def solve():
    MOD = 2019
    S = input()

    """解説AC"""
    # A列を作成
    As = []
    d = 1
    for moji in S[::-1]:
        a = (int(moji)*d)%MOD
        As.append(a)
        d = (d*10)%MOD

    # 累積和を作成
    ruiseki = [0]
    for i, a in enumerate(As):
        r = (ruiseki[i] + a)%MOD
        ruiseki.append(r)

    # ruiseki[i] ≡ ruiseki[j] (mod 2019) となる総数を数える
    ruiseki_dic = {}  # combinationの計算でもいける
    ans = 0
    for r in ruiseki:
        if not r in ruiseki_dic:
            ruiseki_dic[r] = 1
        else:
            ans += ruiseki_dic[r]
            ruiseki_dic[r] += 1

    print(ans)



if __name__ == "__main__":
    solve()


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

const int mod = 1000000007;
int n;
int a[10000];
int b[10000];

long mpow(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return b * mpow(b, e - 1) % mod;
  long t = mpow(b, e / 2);
  return t * t % mod;
}

long inv(long n) {
  return mpow(n, mod - 2);
}

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

  long lcm = 1;
  for (int d = 2; d < 1000; ++d) {
    int mx = 0;
    for (int i = 0; i < n; ++i) {
      int cnt = 0;
      while (b[i] % d == 0) {
        b[i] /= d;
        ++cnt;
      }
      mx = max(mx, cnt);
    }
    
    for (int i = 0; i < mx; ++i) {
      lcm = (lcm * d) % mod;
    }
  }
  
  set<int> divs;
  for (int i = 0; i < n; ++i) {
    divs.insert(b[i]);
  }
  
  for (int div : divs) {
    lcm = (lcm * div) % mod;
  }
  
  long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = (ans + lcm * inv(a[i])) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 1e7;
#define mod 1000000007
 
const int mxN = 3e3 + 1;
ll n, k;
array<ll, 2> dp[mxN][mxN];
ll a[mxN];
 
int main()
{
FIO
 
    cin >> n;
    For(n) cin >> a[i];
    Rev(i,n-1,0)
    {
        dp[i][i] = {a[i], 0};
        Rep(j,i+1,n-1)
        {
            if(dp[i][j-1][1] + a[j] > dp[i+1][j][1] + a[i])
                dp[i][j] = {dp[i][j-1][1] + a[j], dp[i][j-1][0]};
            else
                dp[i][j] = {dp[i+1][j][1] + a[i], dp[i+1][j][0]};

        }
    }

    cout << dp[0][n-1][0] - dp[0][n-1][1] << endl;
}

Measured memory_bytes: 85400
#include <bits/stdc++.h>
using namespace std;
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 long long INFLL = 1LL << 60;
const int INF = 1 << 28;
const long long MOD = 1000000000 + 7;
void solve(int a) { cout << (a ? "YES" : "NO") << endl; }

int main()
{
	bool ans = true;
	int n;
	cin >> n;
	map<int, int> A;
	int bef;
	for (int i = 0; i < n; i++)
	{
		cin >> bef;

		if (A[bef] != 0)
		{
			ans = false;
		}
		A[bef] += 1;
	}

	solve(ans);
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    bool bad[10] = {0};
    for(int i = 0; i < k; i++) {
        int x;
        cin >> x;
        bad[x] = true;
    }
    int ans = n;
    bool found = false;
    while(!found) {
        bool good = true;
        int tmp = n;
        while(tmp > 0) {
            if(bad[tmp % 10]) {
                good = false;
                break;
            }
            tmp /= 10;
        }
        found = good;
        ans = n;
        n++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,i,sum=0,count=0;
	while (scanf("%d%d",&a,&b) != EOF){
	sum=a+b;
	for(;;){
		sum=sum/10;
		count++;
		if(sum==0)
		break;
	}	
	printf("%d\n",count);
	count=0;
	}

	return 0;
}

Measured memory_bytes: 0
def prinum(n)
  for x in 2..n/2+1 do
    if n%x==0 then
      return false;
    end;
  end;
  return true;
end
list=[];
5555.times{|i|
  list[i]=i*10+11;
}
n=gets.to_i;
i=0;
n.times do
  while !prinum(list[i]) do i+=1;end;
  print "#{list[i]} ";
  i+=1;
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    set<string> st;
    int n;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        
        rep(i,s.size()){
            for(int j=1;j<=4;j++){
                if(i+j-1<s.size())st.insert(s.substr(i,j));
            }
        }
    }
    
    string abc = "abcdefghijklmnopqrstuvwxyz";
    
    for(auto a:abc){
        string t = {a};
        if( not st.count(t) ){
            cout<<t<<endl;
            return 0;
        }
    }
    
    for(auto a:abc){
        for(auto b:abc){
            string t = {a,b};
            if( not st.count(t) ){
                cout<<t<<endl;
                return 0;
            }
        }
    }
    
    for(auto a:abc){
        for(auto b:abc){
            for(auto c:abc){
                string t = {a,b,c};
                if( not st.count(t) ){
                    cout<<t<<endl;
                    return 0;
                }
            }
        }
    }
    
    for(auto a:abc){
        for(auto b:abc){
            for(auto c:abc){
                for(auto d:abc){
                    string t = {a,b,c,d};
                    if( not st.count(t) ){
                        cout<<t<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    
    cout<<"NO"<<endl;
}



Measured memory_bytes: 42356
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int n;
int d[10][2]={0};
int dx[]={-2,-2,-2,-1,-1, 0, 0, 1, 1, 2, 2, 2};
int dy[]={-1, 0, 1,-2, 2,-2, 2,-2, 2,-1, 0, 1};
bool func(int a,int kx,int ky){
	rep(i,12){
		int nx=kx+dx[i],ny=ky+dy[i];
		if(nx<0||ny<0||nx>10||ny>10)continue;
		loop(j,-1,2)loop(k,-1,2){
			if(nx==d[a][0]+j&&ny==d[a][1]+k){
				if(a+1==n){return true;}
				if(func(a+1,nx,ny))return true;
			}
		}
	}
	return 0;
}
int main(){
	int kx,ky;
	while(cin>>kx>>ky,kx||ky){
		cin>>n;
		rep(i,n)rep(j,2)cin>>d[i][j];
		cout<<(func(0,kx,ky)?"OK":"NA")<<endl;
	}
}

Measured memory_bytes: 1152