akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long int NUM=pow(10,9)+7;

long long int fact(long long int n){
  long long int ret=1;
  for(long long int i=1;i<=n;i++){
    ret=(ret*i)%NUM;
  }
  return ret;
}

int main() {
  long long int N,M,ans=0;
  cin>>N>>M;
  if(abs(N-M)>1){cout<<0<<endl;return 0;}
  if(abs(N-M)==1){
    ans=(fact(N)*fact(M))%NUM;
  }else{
    ans=2*fact(N)%NUM*fact(M)%NUM;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int MAXV = 100010;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> graph(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  // vector<bool> used(n);
  vector<int> d(n, -1);

  queue<int> q;
  auto push = [&](int v) {
    for (auto u : graph[v]) {
      if (d[u] != -1) continue;;
      d[u] = v;
      q.push(u);
    }
  };
  push(0);
  while(!q.empty()) {
    int v = q.front(); q.pop();
    push(v);
  }

  cout << "Yes" << endl;
  for (int i = 1; i < n; ++i) {
    cout << d[i] + 1 << endl;
  }

}

Measured memory_bytes: 10216
from bisect import bisect_left, bisect_right


def main():
    S = list(input())
    T = list(input())
    sl = len(S)

    Sdic = {}
    for i, s in enumerate(S):
        if not s in Sdic.keys():
            Sdic[s] = [i]
        else:
            Sdic[s].append(i)
    pret = -1
    ans = 0
    for t in T:
        try:
            #print(Sdic[t])
            it = bisect_right(Sdic[t], pret)
            #print(it, t)
            if it < len(Sdic[t]):
                pret = Sdic[t][it]
            else:
                ans += sl
                pret = Sdic[t][0]
            #print(t, update, pret)
        except KeyError:
            ans = -1
            break
    if ans != -1:
        ans += pret+1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 60272
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var K = one[2];
	var alist = nextIntArray();
	var blist = nextIntArray();
	var output = 0;
	for(var i = 1; i < N; i++){
		alist[i] += alist[i - 1];
	}
	for(var i = 1; i < M; i++){
		blist[i] += blist[i - 1];
	}
	alist.unshift(0);
	for(var i = 0; i < N + 1; i++){
		var sum = alist[i];
		var count = 0;
		if(sum <= K){
			count = i;
			var check = binary_search(blist, K - sum);
			if(check != -1){
				count += check + 1;
			}
			output = Math.max(output, count);
		}
	}
	myout(output);
}
function binary_search(list,search){
  //listはあらかじめ昇順ソート済みとする。右側が有効エリア、左側が無効エリアと仮定し、
  //searchによって返す要素(インデックス)は ok:有効な部分の最小値、ng:無効な部分の最大値
  var ng = -1;
  var ok = list.length;
  var center;
  while(Math.abs(ok - ng) > 1){
    center = Math.floor((ok + ng) / 2);
    if(list[center] > search){
       ok = center;
    }else{
       ng = center;
    }
  }
  //return list[ok];
  return ng;
}

Measured memory_bytes: 76152
#include<cstdio>

long n;
long ans=0;
void dfs(long x,long a,long b,long c){
    if(x>n) return;
    if(a&&b&&c) ans++;
    dfs(10*x+3,a+1,b,c);
    dfs(10*x+5,a,b+1,c);
    dfs(10*x+7,a,b,c+1);
}
int main(){
    scanf("%ld",&n);
    dfs(0,0,0,0);
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	int t = m;
	vector<pii> a(n);
	rep(i,n) cin >> a.at(i).first >> a.at(i).second;
	sort(a.rbegin(),a.rend());
	priority_queue<int, vector<int>, greater<int>> pq;
	rep(i,n){
		if(a.at(i).first <= m){
			pq.push(a.at(i).second);
			m--;
		}
		else if(a.at(i).first <= t){
			pq.push(a.at(i).second);
			pq.pop();
		}
	}
	ll ans = 0;
	while(!pq.empty()){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1660
#include<stdio.h>
int main()
{
	char S[3];
	char T[3];
	int N = 0;
	
	scanf("%s", S);
	scanf("%s", T);
	
	if(S[0] == T[0]) N++;
	if(S[1] == T[1]) N++;
	if(S[2] == T[2]) N++;
	
	printf("%d", N);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1e9+7;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> x(n);
    for(auto&i:x) in>>i;
    modint ans{},c{};
    Fr(i,n-1){
        c+=modint(i).inv();
        ans+=c*(x[i]-x[i-1]);
    }
    Fr(i,n-1) ans*=i;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
from collections import Counter

n = int(input())
v = [int(x) for x in input().split()]

v1 = Counter(v[0::2]).most_common() + [(0, 0)]
v2 = Counter(v[1::2]).most_common() + [(0, 0)]

if v1[0][0] != v2[0][0]:
    res = n - v1[0][1] - v2[0][1]
else:
    res = min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1])

print(res)


Measured memory_bytes: 20572
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    std::string S, T;
    std::cin >> S >> T;

    int N = S.length(), M = T.length();

    auto dp = Vec<int>(N + 1, M + 1, 0);

    std::iota(dp[0].begin(), dp[0].end(), 0);
    for (int i = 1; i <= N; ++i) {
        dp[i][0] = i;
        for (int j = 1; j <= M; ++j) {
            dp[i][j] = std::min({dp[i][j - 1] + 1,
                                 dp[i - 1][j] + 1,
                                 dp[i - 1][j - 1] + (S[i - 1] == T[j - 1] ? 0 : 1)});
        }
    }

    std::cout << dp[N][M] << std::endl;
    return 0;
}



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

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

   if (a >= 2 * b) {
       cout << a - 2 * b << endl;
   } else {
       cout << 0 << endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn for(int i=0;i<n;i++)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,W;
    cin>>n>>W;
    ll w[n],v[n];
    forn
    cin>>w[i]>>v[i];
    ll dp[n][W+1];
    for(int j=0;j<=W;j++)
    {
    	if(j>=w[0])
	    dp[0][j]=v[0];
	    else
	    dp[0][j]=0;
	}
	for(int i=1;i<n;i++)
	dp[i][0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(j>=w[i])
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n-1][W];
    
    
}



Measured memory_bytes: 78336
# C
N, M = map(int, input().split())
X = [[int(i) for i in input().split()] + [j] for j in range(M)]
X.sort(key=lambda x: x[1])

Num = [0]*(N+1)

for i in range(M):
    p = X[i][0]
    Num[p] += 1
    c = Num[p]
    X[i].append(str(p).zfill(6) + str(c).zfill(6))

X.sort(key=lambda x: x[2])
for i in range(M):
    print(X[i][3])

Measured memory_bytes: 35008
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 1; i <= 5; ++i){
        int a;
        cin >> a;
        if(a == 0){
            cout << i << endl;
            return 0;
        }
    }
	return 0;
}

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

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define INF 1e+9

using namespace std;

bool dp[100001] ; 

ll answer[100001] ; 

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;
    
    int n , W ;
    cin >> n >> W ;
    int a , b;  
    vector < pair < ll , ll > > v ; 
    for(int i = 0 ; i < n ; i++){
        cin >> a >> b ; v.pb({a , b}) ; 
    }

    dp[0] = 1 ; 
    sort(all(v)) ; 
    ll ans = 0 ; 
    for(int i = 0 ; i < v.size() ; i++){
        int weight = v[i].F ;
        ll value = v[i].S ; 
        for(int j = W ; j >= weight ; j--){
            if(dp[j - weight]){
                dp[j] = 1 ;
                answer[j] = max(answer[j] , answer[j - weight] + value) ; 
                ans = max(ans , answer[j]) ; 
            }
        }
    }

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



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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    int N, M;
    cin >> N >> M;

    vector<ll> dist(100000, 0);

    dist[0] = 0;

    REP(i, 1, N)
    {
        int input;
        cin >> input;
        dist[i] = dist[i - 1] + input;
    }

    int now = 0, ans = 0;

    rep(i, M)
    {
        int input;
        cin >> input;
        
        ans = (ans + abs(dist[now + input] - dist[now])) % 100000;
        now += input;
    }

    cout << ans % 100000 << endl;


    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int32_t price_A, price_B, price_AB, max_A, max_B;
	cin >> price_A >> price_B >> price_AB >> max_A >> max_B;

	int32_t res = numeric_limits<int32_t>::max();

	for (int32_t cnt_A = 0; cnt_A <= max_A; cnt_A++) {
		int32_t cnt_AB = max(max_A - cnt_A, max_B) * 2;
		res = min(res, cnt_A * price_A + cnt_AB * price_AB);
	}

	for (int32_t cnt_B = 0; cnt_B <= max_B; cnt_B++) {
		int32_t cnt_AB = max(max_B - cnt_B, max_A) * 2;
		res = min(res, cnt_B * price_B + cnt_AB * price_AB);
	}

	for (int32_t cnt_AB = 0; cnt_AB <= max(max_A, max_B) * 2; cnt_AB += 2) {
		int32_t cnt_A = max_A - cnt_AB / 2;
		if (cnt_A < 0)
			cnt_A = 0;

		int32_t cnt_B = max_B - cnt_AB / 2;
		if (cnt_B < 0)
			cnt_B = 0;

		res = min(res, cnt_A * price_A + cnt_B * price_B + cnt_AB * price_AB);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
using llong = long long;
using ullong = unsigned long long;

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> P(N);
  for(int i=0;i<N;++i){
    cin >> P[i].first ;
    P[i].second = i+1;
  }
  sort(P.begin(),P.end());
  for(auto p:P){
    cout << p.second << " " ;
  }
  cout << endl;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int testcase_ends() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);
  if (N == 0 && M == 0) return 1;

  size_t r;
  scanf("%zu", &r);
  std::vector<std::vector<int>> tt(M, std::vector<int>(1270));
  for (size_t i = 0; i < r; ++i) {
    size_t t, n, m;
    int s;
    scanf("%zu %zu %zu %d", &t, &n, &m, &s);
    --m;
    if (s == 1) {
      // log in
      ++tt[m][t];
    } else {
      --tt[m][t];
    }
  }

  for (size_t i = 0; i < M; ++i) {
    for (size_t j = 1; j < tt[i].size(); ++j)
      tt[i][j] += tt[i][j-1];
    for (size_t j = 0; j < tt[i].size(); ++j)
      tt[i][j] = !!tt[i][j];
    for (size_t j = 1; j < tt[i].size(); ++j)
      tt[i][j] += tt[i][j-1];
    // for (size_t j = 0; j < tt[i].size(); ++j)
    //   fprintf(stderr, "%d%c", tt[i][j], j+1<tt[i].size()? ' ':'\n');
  }

  size_t q;
  scanf("%zu", &q);
  for (size_t i = 0; i < q; ++i) {
    size_t s, e, m;
    scanf("%zu %zu %zu", &s, &e, &m);
    --m;
    --s;
    --e;
    printf("%d\n", tt[m][e]-tt[m][s]);
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;

int main(){
	setIO();
	int n; cin >> n;
	ll mn1 = _INF, mx1 = -_INF, mn2 = _INF, mx2 = -_INF;
	for (int i = 0; i < n; i++){
		ll a, b; cin >> a >> b;
		mx1 = max(mx1, a+b);
		mx2 = max(mx2, a-b);
		mn1 = min(mn1, a+b);
		mn2 = min(mn2, a-b);
	}
	cout << max(mx1-mn1, mx2-mn2) << endl;
}

Measured memory_bytes: 3612
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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(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)*}
    };

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

#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        p: [usize; 4],
        t: [usize; 4],
    );

    let mut dp: Vec<usize> = Vec::new();
    dp.resize(n+1, 1<<31);
    dp[0] = 0;
    for i in 0..n{
        for j in 0..4 as usize {
            let np = p[j] + dp[i];
            let nt = min(t[j] + i, n);
            dp[nt] = min(dp[nt], np);
        }
    }
    println!("{}", dp[n]);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> f(N, false);
  int ac = 0;
  vector<int> wc(N, 0);
  int wctotal = 0;
  for(int i=0; i<M; i++) {
    int tmp;
    string s;
    cin >> tmp >> s;
    if(f[tmp] == false){
      if(s == "AC"){
        ac++;
        f[tmp] = true;
        wctotal += wc[tmp];
      }else wc[tmp]++;
    }else continue;
  }
  cout << ac << " " << wctotal << endl;
}

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

typedef long long ll;
typedef pair<int, int> pi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool is_prime(int x)
{
    if (x <= 1)
    {
        return false;
    }
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

LL dp[1005][50005];

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

    int h, n;
    cin >> h >> n;
    vector< P > v(n);
    for( int i = 0; i < n; ++i ) {
        cin >> v[i].F >> v[i].S;

    }

    for( int i = 0; i < n; ++i ) {
        for( int j = 1; j <= 50000; ++j ) {
            dp[i][j] = INF;

        }
    }

    for( int i = 0; i < n; ++i ) {
        for( int j = 1; j <= 50000; ++j ) {
            if( i == 0 ) {
                if( j % v[i].F == 0 ) {
                    dp[i][j] = dp[i][j - v[i].F] + v[i].S;

                }
            } else {
                dp[i][j] = dp[i - 1][j];
                if( j >= v[i].F ) {
                    dp[i][j] = min(dp[i][j], dp[i][j - v[i].F] + v[i].S);

                }
            }
        }
    }

    LL res = INF;
    for( int j = h; j <= 50000; ++j ) {
        res = min(res, dp[n - 1][j]);

    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 391424
n = int(input())
a = list(map(int,input().split()))
# (sum(a)^2 - sum(a^2))/2
p = 10**9 + 7
ts = 0
s = 0
for i in range(n):
	s += a[i]
	ts = (ts + pow(a[i], 2, p)) % p
s = s % p
print((pow(s, 2, p)-ts)*pow(2, p-2, p)%p)

Measured memory_bytes: 31588
#define z(m,n) for(;m;m--)scanf("%d",&s),x[s+n]++
x[41];main(m,n,s){for(;scanf("%d%d",&m,&n),m;printf("%d\n",s)){memset(x,0,164);z(m,0);z(n,20);for(m=21,s=0;m--;s+=m*(x[m]>x[m+20]?x[m]:x[m+20]));}return 0;}

Measured memory_bytes: 0
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int64_t S;
	int64_t smaller = 0, ge = INT64_C(1000000000);
	int64_t gosa1, gosa2;
	if (scanf("%" SCNu64, &S) != 1) return 1;
	while (smaller + 1 < ge) {
		int64_t m = smaller + (ge - smaller) / 2;
		if (S <= m * m) ge = m; else smaller = m;
	}
	gosa1 = S - smaller * smaller;
	gosa2 = ge * ge - S;
	if (gosa2 <= gosa1) {
		printf("0 0 %" PRId64 " 1 %" PRId64 " %" PRId64 "\n", ge, gosa2, ge);
	} else {
		printf("0 1 %" PRId64 " 0 %" PRId64 " %" PRId64 "\n", smaller, gosa1, smaller + 1);
	}
}

/*

1点を原点に固定してよい。 (多分)

【応用】ベクトルの内積と三角形の面積 | なかけんの数学ノート
https://math.nakaken88.com/textbook/expert-inner-product-of-vector-and-triangle-area/

S/2 = abs(x1*y2 - y1*x2) / 2

x = 10**9 とすると、

  x
= 1000000000
  (x*x) - ((x-1)*(x-1))
= 1999999999

なので、誤差を規定内に抑えられるはず

x1 = y2 = 一番近くなるやつ
y1 = 1
x2 = 誤差

誤差が負になるとき、y1 = -1 にする → 全体を1上げる

*/


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
ll pwr(ll x, ll e){
	if(e==0){
		return 1;
	}
	ll tmp=pwr(x, e/2);
	tmp=(tmp*tmp)%mod;
	if(e%2){
		tmp*=x;
		tmp%=mod;
	}
	return tmp;
}
int main(){
    ll n, a, b;
    while(cin>>n>>a>>b){
    	ll ans=pwr(2, n)-1;
    	ll tmp1=1, tmp2=1;
    	for(ll i=0; i<a; ++i){
    		tmp1*=(n-i);
    		tmp1%=mod;
    		tmp2*=(i+1);
    		tmp2%=mod;
    	}
    	tmp1=tmp1*pwr(tmp2, mod-2);
    	tmp1%=mod;
    	ans-=tmp1;

    	tmp1=1, tmp2=1;
    	for(ll i=0; i<b; ++i){
    		tmp1*=(n-i);
    		tmp1%=mod;
    		tmp2*=(i+1);
    		tmp2%=mod;
    	}
    	tmp1=tmp1*pwr(tmp2, mod-2);
    	tmp1%=mod;
    	ans-=tmp1;
    	ans%=mod;
    	if(ans<0){
    		ans+=mod;
    	}
    	cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 998244353
inf = float("INF")

#solve
def solve():
    n, s = LI()
    a = LI()
    dp = [[0] * (3001) for _ in range(n)]
    dp[0][0] = 1
    dp[0][a[0]] = 1
    ans = 0
    for i in range(1, n):
        for si in range(a[i], 3001):
            dp[i][si] = dp[i - 1][si - a[i]] % mod
        dp[i][0] += 1
        dp[i][a[i]] += 1
        for si in range(3001):
            dp[i][si] = (dp[i][si] + dp[i - 1][si] * 2) % mod
        ans += dp[i][s]
    print(dp[-1][s] % mod)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 141948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
int main() {
  ll X,A,B;
  cin >> X;
  rep(i,300){
    rep(j,300){
      if(pow(i,5) - pow(j,5) == X){
        cout << i << " " << j << endl;
        return 0;
      }
      if(pow(-1*i,5) - pow(j,5) == X){
        cout << -i << " " << j << endl;
        return 0;
      }
      if(pow(i,5) - pow(-1*j,5) == X){
        cout << i << " " << -j << endl;
        return 0;
      }
      if(pow(-1*i,5) - pow(-1*j,5) == X){
        cout << -i << " " << -j << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

using namespace std;

using ll=long long;

ll r,c;

bool is_wall(ll x,ll y){
	if(x==0 || x==r)return 1;
	if(y==0 || y==c)return 1;
	return 0;
}

int main(){
	ll n;
	cin>>r>>c>>n;
	ll j=0;
	vector<pair<ll,ll>>v;
	for(ll i=0;i<n;++i){
		ll x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(is_wall(x1,y1) && is_wall(x2,y2)){
			if(y1==0)v.push_back(make_pair(x1,j));
			else if(y1==c)v.push_back(make_pair(2*r+c-x1,j));
			else if(x1==0)v.push_back(make_pair(2*r+2*c-y1,j));
			else if(x1==r)v.push_back(make_pair(r+y1,j));
			if(y2==0)v.push_back(make_pair(x2,j));
			else if(y2==c)v.push_back(make_pair(2*r+c-x2,j));
			else if(x2==0)v.push_back(make_pair(2*r+2*c-y2,j));
			else if(x2==r)v.push_back(make_pair(r+y2,j));
			j++;
		}
	}
	sort(v.begin(),v.end());
	int m[100001]={};
	int k=0;
	for(auto x:v){
		if(!m[x.second]){
			m[x.second]=++k;
		}else{
			if(m[x.second]!=k){
				cout<<"NO"<<endl;
				return 0;
			}else{
				k--;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 6512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = 998244353ll;

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll k[225816]={1ll},segtree[816225][3];
bool delayed[816225];

void init(int i=0, int l=0, int r=n){
	if(r-l>1){
		init(i*2+1,l,(l+r)/2);
		init(i*2+2,(l+r)/2,r);
		segtree[i][2] = segtree[i*2+1][2];
		add_mod(segtree[i][2],segtree[i*2+2][2]);
		
	}else{
		segtree[i][2] = k[l];
	}
	segtree[i][0] = segtree[i][2];
}

void eval(int i=0, int l=0, int r=n){
	if(delayed[i]){
		segtree[i][0] = (segtree[i][1]*segtree[i][2])%MOD;
		if(r-l>1){
			segtree[i*2+1][1] = segtree[i][1];
			segtree[i*2+2][1] = segtree[i][1];
			delayed[i*2+1] = true;
			delayed[i*2+2] = true;
		}
		delayed[i] = false;
	}
}


ll query(int a=0, int b=n, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(b<=l || r<=a){
		return 0ll;
	}else if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		return (query(a,b,i*2+1,l,(l+r)/2)+query(a,b,i*2+2,(l+r)/2,r))%MOD;
	}
}

void update(int a, int b, ll v, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(b<=l || r<=a){
		return;
	}else if(a<=l && r<=b){
		delayed[i] = true;
		segtree[i][1] = v;
		eval(i,l,r);
	}else{
		update(a,b,v,i*2+1,l,(l+r)/2);
		update(a,b,v,i*2+2,(l+r)/2,r);
		segtree[i][0] = (segtree[i*2+1][0]+segtree[i*2+2][0])%MOD;
	}
}

int main(void){
	int q,i,l,r;
	ll d;
	std::cin >> n >> q;
	for(i=1; i<n; ++i){
		k[i] = k[i-1];
		mul_mod(k[i],10ll);
	}
	std::reverse(k,k+n);
	init();
	for(i=0; i<q; ++i){
		std::cin >> l >> r >> d; --l;
		update(l,r,d);
		std::cout << query() << std::endl;
	}
	return 0;
}


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

int main(){
    long n;
    scanf("%ld", &n);

    long dig;
    long sum = 0;
    long num = n;
    while(num){
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }

    if((n % sum) == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int N,X,L,i,count=1,sum=0;
    scanf("%d%d",&N,&X);
    for (i=0;i<N;i++)
    {
        scanf("%d",&L);
        sum=sum+L;
        if (sum<=X)
        {
            count++;
        }
    }
    printf("%d",count);
}


Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

public class Main 
{
	static class Edge
	{
		Node nd;
		long dis; //that node is dis to the right of this one.
		boolean vis = false;
		
		public Edge(Node n, long d)
		{
			nd = n;
			dis = d;
		}
	}
	
	static class Node
	{
		int i;
		HashSet<Edge> e = new HashSet<Edge>();
		long x = 0;
		boolean vis = false;
		
		public Node(int id)
		{
			i = id;
		}
	}
	
	static int n, m;
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		m = sc.nextInt();

		Node[] nd = new Node[n];
		
		for(int i = 0; i < n; i++)
			nd[i] = new Node(i);
		
		for(int i = 0; i < m; i++)
		{
			int l = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			long d = sc.nextInt();
			
			nd[l].e.add(new Edge(nd[r], d));
			nd[r].e.add(new Edge(nd[l], -d));
		}

		for(int start = 0; start < n; start++)
		{
			
			Stack<Node> q = new Stack<>();
			if(nd[start].vis)continue;
			else q.add(nd[start]);
			
			while(!q.isEmpty())
			{
				Node pos = q.pop();
				
				//assign x
				if(!pos.vis)pos.x = 0;
				
				for(Edge e : pos.e)
				{
					//do e
					if(!e.vis)
					{
						if(e.nd.vis)
						{
							if(e.nd.x != pos.x + e.dis)
							{
								System.out.println("No");
								return;
							}
						}
						else e.nd.x = pos.x + e.dis;
						
						e.vis = true;
						
						//add node
						if(!e.nd.vis)
						{
							q.add(e.nd);
							e.nd.vis = true;
						}
					}
				}
			}
			
		}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 218700
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int h[100000];
int main(){
  int n, m, i;
  cin>>n>>m;
  for(i=0; i<n; i++)
    cin>>h[i];
  for(i=0; i<m; i++){
    int a, b;
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int ans=0;
  for(i=0; i<n; i++){
    int stg=1;
    for(unsigned int j=0; j<v[i].size(); j++){
      if(h[i]<=h[v[i][j]])
        stg=0;
    }
    ans+=stg;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 9132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int n = sc.nextInt();

			int r = sc.nextInt();

			if (n == 0 && r == 0) {
				break;
			}

			int[] deck = new int[n];
			for (int i = 0; i < n; i++) {
				deck[i] = n - i;
			}

			for (int j = 0; j < r; j++) {

				int p = sc.nextInt();

				int c = sc.nextInt();

				int[] new_deck = new int[n];
				int k = 0;
				for (; k < c; k++) {
					new_deck[k] = deck[p - 1 + k];
				}
				for (; k < c + p - 1; k++) {
					new_deck[k] = deck[k - c];
				}
				for (; k < n; k++) {
					new_deck[k] = deck[k];
				}

				deck = new_deck;

			}

			System.out.println(deck[0]);

		}

		sc.close();

	}

}



Measured memory_bytes: 37136
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define all(c) (c).begin(), (c).end()
#define speed ios::sync_with_stdio(0); cin.tie(0);
 
int const N = 2e5 + 2;
int a[N], ans[N];

int main(){
    speed
    int n;
    cin >> n;
    f(i, 0, n)cin >> a[i];
    f(i, 0, n)ans[a[i]] = i + 1;
    f(i, 1, n + 1)cout << ans[i] << " ";
}
    

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

int main(){
    int s;cin >> s;
    int ans=1;
    int cnt=0;
    
    while(1){
        if (s==1||s==2){
            cout << 4;
            break;
        }
        if (s%2==0) s/=2;
        else if (s%2==1) s=3*s+1;
        if (s==4){
            cout << ans+4;
            break;
        }
        ans++;   
    }   
}

Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Num num = data->getNum();
	const int N = num[0];

	data->getInput();
	num = data->getNum();

	AtCoder::Ans* ans = new AtCoder::Ans();

	int max = num[0];
	for (int i = 1; i < N; i++) {
		if (max >= num[i]) {
			const int sub = (max - num[i]);
			ans->increment(sub);
			max = num[i] + sub;
		}
		max = max < num[i] ? num[i] : max;
	}

	ans->showResult();

	delete(ans);
	delete(data);

	return 0;
}

Measured memory_bytes: 14156
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1000+10;
int n;
int main(){
    while(~scanf("%d",&n)){
        printf("%d\n",n/3);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
int dx[] = {0,-1,0,1};
int dy[] = {-1,0,1,0};

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<vector<bool> > > used(n+2,vector<vector<bool> > (m+2,vector<bool>(4,false) ) );
	vector<vector<bool> >  used2(n+2,vector<bool>  (m+2,false)  );
	mp s,g;
	int d;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char tmp;
			cin>>tmp;
			if(tmp =='.'){
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}else if(tmp == 'G'){
				g = mp(i,j);
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}else if(tmp =='^'){
				s = mp(i,j);
				d = 1;
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}else if(tmp=='<'){
				s = mp(i,j);
				d = 0;
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}else if(tmp=='>'){
				s = mp(i,j);
				d = 2;
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}else if(tmp =='v'){
				s = mp(i,j);
				d = 3;
				for(int k =0 ;k<4;k++) used[i][j][k] = true;
				used2[i][j] = true;
			}
		}
	}
	bool flag = false;
	mp now = s;
	while(now != g){
		//cout<<now.first<<' '<<now.second<<' '<<d<<endl;
		if(!used[now.first][now.second][d]){
			flag = true;
			break;
		}
		used[now.first][now.second][d] = false;
		mp yoko = mp(now.first+dx[(d+1)%4],now.second+dy[(d+1)%4]);
		mp go = mp(now.first+dx[d],now.second+dy[d] );
		if(used2[yoko.first][yoko.second]){
			d = (d+1)%4;
			//used[now.first][now.second][d] = false;
			now = yoko;//next
			continue;
		}
		if(!used2[go.first][go.second]){
			d = (d+3)%4;
			continue;
		}
		now = go;
	}
	if(flag){
		cout<<-1<<endl;
	}else{
		int cnt = 0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(used2[i][j]){
					for(int k=0;k<4;k++){
						if(!used[i][j][k]){
							cnt++;
							break;
						}
					}
				}
			}
		}
		cout<<cnt+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 3304
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.BigInteger;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    BigDecimal A = scan.nextBigDecimal();
    BigDecimal B = scan.nextBigDecimal();
    BigDecimal ANS = new BigDecimal("1");
    ANS = A.multiply(B);
    BigDecimal ans = ANS.setScale(0, BigDecimal.ROUND_DOWN);
    System.out.println(ans);
  }
}




Measured memory_bytes: 37472
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> v(M - 1 + N);
    FOR(i, M - 1, v.size()) v[i] = 1;
    int ret = 0;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    REP(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
    REP(i, Q) A[i]--, B[i]--;
    vector<int> arr(N);
    do
    {
        int curr = 0, i = 0;
        for (auto x : v)
        {
            if (!x) curr++;
            else arr[i++] = curr;
        }
        int tmp = 0;
        REP(i, Q) if (arr[B[i]] - arr[A[i]] == C[i]) tmp += D[i];
        ret = max(ret, tmp);
    } while (next_permutation(v.begin(), v.end()));
    cout << ret << '\n';
}


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

    int main (){
        int h, w;
        int i, j;
        int x = 0, y = 0;
        char c[100][100];
        while(1){
            x = 0; y = 0;
            cin >> h >> w;
            if(h == 0 && w == 0){
                break;
            }
            for(i = 0; i < h; i++){
                for(j = 0; j < w; j++){
                    cin >> c[i][j];
                }
            }
            
            while(1){
                if(c[y][x] == '<'){
                    c[y][x] = 'r';
                    x--;
                }
                if(c[y][x] == '>'){
                    c[y][x] = 'r'; 
                    x++;
                    }
                if(c[y][x] == 'v'){
                    c[y][x] = 'r';
                    y++;
                    }
                if(c[y][x] == '^'){
                    c[y][x] = 'r';
                    y--;
                    }
                if(c[y][x] == '.'){
                    cout << x << " " << y << endl;
                    break;
                }
                if(c[y][x] == 'r'){
                    cout << "LOOP" << endl;
                    break;
                }
            }
        }

    return 0;    
    }

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M * 2);
  
  for (int i = 0; i < M; i++) {
    cin >> a.at( i * 2 ) >> a.at( i * 2 + 1 );
  }
  
  for ( int i = 0; i < N; i++ ) {
    int sum = 0;
    for ( int j = 0; j < M * 2; j++) {
      if ( a.at(j) == i + 1 ) {
        sum++;
      }
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[][] num = new int[N][10];
		for(int i = 0;i < N;i++) {
			for(int k = 0;k < 10;k++) {
				num[i][k] = scan.nextInt();
			}
		}
//		for(int i = 0;i < N;i++) {
//			for(int k = 0;k < 10;k++) {
//				System.out.print(num[i][k] + " ");
//			}
//			System.out.println();
//		}
		for(int i = 0;i < N;i++) {
			int left = 0;
			int right = 0;
			for(int k = 0;k < 10;k++) {
				if(num[i][k] > left) {
					left = num[i][k];
				}else if(num[i][k] > right) {
					right = num[i][k];
				}else {
					System.out.println("NO");
					break;
				}
				if(k == 9) {
					System.out.println("YES");
				}
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 26268
//98tarunkumar

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define lop(i,n) for(int i=0;i<n;i++)
#define rlop(i,n) for(int i=n;i>0;i--)
#define lli long long int
#define MOD 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define ainp(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define aout(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";
#define ss ios::sync_with_stdio(false); cin.tie(NULL);
#define vi vector<int> 
#define ln cout<<"\n"



int main(){
	ss;
	/*#ifndef ONLINE_JUDGE
	freopen("cf_inp.txt","r",stdin);
	freopen("cf_oup.txt","w",stdout);
	#endif*/
	
	int n;
	cin>>n;
	int a[n];

	ainp(a,n)
	if(n==1){
		cout<<0;ln;
	}
	else if(n==2){
		cout<<a[1]-a[0];ln;
	}
	else{
		int dp[n];
		dp[0]=0;
		dp[1]=abs(a[1]-a[0]);
		for(int i=2;i<n;i++){
			dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],dp[i-1]+abs(a[i]-a[i-1]));
		}
		//aout(dp,n)ln;
		cout<<dp[n-1];

	}
}


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

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

void init(){
	nil = (struct node*)malloc(sizeof(struct node));
	nil -> next = nil;
	nil -> prev = nil;
}

void printList(){
	struct node *p;
	for(p = nil -> next; p != nil;p = p -> next){
		if(p != nil -> prev){
			printf("%d ", p -> key);
		}else if(p == nil -> prev){
			printf("%d\n", p -> key);
		}
	}
}

void deleteNode(NodePointer t){
	if(t -> prev == nil){//deleteFirst
		nil -> next = t -> next;
		t -> next -> prev = nil;
		free(t);
	}else if(t -> next == nil){//deleteLast
		nil -> prev = t -> prev;
		t -> prev -> next = nil;
		free(t);
	}else{
		t -> prev -> next = t -> next;
		t -> next -> prev = t -> prev;
		free(t);
	}
}

void deleteFirst(){
	NodePointer t = nil -> next;
	if(t == nil) return;
	deleteNode(t);
}

void deleteLast(){
	NodePointer t = nil -> prev;
	if(t == nil) return;
	deleteNode(t);
}

void del(int key){
	struct node *p;

	if(nil -> key == key){
		deleteFirst();
		return;
	}
	for(p = nil -> next;p != nil;p = p -> next){
		if(p -> key == key){
			deleteNode(p);
			return;
		}
	}
}

void insert(int key){
	NodePointer x;
	x = (struct node*)malloc(sizeof(struct node));
	x -> key = key;

	//when data has nil only
	if(nil -> next == nil){
		nil -> prev = x;
	}

	//set pointer
	x -> next = nil -> next;
	x -> prev = nil;
	//change nil pointer
	nil -> next -> prev = x;
	nil -> next = x;
}

int main(void){
	int key,n,i;
	char com[200];
	scanf("%d", &n);

	init();

	for(i = 0;i < n;i++){
		scanf("%s", com);
		if(com[0] == 'i'){
			scanf("%d", &key);
			insert(key);
		}else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
			}else{
				scanf("%d", &key);
				del(key);
			}
		}
	}

	printList();
	return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e7 + 555;
const double PI = acos(-1.0);


void solve()
{
	ll n;
	cin >> n;
	ll res = inf * 1ll * inf;
	for(ll i = 1; i <= sqrt(n); ++i){
		if(n % i == 0)
		res = min(res, n / i + i - 2);
	}
	cout << res;
}
 
int main()
{
    Red;
    solve();
    return 0;
}

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

int main() {
  string str;
  cin >> str;
  if (str.at(0) == '7' || str.at(1) == '7' || str.at(2) == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620