akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a,b,h,m = I2()
    x = m/60
    y = h/12 + m/60/12
    #print(y-x)
    rad = math.pi*(y-x)*2
    ans = a**2+b**2-2*a*b*math.cos(rad)
    print(math.sqrt(ans))

Measured memory_bytes: 9356
# include <iostream>
# include <string>
# include <set>
# include <algorithm>
# include <cmath>
# include <vector>
# include <string>
# include <map>
# include <iomanip>
# include <queue>
# include <stack>
# include <deque>

using namespace std;

const int N = 1e5 +100;
const int mod = 1e9 + 7;

string s;
int dp[N][13], p[N];

int main()
{
    cin >> s;
    reverse( s.begin(), s.end() );
    int sz =s.size();
    dp[0][0] = 1;
    p[0] = 1;
    for( int i = 1; i <= sz; i ++ ){
        p[i] = (p[i-1] * 10)%13;
    }
    for( int i = 1; i <= sz; i ++ ){
        if( s[i-1] == '?' ){
            for( int j = 0; j <= 9; j ++ ){
                int x = (p[i-1] * j)%13;
                for( int k = 0; k <= 12; k ++ ){
                    dp[i][(k+x)%13] += dp[i-1][k];
                    dp[i][(k+x)%13] %= mod;

                }
            }
        }else{
            int x = ((s[i-1] -'0') * p[i-1]) %13;
            for( int k = 0; k <= 12; k ++ ){
                dp[i][(k + x)%13] += dp[i-1][k];
                dp[i][(k + x)%13] %= mod;
            }
        }
    }
    cout << dp[sz][5];
    return 0;
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;

  vector<int> solved(N, 0);
  vector<int> was(N, 0);  
  int ac = 0, wa = 0;
  for ( int i = 0; i < M; i++ ) {
    int p;
    string s;
    cin >> p >> s; p--;
    if ( s == "AC" ) {
      if ( solved[p] == 0 ) {
	ac++;
	solved[p] = 1;
      } 
    } else {
      if ( solved[p] == 0 ) {
	was[p]++;	
      } 
    }
  }

  for ( int i = 0; i < N; i++ ) {
    if ( solved[i] == 1 ) wa += was[i];    
  }

  cout << ac << " " << wa << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int Ring[3];

int main(void){
    int i, max, sum;
    
    for(i = 0; i < 3; i++) scanf("%d", &Ring[i]);
    sum = max = Ring[0];
    for( i=1; i < 3; i++){
        if(max <= Ring[i]) max = Ring[i];
        sum += Ring[i];
    }
    sum -= max;

    printf("%d", sum);
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val S = next()
    val N = S.length
    val r1 = 0 .. (N - 1) / 2 - 1
    val r2 = (N + 3) / 2 - 1 .. N - 1
    fun isPal(s: String) = (0 until s.length / 2).all { s[it] == s[s.length - it - 1] }
    val ans = isPal(S) && isPal(S.substring(r1)) && isPal(S.substring(r2))
    println(if (ans) "Yes" else "No")
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 33640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, a[51], b[51], ans;
bool g[51][51], used[51];

bool dfs(int p) {
    used[p] = true;
    bool all_used = true;
    rep(i, 0, n) if (!used[i]) all_used = false;
    if (all_used) return true;

    bool ret = false;
    rep(i, 0, n) 
        if (g[p][i] && !used[i]) ret = dfs(i);
    return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    rep(i, 0, m) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        if (!dfs(0)) ans++;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
        rep(j, 0, n) used[j] = false;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=987654321;
int n,a[N],c;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>n; fo(i,0,n-1) cin>>a[i];
	fo(i,0,n-1) while (a[i]%2==0) { a[i]/=2; c++; }
	cout<<c;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int x,count;
int f(int n){
count=count+x/n;
x=x%n;
return 0;
}
int main(){
while(1){
scanf("%d",&x);
if(x==0) break;
count=0;
x=1000-x;
f(500);
f(100);
f(50); 
f(10);
f(5);
count+=x;
printf("%d\n",count);
}
return 0;
}

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

int n, m;
vector<int> edge[100005];
int num[100005] = {0};
int dp[100005] = {0};
int par[100005] = {0};

void solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m + n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    edge[x - 1].push_back(y - 1);
    ++num[y - 1];
  }
  solve();
  for(int i = 0; i < n; ++i) cout << par[i] + 1 << endl;
  return 0;
}

void solve() {
  queue<int> qu;
  for(int i = 0; i < n; ++i) {
    if(num[i] == 0) qu.push(i);
    par[i] = -1;
  }
  while(qu.size() > 0) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i) {
      int to = edge[now][i];
      if(--num[to] == 0) {
        par[to] = now;
        dp[to] = dp[now] + 1;
        qu.push(to);
      }
    }
  }
}

Measured memory_bytes: 7424
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

S = [[1] * W for _ in range(H)]
for x, y, a in xya:
    if a == 1:
        for i in range(H):
            for j in range(x):
                S[i][j] = 0
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                S[i][j] = 0
    elif a == 3:
        for i in range(y):
            for j in range(W):
                S[i][j] = 0
    else:
        for i in range(y, H):
            for j in range(W):
                S[i][j] = 0
A = 0
for i in range(H):
    A += sum(S[i])
print(A)

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (max({a, b, c}) == min({a, b, c})) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

    using namespace std;
    #include <cmath>
    #include <cstring>
    #include <cstdio>
    #include <cstdlib>
    #include <set>
    #include <malloc.h>


    int main()
    {
        long long a,b;
        scanf("%lld %lld",&a,&b);
        int ans=0;
        while(a<=b)
        {
            a*=2;
            ans++;
        }
        printf("%d",ans);

    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 100010
#define rep(i, x, y) for(int i = (x); i <= (y); i ++)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	} while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	} return x * f;
}
int a[M];
int main() {
	int n = read();
	rep(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1);
	if(a[n] - a[1] > 1) {
		return puts("No"), 0;
	} if(a[1] == a[n]) {
		if(a[1] == n - 1) return puts("Yes"), 0;
		else if(a[1] > n / 2) return puts("No"), 0;
		else return puts("Yes"), 0;
	} else {
		int k = 0;
		rep(i, 1, n) if(a[i] == a[1]) k ++;
		if(k >= n - 1) return puts("No"), 0; 
		if(a[1] < k) return puts("No"), 0;
		if(a[1] - (k - 1) > (n - k) / 2) return puts("No"), 0;
		puts("Yes");
	}
	return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  if(n<=k) {cout<<0<<endl; return 0;}
  vector<int> h(n);
  for(int i=0;i<n;i++) cin>>h[i];
  sort(h.begin(),h.end());
  long long ans=0;
  for(int i=0;i<n-k;i++) ans+=h[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ignore() cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n')
#define optimize() ios::sync_with_stdio(0); cin.tie(0);
#define endl "\n"
#define it {0}
int main()
{
    optimize();
    char a;
    cin>>a;
    if(isupper(a)){
        cout<<'A'<<endl;
        }
    else
        cout<<'a'<<endl;
    return 0;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    long[] a = sc.nextLongArray(n);
    long result = 0L;
    for (int i = 1; i < n; i++) {
      if (a[i - 1] <= a[i]) continue;
      result += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
    System.out.println(result);
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<long> B(N-1);
  for(int i=0; i<N-1; i++){
    cin >> B[i];
  }
  vector<long>A(N,10000000);
  for(int i=0; i<N-1; i++){
    if(A[i]>B[i])A[i] = B[i];
    A[i+1]=B[i];
  }
  long ans=0;
  for(int i=0; i<N; i++){
    ans+=A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
string s;
int main(){
  cin>>s;
  int ss=s.size();
  int res;
  rep1(i,ss/2){
    bool f=true;
    rep(j,ss/2-i){
      if(s[j]!=s[ss/2-i+j]){
	f=false;
	break;
      }
    }
    if(f){
      res=ss-2*i;
      break;
    }
  }
  prin(res);
  

  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()
total=0
for i in range(N):
    X=bisect.bisect_left(A, B[i])
    Y=len(C)-bisect.bisect_right(C, B[i])
    total+=X*Y
print(total)


Measured memory_bytes: 23232
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
      		int m2 = sc.nextInt();
		int k = sc.nextInt();
//計算
      if(m1>m2){
      h2-=1;
        m2+=60;
      }
      int h=0;
      h=h2-h1;
      int m=0;
      m=m2-m1;
      int total=0;
      total=(h*60)+m-k;
      
		// 出力
		System.out.println(total);
	}
}

Measured memory_bytes: 35664
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();

    let n = sc.parse::<usize>();
    let mut v = vec![0;n];
    for i in (0..n) {
        v[i] = sc.parse::<i32>();
    }
    v.sort();

    println!("{}", v[n - 1] - v[0]);
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 4352
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

arr = [a,b,c,d,e]

sum = 0
m = 10
arr.each do |i|
  sum += (i+9) / 10 * 10
  t = i % 10
  t += 10 if t == 0
  m = [m,t].min
end

if m == 10
  puts sum
else
  puts sum - 10 + m
end

Measured memory_bytes: 1788
class SegmentTree(object):
    def __init__(self, A, dot, unit):
        n = 1 << (len(A) - 1).bit_length()
        tree = [unit] * (2 * n)
        for i, v in enumerate(A):
            tree[i + n] = v
        for i in range(n - 1, 0, -1):
            tree[i] = dot(tree[i << 1], tree[i << 1 | 1])
        self._n = n
        self._tree = tree
        self._dot = dot
        self._unit = unit

    def __getitem__(self, i):
        return self._tree[i + self._n]

    def update(self, i, v):
        i += self._n
        self._tree[i] = v
        while i != 1:
            i >>= 1
            self._tree[i] = self._dot(self._tree[i << 1], self._tree[i << 1 | 1])

    def add(self, i, v):
        self.update(i, self[i] + v)

    def sum(self, l, r): #これで[l,r)から取り出す。
        l += self._n
        r += self._n
        l_val = r_val = self._unit
        while l < r:
            if l & 1:
                l_val = self._dot(l_val, self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                r_val = self._dot(self._tree[r], r_val)
            l >>= 1
            r >>= 1
        return self._dot(l_val, r_val)

N,x = map(int,input().split()); INF = float("inf")
A = list(map(int,input().split()))
A = A+A
Tree = SegmentTree(A, min, INF)
ans = INF
for kaisu in range(N):
  temp = kaisu*x
  for i in range(N):
    right = 2*N-i
    left = right - (kaisu+1)
    temp += Tree.sum(left, right)
  ans = min(ans,temp)
print(ans)
    


Measured memory_bytes: 70184
#include <cstdio>

typedef long long i64;

const int N = 100000 + 10;

int n, m;

int anc[N], col[N], size[N];
bool flag[N];

int find(int x) {
  if (anc[x] == x) return x;
  int y = find(anc[x]);
  col[x] ^= col[anc[x]];
  return anc[x] = y;
}

void meld(int x, int y) {
  int a = find(x), b = find(y);
  if (a == b) {
    flag[a] |= (col[x] == col[y]);
    return;
  }
  size[b] += size[a];
  anc[a] = b;
  col[a] ^= (col[x] == col[y]);
  flag[b] |= flag[a];
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) size[anc[i] = i] = 1;
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    meld(a, b);
  }
  int x = 0, y = 0, z = 0;
  for (int i = 1; i <= n; ++i) {
    if (find(i) == i) {
      if (size[i] == 1) ++x; else if (flag[i]) ++z; else ++y;
    }
  }
  i64 ans = 2LL * x * n - (i64)x * x;
  ans += 2LL * y * y;
  ans += 2LL * y * z;
  ans += (i64)z * z;
  printf("%lld\n", ans);
  return 0;
}


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

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll x = b/c;
    ll xx = (a-1)/c;
    ll y = b/d;
    ll yy = (a-1)/d;
    ll gun = c*d;
    ll gcd = __gcd(c,d);
    ll e = gun/gcd;
    ll z = b/e;
    ll zz = (a-1)/e;
    //cerr << "x " << x << " " << xx << " " << y << " " << yy << " " << z << " " << zz << endl;
    x-=xx;
    y-=yy;
    z-=zz;
    x+=y;
    ll mhn = b-a+1;
    //cerr << "Mhn " << mhn << endl;
    mhn-=x;
    //cerr << "Mhn " << mhn << endl;
    mhn+=z;
    //cerr << "Mhn " << mhn << endl;
    cout << mhn << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
  double a,b;
  int c;
  cin >> a >> b >> c;
  
  double S = 0.5*a*b*sin( c * M_PI / 180 );
  double L = a+b+((sqrt(a*a+b*b-2*a*b* cos( c * M_PI / 180 ))));
  
  printf("%.8f\n",S);
  printf("%.8f\n",L);
  printf("%.8f\n",2*(S/a));
  
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int ans=0;
  int x[100001]={0};
  repn(i,k){
    if(i==0) break;
    int a=i;
    int num=k/i;
    int p=n;
    int now=1;
    while(p!=0){
      if(p%2==0){
	num=(num*num)%MOD;
	p/=2;
      }else{
	now=(now*num)%MOD;
	p--;
      }
    }
    //cout<<"NOW "<<now<<endl;
    x[a]+=now;
    x[a]%=MOD;
    vector<int> y=divisor(a);
    rep(j,y.size() ){
      // cout<<y[j]<<endl;
      if(y[j]!=a){
	x[y[j]]-=x[a];
	while(x[y[j]]<0){
	  x[y[j]]+=MOD;
	}
      }
    }
    ans+=(x[a]%MOD)*(a%MOD)%MOD;
    ans%=MOD;

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


Measured memory_bytes: 4440
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    int N;
    long[] a;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Read();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        bool[] b = new bool[30];
        for(int i=0;i<30;i++){
            b[i] = false;
        }
        long xor = 0;
        for(int i=0;i<N;i++){
            xor ^= a[i];
            for(int j=0;j<30;j++){
                if((a[i] & (1 << j)) != 0){
                    b[j] = true;
                    break;
                }
            }
        }
        bool c = true;
        int count = 0;
        for(int i=30;i>=0;i--){
            if(((xor & (1 << i)) != 0 && c) || ((xor & (1 << i)) == 0 && !c)){
                c = !c;
                if(b[i]){
                    count++;
                }
                else{
                    count = -1;
                    break;
                }
            }
        }
        sb.Append(count+"\n");
    }
    void Read(){
        N = int.Parse(Console.ReadLine());
        a = new long[N];
        for(int i=0;i<N;i++){
            a[i] = Int64.Parse(Console.ReadLine());
        }
    }    
}

Measured memory_bytes: 7512
N = int(raw_input())
dict = {}
ran = map(chr, range(97,97+26))
for c in ran:
    dict[c] = 51
for i in range(0,N):
    r = raw_input()
    for h in ran:
        dict[h] = min(dict[h], r.count(h))
out = ""
for c in ran:
    out +=  "".join([c for x in xrange(dict[c])])
print out

Measured memory_bytes: 2568
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

result = 0
for A in combinations_with_replacement(range(1, M + 1), N):
#1,2,...,Mの数列から重複込みでN文字の文字列を作る
    t = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            t += d
    result = max(result, t)
print(result)

Measured memory_bytes: 9068
n = int(input())
number = list(map(int,input().split()))
count = 0
for i in range(1,n + 1):
    for j in range(1,i):
        
        if number[i - j] < number[i - j - 1]:
            number[i - j],number[i - j - 1] = number[i - j - 1],number[i - j]
            count += 1
number = list(map(str,number))
print(" ".join(number))
print(count)

Measured memory_bytes: 7708
#include <iostream>
#include <utility>

using namespace std;

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

  int max_bp = 1;
  for (int b=2; b*b<=X; ++b) {
    int bp = b;
    while(bp <= X) {
      max_bp = max(max_bp, bp);
      bp *= b;
    }
  }
  cout << max_bp << endl;
  
  return 0;
}

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

const int MAX_N = 202020;
const ll INF = 1LL<<60;

int n, m;
ll sum;
vector<pair<ll, P>> G;
vector<P> mst;

struct UnionFind {
  vector<int> data;
  
  UnionFind(int sz)
  {
    data.assign(sz, 0);
    for(int i = 0; i < sz; i++) data[i] = i;
  }
  
  int root(int x)
  {
    if(data[x] == x) return x;
    else return data[x] = root(data[x]);
  }
  
  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    data[x] = y;
  }
  
  bool same(int x, int y)
  {
    return root(x) == root(y);
  }
};

void kruskal()
{
  UnionFind uf(n);
  sum = 0;
  for(auto e : G)
  {
    ll cost = e.first;
    int from = e.second.first, to = e.second.second;
    if(!uf.same(from, to))
    {
      uf.unite(from, to);
      sum += cost;
      mst.emplace_back(P(from, to));
    }
  }
}

void init()
{
  cin >> n >> m;
  rep(i,m)
  {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    G.emplace_back(pair<ll, P>(c, P(a, b)));
  }
  sort(G.begin(), G.end());
  
  return;
}

void put()
{
  cout << sum << endl;
  return;
}

int main()
{
  init();
  kruskal();
  put();
  return 0;
}


Measured memory_bytes: 4924
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int bingo[3][3];
    REP(i,3)REP(k,3)cin>>bingo[i][k];
    int N;cin>>N;
    vector<int> b;
    REP(i,N){
        int k;cin>>k;
        b.push_back(k);
    }
    REP(i,3){
        bool isG = true;
        REP(k,3){
            if(find(b.begin(),b.end(),bingo[i][k])==b.end())isG=false;
        }

        if(isG){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    REP(i,3){
        bool isG = true;
        REP(k,3){
            if(find(b.begin(),b.end(),bingo[k][i])==b.end())isG=false;
        }

        if(isG){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(find(b.begin(),b.end(),bingo[1][1])!=b.end()){
        if(find(b.begin(),b.end(),bingo[0][0])!=b.end()){
            if(find(b.begin(),b.end(),bingo[2][2])!=b.end()){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        if(find(b.begin(),b.end(),bingo[0][2])!=b.end()){
            if(find(b.begin(),b.end(),bingo[2][0])!=b.end()){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    int ans = n*2;
    for(int i=n;i>0;i--){
        if(s.substr(n-i,i)==t.substr(0,i)){
            ans = n*2-i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, Q, *A = map(int, read().split())
point = [K - Q] * (N + 1)

for i in A:
    point[i] += 1
ans = '\n'.join('Yes' if i > 0 else 'No' for i in point[1:])
print(ans)


Measured memory_bytes: 11624
fun main(arr: Array<String>) {
    val s = readLine()!!.toLong()
    val log = mutableSetOf(s)
    var current = s
    while (true) {
        if(current % 2 == 0L) {
            current /= 2
        } else {
            current = current * 3 + 1
        }
        if(log.contains(current)) {
            println(log.size + 1)
            return
        } else {
            log.add(current)
        }
    }
}

Measured memory_bytes: 38920
n, m = map(int, input().split())
L = list(map(int, input().split()))
lim = sum(L)/(4*m)
c = 0
for i in range(n):
    if L[i] >= lim:
        c = c + 1
if c >= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

vector<int> v[26];

int64_t foo(const char *s, int n) {
    if (n == 1) return 1;
    return foo(s, n - 1) + n - 1 - v[s[n - 1] - 'a'][n - 2];
}

int main() {
    string a;
    cin >> a;
    int n = (int)a.size();

    for (int i = 0; i < 26; i++) {
        v[i] = vector<int>(n);
        int r = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] == 'a' + i) r++;
            v[i][j] = r;
        }
    }

    cout << foo(a.c_str(), n) << endl;

    return 0;
}

Measured memory_bytes: 27140
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem069c(n, a))
}
 
fun problem069c(n: Int, a: List<Long>): String {
    val fourCount = a.count { it % 4 == 0L }
    val twoCount = a.count { it % 4 == 2L }
    val oneCount = a.count { it % 2 == 1L }
    // 「2の倍数だけど、4の倍数ではない」数はたくさんあっても1つあるのとおなじ
    // if(twoCount >= 1) 1 else 0
  
    // このままだと4の倍数にならない数たちの個数
    // oneCount + ( if(twoCount >= 1) 1 else 0 )
  
    // これらを4の倍数のとなりに置く
    // 4の倍数のとなりは fourCount + 1 個
  
    // 例えば...
    // [1] 4 [5] 4 [2 2 2 6 10] 8 [7] 12 [9]
    return if (oneCount + ( if(twoCount >= 1) 1 else 0 ) <= fourCount + 1) "Yes" else "No"
}


Measured memory_bytes: 50024
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
 
c = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    c += bisect.bisect_right(L, L[i]+L[j]-1) - j - 1


print(c)

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

typedef pair<pair<int, int>, int> PP;

int main() {
	int L;
	cin >> L;
	int r = log2(L), count = 0;
	vector<PP> V;
	cout << r + 1 << " ";
	for (int i = 1; i <= r; i++) {
		V.push_back({ { i, i + 1 }, 0 });
		V.push_back({ {i, i + 1}, (int)pow(2, i - 1) });
	}
	for (int i = r; i >= 1; i--) {
		if (L - pow(2, i - 1) >= pow(2, r)) {
			V.push_back({ {i, r + 1}, L - (int)pow(2, i - 1) });
			L -= pow(2, i - 1);
			count++;
		}
	}
	cout << 2 * r + count << endl;
	for (auto it = V.begin(); it != V.end(); it++) {
		cout << it->first.first << " " << it->first.second << " " << it->second << endl;
	}
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){

int a[20000],b[20000],i=0;

char op[20000];

	for(i=0;i<20000;i++){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op == 0)break;
		
		else if(op[i] == '+'){
			printf("%d\n",a[i]+b[i]);
		}
		
		else if(op[i] == '-'){
			printf("%d\n",a[i]-b[i]);
		}
		
		else if(op[i] == '*'){
			printf("%d\n",a[i]*b[i]);
		}
		
		else if(op[i] == '/'){
			printf("%d\n",a[i]/b[i]);
		}
	}
return 0;
}


Measured memory_bytes: 2048
n = int(input())
Ps = [tuple(map(int, input().split())) for i in range(n)]
Qs = [tuple(map(int, input().split())) for i in range(n)]

Qs.sort()

ans = 0
for i in range(n):
    #l:PsのうちQs[i]とペアになれるものと、そのインデックス
    l = [(Ps[j], j)
         for j in range(len(Ps))
         if Ps[j][0] <= Qs[i][0] and Ps[j][1] <= Qs[i][1]]

    #なかったらなにもしない
    if l == []: continue

    # 条件を満たすもののうち最もy座標が大きいものとそのPsでのインデックス
    E = max(l, key=(lambda e: e[0][1]))
    del Ps[E[1]]
    ans += 1
print(ans)


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	a := 0
	for i := 1; i <= k; i++ {
		a *= 10
		a += 7
		a %= k
		if a%k == 0 {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int s = sc.nextInt();
            if(x == 0 && y == 0 && s == 0){
                break;
            }
            int maxvalue = 0;
            for(int c1 = 1;c1 < s;c1++){
                for (int c2 = 1;c2 < s;c2++){
                    if (consumption(c1,x)+consumption(c2,x) == s){
                        if (consumption(c1,y)+consumption(c2,y)> maxvalue){
                            maxvalue = consumption(c1,y)+consumption(c2,y);
                        }
                    }
                }
            }
            System.out.println(maxvalue);
        }
    }
    static int consumption(int c,int a){
        return((int)Math.floor((double)c*(double)(100+a)/100));
    }
}

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

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

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) { return power(x, MOD - 2); }

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> isum(N + 1, 0);
    for (int i = 1; i <= N; i++) {
      isum[i] = (isum[i - 1] + inverse(i)) % MOD;
    }
    ll res = 0;
    for (int i = 0; i < N; i++) {
      ll coef = 0;
      coef = (coef + isum[i + 1]) % MOD;
      coef = (coef + isum[N - i]) % MOD;
      coef = (coef - 1 + MOD) % MOD;
      res = (res + coef * A[i] % MOD) % MOD;
    }
    for (int i = 1; i <= N; i++) res = res * i % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))

B=A[::-1]

for i in range(1,N):
    if B[i]<=B[i-1]:
        pass
    else:
        if B[i]==B[i-1]+1:
            B[i]-=1
        else:
            print("No")
            exit()
print("Yes")

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

int main() {
    long long n = 0, ncopy = 0;
    cin >> n;
    ncopy = n;
    int digit = 0, sum = 0;
    while(n > 0){
        digit = n % 10;
        n /= 10;
        sum += digit;
    }

    if(ncopy % sum == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}
random_device rd;
mt19937 generator(rd());

vector <double> u(4), post_u(2);
ofstream ofs("logit.csv", ios::out);
vector<double> a;
normal_distribution<double> dist_normal(0.0, 1);
double logit_normal(double y, double myu, double var){
    //yからxの値を逆算
    double ma = 1.0, mi = 0.0;
    while(ma - mi > 0.001){
        double mid = (ma + mi) / 2;
        if( log(mid/(1.0-mid)) > y) ma = mid;
        else mi = mid;
    }
    double res = 1.0/(sqrt(var * 2 * PI)) * 1.0/(mi * (1.0 - mi)) * exp(-(y - myu)*(y - myu)/(2.0*var));
    return mi;
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    
    int K,A,B;cin>>K>>A>>B;
    repk(i,A,B+1){
        if(i%K==0) OK;
    }
NG
}

Measured memory_bytes: 3764
import sys
readline = sys.stdin.readline

candi = []
N, M, Q = map(int, readline().split())

def pp(res, i, j):
    rr = res + [i]
    if j == 0:
        candi.append(res)
        return 
    else:
        for st in range(i, M+1):
            pp(rr, st, j-1)

for i in range(1, M+1):
    pp([], i, 10)


ABCD = [list(map(int, readline().split())) for  _ in range(Q)]

ans = 0
for k in candi:
    res = 0
    for a, b, c, d in ABCD:
        if k[b-1] - k[a-1] == c:
            res += d
    ans = max(res, ans)
print(ans)

Measured memory_bytes: 103020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  
  ll A=INF;
  chmin(A,4*Q);
  chmin(A,2*H);
  chmin(A,S);
  
  if(2*A<D) co(A*N);
  else co(N/2*D+(N%2)*A);
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a*b % 2 == 0){
			System.out.println("No");
		}else{
			System.out.println("Yes");

		}


	}


}




class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
   int n;
   cin>>n;
   int cnt =0;
   range(i,1,n-1){
       range(j,1,n-1){
           int temp = i*j;
           if(temp>=n)break;
           else {
              cnt++;
           }
       }
   }
   cout<<cnt<<endl;

   
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

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

int main(){
  int n, x = 0, ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s.substr(i, 1) == "I") {
      x++;
    } else {
      x--;
    }
    if (x > ans) ans = x;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    long input[3];
    long len = sizeof(input) / sizeof(long);
    long hen_1, hen_2;
    long men;

    cin >> input[0] >> input[1] >> input[2];
    sort(input, input+len, greater<long>());
    men = input[1] * input[2];
    hen_1 = input[0] / 2;
    hen_2 = input[0] - hen_1;
    cout << abs(men * hen_1 - men * hen_2) << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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" ) } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }

#[allow(dead_code)]
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[allow(unused_macros)]
macro_rules ! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }
#[allow(unused_macros)]
macro_rules ! chmax {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_max = max ! ($ ($ cmps ) ,+ ) ; if $ base < cmp_max {$ base = cmp_max ; true } else {false } } } ; }

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut l = vec![0; n + 1];
    let mut r = vec![0; n + 1];
    for i in 0..n {
        l[i + 1] = gcd(l[i], a[i]);
        r[n - i - 1] = gcd(r[n - i], a[n - i - 1]);
    }

    let mut ret = 1;
    for i in 0..n {
        chmax!(ret, gcd(l[i], r[i + 1]));
    }

    println!("{}", ret);
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll k;
    cin>>k;

    auto snuke=[&](ll x)->long double{
        ll y=x;
        ll s=0;
        while(y){
            s+=y%10;
            y/=10;
        }
        return (long double)x/(long double)s;
    };

    ll num=0;
    ll diff=1;

    while(k>0){
        while(true){
            num+=diff;
            cout<<num<<en;
            k--;
            if(k<=0) break;
            ll x = (num/diff)%10;
            //cout<<num<<" "<<x<<en;
            if(x==9){
                break;
            }
        }
        if(k<=0) break;
        //cout<<diff*10+num<<" "<<snuke(diff*10+num)<<":"<<diff+num<<" "<<snuke(diff+num)<<en;
        if(snuke(diff*10+num)>=snuke(diff+num)){
            num+=diff;
            cout<<num<<en;
            k--;
            continue;
        }
        if(snuke(diff*10+num)<snuke(diff+num)) diff*=10;
        
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for len(S) > 0 {
		if S[len(S)-5:] == "erase" || S[len(S)-5:] == "dream" {
			S = S[:len(S)-5]
			continue
		}
		if S[len(S)-6:] == "eraser" {
			S = S[:len(S)-6]
			continue
		}
		if S[len(S)-7:] == "dreamer" {
			S = S[:len(S)-7]
			continue
		}
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

}


Measured memory_bytes: 1280
n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
w = [wv[i][0] for i in range(n)]
v = [wv[i][1] for i in range(n)]
inf = float('inf')
# dp[i][weight] 
# := i-1番目までの品物で重さweightを超えないように選んだときの価値の総和の最大値
dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
for i in range(n):
    for sum_w in range(W+1):
        if sum_w - w[i] >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[n][W])


Measured memory_bytes: 172552