akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 20
using namespace std;
int p,q;
string P[MAX],Q[MAX];
int leading[2][MAX];

bool check(int R,int C,int S)
{
  int r,c,s;
  r = c = s = 0;
  rep(i,p)
    {
      //cout << leading[0][i] << "  = " <<R*r + c*C + s*S << endl;
      if(leading[0][i] != R*r + c*C + s*S)return false;

      rep(j,P[i].size())
	{
	  if(P[i][j] == '(')r++;
	  else if(P[i][j] == '{')c++;
	  else if(P[i][j] == '[')s++;
	  
	  if(P[i][j] == ')')r--;
	  else if(P[i][j] == '}')c--;
	  else if(P[i][j] == ']')s--;
	}
    }
  return true;
}

int main()
{
  while(cin >> p >> q,p|q)
    {
      vector<int> Rv,Cv,Sv;
      rep(i,p)
	{
	  cin >> P[i];
	  int cnt = 0;
	  rep(j,P[i].size())
	    {
	      if(P[i][j] == '.')cnt++;
	      else              break;
	    }

	  leading[0][i] = cnt;
	  //cout << "leading[" << i << "] = "<< leading[0][i] << endl;
	}

      rep(i,q)
	{
	  cin >> Q[i];
	  int cnt = 0;
	  rep(j,Q[i].size())
	    {
	      if(Q[i][j] == '.')cnt++;
	      else              break;
	    }
	  leading[1][i] = cnt;
	}

      //check(9,5,2);
      //return 0;
      REP(R,1,21)
	{
	  REP(C,1,21)
	    {
	      REP(S,1,21)
		{
		  if(check(R,C,S))
		    {
		      Rv.push_back(R);
		      Cv.push_back(C);
		      Sv.push_back(S);
		    }
		}
	    }
	}


      // cout << Rv.size() << " " << Cv.size() << " " << Sv.size() << endl; 
      /*
      int R,C,S;
      R = C = S = -1;

      if(!Rv.empty())
	{
	  R = Rv[0];
	  REP(i,1,Rv.size())
	    {
	      if(Rv[i] != R)
		{
		  R = -1;
		  break;
		}
	    }      
	}

      if(!Cv.empty())
	{
	  C = Cv[0] ;
	  REP(i,1,Cv.size())
	    {
	      if(Cv[i] != C)
		{
		  C = -1;
		  break;
		}
	    }      
	}
      if(!Sv.empty())
	{
	  S = Sv[0];
	  REP(i,1,Sv.size())
	    {
	      if(Sv[i] != S)
		{
		  S = -1;
		  break;
		}
	    }      
	}
      */
      //cout << "RCS = " << 0  << "," << 0<<"," << 0<< endl;

      int totalCost = 0;
      int r,s,c;
      r = s = c = 0;
      rep(i,q)
	{
	  set<int> st;
	  rep(j,Rv.size())
	    {
	      totalCost = r*Rv[j] + c*Cv[j] + s*Sv[j];
	      st.insert(totalCost);
	    }

	  if(st.empty() || (int)st.size() >= 2)
	    {
	      cout << -1;
	    }
	  else 
	    {
	      set<int>::iterator it = st.begin();
	      cout << (*it);
	    }
	  if(i == q-1)cout << endl;
	  else cout << " ";

	  rep(j,Q[i].size())
	    {
	      if(Q[i][j] == '(')r++;
	      else if(Q[i][j] == '{')c++;
	      else if(Q[i][j] == '[')s++;
	      
	      if(Q[i][j] == ')')r--;
	      else if(Q[i][j] == '}')c--;
	      else if(Q[i][j] == ']')s--;
	    }
	  //cout << r << " "<< c <<  " " << s << endl;
	
      
	}
    }
  return 0;
}

Measured memory_bytes: 1360
import sys
from heapq import heappop, heappush

H, W = map(int, sys.stdin.readline().split())
grid = ['#' * (W + 2)]
grid += ['#' + sys.stdin.readline().rstrip() + '#' for _ in range(H)]
grid += ['#' * (W + 2)]

def heuristic_cost(y, x):
    return abs(H - y) + abs(W - x)

def main():
    h = heuristic_cost(1, 1)
    c = 0
    s = h + c
    hq = [(s, c, 1, 1)]
    nex = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    cost = [[None] * (W+1) for _ in range(H+1)]
    while hq:
        s, c, y, x = heappop(hq)
        if not cost[y][x] is None:
            continue
        cost[y][x] = c
        for dy, dx in nex:
            i = y + dy
            j = x + dx
            if grid[i][j] == '.' and cost[i][j] is None:
                h = heuristic_cost(i, j)
                s = h + (c + 1)
                heappush(hq, (s, c+1, i, j))

    white_cnt = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            white_cnt += (grid[i][j] == '.') & 1
    
    ans = white_cnt - (cost[H][W] + 1) if not cost[H][W] is None else -1
    return ans 

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;
    ll ans = 0;
    ll B = 0;
    vector<vector<char>> C(H, vector<char>(W));
    vector<vector<char>> Copy(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> C[i][j];
            if (C[i][j] == '#')
            {
                B++;
            }
        }
    }
    //cout << B << endl;
    for (int bith = 0; bith < (1 << H); bith++)
    {
        for (int bitw = 0; bitw < (1 << W); bitw++)
        {
            Copy = C;
            ll pre = 0;
            for (int i = 0; i < H; i++)
            {
                if(bith & (1 << i))
                {
                    for (int j = 0; j < W;j++)
                    {
                        Copy[i][j] = '.';
                    }
                }
            }
            for (int i = 0; i < W;i++)
            {
                if(bitw & (1 << i))
                {
                    for (int j = 0; j < H;j++)
                    {
                        Copy[j][i] = '.';
                    }
                }
            }
            for (int i = 0; i < H;i++)
            {
                for (int j = 0; j < W;j++)
                {
                    if(Copy[i][j] == '#'){
                        pre++;
                    }
                }
            }
            if (K == pre)
            {
                ans++;
            }
            //cout << "H " << bitset<8>(bith) << " W " << bitset<8>(bitw) << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple

void love() {
	ll n; cin>>n;
	ll arr[n+1];
	for(int i = 0; i<=n; i++) cin>>arr[i];
	ll b[n];
	for(int i = 0; i<n; i++) cin>>b[i];

	ll ans = 0;
	for(int i = 0; i<n; i++) {
		if(b[i] >= arr[i]) {
			ans += arr[i];
			b[i] = b[i] - arr[i];
			arr[i] = 0;
		}
		else {
			ans += b[i];
			arr[i] = arr[i] - b[i];
			b[i] = 0;
		}

		if(b[i] >= arr[i+1]) {
			ans += arr[i+1];
			b[i] = b[i] - arr[i+1];
			arr[i+1] = 0;
		}
		else {
			ans += b[i];
			arr[i+1] = arr[i+1] - b[i];
			b[i] = 0;
		}
	}

	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

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

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    //wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 10680
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define vi vector<ll>
#define pi pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;ll arr[n];
int d[2000004];
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    memset(d,0,sizeof(d));
    inarr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        d[arr[i]]++;
    }
    int di[n+1];
    memset(di,0,sizeof(di));
    for(int i=0;i<n;i++){
        for(int j=1;j<=sqrt(arr[i]);j++){
            if(arr[i]%j==0 && (d[j]!=0|| d[arr[i]/j]!=0)){
                if(j!=arr[i]/j)
                    di[i]+=(d[j]!=0)+(d[arr[i]/j]!=0);
                else
                    di[i]++;
                if(d[arr[i]]>1)
                    di[i]++;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(di[i]==1)
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int n,m,c;
int a[maxn];
int b[maxn];
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	gbtb;
	cin>>n>>m>>c;
	repd(i,1,m)
	{
		cin>>b[i];
	}
	int ans=0;
	repd(i,1,n)
	{
		int num=0;
		repd(j,1,m)
		{
			cin>>a[j];
			num+=a[j]*b[j];
		}
		num+=c;
		if(num>0)
		{
			ans++;
		}
	}
	cout<<ans<<endl;

    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();}
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9')
{*p = *p * 10 + ch - '0';}}}


Measured memory_bytes: 2304
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

struct Node{
	map<int,int> con;
}tree[100010];

int ans=0;

void dfs(int par,int cp,int n){
	int now=1;
	for(auto &i:tree[n].con){
		if(i.F==par) continue;
		if(now==cp) now++;
		tree[n].con[i.F]=now;
		tree[i.F].con[n]=now;
		dfs(n,now,i.F);
		now++;
	}
	ans=max(ans,now-1);
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	int s,t;
	vector<pii> v;
	For(i,1,n-1){
		cin>>s>>t;
		tree[s].con[t]=0;
		tree[t].con[s]=0;
		v.emplace_back(s,t);
	}
	dfs(-1,-1,1);
	cout<<ans<<"\n";
	for(auto &i:v) cout<<tree[i.F].con[i.S]<<'\n';
		return 0;
}


Measured memory_bytes: 19700
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int m,d;
	cin >> m >> d;
	int cnt=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
		{
			if(j%10>=2 and j/10>=2 and (j%10)*(j/10)==i)
			{
				cnt++;
				cerr << i << " : " << j << endl;
			}
		}
	cout << cnt << endl;





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, k, ans=0;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) {
    cin >> h.at(i);
    if(h.at(i) >= k)ans++;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main() {
	char lomba[100];
	
	scanf("%s", &lomba);
	
	if(strcmp(lomba,"ABC")==0){
		printf("ARC");
	}
	
	else if(strcmp(lomba,"ARC")==0){
		printf("ABC");
	}
	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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



Measured memory_bytes: 512
# your code goes here
N,M = map(int,input().split())
query = [list(map(int,input().split())) for i in range(M)]

query.sort()

left = 0
right = N+1
ans = 1
for q in query:
	if (left <= q[0] and q[0] < right) or (left < q[1] and right >= q[1]):
		left = max(left,q[0])
		right = min(right,q[1])
	else:
		ans += 1
		left = q[0]
		right = q[1]
print(ans)

Measured memory_bytes: 29492
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdlib>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)


string sum(string a, string b) {
	if (a.size() > b.size()) swap(a, b);
	int c = 0;
	
	string res = "";
	REP(i, a.size()) {
		int x = a[a.size() - 1 - i] - '0' + b[b.size() - 1 - i] - '0' + c;
		res.push_back(x % 10 + '0');
		c = x / 10;
	}
	FOR(i, a.size(), b.size()) {
		int x = b[b.size() - 1 - i] - '0' + c;
		res.push_back(x % 10 + '0');
		c = x / 10;
	}
	if (c > 0) res.push_back(c + '0');
	
	reverse(res.begin(), res.end());
	return res;
}

string kake(string a, string b) {
	if (a == "0" || b == "0") return "0";
	string res = "";
	if (a.size() > b.size()) swap(a, b);
	
	string s = "0";
	REP(i, b.size()) {
		REP(j, a.size()) {
			int tmp = (a[a.size() - j - 1] - '0') * (b[b.size() - i - 1] - '0');
			if (tmp > 0) {
				stringstream ss;
				ss << tmp;
				REP(k, j) ss << "0";
				s = sum(s, ss.str());
			}
		}
		res.push_back(s[s.size() - 1]);
		s.erase(s.end() - 1);
		if (s.empty()) s = "0";
	}
	
	while (s != "0") {
		res.push_back(s[s.size() - 1]);
		
		s.erase(s.end() - 1);
		if (s.empty()) s = "0";
	}
	reverse(res.begin(), res.end());
	return res;
}

string pow(string x, int n) {
	if (n == 0) return "1";
	string res = pow(kake(x, x), n / 2);
	if (n & 1) res = kake(res, x);
	return res;
}

string jin[19] = {
	"", "Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"
};

int main() {
	string m;
	int n;
	
	while (cin >> m >> n, m != "0" || n) {
		string num = pow(m, n);
		int pos = (num.size() - 1) / 4 ;
		cout << num.substr(0, (num.size() - 1) % 4 + 1) << jin[pos];
		while (--pos >= 0) {
			string out = num.substr((num.size() - 1) % 4 + 1 + ((num.size() - 1) / 4 - pos - 1) * 4, 4);
			if (atoi(out.c_str()) > 0) cout << atoi(out.c_str()) << jin[pos];
		}
		puts("");
	}
}

Measured memory_bytes: 3184
using System;

class ITP1_4_A {
    public static void Main() {

        string[] Input = Console.ReadLine().Split(' ');
        int a = int.Parse(Input[0]);
        int b = int.Parse(Input[1]);

        Console.WriteLine("{0} {1} {2:f5}", (a / b), (a % b), ((double)a / (double)b));
    }
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	ll n;
	cin>>n;
	for(int i=1; i<=9; i++)
	{
		if(n%i==0 && (n/i)<=9)
		{
			cout<<"Yes\n";
			return;
		}		
	}
	cout<<"No\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a;
  cin >> b;
  if ( (a * b) % 2 == 0 ){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  char w[11];
  char t[1001];
  int cnt = 0;
  int p;
  scanf("%s", &w);
  for (p = 0; p < strlen(w); p++) {
    w[p] = tolower(w[p]);
  }
  while(1) {
    scanf("%s", &t);
    if (strcmp(t, "END_OF_TEXT") == 0) break;
    for (p = 0; p < strlen(t); p++) {
      t[p] = tolower(t[p]);
    }
    if (strcmp(t, w) == 0) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 2044
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 998244353
#define INIT -1

int main()
{
   long long int n;
   cin >> n;
   long long int ans = 0;
   for (long long int i = 1; i <= n; i++)
   {
      ans += i * (n / i) * (n / i + 1) / 2;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3608
/* You can't hack me! */
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vch;
typedef set<ll> sll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define sc scanf
#define pr printf
#define il(x) sc("%lld", &(x))
#define id(x) sc("%Lf", &(x))
#define os(x) pr("%lld ", x)
#define on(x) pr("%lld\n", x)
#define nl pr("\n")

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t=1;
    //il(t);
    while(t--)
    {
        ll n;
        cin>>n;
        set<string> st;
        string s;
        fo(i, n)
        {
            cin>>s;
            st.insert(s);
            //cout<<s[i];
        }
        cout<<(st.size());
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 19328
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define pii pair<int,ii>
#define st first
#define nd second
#define mp make_pair
#define N 100005
using namespace std;

int n,x,y,ata[N];
ll ans;
vector<ii> xs,ys;
vector<pii> yol;

int bul(int node) {
  if(ata[node]==node) return node;
  return ata[node]=bul(ata[node]);
}

int main() {
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d %d",&x,&y);
    xs.push_back(mp(x,i));
    ys.push_back(mp(y,i));
    ata[i]=i;
  }
  sort(xs.begin(),xs.end());
  sort(ys.begin(),ys.end());
  for(int i=0;i<xs.size()-1;i++) {
    int fs=xs[i].nd;
    int ss=xs[i+1].nd;
    int cs=xs[i+1].st-xs[i].st;
    yol.push_back(mp(cs,mp(fs,ss)));
  }
  for(int i=0;i<ys.size()-1;i++) {
    int fs=ys[i].nd;
    int ss=ys[i+1].nd;
    int cs=ys[i+1].st-ys[i].st;
    yol.push_back(mp(cs,mp(fs,ss)));
  }
  sort(yol.begin(),yol.end());
  for(int i=0;i<yol.size();i++) {
    int n1=yol[i].nd.st;
    int n2=yol[i].nd.nd;
    if(bul(n1)!=bul(n2)) {
      ata[ata[n1]]=ata[n2];
      ans+=yol[i].st;
    }
  }
  printf("%lld",ans);
}


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

int main() {
    int T; cin >> T;
    while (T--) {
        int h, w; cin >> h >> w;
        vector<string> grid(h);
        vector<int> Top(26, h), Bottom(26, -1);
        vector<int> Left(26, w), Right(26, -1);
        for (int i = 0; i < h; i++) {
            cin >> grid[i];
            for (int j = 0; j < w; j++) if (grid[i][j] != '.') {
                char c = grid[i][j] - 'A';
                Top[c] = min(Top[c], i);
                Bottom[c] = max(Bottom[c], i);
                Left[c] = min(Left[c], j);
                Right[c] = max(Right[c], j);
            }
        }
        bool update = true;
        while (update) {
            update = false;
            for (int k = 0; k < 26; k++) if (Bottom[k] + 1) {
                bool is_rectangle = true;
                for (int i = Top[k]; is_rectangle && i <= Bottom[k]; i++) {
                    for (int j = Left[k]; is_rectangle && j <= Right[k]; j++) {
                        if (grid[i][j] != 'A' + k && grid[i][j] != '#') {
                            is_rectangle = false;
                        }
                    }
                }
                if (is_rectangle) {
                    update = true;
                    for (int i = Top[k]; i <= Bottom[k]; i++) {
                        for (int j = Left[k]; j <= Right[k]; j++) {
                            grid[i][j] = '#';
                        }
                    }
                    Bottom[k] = -1;
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
            ok &= grid[i][j] == '.' || grid[i][j] == '#';
        }
        puts(ok ? "SAFE" : "SUSPICIOUS");
    }
    return 0;
}


Measured memory_bytes: 2988
/*AOJ-ITP-2-4*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int W = Integer.parseInt(str[0]);
		int H = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);
		int y = Integer.parseInt(str[3]);
		int r = Integer.parseInt(str[4]);

		if(!( x >= -100 && x <= 100 && y >= -100 && y <= 100)){System.exit(1);}
		if(((x+r) > 0 && (x+r) <= W && (y+r) > 0 && (y+r) <= H) ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24420
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		int n, k;
		cin >> n >> k;
		vector<int>a(n);
		for (int i = 0; i < n; i++)
			cin >> a[i];
		vector<bool> dp(k+1, false);
		for (int stones = 1; stones <= k; stones++)
			for (int i = 0; i < a.size(); i++)
				if (stones >= a[i] && dp[stones - a[i]] == false)
					dp[stones] = true;
		if (dp[k])
			cout << "First\n";
		else
			cout << "Second\n";
	}
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { std::cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
  bool operator==(const mint rhs) const { return x == rhs.x; }
  bool operator!=(const mint rhs) const { return x != rhs.x; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll gcd (ll x, ll y) { return y ? gcd(y,x%y) : x; }

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  map<pair<ll,ll>,P> mp;
  ll zero_zero = 0;
  ll a_zero = 0, zero_b = 0;
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    if (x == 0 && y == 0) zero_zero++;
    else {
      ll g = gcd(llabs(x),llabs(y));
      if (g == 0) x = 0, y = 1;
      else x /= g, y /= g;
      if (y < 0) x *= -1, y *= -1;
      else if (y == 0 && x < 0) x *= -1, y *= -1;
      if (x <= 0) { //rotate
        ll temp = x;
        x = y; y = -temp;
        mp[make_pair(x,y)].second++;
      }
      else mp[make_pair(x,y)].first++;
    }
  }
  mint ans = 1;
  for (auto p : mp) {
    mint now = 1;
    int s = p.second.first;
    int t = p.second.second;
    now += mint(2).pow(s)-1;
    now += mint(2).pow(t)-1;
    ans *= now;
  }
  ans += zero_zero - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int h, w;
	cin >> h >> w;
	REP(i, h)REP(j, w)
	{
		string s; cin >> s;
		if (s == "snuke") cout << char(j + 'A') << i + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  ll sum=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum += A[i];
  }
  priority_queue<pair<int,int>> que;
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    que.push(make_pair(b,a));
  }
  sort(A.begin(),A.end());
  int i=0;
  bool finished=false;
  while(!que.empty() && i<N){
    auto P = que.top();
    que.pop();
    while(i < N && P.second>0){
      if(P.first > A[i]){
        sum += P.first-A[i];
        P.second--;
        i++;
      }else{
        finished = true;
        break;
      }
    }
    if(finished){
      break;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>

int main()
{
 int i,j,n,max,min;

 /*整数ｎを入力*/
 scanf("%d",&n);
 int R[n];

 /*R(t)を入力*/
for(i=0;i<n;i++)
    {
     scanf("%d",&R[i]);
    }   

 /*最大値最小値の初期値入力*/
 min=R[0];
 max=R[1]-min;

for(i=2;i<n;i++){
     /*最大値最小値の更新*/
    if(R[i-1]<min){
        min=R[i-1];
    }
    if(R[i]-min>max){
        max = R[i]-min;
    }
    
}
 /*最大値の表示*/
printf("%d\n",max);
    
    return 0;
}


Measured memory_bytes: 2512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{

    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::cin>> a;
    std::cin>> b;

    d = b;
    c = 1;
    
    while( b <= a )
    {
        b *= d;
        c += 1;
    }

    std::cout<< c;
}


Measured memory_bytes: 256
#include <stdio.h>

int a, b;

int main(){

  scanf("%d %d", &a, &b);
  if (a > b){
    printf("a > b\n");
  }else if(a < b){
    printf("a < b\n");
  }else{
    printf("a == b\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  outl(n * (n - 1) / 2 + m * (m - 1) / 2);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

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

const ll INF = 100000000000;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> x(n), y(n);
	ll rmax = 0, rmin = INF, bmax = 0, bmin = INF;
	vector<P> hoge;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		if (x[i] > y[i]) swap(x[i], y[i]);
		hoge.emplace_back(x[i], i);
		rmax = max(rmax, x[i]);
		rmin = min(rmin, x[i]);
		bmax = max(bmax, y[i]);
		bmin = min(bmin, y[i]);
	}

	ll ans = (rmax - rmin) * (bmax - bmin);
	sort(hoge.begin(), hoge.end());
	ll vmax = y[hoge.front().second], vmin = y[hoge.front().second];
	ll d = hoge.back().first - hoge.front().first;
	for (int i = 1; i < n; i++) {
		d = min(d, max(vmax, hoge.back().first) - min(vmin, hoge[i].first));
		vmax = max(vmax, y[hoge[i].second]);
		vmin = min(vmin, y[hoge[i].second]);
	}
	d = min(d, vmax - vmin);
	rmax = bmax;
	ans = min(ans, (rmax - rmin) * d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename T>
struct RangeCount{
  struct BIT{
    vector<T> dat;
    BIT(){}
    BIT(int n){dat.assign(++n,0);}
    T sum(int k){
      T res=0;
      for(;k;k-=k&-k) res+=dat[k];
      return res;
    }
    void add(int k,T v){
      for(++k;k<(int)dat.size();k+=k&-k) dat[k]+=v;
    }
  };
  int n;
  vector<vector<int> > val;
  vector<BIT> dat;
  RangeCount(){}
  RangeCount(int n_){
    n=1;
    while(n<n_) n<<=1;
    val.assign(n<<1,vector<int>());
    dat.reserve(n<<1);
  }
  void preupdate(int a,int x){
    a+=n;
    while(a){
      val[a].emplace_back(x);
      a>>=1;
    }
  }
  void build(){
    for(int i=0;i<n*2;i++){
      auto &v=val[i];
      sort(v.begin(),v.end());
      v.erase(unique(v.begin(),v.end()),v.end());
      dat.emplace_back(v.size());
    }
  }
  void update(int a,int x,T z){
    a+=n;
    while(a){
      auto &v=val[a];
      int k=lower_bound(v.begin(),v.end(),x)-v.begin();
      dat[a].add(k,z);
      a>>=1;
    }
  }
  T calc(int k,T x,T y){
    auto &v=val[k];
    int p=lower_bound(v.begin(),v.end(),x)-v.begin();
    int q=lower_bound(v.begin(),v.end(),y)-v.begin();
    return dat[k].sum(q)-dat[k].sum(p);
  }
  // [a, b) * [x, y)
  T query(int a,int b,int x,int y){
    T res=0;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
      if(l&1) res+=calc(l++,x,y);
      if(r&1) res+=calc(--r,x,y);
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int h,w,t,q;
  cin>>h>>w>>t>>q;

  RangeCount<int> beet(h),ushi(h);


  vector<int> ts(q),cs(q);
  vector<int> y1(q),x1(q),y2(q),x2(q);

  for(int i=0;i<q;i++){
    cin>>ts[i]>>cs[i]>>y1[i]>>x1[i];
    y1[i]--;x1[i]--;

    if(cs[i]==0||cs[i]==1){
      beet.preupdate(y1[i],x1[i]);
      ushi.preupdate(y1[i],x1[i]);
    }

    if(cs[i]==2) cin>>y2[i]>>x2[i];
  }
  beet.build();
  ushi.build();

  using P = pair<int, int>;
  queue<P> que;

  for(int i=0;i<q;i++){
    while(!que.empty()&&que.front().first<=ts[i]){
      int k=que.front().second;que.pop();
      beet.update(y1[k],x1[k],-1);
      ushi.update(y1[k],x1[k],+1);
    }
    if(cs[i]==0){
      beet.update(y1[i],x1[i],+1);
      que.emplace(ts[i]+t,i);
    }
    if(cs[i]==1){
      if(ushi.query(y1[i],y1[i]+1,x1[i],x1[i]+1)==0) continue;
      ushi.update(y1[i],x1[i],-1);
    }
    if(cs[i]==2){
      cout<<ushi.query(y1[i],y2[i],x1[i],x2[i])<<" ";
      cout<<beet.query(y1[i],y2[i],x1[i],x2[i])<<"\n";
    }
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 22992
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int  main(){
	lli  n,m;
	cin>>n>>m;
	vector<lli > w(n);
	vector<lli > v(n);
	for(lli  i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	vector<lli >dp(m+1,0);
	dp[0]=0;
	for(lli  i=0;i<n;i++){
		for(lli  j=m ;j>0;j--){
			if((j-w[i])>=0)dp[j]=max(dp[j-w[i]]+v[i],dp[j]);	
		}
	}
	cout<<dp[m];
	
}


Measured memory_bytes: 4060
from itertools import permutations

N = int(input())
P = tuple([int(s) for s in input().split()])
Q = tuple((int(s) for s in input().split()))

seqs = []
for i, x in enumerate(permutations(range(1, N + 1), N)):
    if x == P:
        p = i + 1
    
    if x == Q:
        q = i + 1
print(abs(p-q))

Measured memory_bytes: 73044
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
x = a.index(max(a))
a0 = sorted(a)
for i in range(n):
  if i != x:
    print(a0[n-1])
  else:
    y = a[:x] + a[x+1:]
    print(max(y))

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


ll D (ll A,ll B,ll x){
  return floor((A*x)/B)-(A*floor(x/B));
}

int main() {

  ll A,B,N,MAX=0,result=0;
  cin >> A >> B >> N;

  cout << D(A,B,min(B-1,N)) << endl;

}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int can_move[10][10] = {{6, 3, 1, 4},
                        {2, 0, 2, 0},
                        {1, 3, 6, 4},
                        {5, 0, 5, 0}
                        };

int main(void) {
    vector<vector<int>> field(105, vector<int>(105, -1));
    int H, W; cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            char c; cin >> c;
            if (c == '#') field[i][j] = -1;
            else field[i][j] = c - '0';
        }
    }

    vector<vector<int>> reachable_cell(105, vector<int>(105));
    reachable_cell[1][1] = 1;
    int dh[] = {1, 0, -1, 0};
    int dw[] = {0, 1, 0, -1};
    queue<pair<int, int>> q;
    q.push({1, 1});
    while (!q.empty()){
        auto crt = q.front();
        q.pop();
        int h = crt.first;
        int w = crt.second;

        for (int k = 0; k < 4; k++) {
            int next_h = h + dh[k];
            int next_w = w + dw[k];
            if (reachable_cell[next_h][next_w] == 1 || field[next_h][next_w] == -1) continue;
            if (can_move[(next_h-1)%4][(next_w-1)%4] == field[next_h][next_w]) {
                reachable_cell[next_h][next_w] = 1;
                q.push({next_h, next_w});
            }
        }
    }
    if (reachable_cell[H][W]) cout << "YES" << endl;
    else cout << "NO" << endl;   
}



Measured memory_bytes: 3268
#include<iostream>
using namespace std;
#define lli long long int
#include<bits/stdc++.h>
int main(){
  lli n,m,k,a,sum=0;
  cin>>n;
  cin>>m;
  vector<lli>v(m+1);
  for(lli i=0;i<n;i++){
    cin>>k;
    for(lli j=0;j<k;j++){
      cin>>a;
      v[a]++;
    }
  }
  for(lli i=1;i<=m;i++){
    if(v[i]==n)
      sum++;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#define int long long
using namespace std;

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}


signed main() {
	fast();
	int k, a, b;
	cin >> k >> a >> b;
	if (b - a > 2) {
		if (a >= k + 2) {
			cout << k + 1;
		} else {
			cout << ((k - a + 1) / 2) * (b - a) + a + ((k - a + 1) % 2);
		}
	} else {
		cout << k + 1;
	}
	return 0;
}

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

int gcd(int a, int b){
  if(!a) return b;
  return gcd(b%a,a);
}

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  
  vector<int> left(N+1);
  vector<int> right(N+1);
  
  for( int i = 0; i < N; i++ ) left.at(i+1) = gcd(left.at(i), A.at(i));
  
  reverse(A.begin(), A.end());
  for( int i = 0; i < N; i++ ) right.at(i+1) = gcd(right.at(i), A.at(i));
  reverse(right.begin(), right.end());
  
  int ans = 1;
  for( int i = 0; i < N; i++ ){
    int A = gcd(left.at(i), right.at(i+1));
    int B = gcd(right.at(i), left.at(i+1));
    if( A > ans ) ans = A;
    if( B > ans ) ans = B;
  }
  cout << ans << endl;                                    
}

Measured memory_bytes: 2560
import numpy as np
from itertools import accumulate

n = int(input())
aa = np.zeros(n, np.int64)
bb = np.zeros(n, np.int64)
for i in range(n):
    aa[i], bb[i] = list(map(int, input().split()))
asums = list(accumulate(aa))

cc = np.argsort(bb)
aa = [aa[c] for c in cc]
aa = np.array(list(accumulate(aa)))
bb.sort()
if (aa > bb).sum()>0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 41964
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
const int INF = 1000000;

void bfs_a();
void warp_a();

vector<vector<char>> maze;
vector<vector<int>> cost;
queue<p> que_a, que_b;
int h,w,ch,cw,dh,dw;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void bfs_a(){
    while(que_a.size() > 0){
        p r = que_a.front();
      	que_b.push(r);
      	que_a.pop();
        for(int i = 0; i < 4; i++){
            int nx = r.first + dx[i], ny = r.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w 
                    && maze[nx][ny] != '#' && cost[nx][ny] == INF){
                cost[nx][ny] = cost[r.first][r.second];
                que_a.push(p(nx,ny));
                que_b.push(p(nx,ny));
            }
        }
    }
}

void warp_b(){
    while(que_b.size() > 0){
        p r = que_b.front(); que_b.pop();
        for(int x = -2; x <= 2; x++){
            for(int y = -2; y <= 2; y++){
                int nx = r.first + x, ny = r.second + y;
                if(0 <= nx && nx < h && 0 <= ny && ny < w 
                        && maze[nx][ny] != '#' && cost[nx][ny] == INF){
                    cost[nx][ny] = cost[r.first][r.second] + 1;
                    que_a.push(p(nx, ny));
                }
            }
        }
    }
}

int main(){
    cin >> h >> w >> ch >> cw >> dh >> dw;
    vector<char> tmp(w);
    vector<int> tmp2(w, INF);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> tmp[j];
        }
        maze.push_back(tmp);
        cost.push_back(tmp2);
    }
    que_a.push(p(ch - 1, cw - 1));
    que_b.push(p(ch - 1, cw - 1));
    cost[ch - 1][cw - 1] = 0;

    while(que_a.size() > 0){
        bfs_a();
        warp_b();
    }
    if(cost[dh - 1][dw - 1] == INF) puts("-1");
    else cout << cost[dh - 1][dw - 1] << endl;
    return 0;
}


Measured memory_bytes: 8576
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::Chars;

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       R: f64,
    }

    let mut ans = 2.0 * R * PAI;
    echo!(ans);
}


Measured memory_bytes: 2224