akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

template<typename T>
struct SegmentTree {
	int n;
	T unit;
	vector<T>dat;
	function<T(T, T)> func;
	SegmentTree(const int N, T _unit, function<T(T, T)> _func)
		:unit(_unit), func(_func) {
		n = 1;
		//簡単のため、要素数を2のべき乗に
		while (n < N)n *= 2;
		dat.assign(2 * n, unit);
	}

	void update(int k, T a) {
		k += n - 1;//葉の節点
		dat[k] = a;
		//上りながら更新
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	T _query(int a, int b, int k, int l, int r) {
		//[a,b)と[l,r)が交差していなければ、funcに影響を与えない値を返す
		if (r <= a || b <= l)return unit;
		//[a,b)が[l,r)を完全に含んでいれば、この節点の値
		if (a <= l && r <= b)return dat[k];
		else {
			int vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
			return func(vl, vr);
		}
	}
	//[a,b)
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}
};
//auto f = [](int a, int b) {return a + b; };
//SegmentTree<int>seg(N,0,f);

int cnt[100010];
void solve() {
	unordered_map<int, int>mp;
	int N, K; cin >> N >> K;
	vector<int>A(N), cum(N + 1);
	REP(i, N) {
		cin >> A[i];
		A[i] = A[i] + K - 1;
		A[i] %= K;
	}
	ll ans = 0;
	mp[0]++;
	queue<int>que;
	que.push(0);
	REP(i, N) {
		if (i >= K - 1) {
			int tmp = que.front(); que.pop();
			mp[tmp]--;
		}
		int now = A[i];
		cum[i + 1] = cum[i] + A[i];
		cum[i + 1] %= K;
		ans += mp[cum[i + 1]];
		que.push(cum[i + 1]);
		mp[cum[i + 1]]++;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//test();
	solve();
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        set<int> s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        ans += s.size() - 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
int h[101];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    int ans = h[0];
    for(int i = 1; i < N; i++){
        if(h[i] >= h[i-1]) ans += (h[i]-h[i-1]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(str(input()))
cntr = t.count("r")
cnts = t.count("s")
cntp = t.count("p")
cntr0 = 0
cnts0 = 0
cntp0 = 0
ans = 0
# print(t)
for i in range(n-k):
    if t[i] == "r"and t[i] == t[i+k]:
        cntr0 += 1
        t[i+k] = "q"
    elif t[i] == "s"and t[i] == t[i+k]:
        cnts0 += 1
        t[i+k] = "q"
    elif t[i] == "p"and t[i] == t[i+k]:
        cntp0 += 1
        t[i+k] = "q"

ans = p*(cntr - cntr0) + r*(cnts - cnts0) + s*(cntp - cntp0)
print(ans)
    



Measured memory_bytes: 49136
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


using ll=long long;

#define MOD 1000000007

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=MOD; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v) {}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return m_v;}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		return *this;
	}
	mod_ll operator += (ll rhs)
	{
		m_v=(m_v+rhs)%m_m;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator *= (ll rhs)
	{
		m_v=(m_v*rhs)%m_m;
		return *this;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator /= (ll rhs)
	{
		mod_ll t(rhs);
		return *this/=t;
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};


mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if(memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}


mod_ll mod_nCr(int n, int r)
{
	mod_ll bunsi=mod_fact(n);
	mod_ll bunbo=mod_fact(n-r)*mod_fact(r);
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r)
{
	mod_ll ret(1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}



int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		vi a(n);
		for(int i=0;i<n;i++) scanf("%d", &a[i]);

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

		mod_ll sn, sp;
		for(int i=0;;i++)
		{
			if(n-1-i<k-1) break;
			sn+=mod_nCr(n-1-i, k-1)*((MOD-a[i])%MOD);
			sp+=mod_nCr(n-1-i, k-1)*((a[n-1-i]+MOD)%MOD);
		}
		auto ans=sp+sn;
		printf("%lld\n", ans());
	}
	return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

int main() {
    string s;
    cin>>s;
    int sum=0;
    int n=s.size();
    rep(i,n){
        int a=stoi(s.substr(i,1));
        sum+=a;
    }
    
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


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

using namespace std;

const int NMAX = 100000;

typedef long long I64;

I64 pos[NMAX+2], val[NMAX+2], sp[NMAX+2], sp2[NMAX+2];
I64 cost_lef[NMAX+2], cost_rig[NMAX+2];
I64 best_lef[NMAX+2], best_rig[NMAX+2];
I64 best = 0;
I64 N, C;

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

    cin >> N >> C;
    for( int i = 1;  i <= N;  ++i ) {
        cin >> pos[i] >> val[i];
        sp[i] = sp[i - 1] + val[i];
        cost_rig[i] = sp[i] - pos[i];
        best_rig[i] = max(best_rig[i - 1], cost_rig[i]);
    }
    for( int i = N;  i >= 1;  --i ) {
        sp2[i] = sp2[i + 1] + val[i];
        cost_lef[i] = sp2[i] - (C - pos[i]);
        best_lef[i] = max(best_lef[i + 1], cost_lef[i]);
    }
    best = max(0LL, max(best_lef[1], best_rig[N]));
    for( int i = 1;  i <= N;  ++i ) {
        I64 c_lef = cost_lef[i] + best_rig[i - 1] - (C - pos[i]);
        if( i > 1 )
            best = max(best, c_lef);
        I64 c_rig = cost_rig[i] + best_lef[i + 1] - pos[i];
        if( i < N )
            best = max(best, c_rig);
    }
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 6528
n,m = [int(i) for i in input().split()]
l = [[int(i) for i in input().split()] for _ in range(m)]   
ans = [0 for _ in range(n)]

flg = True
for x,y in l:
    if x == 1 and y == 0 and n > 1:
        flg = False
    elif ans[x-1] == 0 or ans[x-1] == y:
        ans[x-1] = y
    else:
        flg = False
        break


ans = [str(i) for i in ans]

if n > 1 and ans[0] == '0':ans[0] = '1'

print(''.join(ans) if flg else -1)    






Measured memory_bytes: 3064
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51];main(n,d,T){for(n=1;n<51;n++)for(m[n]=9999,d=5;~d;d--)if(a[d]<=n&&m[n]>(T=m[n-a[d]]+b[d]))m[n]=T;for(;scanf("%d",&n),n;)printf("%d\n",m[n/100]);exit(0);}

Measured memory_bytes: 600
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

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

int n;

int indx[1010][1010];

int eges[1010][1010];

vi graph[1000010];

int indeg[1000010];

int vis[1000010];

map<ii,bool> m;

int color[1000010];

bool dfs(int v){
	color[v] = 1;
	for(auto u:graph[v]){
		if(color[u]==0){
			if(dfs(u))
			  return true;
		}
		else if(color[u]==1)
			return true;
	}
	color[v] = 2;
	return false;
}

int dp[1000010];

void diam(int v){
	vis[v] = 1;
	for(int u:graph[v]){
		if(vis[u]==0)
			diam(u);
	}
	for(int u:graph[v])
		dp[v] = max(dp[v],dp[u] + 1);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n;
	int loli = 1;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			indx[i][j] = loli;
			indx[j][i] = loli;
			loli++; 
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			int x;
			cin>>x;
			int index = indx[i][x];
			eges[i][j] = index; 
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j+1<n;j++){
			ii point1 = {eges[i][j],eges[i][j+1]};
			if(m.find(point1)==m.end()){
				m[point1] = 1;
				graph[eges[i][j]].pb(eges[i][j+1]);
				indeg[eges[i][j+1]]+=1;
			}
		}
	}
	for(int i=1;i<loli;i++){
		if(indeg[i]==0){
			graph[0].pb(i);
		}
	}
	if(dfs(0)==true){
		cout<<-1;
		return 0;
	}
	diam(0);
	if(dp[0]==0){
		cout<<-1;
		return 0;
	}
	cout<<dp[0]<<endl;
	return 0;
}


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

int main()
{
     int n;
     int prm[1000000];
     for (int i = 0; i < 1000000; i++) prm[i] = 1;
     prm[0] = prm[1] = 0;
     for (int i = 2; i <= 123456; i++)
          for (int j = 2; j * i <= 123456 * 2; j++)
               prm[i * j] = 0;

     while (cin >> n, n) {
          int count = 0;
          for (int i = n + 1; i <= n * 2; i++)
               if (prm[i] == 1)
                    count++;
          cout << count << endl;
     }

     return 0;
}

Measured memory_bytes: 5064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N;
    cin >> N;
    map<int, int> A;
    set<int> B;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        B.insert(tmp);
        A[tmp]++;
    }
    int ans = 0;
    for (int i : B)
    {
        if (A[i] & 1)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  if (N%1110 < 10) {
    cout << "Yes" << endl;
  }
  else if (N%1000%111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
return 0;
}

Measured memory_bytes: 3624
N,Y = map(int,input().split())
for x in range(N + 1):
    for y in range(N + 1):
        z = N - x - y
        if z < 0:
            continue
        sm = 10000 * x + 5000 * y + 1000 * z
        if sm == Y:
            print(x, y, z)
            exit(0)
print(-1, -1, -1)

Measured memory_bytes: 40924
# 2019/05/13
# AtCoder Beginner Contest 076 - C

# Input
s = input()
t = input()
aidx = -1

# Search t
for i in range(len(s)-1, len(t)-2, -1):
    if s[i] == "?" or s[i] == t[len(t)-1]:
        aflg = True
        for j in range(len(t)-2, -1, -1):
            if s[i-(len(t)-j)+1] == "?":
                continue
            elif s[i-(len(t)-j)+1] == t[j]:
                continue
            else:
                aflg = False
                break
        if aflg == True:
            aidx = i
            break

if aidx == -1:
    ans = "UNRESTORABLE"
else:
    # Make answer
    ans = ""
    i = len(s)-1
    while(i >= 0):
        if i != aidx:
            if s[i] == "?":
                ans = "a" + ans
            else:
                ans = s[i] + ans
            i -= 1
        else:
            ans = t + ans
            i -= len(t)
# Output
print(ans)

Measured memory_bytes: 3064
n, k = map(int,input().split())
d = list(map(str, input().split()))
def search(x):
    count = 0
    for i in d:
        if str(x).find(i) == -1:
            count += 1
    if len(d) == count:
        return True
while True:
   if search(n):
       break
   else:
       n += 1
print(n)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int f[256] = {0};
	f['q'] = f['w'] = f['e'] = f['r'] = f['t'] = 1;
	f['a'] = f['s'] = f['d'] = f['f'] = f['g'] = 1;
	f['z'] = f['x'] = f['c'] = f['v'] = f['b'] = 1;
	string s;
	while( cin >> s ){
		if( s == "#" ) break;

		int cnt = 0;
		int prev = f[ s[0] ];
		for(int i=1 ; i < s.size() ; i++ ){
			if( prev != f[ s[i] ] ){
				cnt++;
				prev = f[ s[i] ];
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string.h>
int main() 
{ 
     long int n;cin>>n;
     long int array[n];
     for(long int i=0;i<n;i++)
        cin>>array[i];
        
    long int h=0;    
     for(long int i=0;i<n-1;i++)
    {
        if(array[i]>array[i+1]){
            h+=array[i]-array[i+1];
            array[i+1]=array[i];
        }
    }
    cout<<h;
        
   
        
}         

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, W;
vector<long long> v(110, 0);
vector<long long> v0(110, 0);
vector<long long> v1(110, 0);
vector<long long> v2(110, 0);
vector<long long> v3(110, 0);
vector< vector<long long> > graphlist(4, vector<long long>());
long long ans = 0;

int main() {
    cin >> n >> W;
    long long w1 = 0;
    for(int i = 0; i < n; ++i) {
        long long v, ww;
        if(i == 0) {
            cin >> w1 >> v;
            graphlist.at(0).push_back(v);
        }else {
            cin >> ww >> v;
            graphlist.at(ww-w1).push_back(v);
        }
    }

    int wsize0 = graphlist.at(0).size();
    int wsize1 = graphlist.at(1).size();
    int wsize2 = graphlist.at(2).size();
    int wsize3 = graphlist.at(3).size();

    sort(graphlist.at(0).begin(), graphlist.at(0).end(), greater<long long>());
    sort(graphlist.at(1).begin(), graphlist.at(1).end(), greater<long long>());
    sort(graphlist.at(2).begin(), graphlist.at(2).end(), greater<long long>());
    sort(graphlist.at(3).begin(), graphlist.at(3).end(), greater<long long>());

    for(int i = 0; i < wsize0; ++i) v0.at(i+1) += v0.at(i) + graphlist.at(0).at(i);
    for(int i = 0; i < wsize1; ++i) v1.at(i+1) += v1.at(i) + graphlist.at(1).at(i);
    for(int i = 0; i < wsize2; ++i) v2.at(i+1) += v2.at(i) + graphlist.at(2).at(i);
    for(int i = 0; i < wsize3; ++i) v3.at(i+1) += v3.at(i) + graphlist.at(3).at(i);
    
    for(int i = 0; i <= wsize0; ++i) {
        for(int j = 0; j <= wsize1; ++j) {
            for(int k = 0; k <= wsize2; ++k) {
                for(int l = 0; l <= wsize3; ++l) {
                    long long wlimit = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
                    if(wlimit <= W) {
                        long long vmax = v0.at(i)+v1.at(j)+v2.at(k)+v3.at(l);
                        chmax(ans, vmax);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
  int k=0;
  cin>>k;
  vector<int> vec={1,1,1};
  vector<int> svec(3);
  int sum=0;
  
  for(int i=1;i<k+1;i++){
    for(int j=1;j<k+1;j++){
      for(int l=1;l<k+1;l++){
        svec=vec;
        sort(svec.begin(),svec.end());
        reverse(svec.begin(),svec.end());
        for(int m=svec.at(2);m>0;m--){
          if(svec.at(0)%m==0&&svec.at(1)%m==0&&svec.at(2)%m==0){
            sum+=m;
            break;
          }
        }
        vec.at(2)++;
      }
      vec.at(2)=1;
      vec.at(1)++;
    }
    vec.at(2)=1;
    vec.at(1)=1;
    vec.at(0)++;
  }
  cout<<sum;
}

Measured memory_bytes: 3628
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
string S = "";

int main() {
	scanf("%lld", &N);
	cin >> A;
	cout << A * N << "\n";

	
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3764
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	S := make([]int, N)
	S[0] = A[0]
	mp := map[int]int{}
	mp[0]++
	mp[S[0]]++

	count := 0
	for i := 1; i < N; i++ {
		S[i] = A[i] + S[i-1]
		mp[S[i]]++
	}

	for _, v := range mp {
		count += ((v - 1) * v) / 2
	}

	fmt.Println(count)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

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

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

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


Measured memory_bytes: 18816
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

char S[8001];
int n, x, y;
vector<int> mv[2];

bool dp[16001], tp[16001];
bool check(vector<int> &vs, int x) {
    if (x > n || x < -n) return 0;
    for (int i = 0; i <= n + n; ++i) tp[i] = dp[i] = 0;
    dp[n] = 1;
    for (int v : vs) {
        for (int i = 0; i <= n + n; ++i) {
            if (dp[i]) {
                tp[i + v] = 1;
                tp[i - v] = 1;
            }
        }
        for (int i = 0; i <= n + n; ++i) {
            dp[i] = tp[i];
            tp[i] = 0;
        }
    }
    return dp[x + n];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> S >> x >> y;
    n = strlen(S);
    int st = 0;
    for (int i = 0; i < n; ++i) {
        if (S[i] == 'T') st ^= 1;
        else {
            int j = i;
            while (j + 1 < n && S[j + 1] == 'F') ++j;
            if (i > 0) mv[st].push_back(j - i + 1);
            else x -= j - i + 1;
            i = j;
        }
    }
    printf(check(mv[0], x) && check(mv[1], y) ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int j = 0;
 
  for (int i = A; i <= B; i++) {
    if (i / 10000 == i % 10 && i / 1000 - (i / 10000) * 10 == (i % 100 - i % 10) / 10) {
    j++;
    }
  }

  cout << j <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

#define int ll

const int maxn = 3005;
int dp[maxn][maxn][2], n;
ii a[maxn];

int f(int i, int t, int g){
  if(i == n) return 0;
  int& ret = dp[i][t][g];
  if(ret != -1){
    return ret;
  }
  ret = 0;
  ret = max(ret, f(i + 1, t, g));
  if(t > 0){
    ret = max(ret, a[i].second + f(i + 1, max(0ll, t - a[i].first), g));
  }
  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int t;
  cin >> n >> t;
  for(int i = 0; i < n; i++){
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n);
  memset(dp, -1, sizeof dp);
  cout << f(0, t, 0);
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;

void work()
{
    cin >>n;
    int cnt = 0;
    int mn = n + 1;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >>x;
        if(x < mn) cnt++;

        mn = min(mn, x);
    }
    cout <<cnt <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

const int INF = 10e6;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];
    int ans = 10000;
    int minW = 10000000;
    for(int i = 1; i < n; i++) {
        int s1 = 0;
        int s2 = 0;
        for(int a = 0; a < i; a++) {
            s1 += w[a];
        }
        for(int a = i; a < n; a++) {
            s2 += w[a];
        }
        if(min(minW, abs(s1-s2)) == abs(s1-s2)) {
            ans = i - 1;
            minW = abs(s1-s2);
        }
    }

    cout << minW << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x;  cin >> x;
	if (x >= 400 && x <= 599) cout << 8;
	if (x >= 600 && x <= 799) cout << 7;
	if (x >= 800 && x <= 999) cout << 6;
	if (x >= 1000 && x <= 1199) cout << 5;
	if (x >= 1200 && x <= 1399) cout << 4;
	if (x >= 1400 && x <= 1599) cout << 3;
	if (x >= 1600 && x <= 1799) cout << 2;
	if (x >= 1800 && x <= 1999) cout << 1;
}

Measured memory_bytes: 3632
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

long int gcd(long int a, long int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {
	long int a, b;
	cin >> a >> b;
	long int g = gcd(a, b);
	long int c = a * b / g;
	cout << c;


}


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

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x; cin >> x;
    while (!prime(x)) x++;
    cout << x << '\n';
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multi_array.hpp>
//#include <boost/optional.hpp>

using namespace std;
using boost::irange;

typedef long long           ll;
typedef pair<ll, ll>	    P;

#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
static void solve()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (auto i : irange<ll>(0, N)) {
		cin >> A[i];
	}
	sort(ALL(A));

	string ans = "IMPOSSIBLE";
	if (A.end() != find_if(ALL(A), [K](int a) {return K == a; })) {
		ans = "POSSIBLE";
	}

	ll divVal = A[0];
	while (1) {
		ll nextDivVal = 0;
		for (auto one : A) {
			nextDivVal = one % divVal;
			if (nextDivVal != 0) break;
		}
		if (0 == nextDivVal) {
			break;
		}
		divVal = nextDivVal;
	}

	for (auto one : A) {
		if (one > K) {
			ll diff = one - K;
			if (diff % divVal == 0) {
				ans = "POSSIBLE";
				break;
			}
		}
	}

	cout << ans << endl;
}

/*-----------------------------------------------------------------------------
　メイン
 -----------------------------------------------------------------------------*/
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int n,i,ans=0;
char a[111],b[111],c[111];
scanf("%d",&n);
scanf("%*c%s%*c%s%*c%s",a,b,c);
for(i=0;i<n;i++){
if(a[i]!=b[i]||b[i]!=c[i]){
if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])
ans+=2;
else
ans++;
}
}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		for(int j=0; j<data; j++){
			int max = 0;
			int before = sc.nextInt();
			int year = sc.nextInt();
			int type_num = sc.nextInt();
			for(int i=0; i<type_num; i++){
				int type = sc.nextInt();
				double rate = sc.nextDouble();
				int fee = sc.nextInt();
				int after = 0;
				switch(type){
					case 0:
					after = Simple_interest(before, year, rate, fee);
					break;
					case 1:
					after = Compound_interest(before, year, rate, fee);
					break;
				}
				if(max < after) max = after;
			}
			System.out.println(max);
		}
	}

	public static int Simple_interest(int before, int year, double rate, int fee){
		int fortune = before, interest = 0;

		for(int i=0; i<year; i++){
			interest += fortune*rate;
			fortune -= fee;
		}

		return fortune+interest;
	}

	public static int Compound_interest(int before, int year, double rate, int fee){
		int fortune = before, interest = 0;

		for(int i=0; i<year; i++){
			interest += fortune*rate;
			fortune = fortune + interest - fee;
			interest = 0;
		}

		return fortune;
	}
}

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    for(int i = 0;i < k;i++){
        if(a >= b){
            b=b*2;
        }else if(b >= c){
            c=c*2;
        }
    }
    if(b > a && c > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3616
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	t = readline() |> chomp
	l = length(s)
	alf = Array{Int}(26,l)
	d = Dict{Char,Array{Int,1}}()
	for i in 1:l
		if haskey(d,s[i])
			push!(d[s[i]],i)
		else
			d[s[i]] = [i]
		end
	end
	for i in 1:26
		if haskey(d,Char(i+96))
			now = 1
			for j in 1:length(d[Char(i+96)])
				while now<d[Char(i+96)][j]
					alf[i,now] = d[Char(i+96)][j]
					now += 1
				end
			end
			while now <= l
				alf[i,now] = d[Char(i+96)][1]
				now += 1
			end
		end
	end
	k = 0
	f = 0
	z = length(t)
	now = l
	for i in 1:z
		if alf[Int(t[i])-96,now] == 0
			f = 1
			break
		elseif alf[Int(t[i])-96,now]<=now
			k += l-now+alf[Int(t[i])-96,now]
			now = alf[Int(t[i])-96,now]
		else
			k += alf[Int(t[i])-96,now]-now
			now = alf[Int(t[i])-96,now]
		end
	end
	println(f==1?-1:k)

end

main()

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

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

using namespace std;

int main(){
  ll h,w,k;
  cin>>h>>w>>k;
  
  vector<vector<ll>> b;
  rep(i,h){
    vector<ll> t(w);
    rep(i,w){
      t[i]=0;
    }
    b.push_back(t);
  }
  ll s=1;
  rep(i,h){
    string t;
    cin>>t;
    rep(j,w){
      if(t[j]=='#'){
        b[i][j]=s++;
      }
    }
  }

  ll c=0;
  rep(i,h){
    rep(j,w){
      if(b[i][j]!=0 && b[i][j]!=c){
        c=b[i][j];
      }
      b[i][j]=c;
    }
    rep(j,w){
      ll jj=w-1-j;
      if(b[i][jj]!=0 && b[i][jj]!=c){
        c=b[i][jj];
      }
      b[i][jj]=c;
    }
    c=0;
  }
  
  c=0;
  rep(j,w){
    rep(i,h){
      if(b[i][j]!=0 && b[i][j]!=c){
        c=b[i][j];
      }
      b[i][j]=c;
    }
    rep(i,h){
      ll ii=h-1-i;
      if(b[ii][j]!=0 && b[ii][j]!=c){
        c=b[ii][j];
      }
      b[ii][j]=c;
      
    }
    c=0;
  }

  
  rep(i,h){
    rep(j,w){
      cout<<b[i][j]<<' ';
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字数の取得
		int a = sc.nextInt();
		// 文字列の取得
		String word = sc.next();
		// 指定インデックスの取得
		int c = sc.nextInt();
		
		//比較する文字の取り出し
		String base = word.substring(c-1, c);
		
		// base文字と違ったら"*"を返す
		for(int i = 0; i<a; i++){
			if(base.equals(word.substring(i,i+1))){
				System.out.print(word.substring(i,i+1));
			}else{
				System.out.print("*");
			}
		}
	}
}

Measured memory_bytes: 23124
/*
 * 2508.cc: King's Inspection
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int ks[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) cin >> ks[i];

    string s;
    cin >> s;
    int m = s.size();

    for (int i = 0, j = 0; i < m; i++, j = (j + 1) % n) {
      int d = (s[i] >= 'a' && s[i] <= 'z') ? s[i] - 'a' : s[i] - 'A' + 26;
      d = (d + 52 - ks[j]) % 52;
      putchar((d < 26) ? 'a' + d : 'A' + d - 26);
    }
    putchar('\n');
  }

  return 0;
}

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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	if (B - A + 1 >= 2 * K) {
		for (int i = A; i < A + K; i++) {
			cout << i << endl;
		}
		for (int j = B - K + 1; j < B + 1; j++) {
			cout << j << endl;
		}
	}
	else {
		for (int k = A; k < B + 1; k++) {
			cout << k << endl;
		}
	}

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a,b;
    cin >>a>>b;
    if((a*b)%2==0){
        cout<<"Even"<<endl;
    }else{
        cout << "Odd" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};

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

    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];

    int x = 0;
    int y = 0;

    while(1){
        int cnt = 0;
        int togo;
        rep(d, 4){
            int dx = x + di[d];
            int dy = y + dj[d];

            if(dx<0 || dx>=w || dy<0 || dy>=h) continue;
            if(a[dy][dx] == '#') {
                ++cnt;
                togo = d;
            }
        }
        if(cnt>1 || (cnt==1) && (togo==2 || togo==3)){
            puts("Impossible");
            return 0;
        }
        else{
            a[y][x] = '.';
            x = x + di[togo];
            y = y + dj[togo];
        }
        // cout << x << " " << y << endl;
        // rep(i, h) cout << a[i] << endl;
        // return 0;
        if(x==w-1 && y==h-1) break;
    }

    rep(d, 4){
        int dx = x + di[d];
        int dy = y + dj[d];

        if(dx<0 || dx>=w || dy<0 || dy>=h) continue;
        if(a[dy][dx] == '#') {
            puts("Impossible");
            return 0;
        }
    }

    puts("Possible");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N;
	cin >> N;
	int V[N];
	int C[N];
	int sum=0;
	rep(i,0,N){
		cin >> V[i];
	}
	rep(i,0,N){
		cin >> C[i];
	}
	rep(i,0,N){
		if(V[i]>C[i]){
			sum += V[i]-C[i];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int s[100001];

int nibun(int k,int n){
  int h,t;
  h=0;
  t=n;
  while(h<t){
    if(k==s[(h+t)/2]){
      return 1;
    }else if(k<s[(h+t)/2])t=(h+t)/2;
    else if(k>s[(h+t)/2])h=(h+t)/2+1;
  }
  return 0;
}

int main(){
  int n,q,t,h,k;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    h=0;
    cin>>t;
    h=nibun(t,n);
    if(h==1)k++;
  }
  cout<<k<<endl;
  return 0;
}

Measured memory_bytes: 1544
import math
if __name__ == '__main__':
    #s = input().rstrip().split(' ')
    X = int(input())
    #print((math.log(X)-math.log(100))/math.log(1.01))
    acc = 100
    for i in range(3800):
        acc *= 1.01
        acc = math.floor(acc)

        if(acc >= X):
            print(i+1)
            exit()


Measured memory_bytes: 9156
#include <iostream>

using namespace std;

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, A, B, C;
	cin >> A >> B;

	if ((A % 2) && (B % 2))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long M=1000000007;
long long n,a[200005],b[200005],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
		b[i]=b[i-1]+a[i];
		b[i]%=M;
	}
	for(int i=2;i<=n;++i)
	 ans=(ans+a[i]*b[i-1])%M;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
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);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  int cnt = 0, ans = 0;
  rep(i, m) {
    cin >> a[i] >> b[i];
    if(a[i] < n) cnt += n - a[i];
  }
  sort(a, a + m);
  if(a[0] < n) cnt -= n - a[0];
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{ll s,t,d;};
typedef vector<vector<Edge>> Graph;

pair<bool, vvi> allPairsShortestPath(Graph &graph){
  bool hasNegativeCycle=false;
  ll V=graph.size();
  vvi dist(V,vi(V,INF));
  REP(i,V) dist[i][i]=0;
  REP(i,V) for(Edge e:graph[i]) dist[e.s][e.t]=e.d;
  REP(l,V+1){
    REP(i,V) REP(j,V) REP(k,V) {
      if(dist[i][k]!=INF&&dist[k][j]!=INF&&dist[i][j]>dist[i][k]+dist[k][j]){
        dist[i][j]=dist[i][k]+dist[k][j];
      }
    }
  }
  REP(i,V) if(dist[i][i]<0) hasNegativeCycle=true;
  return {hasNegativeCycle,dist};
}

int main(){
  ll V,E; cin>>V>>E;
  Graph graph(V);
  REP(i,E){
    Edge e; cin>>e.s>>e.t>>e.d;
    graph[e.s].PB(e);
  }
  pair<bool,vvi> ans=allPairsShortestPath(graph);
  if(ans.first) {cout<<"NEGATIVE CYCLE"<<endl; return 0;}
  vvi dist=ans.second;
  REP(i,V){
    REP(j,V){
      if(dist[i][j]==INF) cout<<"INF";
      else cout<<dist[i][j];
      if(j!=V-1) cout<<' ';
      else cout<<endl;
    }
  }
}

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

int main(void){
    int a = 0, b = 0;
    int ans = 0;

    scanf("%d%d", &a, &b);

    if(a == 1 && b == 2){
        ans = 3;
    }else if(a == 2 && b == 1){
        ans = 3;
    }else if(a == 2 && b == 3){
        ans = 1;
    }else if(a == 3 && b == 2){
        ans = 1;
    }else if(a == 3 && b == 1){
        ans = 2;
    }else if(a == 1 && b == 3){
        ans = 2;
    }

    printf("%d\n", ans);


    return 0;

} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int a[26];
	memset(a, 0, sizeof(a));
	if (s.size() == 26) {
		rREP(i, 0, s.size()) {
			int x = s[i] - 'a';
			a[x]++;
			if (s[i] == 'z')continue;
			rep(j, x + 1, s.size()) {
				if (a[j] != 0) {
					s[i] = (char)'a' + j;
					rep(k, 0, i + 1) {
						cout << s[k];
					}
					cout << "\n";
					return 0;
				}
			}
		}
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << "\n";
		}
		else {
			s[0]++;
			cout << s[0] << "\n";
		}
	}

	else {
		cout << s;
		rep(i, 0, s.size()) {
			int x = s[i] - 'a';
			a[x]++;
		}
		rep(i, 0, 26) {
			if (!a[i]) {
				char ch = 'a' + i;
				cout << ch << "\n";
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
time = []
result = []
ut = []
3.times do
  time = []
  8.times { time << gets.split.map(&:to_f) }
  temp = time.sort_by{ |t| t.last }
  result << temp[0,2]
  ut << temp[2,2]
end
result << ut.flatten(1).sort_by{ |t| t.last }[0,2]
result.flatten(1).each{ |t| puts "#{t.first.to_i} #{t.last}"}

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

 
int main() {
   //平方数の判定
   auto hantei=[](int n){
       int m=sqrt(n);
       if(m*m==n)return 1;
       else return 0;
   };

   int n,d;
   cin>>n>>d;
   int X[n][d];
   rep(i,n)rep(j,d)cin>>X[i][j];
   int ans=0;
   for(int i=0;i<=n-2;i++){
       for(int j=0;j<=n-1;j++){
           if(j<=i)continue;
           int sum=0;
           rep(k,d)sum+=pow(X[i][k]-X[j][k],2);
            if(hantei(sum))ans++;
        }
   }

   cout<<ans<<endl;
}

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

int gcd(int a, int b) {
   if (a%b == 0) {
       return(b);
   }
   else {
       return(gcd(b, a%b));
   }
}

int main() {
  int K;
  cin >> K;
  
  int gcd_sum = 0;
  for (int i = 1; i < K+1; i++) {
    for (int j = 1; j < K+1; j++) {
      for (int k = 1; k < K+1; k++) {
        gcd_sum += gcd(i,gcd(j,k));
      }
    }
  }
  
  cout << gcd_sum << endl;
  
  return 0;
}

Measured memory_bytes: 3620