akhauriyash/Code-Regression huggingface dataset:
# include <stdio.h>
# include <string.h>
# include <algorithm>
// # include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int M = 5e5 + 10;
const int mod = 1e9+7;

# define FO_OPEN 0
# define RG register
# define ST static

int n, q;
ll add[M], st[M], s[M], cur;
int stn=0;

int main() {
	FO_OPEN ? freopen(".in", "r", stdin), freopen(".out", "w", stdout) : 0;
	scanf("%d%d", &n, &q);
	st[++stn] = n;
	for (int i=1; i<=q; ++i) {
		scanf("%lld", &cur);
		while(stn && st[stn] >= cur) --stn;
		st[++stn] = cur; 
	}
	
	add[stn] = 1;
	for (int i=stn; i>1; --i) {
		if(!add[i]) continue;
		ll x = st[i];
		while(x >= st[1]) {
			int pos = upper_bound(st+1, st+stn+1, x) - st - 1;
			pos = min(pos, i-1);
			add[pos] += add[i] * (x/st[pos]);
			x = x % st[pos];
		}
		s[x] += add[i];
		add[i] = 0;
	}
	
	s[st[1]] += add[1];
	for (int i=n; i; --i) 
		s[i] += s[i+1];
	for (int i=1; i<=n; ++i)
		printf("%lld\n", s[i]);
	return 0;
}





Measured memory_bytes: 10624
def selection_sort(array):
    count_swap = 0
    for i in range(len(array)):
        minj = i
        for j in range(i + 1,len(array)):
            if array[j] < array[minj]:
                minj = j
        if array[minj] is not array[i]:
            tmp = array[minj]
            array[minj] = array[i]
            array[i] = tmp
            count_swap += 1
    return count_swap


def print_array(array):
     print(str(array)[1:-1].replace(', ', ' '))


def main():
    N = int(input())
    array = [int(s) for s in input().split(' ')]
    count = selection_sort(array)
    print_array(array)
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7752
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


using namespace std;

#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}

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

    eratosthenes();

    // REP(i,10){
    //     cout<<i<<":"<<arr[i]<<endl;
    // }

    REP(i,N){
        if(arr[i]==1&&arr[(i+1)/2]==1){
            a[i]=1;
        }
    }

    for(int i=1;i<N;i++){
        a[i]+=a[i-1];
    }

    for(int i=0;i<n;i++){
        int left,right;
        cin>>left>>right;

        int ans=a[right]-a[left-1];
        cout<<ans<<endl;

    }
    
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
#define rep(i, a) for(int i = 0; i < a; ++i)

int main(void) {
  char s[1500];
  int i, ans = 0;
  while( 1 ) {
  ans = 0;
  scanf("%s", s);
  if(strlen(s) == 1 && s[0] == '0') break;
  rep(i, strlen(s)) ans += s[i] - '0';
  printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2728
S = gets.chomp.chars.map(&:to_i)

def dfs(nums, n, acc)
  return acc + n if nums.empty?
  rest = nums.drop(1)
  dfs(rest, nums[0], acc + n) \
    + dfs(rest, n * 10 + nums[0], acc)
end

puts dfs(S.drop(1), S[0], 0)

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

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

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  long int a,b,c,d;
  scanf("%ld%ld%ld%ld",&a,&b,&c,&d);
  long int max=-1e18;
  if(max<a*c){
    max=a*c;
  }
  if(max<a*d){
    max=a*d;
  }
  if(max<b*c){
    max=b*c;
  }
  if(max<b*d){
    max=b*d;
  }
  printf("%ld\n",max);
  return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int MAX_N = 100000;

vector<int> graph[MAX_N];
int n, k;

ll dfs(int node, int par) {
    ll ret = 1LL;
    int n_color = k-1;
    if(par != -1) --n_color;
    for(int child: graph[node]) {
        if(child == par) continue;
        ret *= n_color--;
        ret %= MOD;
        ret *= dfs(child, node);
        ret %= MOD;
    }
    // cerr << node+1 << ": " << ret << endl;
    return ret;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    int x,y;
    for(int i=0;i<n-1;++i){
        cin >> x >> y;
        --x; --y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    cout << (k*dfs(0, -1))%MOD << endl;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
int modexp(int x,int n,int mod){
	x%=mod;
	int res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return res;
}
int modInverse(int n, int p)
{ 
    return modexp(n, p - 2, p); 
} 
int nCr(int n,int r, int p) 
{ 
    if (r == 0) 
        return 1; 
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
signed main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int num=7;
		int ans=1;
		bool ok=true;
		int prev=7;
		if(n%2==0||n%5==0)
		{
			cout<<-1<<endl;
			return 0;
		}
		int t=1000005;
		while(t--)
		{
			num=num*10+7;
			ans++;
			if(num%n==0) break;
			else num=num%n;
			prev=num;
		}
		if(n==1) cout<<1<<endl;
		else if(n==7) cout<<1<<endl;
		else if(ans>n) cout<<-1<<endl;
		else if(ok) cout<<ans<<endl;
		else cout<<-1<<endl;
   }
   return 0;
}

Measured memory_bytes: 3636
// Problem : C - ThREE
// Contest : AtCoder - Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020
// URL : https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 1;

int n, c[N];
bool vis[N];
vector<int> v[3], adj[N];

void dfs(int v, bool cur = 0) {
	vis[v] = 1;
	c[v] = cur;
	for (auto& u : adj[v]) {
		if (c[u] != -1 && c[u] == cur) {
			cout << -1;
			exit(0);
		}
		if (vis[u]) continue;
		dfs(u, cur ^ 1);
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(c, -1, sizeof c);
	dfs(1);
	int l = 0, r = 0;
	for (int i = 1; i <= n; i++) {
		if (!c[i]) l++;
		else r++;
		if (i % 3 == 0) {
			v[0].push_back(i);
		} else if (i % 3 == 1) {
			v[1].push_back(i);
		} else {
			v[2].push_back(i);
		}
	}
	if (l > r) {
		for (int i = 1; i <= n; i++) {
			c[i] ^= 1;
		}
		swap(l, r);
	}
	if (l <= n / 3) {
		for (int i = 1; i <= n; i++) {
			if (!c[i] && !v[0].empty()) {
				cout << v[0].back();
				v[0].pop_back();
			} else if (!v[1].empty()) {
				cout << v[1].back();
				v[1].pop_back();
			} else if (!v[2].empty()) {
				cout << v[2].back();
				v[2].pop_back();
			} else {
				cout << v[0].back();
				v[0].pop_back();
			}
			cout << ' ';
		}
	} else {
		for (int i = 1; i <= n; i++) {
			if (!c[i] && !v[1].empty()) {
				cout << v[1].back();
				v[1].pop_back();
			} else if (c[i] && !v[2].empty()) {
				cout << v[2].back();
				v[2].pop_back();
			} else {
				cout << v[0].back();
				v[0].pop_back();
			}
			cout << ' ';
		}
	}
}

Measured memory_bytes: 19576
n=int(input())
a=list(map(int,input().split()))
a.sort()
judge=True
if n%2!=0:#奇数のとき
	if a[0]==0:
		for i in range(1,n//2+1):
			if a[i*2-1]!=i*2 or a[i*2]!=i*2:
				judge=False
				break
	else:
		judge=False
	if judge:
		ans=2**(n//2)
	else:
		ans=0

else:
	for i in range(n//2):
		if a[i*2]!=i*2+1 or a[i*2+1]!=i*2+1:
			judge=False
			break
	if judge:
		ans=2**(n//2)
	else:
		ans=0
		
print(ans%1000000007)

Measured memory_bytes: 14008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long M = 1_000_000_007L;
		int n = sc.nextInt();
		sc.nextLine();
		char[] s = sc.nextLine().toCharArray();
		char[] t = sc.nextLine().toCharArray();
		List<Integer> c = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			if (s[i] == t[i]) {
				c.add(0);
			} else {
				c.add(1);
				i++;
			}
		}

		long a;
		if (c.get(0) == 0) {
			a = 3;
		} else {
			a = 6;
		}

		for (int i = 1; i < c.size(); i++) {
			int prev = c.get(i - 1);
			int x = c.get(i);
			if (prev == 1) {
				if (x == 0) {
					a *= 1;
				} else {
					a = (a * 3) % M;
				}
			} else {
				a = (a * 2) % M;
			}
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 21844
n,d=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))

count=0
for i in range(n):
    for j in range(i+1,n):
        s=0
        for k in range(d):
            s+=(a[i][k]-a[j][k])**2
        if s**0.5-int(s**0.5)==0:
            count+=1
print(count)

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

using namespace std;

int main() {
    int a, b, n;
    while (scanf("%d %d %d", &a, &b, &n) != EOF) {
        if (a == b) {
            cout << 0 << endl;
            continue;
        }
        if (a > b) a %= b;

        int ans = 0;
        for (int i = 0; i < n; i++) {
            a *= 10;
            ans += a / b;
            a %= b;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int n;
vi A(100);

int main() {
	cin >> n;
	Loop(i, n) cin >> A[i];
	sort(A.begin(), A.begin() + n);
	int m = A[0], M = A[n - 1];
	int ret = INF;
	for (int i = m;i <= M;i++) {
		int buf = 0;
		Loop(j, n) {
			buf += (A[j] - i)*(A[j] - i);
		}
		ret = min(ret, buf);
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array);
ll tens[200005];
ll MOD;
void pre(){
    tens[0]=1;
    FOR(i,1,200005){
        tens[i]=((tens[i-1]%MOD)*(10%MOD))%MOD;

    }

}


int main(){
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;

    MOD=p;
    ll ans=0;
    if(p==2||p==5){
        fo(i,sz(s)){
            if((s[i]-'0')%p==0) ans+=(i+1);
          
        }
        cout<<ans<<endl;

    }
    else{
        pre();
        ll count[p];
        fo(i,p) count[i]=0;
        ll tmp=0;
        ll len=sz(s);
        fo(i,sz(s)){
            tmp=(tmp+(((s[i]-'0')%MOD)*(tens[len-1-i]%MOD))%MOD+MOD)%MOD;
            count[tmp]++;
        }
        for(auto j:count){
            if(j>1) ans=ans+((j)*(j-1))/2;
        }
        ans=ans+count[0];
        cout<<ans<<endl;

    }
    
}

Measured memory_bytes: 2180
fun main(args: Array<String>) = yorukatsu8e()

fun yorukatsu8e() {
    val (n, t) = readLine()!!.split(' ').map { it.toInt() }
    val foods = (1..n).map {
        readLine()!!.split(' ').map { it.toInt() }.let { Food(it[0], it[1]) }
    }.sortedBy { it.time }

    val dp = Array(n + 1) { IntArray(t) }
    var answer = 0

    for (i in 1..n) {
        val food = foods[i - 1]
        for (time in 0 until t) {
            dp[i][time] = dp[i - 1][time]
            answer = Math.max(answer, dp[i][time] + food.point)
            if (time - food.time >= 0) {
                dp[i][time] = Math.max(
                    dp[i][time],
                    dp[i - 1][time - food.time] + food.point
                )
            }
        }
    }

    println(answer)
}

private data class Food(val time: Int, val point: Int)


Measured memory_bytes: 85944
#include<iostream>
using namespace std;
int main(){
  int n,a[100];
  cin >>n;
  for(int i=0;i<n;i++)cin >>a[i];
  for(int i=n-1;i>0;i--)cout <<a[i]<<" ";
  cout <<a[0]<<endl;
  return 0;
}
 

Measured memory_bytes: 1160
I = input().split()
a = int(I[0])
e = I[1]
b = int(I[2])

while(True):
    if(e == '+'):
        print(a + b)
    if(e == '-'):
        print(a - b)
    if(e == '*'):
        print(a * b)
    if(e == '/'):
        print(int((float(a) / float(b))))
    if(e == '?'):
        break
    I = input().split()
    a = int(I[0])
    e = I[1]
    b = int(I[2])

Measured memory_bytes: 7732
use std::io::*;
use std::collections::*;

fn main(){
    let n : usize = input();
    let m : usize = input();
    let mut e : Vec<Vec<usize>> = vec![vec![]; n * 3];
    for _ in 0..m{
        let mut u : usize = input();
        let mut v : usize = input();
        u -= 1;
        v -= 1;
        e[u].push(v + n);
        e[u + n].push(v + n * 2);
        e[u + n * 2].push(v);
    }
    let mut s : usize = input();
    let mut t : usize = input();
    s -= 1;
    t -= 1;
    let mut d : Vec<isize> = vec![std::isize::MAX; n * 3];
    d[s] = 0;
    let mut q : VecDeque<usize>= VecDeque::new();
    q.push_back(s);
    while !q.is_empty(){
        let t = q.pop_front().unwrap();
        for i in &e[t]{
            if d[*i] > (d[t] + 1){
                d[*i] = d[t] + 1;
                q.push_back(*i);
            }
        }
    }
    let ans = if d[t] != std::isize::MAX {d[t] / 3}else{-1};
    println!("{}", ans);
}
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()
}

Measured memory_bytes: 24828
import math
A, B, H, M = map(int,input().split())
Ha = H*math.pi/6 + M*math.pi/360
Ma = M*math.pi/30
if Ha == Ma:
    print(abs(A-B))
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(Ha-Ma)))

Measured memory_bytes: 9392
#import sys
#input = sys.stdin.readline
 
n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))
    value.append([A, c])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        if dp[t] > cost:
            dp[t] = cost
        
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])

Measured memory_bytes: 3300
n=gets.to_i
h=gets.split.map(&:to_i)

dp=Array.new(n+1,0)
dp[1]=(h[1]-h[0]).abs
1.upto(n-2) do |i|
    dp[i+1]=[dp[i]+(h[i+1]-h[i]).abs,dp[i-1]+(h[i+1]-h[i-1]).abs].min
end
puts dp[n-1]


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


int main(){
  int n,l,sum=0; cin>>n>>l;
  int min=1000;

  for(int i=0;i<n;i++){
    int aji;
    aji=l+i;
    sum+=aji;
    if(abs(aji)<abs(min))min=aji;
  
  }
 
   cout<<sum-min<<endl;
}

Measured memory_bytes: 256
i = list(map(int, input().split()))
N = i[0]
M = i[1]
A = list(map(int, input().split()))
A_A = A.copy()
A_A.sort(reverse=True)
count = 0

total = sum(A)
touhyousuu = 1 / (4 * M)
wari = total * touhyousuu

for j in range(M):
    if A_A[j] < wari:
        count += 1


if count >= 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main(void){
  int n, t, a, i, ans=0;
  double h, diff, x;
  scanf("%d%d%d", &n, &t, &a);
  scanf("%lf", &h);
  diff=fabs((t-(0.006*h))-a);
  for( i=1; i<n; i++){
    scanf("%lf", &h);
    x=fabs((t-(0.006*h))-a);
    if(x<diff){
      diff=x;
      ans=i;
    }
  }
  printf("%d\n", ans+1);
  return 0;
}
  

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

int main() {
	vector<int> used(4);
	int a,b;
	cin >> a >> b;
	used[a] = used[b] = true;
	
	for(int i = 1; i <= 3;i++)
		if(!used[i]){
			cout << i << endl;
		}
	return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    if ((A == 1 && B == 2) || (A == 2 && B == 1))
    {
        cout << "3" << endl;
    }
    else if ((A == 1 && B == 3) || (A == 3 && B == 1))
    {
        cout << "2" << endl;
    }
    else if ((A == 2 && B == 3) || (A == 3 && B == 2))
    {
        cout << "1" << endl;
    }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        r:f64,
    }
    println!("{}", r * 2f64 * 3.14159265);
}


Measured memory_bytes: 2224
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)3e3 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

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

char s[maxn], t[maxn];
int dp[maxn][maxn];
PII pre[maxn][maxn];
char ans[maxn];
int tot = 0;

void output(int i, int j){
	if(!i && !j) return ;
	if(dp[i][j] == dp[pre[i][j].fi][pre[i][j].se] + 1) {
		ans[++tot] = s[i];
	}
	output(pre[i][j].fi, pre[i][j].se);
}

int main()
{
	scanf("%s %s", s + 1, t + 1);
	int n = strlen(s + 1), m = strlen(t + 1);
	rep(i, 1, n) rep(j, 1, m){
		if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1, pre[i][j] = mp(i - 1, j - 1);
		else {
			if(dp[i-1][j] > dp[i][j-1]) dp[i][j] = dp[i-1][j], pre[i][j] = mp(i - 1, j);
			else dp[i][j] = dp[i][j-1], pre[i][j] = mp(i, j - 1);
		}
	}
	output(n, m);
	Rep(i, tot, 1) printf("%c", ans[i]);
	if(tot) puts("");
	return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

ll a[2000005] , pos[200005];

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

    ll n,k,st=0;
    cin >> n >> k;

    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        if (a[i] == 1) st=i;
    }

    ll ans=0;
    for(int i=1; i<n; i+=(k-1))
    {
        ans++;
    }

    cout << ans;


    return 0;
}

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

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

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

  double d;
  cin >> d;

  double ans = sqrt(2.0) * d;
  for ( int i = 0; i <= 100; i++ ) {
    for ( int j = 0; j <= 100; j++ ) {
      int ab = abs(i-j);
      if ( ab > d ) continue;      
      double b = sqrt(d*d - ab*ab);
      if ( b < 1.0 ) b = 1.0;
      ans = max(ans, ab+b);      
    }
  }

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



Measured memory_bytes: 3296
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

count = 0
for i in range(N):
    if B[i] <= A[i]:
        count += B[i]
    else:
        count += A[i] + np.minimum((B[i] - A[i]), A[i+1])
        A[i+1] -= np.minimum((B[i] - A[i]), A[i+1])
print(count)

Measured memory_bytes: 27260
#include <stdio.h>
#include <math.h>

int main(void) {
	int n, memo, ans = 0;

	scanf("%d", &n);

	memo= (int)log10(n)+1;
	for (int i = 1; i < memo; ++i) {
		if (i % 2 == 1) {
			ans += 9 * pow(10, i - 1);
		}
	}
	if (memo % 2 == 1) {
		ans += n - pow(10, memo - 1)+1;
	}
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=51;
const int Dl=2501;
const int P=1e9+7;

int f[N][N][2*N*N];

int main()
{
	int n,m,i,j,k;
	scanf("%d%d",&n,&m);
	f[0][0][Dl]=1;
	for(i=1;i<=n;i++)
		for(j=0;j<i;j++)
			for(k=-n*n;k<=n*n;k++){
				if(j&&k+2*i<=n*n)(f[i][j-1][k+2*i+Dl]+=1ll*f[i-1][j][k+Dl]*j*j%P)%=P;
				(f[i][j][k+Dl]+=1ll*f[i-1][j][k+Dl]*(2*j+1)%P)%=P;
				if(k-2*i>=-n*n)(f[i][j+1][k-2*i+Dl]+=f[i-1][j][k+Dl])%=P;
			}
	printf("%d",f[n][0][m+Dl]);
	return 0;
}

Measured memory_bytes: 51072
import java.util.*;

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

    int N = sc.nextInt();
    int L = sc.nextInt();
    
    List<String> ary = new ArrayList();

    for(int i = 0; i < N; i++) {
        String str = sc.next();
        
        if(str.length() == L) {
            ary.add(str);
        }
    }
    
    Collections.sort(ary);
    
    String res = String.join("",ary);

    System.out.println(res);
 
  }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

int cap[1010][1010];
int flow[1010][1010];

bool used[1010];
vector<int> G[1010];
int N;

int dfs(int v,int t,int f){
//	printf("%d %d %d\n",v,t,f);
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i];
		if(used[u]) continue;
		int x=(cap[v][u]-flow[v][u])+flow[u][v];
		int nf=min(f,x);
		if(nf==0) continue;
		int ret=dfs(u,t,nf);
		if(ret>0){
			int tmp=cap[v][u]-flow[v][u];
			if(ret<=tmp){
				flow[v][u]+=ret;
			}else{
				flow[v][u]=cap[v][u];
				flow[u][v]-=(ret-tmp);
			}
			return ret;
		}
	}
	return 0;
}

bool can_reach[2][1010];

queue<int> que;
void bfs(int s,bool *res,bool rev){
	while(!que.empty()) que.pop();
	for(int i=0;i<1010;i++) res[i]=false;
	que.push(s);
	res[s]=true;
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			int u=G[v][i];
			if(res[u]) continue;
			if(!rev){
				int x=(cap[v][u]-flow[v][u])+flow[u][v];
				if(x<=0) continue;
			}else{
				int x=(cap[u][v]-flow[u][v])+flow[v][u];
				if(x<=0) continue;
			}
			res[u]=true;
			que.push(u);
		}
	}
}

int maxFlow(int s,int t){
	int res=0;
	while(true){
		for(int i=0;i<1010;i++) used[i]=false;
		int f=dfs(s,t,100100);
		if(f==0) return res;
		res+=f;
	}
	return -1;
}

int S,T;

int count(){
	bfs(S,can_reach[0],false);
	bfs(T,can_reach[1],true);
	int res=0;
	for(int i=0;i<N;i++) for(int j=0;j<N;j++){
		if(i==j) continue;
		if(can_reach[0][i]&&can_reach[1][j]){
			res+=cap[j][i];
		}
	}
	if(res>0) return res;
	else return -1;
}

void solve(){
	int flow=maxFlow(S,T);
	int num=count();
	if(num>0){
		printf("%d %d\n",flow+1,num);
	}else{
		printf("%d %d\n",flow,0);
	}
}

void init(){
	for(int i=0;i<N;i++) for(int j=0;j<N;j++){
		cap[i][j]=0;
		flow[i][j]=0;
	}
	for(int i=0;i<N;i++){
		G[i].clear();
	}
}

void input(){
	init();
	int M;
	scanf("%d%d",&N,&M);
	scanf("%d%d",&S,&T);
	if(S==0&&T==0) exit(0);
	S--;T--;
	for(int i=0;i<M;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
		cap[u][v]++;
	}
}

int main(){
	while(true){
		input();
		solve();
	}
	return 0;
}

Measured memory_bytes: 9244
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int a; cin >> a;
    dunk(pow(a,2)+a+pow(a,3));
    return 0;
}

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

template<typename T>
class SegTree{
    //const T identity_element = 0; // additive identity
    //const T identity_element = 1LL; // multiplicative identity
    const T identity_element = numeric_limits<int>::max(); // identity element for min()
    //const T identity_element = -1e9; // identity element for max()
    //static const T mod = 1e9+7;
    static T combine(T L, T R){
        //return (L + R) % mod;  // modify this code.
        //return (L * R) % mod;
        return min(L, R);
        //return max(L, R);
    }
    size_t n;
    vector<T> data;
public:
    SegTree(size_t _n): n(_n), data(vector<T>(2 * _n, identity_element)) {}
    SegTree(const vector<T> &src): n(src.size()), data(2 * n, identity_element) {init(src);}
    void init(const vector<T> &src){
        for (size_t i = 0; i != n; ++i) data[n + i] = src[i];
        for (size_t i = n - 1; i != 0; --i) data[i] = combine(data[i<<1], data[i<<1|1]);
    }
    void modify(size_t i, T v){
        for (data[i += n] = v; i >>= 1; ) data[i] = combine(data[i<<1], data[i<<1|1]);
    }
    T query(size_t L, size_t R){
        T retL = identity_element;
        T retR = identity_element;
        for (L += n, R += n; L < R; L>>= 1, R >>= 1){
            if (L & 1) retL = combine(retL, data[L++]);
            if (R & 1) retR = combine(data[--R], retR);
        }
        return combine(retL, retR);
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegTree<int> seg(n);
    while (q--){
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0){
            seg.modify(x, y);
        }else{
            cout << seg.query(x, y + 1) << '\n';
        }
    }
    return 0;
}

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e6 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";


ll po(ll a,ll x){
	if(x==0)
		return 1;
	if(x==1)
		return a;
	ll z=po(a,x/2);
	z=(z*z)%mod;
	if(x&1)
		z=(z*a)%mod;
	return z;
}

void work(){
	ll n,k,ans=0;
	cin >> n >> k;
	ll dp[k+1];
	memset(dp,0,sizeof(dp));
	for(ll i=k;i>=1;i--){
		ll cnt=k/i;
		ll cur=(po(cnt,n))%mod;
		dp[i]=cur;
		for(ll j=2;i*j<=k;j++){
			dp[i]=(dp[i]-dp[i*j]+mod)%mod;
		}
		// cout << i << " " << dp[i] << "\n";
		ans=(ans+(i*dp[i])%mod)%mod;
	}

	cout << ans ;
}

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

	
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}

	return 0;
}
	

Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

    int a,b; cin >>a>>b;

    if (a+b < 10) {
        cout << a+b << endl;
    } else {
        cout << "error" << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  long long int n;
  cin >> n;
  long long int dp[n][3];
  for (long long int i = 0; i < n; i++)
  {
    cin >> dp[i][0] >> dp[i][1] >> dp[i][2] ;
  }
  for (long long int i = 1; i < n; i++)
  {
    dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]);
  }

  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
  return 0;
}


Measured memory_bytes: 2560
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val (even, odd) = sc.next().zipWithIndex.partition { case (_, i) => i % 2 == 0 }
  val ((evenSteps, _), (oddSteps, _)) = (even.unzip, odd.unzip)
  println(if (evenSteps.contains('L') || oddSteps.contains('R')) "No" else "Yes")
}


Measured memory_bytes: 55456
import sys
def input():
    return sys.stdin.readline()[:-1]
from operator import itemgetter
N=int(input())
s=[tuple(map(int, input().split())) for i in range(N)]
s.sort(key=itemgetter(1))
t=0
for i in s:
    t+=i[0]
    if t>i[1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 31836
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(i,a,b) for(int i=be[a];i;i=b[i].ne)
using namespace std;
char rch;
void readd(int &x){
	while ((rch=getchar())<'0');
	x=rch-'0';
	while ((rch=getchar())>='0') x=x*10+rch-'0';
}
const int p=1e9+7;
int n,t,x;
long long ans;
int main(){
	ans=1;
	scanf("%d",&n);
	t=1;//!!!
	fo(i,1,n-1){
		scanf("%d",&x);
		if (x<2*t-1){
			ans=ans*t%p;
			continue;
		}
		t++;
	}
	//t++;
	fo(i,2,t) ans=ans*i%p;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn manhattern_dist(p1: (usize, usize), p2: (usize, usize)) -> usize {
    let (x1, y1) = p1;
    let (x2, y2) = p2;
    ((x1 as i32- x2 as i32).abs() + (y1 as i32 - y2 as i32).abs()) as usize
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, d) = (v[0], v[1], v[2]);
    let mut grid: HashMap<usize, (usize, usize)> = HashMap::new();
    for i in 0..h {
        let v = read_vec::<usize>();
        for j in 0..w {
            grid.insert(v[j] - 1, (i, j));
        }
    }
    // println!("grid {:?}", grid);

    let query_size: usize = read();
    let mut queries = vec![(0, 0); query_size];
    for q_idx in 0..query_size {
        let v = read_vec::<usize>();
        queries[q_idx] = (v[0] - 1, v[1] - 1);
    }

    let mut sums = vec![vec![0; h * w / d + 1]; d];
    for i in 0..d {
        let mut search_num = i;
        let mut j = 0;
        while search_num + d < h * w {
            sums[i][j + 1] = sums[i][j] + manhattern_dist(grid[&search_num], grid[&(search_num + d)]);
            // println!("{:?}", (search_num, sums[i][j], grid[&search_num], grid[&(search_num + d)], manhattern_dist(grid[&search_num], grid[&(search_num + d)])));
            search_num += d;
            j += 1;
        }
    }
    // println!("sums {:?}", sums);

    for q in queries {
        let q = (q.0, q.1);
        let idx1 = q.0 % d;
        let start_idx2 = q.0 / d;
        let end_idx2 = q.1 / d;
        // println!("{:?}", (q, d, &sums[idx1], start_idx2, end_idx2));
        let ans = sums[idx1][end_idx2] - sums[idx1][start_idx2];
        println!("{:?}", ans);
    }
}


Measured memory_bytes: 14016
N = int(input())
W = [input() for _ in range(N)]

solver = [W[0]]
for i in range(1,N):
  if W[i] not in solver and W[i][0] == solver[-1][-1]:
    solver.append(W[i])
  else:
    print('No')
    exit()
else:
  print('Yes')

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int N,K,d;
	int c=0;
	int A[100]={};
	int B[105]={};


	scanf("%d%d",&N,&K);
	while(K--)
	{
		scanf("%d",&d);
		for(int i=0;i<d;++i)
		{
			scanf("%d",&A[i]);
			B[A[i]]=A[i];
		}
	}
	for(int i=1;i<=N;++i)
	{
		if(B[i]==0)
			++c;
	}
	printf("%d",c);
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    int x[8], y[8];
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    // ルート組み合わせ
    vector<int> src;
    vector<vector<int>> routes;
    for (int i = 0; i < N; i++) src.push_back(i);
    do {
        vector<int> route;
        for (int i = 0; i < N; i++) {
            route.push_back(src[i]);
        }
        routes.push_back(route);
    } while (std::next_permutation(src.begin(), src.end()));

    double sum_distance = 0;
    for (vector<int> route : routes) {
        for (int i = 1; i < route.size(); i++) {
            int bef_i = route[i-1];
            int aft_i = route[i];
            double dis = sqrt(pow(x[bef_i] - x[aft_i], 2) + pow(y[bef_i] - y[aft_i], 2));
            sum_distance += dis;
        }
    }
    cout << setprecision(11) << sum_distance / routes.size() << endl;
}


Measured memory_bytes: 3256
#include<stdio.h>

int main(){
    int N , i;
    double A[100],ans;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%lf",&A[i]);
    }
    for(i=0;i<N;i++){
        ans += 1 / A[i];
    }
    printf("%lf",1 / ans);
}

Measured memory_bytes: 128
N, M = map(int, input().split())
ac_total = 0
wa_total = 0
ac = [0] * (N + 1)
wa = [0] * (N + 1)

for _ in range(M):
    x = input().split()
    p = int(x[0])
    s = x[1]
    if s == 'AC':
        if ac[p] == 0:
            ac[p] = 1
            ac_total += 1
            wa_total += wa[p]
    else:
        wa[p] += 1
print(ac_total, wa_total)

Measured memory_bytes: 4596
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: dp

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }

const int mod = 1e9 + 7;

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

int f[310][310][310];
vector<pair<int, int> >limit[310];

inline bool chk(int l, int x, int r) { return l <= x && x < r; }

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri, m = ri;
	for(int i = 1; i <= m; i++) {
		int L = ri, R = ri, X = ri;
		limit[R].push_back(make_pair(L, X));
	} f[0][0][0] = 1;
	for(int i = 1; i <= n; ++i) {
		int la = 0, ra = i;
		int lb = 0, rb = i;
		for(auto pr : limit[i]) {
			int p = pr.first;
			if(pr.second == 3) chkmax(la, p), chkmax(lb, p);
			if(pr.second == 2) chkmin(rb, p), chkmax(la, p);
			if(pr.second == 1) chkmin(ra, p), chkmin(rb, p);
		}
		for(int a = 0; a < i; ++a) {
			for(int b = 0; !b || b < a; ++b) {
				int F = f[i - 1][a][b], c = i - 1;
				if(chk(la, a, ra) && chk(lb, b, rb)) Add(f[i][a][b], F);
				if(chk(la, c, ra) && chk(lb, a, rb)) Add(f[i][c][a], F);
				if(chk(la, c, ra) && chk(lb, b, rb)) Add(f[i][c][b], F);
			}
		}
	} int res = 0;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n; j++)
			Add(res, f[n][i][j]);
	printf("%d\n", res);
	return 0;
}

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



int main() {
    int n, d;
    cin >> n >> d;
    
    vector<vector<double>> x(n,vector<double>(d));
    rep(i,n) rep(j,d) cin >> x[i][j];
    
    vector<int> dis;
    for(int i = 0; i < n-1; i++) {
        for(int j = i+1; j < n; j++) {
            int sum = 0;
            for(int k = 0; k < d; k++) {
                sum += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
            }
            dis.push_back(sum);
        }
    }
    
    int ans = 0;
    rep(i,dis.size()) {
        rep(j,10000) {
            if(dis[i] == j*j) {
                ans++;
                break;
            }
        }
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a <= c && c <= b) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else if (c <= a) {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a <= c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b <= c && c <= a) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else if (c <= b) {
                System.out.printf("%d %d %d\n", c, b, a);
            }

        }
    }
}



Measured memory_bytes: 26340
use proconio::{fastout, input};
use proconio::marker::Chars;

const MOD: i32 = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: [Chars; h],
    };

    let mut dp = vec![vec![0; w]; h];

    dp[0][0] = 1;

    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                continue;
            }

            if i > 0 {
                dp[i][j] += dp[i-1][j];
            }

            if j > 0 {
                dp[i][j] += dp[i][j-1];
            }

            dp[i][j] = dp[i][j] % MOD;
        }
    }

    println!("{}", dp[h-1][w-1]);
}


Measured memory_bytes: 10880
def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1])

def insertionSort(A, N):
    showList(A,N)
    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j>=0 and A[j]>v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        showList(A,N)


N = int(input())
A = [int(x) for x in input().split(' ')]

A = insertionSort(A, N)


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

int main() {
	int K;
  	string S;
  	cin >> K >> S;
  	if (S.size() <= K) {
      cout << S << endl;
      return 0;
    }
  	rep(i, K) {
      cout << S.at(i);
    }
  	cout << "..." << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   string a,b;
   int n;
   cin>>n;
   cin>>a>>b;
   string s;
   for (int i=0;i<a.size();i++)
   {
      s.push_back(a[i]);
      s.push_back(b[i]);
   }
   cout<<s;
}


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

const int MAX = 200000;

int main(){
	int n;
	cin >> n;
	int arr[MAX];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
		
	int maxv = -1000000000;
	int minv = arr[0];
	
	for(int i = 1; i < n; i++){
		maxv = max(maxv, arr[i]-minv);
		minv = min(minv, arr[i]);
	}
	
	cout << maxv << endl;
	return 0;
} 


Measured memory_bytes: 3884
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

int main(){
	vvl bing(3, vl(3, 0));
	rep(i, 3) rep(j, 3) cin >> bing[i][j];
	ll n; cin >> n;
	rep(i, n){
		ll b; cin >> b;
		rep(j, 3) rep(k, 3) if (bing[j][k] == b) bing[j][k] = -1;
	}
	if (bing[0][0] == -1 && bing[0][1] == -1 && bing[0][2] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[1][0] == -1 && bing[1][1] == -1 && bing[1][2] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[2][0] == -1 && bing[2][1] == -1 && bing[2][2] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[0][0] == -1 && bing[1][0] == -1 && bing[2][0] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[0][1] == -1 && bing[1][1] == -1 && bing[2][1] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[0][2] == -1 && bing[1][2] == -1 && bing[2][2] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[0][0] == -1 && bing[1][1] == -1 && bing[2][2] == -1){
		cout << "Yes" << endl;
	}
	else if (bing[0][2] == -1 && bing[1][1] == -1 && bing[2][0] == -1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll x, ll y){
	if(x < y) return gcd(y, x);
	if(y == 0) return x;
	return gcd(y, x % y);
}

ll lcm(ll x, ll y){
	return x * y / gcd(x, y);
}



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

	ll n, m;
	cin >> n >> m;

	string s, t;
	cin >> s >> t;

	for(ll i = 0; i < n; i++){
		if((i * m) % n == 0){
			if(s[i] != t[i * m / n]){
				cout << -1 << endl;
				return 0;
			}
		}
	}

	cout << lcm(n, m) << endl;
}


Measured memory_bytes: 640
use std::io;


fn main() {
    let s = read_one::<String>();
    if s.contains(&"AC") { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352