akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<long long> dp, h;
const long long inf = 2 * 1e+18;

void solve()
{
	int n, k;
	cin >> n >> k;

	dp.assign(n, inf);
	h.resize(n);

	dp[0] = 0;
	cin >> h[0];
	for (int i = 1; i < n; i++)
	{
		cin >> h[i];
		for (int j = 1; i - j >= 0 && j <= k; j++)
		{
			
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}

	cout << dp[n - 1];

}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.12lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
vector<int>a[200004];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    for(int i=0;i<a[1].size();i++)
    {
        if(a[1][i]==n){cout<<"POSSIBLE"<<endl;return 0;}
        int v=a[1][i];
        for(int j=0;j<a[v].size();j++)
        {
            if(a[v][j]==n){cout<<"POSSIBLE"<<endl;return 0;}
        }
    }
    cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 12016
a = Array.new
loop do
    m, f, r = gets.split().map(&:to_i)
    if m == -1 and  f == -1 and r == -1
        break
    elsif (m == -1 or f == -1) or (m + f < 30)
        a.push("F")
    elsif m + f >= 80
        a.push("A")
    elsif m + f >= 65 and m + f < 80
        a.push("B")
    elsif m + f >= 50 and m + f < 65
        a.push("C")
    elsif m + f >= 30 and m + f < 50
        if r >= 50
            a.push("C")
        else
            a.push("D")
        end
    end
end

puts a

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  for(; A >= B && K > 0; K--) {
    B *= 2;
  }

  for(; B >= C && K > 0; K--) {
    C *= 2;
  }

  if(K >= 0 && A < B && B < C) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int compare(pair<int,int> &p1,pair<int,int> &p2)
{
	if(p1.first<p2.first)
	return 1;
	if(p1.first==p2.first)
	{
		if(p1.second<p2.second)
		return 1;
	}
	return 0;
}
int hands(vector<pair<int,int>> &v)
{
	stack<pair<int,int>> s;
	for(auto itr : v)
	{
	   int fir=itr.first,scnd=itr.second;
	   if(s.empty()==1)
	   s.push({fir,scnd});
	   else 
	   {
	       if(scnd <= s.top().second)
	       {
	       	  s.pop();
	       //	  cout<<"yaha"<<endl;
	       	  s.push({fir,scnd});
	       }
	       else if(fir>=s.top().second)
	       s.push({fir,scnd});
	   }
	}
	return s.size();
}
int main()
{
	int n,point,range;
	cin>>n;
	vector<pair<int,int>> v;
	for(int i=0;i<n;++i)
	{
		cin>>point>>range;
		v.push_back({point-range,point+range});
	}
	sort(v.begin(),v.end(),compare);
	int count=hands(v);
	cout<<count;
	return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
    }

    sort(all(s));

    int cnt = 1;
    int mx = 0;
    vector<string> ans[200005];
    REP(i, 1, n){
        if(s[i] == s[i-1]){
            cnt++;
        }
        else{
            if(mx < cnt){
                mx = cnt;
            }
            ans[cnt].push_back(s[i-1]);
            cnt = 1;
        }
    }
    ans[cnt].push_back(s[n-1]);

    int c = 0;
    rep(i, 200001){
        if(ans[i].size()){
            c = i;
        }
    }
    for(auto e : ans[c]){
        cout << e << endl;
    }


    return 0;
}

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

int main()
{
    int n,k,s=0;
    cin >>n>>k;
    int a[n];
    for (int i=0; i<n; ++i){
        cin>>a[i];
    }
    sort(a, a+n);
    for(int i=0;i<k;++i){
        s=s+a[i];
    }
    cout<<s;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	multiset<ll> s;
	ll n,ans=0;
	cin>>n;
	vl v(n),ind(n);
	rep(i,n)cin>>v[i],ind[v[i]-1]=i+1;
	s.insert(0);
	s.insert(0);
	s.insert(n+1);
	s.insert(n+1);
	rrep(i,n){
		ll num=ind[i];
		auto rl=s.lower_bound(num);
		auto rr=rl;
		auto ll=rl;
		auto lr=rl;
		rr++;
		lr--;
		ll--;ll--;
		ans+=(i+1)*(*lr-*ll)*(*rl-num);
		ans+=(i+1)*(num-*lr)*(*rr-*rl);
		s.insert(num);
	}
	puta(ans);
}


Measured memory_bytes: 6528
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int N;
	scanf("%d" ,&N);
	int tmp = 0;
	for(int i = 1; i <= N; i++)
		if(i % 2) tmp++;
	printf("%f", 1.0 * tmp / N);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  string s;
  cin >> s;
  int count[2000] = {0};
  for (int i = 0; i < s.size(); i++) {
    count[s[i]]++;
  }

  bool flag = true;

  for (int i = 0; i < 2000; i++) {
    if (count[i] % 2 != 0) {
      flag = false;
    }
  }

  if (flag) {
    D("Yes");
  } else {
    D("No");
  }

  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a, b, x, y, c, aCopy,bCopy;
    for (int i = 0; i < A; i++)
    {
        int input;
        cin >> input;
        a.push_back(input);
        aCopy.push_back(input);
    }
    for (int i = 0; i < B; i++)
    {
        int input;
        cin >> input;
        b.push_back(input);
        bCopy.push_back(input);
    }
    for (int i = 0; i < M; i++)
    {
        int input;
        cin >> input;
        x.push_back(input);
        cin >> input;
        y.push_back(input);
        cin >> input;
        c.push_back(input);
        
    }
    
    //tanpa tiket
    sort(aCopy.begin(), aCopy.end());
    sort(bCopy.begin(), bCopy.end());
    int minim = aCopy[0] + bCopy[0];

    //dengan tiket
    for (int i = 0; i < M; i++)
    {
        minim = min(minim, a[x[i]-1] + b[y[i]-1] - c[i]);
    }

    cout << minim << '\n';
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    vector<ll> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll K;
    cin >> K;
    cout << a[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if a+b<2*c:
    print(a*x+b*y)
else:
    if x > y:
        amari = x - y
        if a > 2*c:
            print(2*c*y + amari*2*c)
        else:
            print(2*c*y + amari*a)
    else:
        amari = y - x
        if b > 2*c:
            print(2*c*x + amari*2*c)
        else:
            print(2*c*x + amari*b)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int MaxN = 10;
int a[MaxN + 5];
int n, k;

int solve(int n)
{
    int y;
    int flag = 1;
    while(n)
	{
        y = n % 10;
	    if(a[y] != 0)
        {
            flag = 0;
			break;
        }
        n /= 10;
     }
     if(flag == 1) return 1;
     if(flag == 0) return 0;
}
int main()
{
	int x;
	scanf("%d %d", &n, &k);
	for(int i = 0; i < k; i++)
	{
		scanf("%d", &x);
		a[x] = 1;
	}
	for(int i = n;; i++)
	{
		if(solve(i) == 1)
		{
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
ans=[-1]*3

for a in range(n+1):
    for b in range(n+1-a):
        c=n-a-b
        if y==a*10000+b*5000+c*1000:
            ans=[a,b,c]
            break
    else:
        continue
    break

print(*ans)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
  int N;
  cin >> N;
  string s1,s2;
  cin >> s1;
  cin >> s2;
  string s3="";
  for(int i=0;i<N;i++){
    s3.insert(s3.end(),s1[i]);
    s3.insert(s3.end(),s2[i]);
  }
  cout << s3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2005,INF=1<<30;
bool exist[MAX];
vector<int> G[MAX];
int depth[MAX],cnt[MAX];
vector<pair<int,int>> dis;

void DFS(int u,int p){
    for(int to:G[u]){
        if(to==p) continue;
        
        depth[to]=depth[u]+1;
        DFS(to,u);
        cnt[u]+=cnt[to];
    }
    if(exist[u]) cnt[u]++;
}

pair<int,int> solve(int u,int p){
    pair<int,int> sum={0,0};
    vector<int> T;
    for(int to:G[u]){
        if(to==p) continue;
        pair<int,int> a=solve(to,u);
        sum.first+=a.first;
        sum.second+=a.second;
        
        if(a.first-2*a.second-cnt[to]*depth[u]) T.push_back(a.first-2*a.second-cnt[to]*depth[u]);
    }
    if(exist[u]){
        sum.first+=depth[u];
    }
    
    sort(all(T));
    int s=0;
    for(int i=0;i<T.size();i++) s+=T[i];
    
    if(T.size()) sum.second+=min(s/2,s-T.back());
    return sum;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    string S;cin>>S;
    for(int i=0;i<N;i++){
        if(S[i]=='1') exist[i]=1;
    }
    
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    int ans=INF;
    
    for(int i=0;i<N;i++){
        memset(depth,0,sizeof(depth));
        memset(cnt,0,sizeof(cnt));
        dis.clear();
        DFS(i,-1);
        
        for(int to:G[i]){
            pair<int,int> a=solve(to,i);
            if(a.first) dis.push_back(a);
        }
        if(dis.size()==0){
            ans=0;
            continue;
        }
        sort(all(dis));
        
        int sum=0;
        for(pair<int,int> a:dis) sum+=a.first;
        if(sum%2==0){
            if(dis.back().first*2<=sum) ans=min(ans,sum/2);
            else{
                if(dis.back().first-2*dis.back().second<=(sum-dis.back().first)) ans=min(ans,sum/2);
            }
        }
    }
    
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
}




Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define int long long

const int INF=1e9;
const int MAX_V=1000;

signed main(){

	int n;
	cin>>n;

	vector< pair<int , int> > v;

	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;

		v.push_back(make_pair(a,b));
	}

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

	// for(int i=0;i<n;i++){
	// 	cout<<v[i].first<<" "<<v[i].second<<endl;
	// }

	int ma=v[0].first;
	int mi=v[n-1].second;

	cout<<(v[0].first-1)+(v[n-1].first-v[0].first+1)+v[n-1].second<<endl;
	


}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

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

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	long long ans = a[0];
	int cnt = n - 2;
	for (int i = 1; cnt > 0; i++) {
		int res = min(cnt, 2);
		ans += a[i] * res;
		cnt -= res;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b, x; 
	long long z=0;
	cin>>a>>b>>x;
 	if (1<=x){				
		for(int i=a;i<=b;i++)
		z=(b/x)-(a/x);
		if(a%x==0){
			z++;
			cout<<z;
		}	
		else {
			cout<<z;
		}
	}		
	return 0;		
}

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

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

    int r=0,g=0,b=0;
    rep(i,n) {
        if (s[i] == 'R') {
            r++;
        }
        else if (s[i] == 'G') {
            g++;
        }
        else {
            b++;
        }
    }

    ll count = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            int k = j + (j-i);
            if (k >= n) {
                break;
            }
            if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) {
                count++;
            }
        }
    }

    ll ans = (ll)r*g*b - count;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3544
package main

import "fmt"

func main() {
	var b string
	fmt.Scan(&b)

	switch b {
	case "A":
		fmt.Println("T")
	case "C":
		fmt.Println("G")
	case "T":
		fmt.Println("A")
	case "G":
		fmt.Println("C")
	}
}


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

using namespace std;


#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)


using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;


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

    int n, m;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    cin >> m;
    vint b(m);
    vint c,d;
    rep(i, m) cin >> b[i];
    set_symmetric_difference(all(a), all(b), inserter(c, c.end()));
    for (int i :c) cout << i << endl;
    return 0;
}


Measured memory_bytes: 10216
fun main(args: Array<String>) {
    data class Coupon(val ai: Int, val bi: Int, val discount: Int)
    val (a, b, m) = readLine()!!.split(" ").map(String::toInt)
    val an = readLine()!!.split(" ").map(String::toInt)
    val bn = readLine()!!.split(" ").map(String::toInt)

    val coupons = Array(m) {
        val (ai, bi, dis) = readLine()!!.split(" ").map(String::toInt)
        Coupon(ai - 1, bi - 1, dis)
    }

    var min = an.min()!! + bn.min()!!

    for ((ai, bi, dis) in coupons) {
        min = Math.min(min, an[ai] + bn[bi] - dis)
    }
    println(min)
}





Measured memory_bytes: 103244
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Dec  6 23:48:41 2018
//
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	fmt.Println((A - 1) * (B - 1))
}


Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    string N;cin>>N;
    while(N[0]!=N[1]||N[1]!=N[2]){
        int a=stoi(N);
        a++;
        N=to_string(a);
    }
    cout<<N<<endl;
    return 0;
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int n;
	cin >> n;
	int u = n/100, d = n % 100;
    if(u > 0 && u <= 12 && d > 0  && d <= 12 )cout << "AMBIGUOUS" << endl;
	else if(u > 0 && u <= 12) cout << "MMYY" << endl;
	else if(d > 0 && d <= 12) cout << "YYMM" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
#[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 mut $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 main() {
    input! {
        s: chars,
        t: chars,
    }

    let ans = (0..3).filter(|&i| s[i] == t[i]).count();

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


Measured memory_bytes: 4352
MOD = 10 ** 9 + 7

n, a, b = gets.chomp.split.map(&:to_i)
m = 2 * (10 ** 5)

inv = Array.new(m + 1)
m.times do |i|
  if i == 0
    inv[i + 1] = 1
  else
    inv[i + 1] = (- inv[MOD % (i + 1)] * (MOD / (i + 1))) % MOD
  end
end

comb = Array.new(b + 1)
comb[0] = 1
b.times do |i|
  comb[i + 1] = comb[i] * (n - i) * inv[i + 1] % MOD
end

res = 2.pow(n, MOD) - 1
res -= comb[a]
res -= comb[b]
res %=  MOD
puts res

Measured memory_bytes: 17360
#include <stdio.h>

int main()
{
	int i, N;
	long long A[300001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	
	int j;
	long long n, ans = 0, count[61][2] = {};
	for (i = 0, n = 1; i < 61; i++, n = n * 2 % 1000000007) {
		for (j = 1; j <= N; j++) {
			count[i][A[j]%2]++;
			A[j] /= 2;
		}
		ans = (ans + n * (count[i][0] * count[i][1] % 1000000007)) % 1000000007;
		for (j = 1; j <= N; j++) if (A[j] > 0) break;
		if (j > N) break;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	string s;
	cin>>s;
	bool res =true;
	if (s.size()%2!=0)
	{
		res = false;
	}
	
	for (size_t i = 0; i < s.size()-1; i+=2)
	{
		if (s.at(i)=='h' && s.at(i+1)=='i')
		{
			
		}else
		{
			res = false;
		}
		
		
	}

	if (res)
	{
		cout<<"Yes";
	} else
	{
		cout<<"No";
	}
	
	
	
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include <vector>
using namespace std;
int main() {
	long long n;
	for (int h = 0; h < 5; h++) {
		cin >> n; long long aa = 0, bb = 0, t = 0, f = 0, sum = 0, ans = 0;
		if (n == 0) { cin >> n; return 0; }
		int a[101], b[101] = { 0 };
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		for (int i = 1; i <= 2 * n; i++) {
			if (t == n + 1) { b[f] = i; f++; }
			else if (i != a[t]) { b[f] = i; f++; }
			else { t++; }
		}
		for (int i = 0; i < 1001; i++) {
			int usi = 0;
			for (int j = 0; j < n; j++) {
				if (sum < a[j] && usi == 0) { usi++; sum = a[j]; a[j] = 0; aa++; }
			}
			if (usi == 0) { sum = 0; }
			if (aa == n) { cout << n - bb << endl; cout << 0 << endl; i = 1001; }
			usi = 0;
			for (int j = 0; j < n; j++) {
				if (sum < b[j] && usi == 0) { usi++; sum = b[j]; b[j] = 0; bb++; }
			}
			if (usi == 0) { sum = 0; }
			if (bb == n) { cout << 0 << endl; cout << n - aa << endl; i = 1001; }
		}
	}
	cin >> n;
}


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<cstring>
#define cost first
#define val second
using namespace std;
typedef pair<int, int> Food;
const int N_FOOD = 3005;
const int TIME = 6005;


int nFood, limit;
Food food[N_FOOD];

void read() {
    cin >> nFood >> limit;
    for (int i = 0; i < nFood; ++i) {
        cin >> food[i].cost >> food[i].val;
    }
}


void work() {
    sort(food, food + nFood);
    
    int dp[TIME];
    memset(dp, -1, sizeof(dp));
    
    dp[0] = 0;
    for (int i = 0; i < nFood; ++i) {
        for (int j = limit - 1; j >= 0; --j) {
            if (dp[j] == -1) continue;
            dp[j + food[i].cost] = max(dp[j + food[i].cost], dp[j] + food[i].val);
        }
    }

    cout << *max_element(dp, dp + TIME) << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

int main() {
  int64_t n, y;
  std::cin >> n >> y;
  y /= 1000;

  for (int64_t a = 0; 9 * a <= y - n; a++) {
    const auto b = (y - n - 9 * a) / 4;
    const auto c = n - a - b;
    if (0 <= a && 0 <= b && 0 <= c && a + b + c == n
      && 10 * a + 5 * b + c == y) {
        std::cout << a << " " << b << " " << c << std::endl;
        return 0;
      }
  }
  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n500 = sc.nextInt();
        int n100 = sc.nextInt();
        int n50 = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;

        for (int i = 0; i <= n500; i++) {
            for (int j = 0; j <= n100; j++) {
                for (int k = 0; k <= n50; k++) {
                    if (i * 500 + j * 100 + k * 50 == x) {
                        count++;
                    }
                }
            }
        }
        // 出力
        System.out.println(count);
    }
}


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

int main(){
    string s;
    string t;
    rep(i,4){
        getline(cin, t);
        if(t=="")break;
        s+=t;
    }
    int count[26];
    rep(i,26)count[i]=0;
    rep(i,s.length()){
        int d=-1;
        rep(j,52){
            if(j<26){
                if(s[i]==((char)'a'+j))d=j;
            }
            if(j>=26){
                if(s[i]==((char)'A'+j-26))d=j-26;
            }
        }
        if(d!=-1)count[d]++;
    }
    rep(i,26){
        if(i<26)cout<<(char)('a'+i)<<" : "<<count[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <complex>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	long long n, k , r;
	cin >> n >> k;
	r = n / k;
	cout << min(abs(n - k * (r + 1)), abs(n - k * r)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  int c[6][6];
  rep(i,H) rep(j,W) {
    char color;
    cin >> color;
    if (color == '#') c[i][j] = 1;
    else c[i][j] = 0;
  }
  int ans = 0;
  rep(s,1<<(H+W)) {
    vector<bool> chosen(H+W);
    rep(i,(H+W)) {
      if (s>>i&1) chosen[i] = true;
    }
    int temp = 0;
    rep(i,H) rep(j,W) {
      if (chosen[i] || chosen[H+j]) continue;
      else if (c[i][j]) temp++;
    }
    if (temp == K) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>
    #include<string.h>
    int main(void) {
      int A,B,C;
      scanf("%d %d %d",&A,&B,&C);
      if(A==B){
          printf("%d",C);
      }else if(A==C){
          printf("%d",B);
      }else{
          printf("%d",A);
      }
      return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int A, B;
    cin >> A >> B;
    OUT(max(A-B*2,0))

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	if(c=='+') {
		printf("%d\n",a+b);
	}
	else{
		printf("%d\n",a-b);
	} 
	return 0;
}

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

using namespace std;

const int N = 55;
//51min!!
const int mod = 1e9+7;

int h;
int w;
int n;
long long ans[11];
set < pair < int , int > > grid , points;

int main(){
    scanf("%d%d%d" , &h , &w , &n);
    long long subgrids = 1LL * (h - 2) * (w - 2);
    //cout << subgrids << "\n";
    for(int i = 1; i <= n; i++){
        int x , y;
        scanf("%d%d" , &x , &y);
        points.insert({x , y});
        for(int a = -2; a <= 0; a++)
            for(int b = -2; b <= 0; b++)
                    grid.insert({x + a , y + b});
    }
    long long sum = 0;
    auto it = grid.begin();
    for(; it != grid.end(); it++){
        int cnt = 0;
        int x = it->first;
        int y = it->second;
        if(x < 1 || x > h-2 || y < 1 || y > w - 2)
            continue;
        for(int i = 0; i <= 2; i++)
            for(int j = 0; j <= 2; j++)
                if(points.find({x+i , y+j}) != points.end()){
                    cnt++;
                }
        //if(x + 2 <= h && y + 2 <= w){
            sum ++;
            ans[cnt]++;
        //}
    }
    ans[0] = subgrids - sum;
    for(int i = 0; i <= 9; i++){
        printf("%lld\n" , ans[i]);
    }
}

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

const int64_t MAX=505;
int64_t n,k,sum=0,a[MAX];

bool Check(int64_t g)
{
	vector<int64_t> V;
	for(int64_t i=1;i<=n;i++)
		V.push_back(a[i]%g);
	sort(V.begin(),V.end());
	int64_t l=0,r=V.size()-1,rem=0,sum=0;
	while(l<=r)
	{
		if(rem<=0)
		{
			rem+=V[l];
			sum+=V[l];
			l++;
		}
		else
		{
			rem-=(g-V[r]);
			sum+=(g-V[r]);
			r--;
		}
	}
	return (sum<=2*k&&rem==0);
}

int main() 
{
	ios_base::sync_with_stdio(false);
	// freopen("E.inp","r",stdin);
	cin>>n>>k;
	for(int64_t i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for(int64_t i=1;i*i<=sum;i++)
		if(sum%i==0&&Check(sum/i)==true)
		{
			cout<<sum/i;
			return 0;
		}
	for(int64_t i=sqrt(sum);i>=1;i--)
		if(sum%i==0&&Check(i)==true)
		{
			cout<<i;
			return 0;
		}

}

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

#define int long long

int q, a, b;

int get(int x) {
	int st = 0, ed = (int)1e9 + 10;
	while (ed - st > 1) {
		int mid = st + ed >> 1;
		if (mid * mid < x)
			st = mid;
		else
			ed = mid;
	}
	return st;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> q;
	while (q--) {
		cin >> a >> b;
		if (a > b)
			swap(a, b);
		
		if (b - a <= 1) {
			cout << 2 * a - 2 << '\n';
			continue;
		}
		
		int c = get(a * b);
		if (c * (c + 1) >= a * b)
			cout << 2 * c - 2 << '\n';
		else
			cout << 2 * c - 1 << '\n';
	}
}

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

int main() {
  string S;
  cin >> S;
  map<char,int> m;
  string alpha = "abcdefghijklmnopqrstuvwxyz";

  for(int i=0; i<S.size(); i++) {
    m[S[i]]++;
  }

  for(int j=0; j<26; j++) {
    if(m[alpha[j]] == 0) {
      cout << alpha[j] << endl;
      return 0;
    }
    if(j == 25)
      cout << "None" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

ll n,m,q;
ll a[55],b[55],c[55],d[55];
ll ans;

void keisan(vl vec){
    ll res=0;
    rep(i,q){
        if(vec[b[i]]-vec[a[i]]==c[i]) res+=d[i];
    }
    ans=max(ans,res);
}

void dfs(vl vec){
    if(vec.size()==n){
        keisan(vec);
    }
    else{
        ll last;
        if(vec.size()==0){
            last=1;
        }
        else{
            last=vec.back();
        }
        for(ll i=last;i<=m;i++){
            vec.pb(i);
            dfs(vec);
            vec.pop_back();
        }
    }
}


void solve(){
    cin >> n >> m >>q;
    ans=0;
    rep(i,q){
        cin >>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    vl vec={};
    dfs(vec);
    kaku(ans);
}

int main(){
    solve();
}

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

signed main(){
    int n; cin>>n;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    vector<int> nums;
    rep(i,n) nums.push_back(i+1);
    vector<int> vec(1000,0);
    
    rep(i,n){
        while(nums.at(i)!=1){
            for(int j=2; j<=nums.at(i); j++){
                if(nums.at(i)%j==0){
                    int cnt=0;
                    while(nums.at(i)%j==0){
                        cnt++;
                        nums.at(i)/=j;
                    }
                    vec.at(j-1)+=cnt;
                }
            }
        }
    }
    int ans=1,mod=pow(10, 9)+7;
    for(auto i:vec){
        ans=(ans*(i+1))%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007

 #define int long long


int MIN = I64_MAX;



const int MAX = 1000000;



void solve()
{

  int N,T;
  cin>>N>>T;

  vector<pair<int,int> > data(N,pair<int,int>(0,0));

  for (int i = 0; i < N; i++)
  { 
    int A,B;
    cin>>A>>B;
    data[i].first = A;
    data[i].second = B;
  }
  
  sort(data.begin(),data.end());

  

  vector<vector<int> > DP (N + 1,vector<int>(T, 0 ));
  
   for (int i = 1; i <= N; i++)
  {
    for (int j = 0; j < T; j++)
    {
      if(j - data[i-1].first < 0)
      {
        DP[i][j] = DP[i-1][j];
        continue;
      }
      DP[i][j] =max(DP[i-1][j],DP[i-1][j-data[i-1].first] + data[i-1].second);
    }  
  }
  int ANS = 0;
  
  for (int i = 0; i < N ; i++)
  {
    ANS = max(ANS,DP[i][T-1] + data[i].second);
  }

  cout<<ANS;
  
  return;  
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>


 int main(){int n,b,f,r,v,i,kanri[4][3][10];
 	scanf("%d",&n);
 	
 		for(b=0;b<4;b++){
 			for(f=0;f<3;f++){
 				for(r=0;r<10;r++){
 				kanri[b][f][r]=0;};
 	    };   
 	};
 	for(i=0;i<n;i++){
 	scanf("%d %d %d %d",&b,&f,&r,&v);
 	   kanri[b-1][f-1][r-1]= kanri[b-1][f-1][r-1]+v;
 	} 	;
 	for(b=0;b<4;b++){
 			for(f=0;f<3;f++){
 				for(r=0;r<10;r++){
 				printf(" %d",kanri[b][f][r]);
 				};
 	       printf("\n");};  
 	       if(b<3){
 	printf("####################\n");};};
 	
 return 0;}



Measured memory_bytes: 2088
use std::io;


fn main() {
    let (_, x) = {
        let i = read::<isize>();
        (i[0], i[1])
    };
    let xn = read::<isize>();

    let mut ans = 0;
    for i in xn {
        let dist = (i - x).abs() as u64;
        ans = gcd(ans, dist);
    }

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

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[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: 6396
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    
    int len = (int)s.length();

    vector<int> rng(len+1);
    for(int i = 1; i < len; i++){
        if(s[i]=='C' && s[i-1]=='A') rng[i+1] = 1;
    }

    for(int i = 1; i <= len; i++){
        rng[i]+=rng[i-1];
    }

    while(q--){
       int l,r;
        cin>>l>>r;
        int sb = 0;
        if(s[l-1]=='C' && l-1 && s[l-2]=='A') sb=1;
       cout<<(rng[r]-rng[l-1] - sb)<<"\n";
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ull nax=1e9;
ll n,m;
ll valid(ll i,ll j)
{
 if(i>=0 && i<n && j>=0 && j<m)
 return true;
 return false;
 //return 0;
}
int main()
{ 
    int n,k;
    cin>>n>>k;
    cout<<n*k;
    return 0;
}


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

int main()
{
    long n,ans; cin>>n;
    long a[n],max1,max2;
    priority_queue<long, vector<long>, less<long>> Q;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
        Q.push(a[i]);
    }
    
    max1 = Q.top();
    Q.pop();
    max2 = Q.top();
    
    for(int i=0;i<n;++i){
        if(a[i]==max1)cout<<max2<<endl;
        else cout<<max1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int x;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.x = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        if(x==0) {
        	answer = 1;
        }
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  int min = a.at(0);
  int count = 1;
  
  for(int i=0; i<n; i++) {
    if(a.at(i) < min) {
      count ++;
      min = a.at(i);
    }
  }
  
  cout << count << endl;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,K;
  cin >> N >> K;

  if(K > (N-1)*(N-2)/2){
    cout << -1 << endl;
    return 0;
  }


  // 追加するへんの数
  int M = 0;
  M = N-1 + (N-1)*(N-2)/2 - K;
  cout << M << endl;

  // 0と、1からN-1までをつないでおく
  for(int i = 2; i <= N; i++){
    cout << 1 << " " << i << endl;
  }
  // iとj(1<=i<j<=N)の組みを、(N-1)*(N-2)/2 - K本出す
  int target = (N-1)*(N-2)/2 - K;
  int num = 0;
  cerr << "target: " << target << endl;
  for(int i = 2; i <= N-1; i++){
    for(int j = i+1; j <= N; j++){
      if(num == target) break;
      cout << i << " " << j << endl;
      num++;
    }
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
isAC = [False for _ in range(N)]
correct = 0
penalty = [0 for _ in range(N)]
for _ in range(M):
    tmp = input().split()
    pi, Si = int(tmp[0]), tmp[1]
    if not isAC[pi-1]: # すでにAC
        if Si == 'AC':
            isAC[pi-1] = True
            correct += 1
        else:
            penalty[pi-1] += 1
pnl = 0
for idx in range(N):
    if isAC[idx]:
        pnl += penalty[idx]
print(correct, pnl)

Measured memory_bytes: 50736
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int d;

vector<int> c;
vector<vector<int>> s;
vector<int> t;

int last(int d, int i) {
  int j;

  for (j=d; j>=0; j--) {
    if (t[j] == i) return d-j;
  }
  return d+1;
}

int cdiff(int, int);

int main()
{
  int i, j;

  c.resize(26);
  cin >> d;
  for(i=0; i<26; i++) {
    cin >> c[i];
  }

  s.resize(d);
  for (i=0; i<d; i++) {
    s[i].resize(26);
    for (j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  t.resize(d);

  for (i=0; i<d; i++) {
//    t[i] = i%26;
    t[i] = 0;
  }
  int conf = 0;

  for (i=0; i<d; i++) {
    conf += s[i][t[i]];
//printf("+ %d\n", s[i][t[i]]);
    for (j=0; j<26; j++) {
      int cm;
      cm = c[j] * last(i, j);
      conf -= cm;
//printf("- %d\n", cm);
    }
  }

//printf("conf = %d\n", conf);

  int maxconf, pmax;
  maxconf = conf;

  for (int loop=0; loop<100; loop++) {

    pmax = maxconf;
    for (i=0; i<d; i++) {
      int oc;
      int mc;
      oc = t[i];
      mc = oc;
//printf("t[%d] = %d conf = %d\n", i, oc, conf);
      for (j=(oc+1)%26; j!=oc; j=(j+1)%26) {
        conf += cdiff(i, j);
//printf("t[%d] = %d conf = %d\n", i, t[i], conf);
        if (conf > maxconf) {
          maxconf = conf;
          mc = j;
//printf("%d %d %d\n", i, j, conf);
        }
      }
      t[i] = mc;
      conf = maxconf;
    }
    if (maxconf == pmax) break;
    pmax = maxconf;
//printf("maxconf = %d\n", maxconf);
  }

  for (i=0; i<d; i++) {
    printf("%d\n", t[i]+1);
  }
  return 0;
}
int cdiff(int xd, int xq) {
  int rdiff;
  int oq;
  int j;

  oq = t[xd];

  rdiff = s[xd][xq] - s[xd][oq];
//printf("s[%d][%d] = %d -> s[%d][%d] = %d\n", xd ,oq, s[xd][oq], xd, xq, s[xd][xq]);

  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff += c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff += c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }

  t[xd] = xq;
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff -= c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff -= c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }
  return rdiff;
}


Measured memory_bytes: 3796
#!python3.4
# -*- coding: utf-8 -*-
# abc162/abc162_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2s()
    if '7' in N:
        print('Yes')
    else:
        print('No')
    return

main()


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    int a, b, k, cnt = 0, tmp;
    cin >> a >> b >> k;
    vector<int> v(100);
    for (int i = 100; i >= 1; i--)
    {
        if (((a % i) == 0) && ((b % i) == 0))
        {
            cnt++;
            tmp = i;
        }
        if (cnt == k)
        {
            cout << tmp << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,w[N];
inline int read(){
	int num=0; char g=getchar(); while(g<48||57<g) g=getchar();
	while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); return num;
}
inline int gcd(int a,int b){
	if(!b) return a; return gcd(b,a%b);
}
inline bool solve(int k){
	if(k&1) return 1;
	if(k+1==n){
		int x=0;
		for(int i=1;i<=n;i++){
			if(w[i]==1) return 0;
			else if(w[i]&1) {w[i]--; break;}
		}
		for(int i=1;i<=n;i++) x=gcd(x,w[i]);
		for(int i=1;i<=n;i++) w[i]/=x;
		k=0; for(int i=1;i<=n;i++) if(!(w[i]&1)) k++;
		return solve(k)^1;
	}
	return 0;
}
int main(){
	n=read(); int x=0; int pos=0,cnt=0;
	for(int i=1;i<=n;i++) w[i]=read();
	for(int i=1;i<=n;i++) if(!(w[i]&1)) cnt++;
	if(solve(cnt)) puts("First"); else puts("Second");
	return 0;
}

Measured memory_bytes: 640