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

using namespace std;

const int MAX_H = 500, MAX_W = 500, INDEX = 1;

int H, W, h, w, a[MAX_H + INDEX][MAX_W + INDEX];

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

    cin >> H >> W >> h >> w;

    if (H % h == 0 && W % w == 0) {
        cout << "No" << endl;

        return 0;
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (H % h != 0) {
                switch (i % h) {
                    case 0:
                        a[i][j] = -(2 * (H / h) + 1);

                        break;

                    case 1:
                        a[i][j] = 2 * (H / h);

                        break;

                    default:
                        a[i][j] = 0;

                        break;
                }
            } else {
                switch (j % w) {
                    case 0:
                        a[i][j] = -(2 * (W / w) + 1);

                        break;

                    case 1:
                        a[i][j] = 2 * (W / w);

                        break;

                    default:
                        a[i][j] = 0;

                        break;
                }
            }
        }
    }

    cout << "Yes" << endl;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << a[i][j];

            if (j < W) {
                cout << ' ';
            } else {
                cout << '\n';
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll now=1;
    string face="",tale="";
    
    ll Q; cin>>Q;
    rep(i,Q){
        ll x; cin>>x;
        if(x==1){
            now*=-1;
        }
        else{
            ll y; cin>>y;
            char c; cin>>c;
            
            if(now*(y*-2+3)==1){
                face+=c;
            }
            else{
                tale+=c;
            }
        }
    }
    
    if(now==1){
        rrep(i,sz(face)) cout<<face[i];
        cout<<s;
        cout<<tale;
    }
    else{
        rrep(i,sz(tale)) cout<<tale[i];
        rrep(i,sz(s)) cout<<s[i];
        cout<<face;
    }
}



Measured memory_bytes: 3936
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
long long minmax(int n, int k){
    long long ans = 0;
    int tmp1 = 0;
    int tmp2 = n;
    for(int i = 0; i < k; i++){
        ans += tmp2 - tmp1;
        ans %= mod;
        tmp1 ++;
        tmp2 --;
    }
    return ans;
}
int main(){
    //std::stack<int> stack;
    
    int n,k;
    cin >> n >> k;
    long long ans = 0;
    vector<long long> Max(n+2);
    vector<long long> Min(n+2);
    int tmp1 = 0; 
    int tmp2 = n;
    for(int i = 1; i <= n+1; i++){
        Max[i] = Max[i-1] + tmp2;
        Min[i] = Min[i-1] + tmp1;
        // Max[i] %= mod;
        // Min[i] %= mod;
        tmp2 --;
        tmp1 ++;
    }
    // for(int i = 0; i <= n+1; i++){
    //     cout << Max[i] << " ";
    // }
    // cout << endl;
    // for(int i = 0; i <= n+1; i++){
    //     cout << Min[i] << " ";
    // }
    // cout << endl;
    for(int i = k; i <= n+1; i++){
        ans += Max[i] - Min[i] + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 6368
#include<iostream>
#include<cstdio>
using namespace std;
int m,d,ans=0;
int main(){
	scanf("%d%d",&m,&d);
	for(register int i=1;i<=m;i++){
		for(register int j=1;j<=d;j++){
			if((j%10)>1&&(j/10)>1&&(j%10)*(j/10)==i)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  int now = 1;
  int c = 0;
  rep(i,n){
    now =v.at(now-1);
    c++;
    if (now == 2) break;
  }
  if(now == 2)cout << c << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		// スペース区切りの整数の入力
		List<Integer> list = new ArrayList<>();
		for(int i=0;i<N;i++){
			list.add(sc.nextInt());
		}
		Optional<Integer> max = list.stream().max(Comparator.naturalOrder());
		Optional<Integer> min = list.stream().min(Comparator.naturalOrder());
		
		// 出力
		System.out.println(max.get()-min.get());
	}
}

Measured memory_bytes: 27336
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> A(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}
	sort(A.rbegin(), A.rend());

	ll ans = A[0];
	int cnt = 1;
	for (int ii = 1; ii < N-1; ++ii){
		ans += A[cnt];
		if (ii % 2 == 0) cnt++;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

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

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

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    //int sum = nums[0];
    //rep(i, n-1) sum += nums[i+1];
    //int out = 0;
    //rep(i, n) out += sum % nums[i];

    int sum = 0;
    rep(i, n) sum += nums[i] - 1;

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 1000000

vector<int> p;

int main() {
	p.push_back(0);
	for (int i = 1; p[i - 1] < MAX; i++) {
		p.push_back(i*(i + 1)*(i + 2) / 6);
		//cout << p[i] << endl;
	}

	static int dp[MAX + 1], dp2[MAX + 1];

	for (int i = 0; i <= MAX; i++) {
		dp[i] = dp2[i] = i;
	}

	for (int i = 1; i < p.size() - 1; i++) {
		//cout << i << " ";
		for (int j = p[i]; j <= MAX; j++) {
			dp[j] = min(dp[j - p[i]] + 1, dp[j]);
		}

		if (p[i] % 2 == 1) {
			for (int j = p[i]; j <= MAX; j++) {
				dp2[j] = min(dp2[j - p[i]] + 1, dp2[j]);
			}
		}
	}

	for (int n; cin >> n, n;) {
		cout << dp[n] << " " << dp2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 9032
N,T=map(int,input().split())
c=[0]*N
t=[0]*N
for i in range(N):
  c[i],t[i]=map(int,input().split())
ans=10000
for i in range(N):
  if t[i]<=T:
    ans=min(ans,c[i])
if ans==10000:
  print('TLE')
else:
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============prime_factor============================
vector<pll> prime_factor(ll N)
{
  vector<pll> res;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        cnt += 1;
      }
      res.push_back({i, cnt});
    }
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
//=================================================

int main()
{
  ll N, P;
  cin >> N >> P;
  vector<pll> factor = prime_factor(P);
  ll ans = 1;
  for (ll i = 0; i < factor.size(); ++i) {
    ans *= pow(factor.at(i).first, factor.at(i).second / N);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
using System;

class ABC_131_C
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        long A = long.Parse(input[0]);
        long B = long.Parse(input[1]);
        long C = long.Parse(input[2]);
        long D = long.Parse(input[3]);

        long c1 = A / C;
        long c2 = B / C;
        long countC = c2 - c1;
        if (A%C==0 && B%C==0) countC++;
        else  if (A%C==0) countC++;

        long d1 = A / D;
        long d2 = B / D;
        long countD = d2 - d1;
        if (A%D==0 && B%D==0) countD++;
        else if (A%D==0) countD++;

        long CD = LCM(C, D);
        long cd1 = A / CD;
        long cd2 = B / CD;
        long countCD = cd2 - cd1;
        if (A%CD==0 && B%CD==0) countCD++;
        else if (A%CD==0) countCD++;

        long ans = B - A + 1 - countC - countD + countCD;

        Console.WriteLine(ans);
    }

    static long GCD(long a, long b)
    {
        if (b == 0) return a;
        return GCD(b, a % b);
    }
    static long LCM(long a, long b)
    {
        return (a * b) / GCD(b, a % b);
    }
}

Measured memory_bytes: 13140
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll n,m;
    cin>>n>>m;
    map<ll,ll>wa;
    set<ll>ac;
    ll pen=0;
    ll ind;
    string s;
    for(ll i=0;i<m;i++){
        cin>>ind>>s;
        if(s=="AC"){
            if(ac.find(ind)==ac.end()){
                pen+=wa[ind];
            }
            ac.in(ind);
        }else{
            ++wa[ind];
        }
    }
    cout<<ac.size()<<" "<<pen<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}


ll N;

int main(void) {
  cin >> N;
  ll i;
  ll cnt[111]={};
  for(i=2; i<=N; i++) factrization(i);
  
  for(auto it=prime.begin(); it!=prime.end(); it++) {
    cnt[it->second]++;
  }
  
  
  ll sc[111]={};
  for(i=99; i>=0; i--) {
    sc[i]=sc[i+1]+cnt[i];
  }
  
  ll ans=0;
  ans+=sc[74];
  ans+=sc[24]*(sc[2]-1);
  ans+=sc[14]*(sc[4]-1);
  ans+=sc[4]*(sc[4]-1)/2*(sc[2]-2);
  
  pt(max(ans, 0LL));
}






Measured memory_bytes: 256
n,k,*v=map(int,open(0).read().split())
motimono=[]
ans=[]
v*=2
for j in range(1,min(n,k)+1):
    for i in range(n-j,n+1):
        motimono=v[i:i+j]
        ans.append(sum(motimono))
        motimono.sort()
        for i in range(min(k-j,j)):
            del motimono[0]
            ans.append(sum(motimono))
print(max(ans))


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

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


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

int main(){

    int n;
    cin >> n;

    int num;
    string pattern;    

    bool cards[4][13] = {{false}};

    for(int i=0; i<n; i++){
        cin >> pattern >> num;
        if(pattern == "S")  cards[0][num-1] = true;
        if(pattern == "H")  cards[1][num-1] = true;
        if(pattern == "C")  cards[2][num-1] = true;
        if(pattern == "D")  cards[3][num-1] = true;
    }

    for(int j=0; j<4; j++){
        for(int i=0; i<13; i++){
            if((cards[j][i] == false) && (j == 0)) cout << "S " << i+1 << endl;
            if((cards[j][i] == false) && (j == 1)) cout << "H " << i+1 << endl;
            if((cards[j][i] == false) && (j == 2)) cout << "C " << i+1 << endl;
            if((cards[j][i] == false) && (j == 3)) cout << "D " << i+1 << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 3144
def __main__():
    s = input()

    turn = 0
    s = rem(s)
    while s:
        turn += 1
        s = rem(s)
    if turn % 2 == 0:
        print('Second')
    else:
        print('First')

def rem(s):
    if len(s) == 2:
        return False
    for i in range(len(s) - 2):
        if s[i] != s[i + 2]:
            s = s[:(i + 1)] + s[(i + 2):]
            return s
    return False
    
__main__()

Measured memory_bytes: 3444
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
q = int(input())
data = []
ans = sum(a)
for i in range(q):
    b, c = map(int, input().split())
    ans += count[b] * (c - b)
    if b in count : 
        count[c] += count[b]
        count[b] = 0
    print(ans)


Measured memory_bytes: 86216
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
k = int(input())
for a in range(1,k + 1):
    for b in range(1,k + 1):
        for c in range(1,k + 1):
            ans += gcd(a,b,c)
print(ans)           


        

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

using namespace std;

int main()
{
	string S;
	cin >> S;
	string week[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

	for (int i = 0; i < 7; i++) {
		if (week[i] == S) {
			cout << 7 - i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(int i=1;i<=n;i++)
#define fox(i,x,y)      for(int i=x;i<=y;i++)
#define rfo(i,n)       for(int i=n;i>0;i--)
#define rfo1(i,n)       for(int i=n-1;i>=0;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define mod             1000000007
#define M               (int)1e6+6
#define inf             1e18
using namespace std;

int n,m,k,x,y,z,a1,b,c,d,i,j,l,r;

//top down approach
int dp[M][105]={};

// int profit(int w[],int v[],int i,int W)
// {
//   if(i<0)return 0;
  
//   if(dp[W][i]!=0)return dp[W][i];
//   if(w[i]>W)return dp[W][i]=profit(w,v,i-1,W);

//   int op1=v[i]+profit(w,v,i-1,W-w[i]);
//   int op2=profit(w,v,i-1,W);

//   return  dp[W][i]=max(op1,op2);
// }



void sol()
{   int W;
    cin>>n>>W;
    int w[n],v[n];
    fo(i,n)
    {
        cin>>w[i]>>v[i];
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int t=1;t<=W;t++)
        {   
            if(w[i-1]>t)dp[t][i]=dp[t][i-1];
            else
            {
                dp[t][i]=max(v[i-1]+dp[t-w[i-1]][i-1],dp[t][i-1]);
            }
            
        }
    }
    
    
    
    cout<< dp[W][n]<<endl;
}





int32_t main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}



Measured memory_bytes: 84224
N,K,Q=map(int,input().split())
A=[0]*Q
for i in range(0,Q):
  A[i] = int(input())
point=[K-Q]*N
for a in A:
  point[a-1] += 1
#print(point)
for i in range(0,N):
  if point[i] >0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 10416
# include <iostream>
# include <cstdio>
# include <cmath>
# include <cstring>
# include <string>
# include <cstdlib>
# include <algorithm>
# include <stack>
# include <queue>
# include <vector>
# define maxx (103)
# define Pi (3.14159265358979)
# define inf (2147483647)
using namespace std;
int read() {
	int x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9')  {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main() {

	int a,b,c;
	a=read();
	b=read();
	c=read();
	
	if(a+b>=c){
		cout << "Yes";
	}else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

#define x first
#define y second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

typedef pair<pii,pii> C;

C norm(C c) {
    return min(min(C{{c.x.y, c.y.x}, {c.y.y, c.x.x}}, C{{c.y.y,c.x.x},{c.x.y,c.y.x}}), min(c, {c.y,c.x}));
}

int get(const C&c, int i) {
    switch(i&3) {
        case 0: return c.x.x;
        case 1: return c.x.y;
        case 2: return c.y.x;
        case 3: return c.y.y;
    }
}

int rot(const C&c) {
    if (c.x == c.y) {
        if (c.x.x == c.x.y) return 4;
        else return 2;
    } else return 1;
}

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    int N; cin >> N;

    map<C, int> P;
    map<C, int> R;
    vector<C> Q;
    for (int i = 0; i < N; i++) {
        int a,b,c,d; cin >> a >> b >> c >> d;
        C x{{a,b},{c,d}};
        x = norm(x);
        P[x] += 1;
        R[x] = rot(x);
        Q.push_back(x);
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        C &p = Q[i];
        P[p]--;
        for (int j = i+1; j < N; j++) {
            C &q = Q[j];
            P[q]--;
            for (int k = 0; k < 4; k++) {
                ll cur = 1;
                C u[4];
                for (int l = 0; l < 4; l++) {
                    u[l] = norm({{get(p,l+1),get(p,l)},{get(q,k-l+1),get(q,k-l)}});
                    int opts = P[u[l]];
                    if (opts <= 0) {
                        cur = 0;
                    } else {
                        cur *= opts*rot(u[l]);
                    }
                    P[u[l]]--;
                }
                for (int l = 0; l < 4; l++) {
                    P[u[l]]++;
                }
                ans += cur;
            }
            P[q]++;
        }
        P[p]++;
    }

    cout << ans/3 << endl;
}


Measured memory_bytes: 80128
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl //[l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<endl;out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int N,T;
vi c,t;
int ans=INF;

signed main(){
    io();

    in(N,T);
    c.resize(N);t.resize(N);
    rep(i,N){
        in(c[i],t[i]);
        if(t[i]<=T){
            ans=min(c[i],ans);
        }
    }

    if(ans==INF){
        out("TLE");
    }else{
        out(ans);
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
	int h[2], m[2], k;
	cin >> h[0] >> m[0] >> h[1] >> m[1] >> k;
	cout << h[1] * 60 + m[1] - h[0] * 60 - m[0] - k << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int H,W,h,w;

int main() {
	cin >> H >> W >> h >> w;
	if (H%h != 0 || W%w != 0) {
		cout << "Yes\n";

		int k=(H/h)*(W/w)+1;
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				if (i%h == h-1 && j%w == w-1)
					cout << -k-1 << " ";
				else if (i%h == 0 && j%w == 0)
					cout << k << " ";
				else
					cout << "0 ";
			}
			cout << "\n";
		}
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
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 all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    ll cnt = 0;
    ll r = 5;
    while (r <= n) {
        cnt += n / r;
        r *= 5;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    int t = n-1;
    rep(i,0,n){
        int lim = 2;
        if(i == 0) lim=1;
        rep(j,0,lim){
            if(t > 0){
                ans += a[i];
                t--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6388
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  const n = +readLine();
  let ans = 0;

  for (let i = 1; i <= n; i++) {
    ans += Math.floor((n - 1) / i);
  }

  console.log(ans);
}


Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int x, y;
  cin >> x >> y;
  int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  if(a[x] == a[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
} 






Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define T 2000000000

typedef struct{
  char suit;
  int value;
}Card;

Card L[MAX/2+2],R[MAX/2+2];
void merge(Card A[], int n, int l, int m, int ri)
{
  int i, j, k;
  
  int a1, a2;
  a1=m-l;
  a2=ri-m;
  for(i=0;i<a1;i++)
    L[i]=A[l+i];
  for(i=0;i<a2;i++)
    R[i]=A[m+i];
  L[a1].value=R[a2].value=T;
  i=j=0;
  for(k=l;k<ri;k++){
    if(L[i].value<=R[j].value)
      A[k]=L[i++];
    else
      A[k]=R[j++];
  }
}

void qmerge(Card A[], int n, int l, int ri)
{
  int m;
  if(l+1<ri){
    m=(l+ri)/2;
    qmerge(A,n,l,m);

    
    qmerge(A,n,m,ri);
    
    merge(A,n,l,m,ri);
    
  }
}

int partition(Card A[], int n, int p, int r)
{
  int i, j;
  Card tmp, x;
  x=A[r];
  i=p-1;
  
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

void quick(Card A[], int a, int b, int c)
{
  int q=0;
  if(b<c){
    q=partition(A,a,b,c);
    
    quick(A,a,b,q-1);
    
    quick(A,a,q+1,c);
  }
}


int main(){
  int n, i, v;
  Card A[MAX],B[MAX];
  char S[11];
  int sta=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  qmerge(A,n,0,n);
  quick(B,n,0,n-1);

  for(i=0;i<n;i++)
    if(A[i].suit!=B[i].suit)
      sta=0;

  if(sta==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for(i=0;i<n;i++)
    printf("%c %d\n",B[i].suit,B[i].value);

  return 0;
}




Measured memory_bytes: 4144
#include <stdio.h>
int main(){
  int i,j,N,v;
  
  scanf("%d",&N);

  int A[N];

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  
  printf("%d\n",A[N-1]);

  for(i=1;i<=N-1;i++){   
    v=A[i];
    j=i-1;

    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }

    A[j+1]=v;

    for(j=0;j<N-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[N-1]);
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;cin>>n>>k;
  ll x[n];for(ll i=0;i<n;i++)cin>>x[i];
  ll ans=1000000000000000000;
  for(ll i=0;i<n-k+1;i++){
   ans=min(ans,abs(x[i])+x[i+k-1]-x[i]);
  }
  for(ll i=k-1;i<n;i++){
    ans=min(ans,abs(x[i])+x[i]-x[i-k+1]);
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1024
from itertools import product
N = int(input())
cnt = 0
num = ["3","5","7"]
for k in range(3,10):
    for x in product(num,repeat=k):
        if x.count("3")>=1 and x.count("5")>=1 and x.count("7")>=1:
            if int("".join(x))<=N:
                cnt += 1
print(cnt)

Measured memory_bytes: 73932
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if (n >= m) {
            System.out.println(0);
            return;
        }
        Integer[] ary = new Integer[m];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
        }
        Integer[] diff = new Integer[m - 1];
        Arrays.sort(ary, Comparator.reverseOrder());
        for (int i = 0; i < m - 1; i++) {
            diff[i] = ary[i] - ary[i + 1];
        }
        Arrays.sort(diff);
        int ans = 0;
        for (int i = 0; i < m - (n - 1) - 1; i++) {
            ans += diff[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 47888
def solution():
	h,v  = [int(x) for x in input().split(' ')]
	ls = []
	ans = []
	for i in range(h):
		ls.append(list(input()))
		ans.append([0]*v)
	
	for i in range(h):
		for j in range(v):
			if ls[i][j] == '#':
				if i>0:
					ans[i-1][j]+=1
					if j>0:
						ans[i-1][j-1]+=1
					if j<v-1:
						ans[i-1][j+1]+=1
				if i<h-1:
					ans[i+1][j]+=1
					if j>0:
						ans[i+1][j-1]+=1
					if j<v-1:
						ans[i+1][j+1]+=1
				if j>0:
					ans[i][j-1]+=1
				if j<v-1:
					ans[i][j+1]+=1

	for i in range(h):
		for j in range(v):
			if 	ls[i][j] == '#':
				print('#',end='')
			else:
				print(ans[i][j],end='')

		print("")

solution()

Measured memory_bytes: 3572
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 1e9 + 7;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

int mul(int x, int y) {
    return (1LL * x * y) % MOD;
}

int bin_pow(int a, int p) {
    if (!p)
        return 1;
    if (p % 2)
        return (1LL * bin_pow(a, p - 1) * a) % MOD;
    int t = bin_pow(a, p / 2);
    return (1LL * t * t) % MOD;
}

int inv(int x) {
    return bin_pow(x, MOD - 2);
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    cout << add(sub(bin_pow(10, n), mul(2, bin_pow(9, n))), bin_pow(8, n));
    return 0;
}

Measured memory_bytes: 3652
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()

    r = 0
    for i in range(1, n+1):
        t = n // i
        r += t * (t+1) // 2 * i

    return r


print(main())




Measured memory_bytes: 10900
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a <= 0 && 0 <= b) {
            _out.println("Zero");
        } else if (a > 0) {
            _out.println("Positive");
        } else {
            if ((b - a + 1) % 2 == 0) {
                _out.println("Positive");
            } else {
                _out.println("Negative");
            }
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

using namespace std;

int main()
{
	int n,sum=0;
	cin>>n;
	string str[n],s;
    int arr[n],x;
    for(int i=0;i<n;++i)
    {
    	cin>>str[i];
    	cin>>arr[i];
	}
	cin>>s;
	if(s==str[n-1])
	cout<<"0"<<endl;
	else
	{
	
	for(int i=0;i<n;++i)
    {
    if(str[i]==s)
	{
		x=i+1;
		break;
		}	
	}
    for(int j=x;j<n;++j)
    {
    	sum+=arr[j];
	}
	cout<<sum<<endl;
}
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    if(n%3==0||m%3==0||(n+m)%3==0)cout<<"Possible";
    else cout<<"Impossible";
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  vector<int> dp(N, 2000000000);
  dp.at(0) = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < min(K, N - 1 - i); j++) {
      dp.at(i + j + 1) = min(dp.at(i + j + 1), dp.at(i) + abs(h.at(i) - h.at(i + j + 1)));
    }
  }
  cout << dp.at(N - 1) << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD=1e9+7;
const int INF=1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m=MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------//
void solve(){
   string s;
   cin>>s;
   bool ok=true;
   for(int i=0;i<4;i++){
	    if(s[i]==s[i+1]){
		   ok=false;
		   break;	
		} 
	  }
	cout<<(!ok?"Bad":"Good")<<endl;	
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;

struct Tag{
	public:
	string name;
	P p, q;
	vector<Tag> vec;
	Tag(string _name, P _p, P _q): name(_name), p(_p), q(_q) {}
	
	bool check(P t);
	bool comp(P t);
};

bool Tag::check(P t)
{
	bool f = false;
	
	if(comp(t)){
		f = true;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i].comp(t)){
				return vec[i].check(t);
			}
		}
		
		cout << name << " " << vec.size() << endl;
	}
	
	return f;
}

bool Tag::comp(P t)
{
	if(p.first <= t.first && t.first <= q.first &&
		 p.second <= t.second && t.second <= q.second){
		return true;
	}
	
	return false;
}

pair<P,P> split(string str)
{
	vector<int> v;
	string s = "";
	
	for(int i =0; i < str.size(); i++){
		if(str[i] == ','){
			v.push_back(atoi(s.c_str()));
			s = "";
		} else {
			s += str[i];
		}
	}
	v.push_back(atoi(s.c_str()));
	
	return pair<P,P>(P(v[0], v[1]), P(v[2], v[3]));
}

int l;
Tag mktag(string str)
{
	string s, t;
	s = t = "";
	l++;
	while(str[l] != '>'){
		s += str[l++];
	}
	l++;
	while(str[l] != '<'){
		t += str[l++];
	}
	pair<P, P> pr = split(t);
	Tag tg = Tag(s, pr.first, pr.second);
	s = "</" + s + ">";
	while(str.substr(l, s.size()) != s){
		tg.vec.push_back(mktag(str));
	}
	l += s.size();
	
	return tg;
}

int main()
{
	int n;
	string str;
	P p;
	
	while(cin>>n && n){
		cin >> str;
		l = 0;
		Tag tg = mktag(str);
		while(n--){
			cin >> p.first >> p.second;
			if(!tg.check(p)){
				cout << "OUT OF MAIN PANEL 1" << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
/* ex 7_1
   cy_an  */

#include <stdio.h>

// 構造体の宣言
typedef struct point{
    int x_elem;
    int y_elem;
}point;

// a + bを返す関数
point shift_point(point a, point b){
    point c;
    c.x_elem = a.x_elem + b.x_elem;
    c.y_elem = a.y_elem + b.y_elem;
    return(c);
}

int main(void){

    
    point p1, p2, p3, p4, vector12, vector14;

    // 構造体へ代入
    scanf("%d %d %d %d", &p1.x_elem, &p1.y_elem, &p2.x_elem, &p2.y_elem);

    // 計算
    // vector12 = p2 - p1
    vector12.x_elem = p2.x_elem - p1.x_elem;
    vector12.y_elem = p2.y_elem - p1.y_elem;
    // 90degree turn
    vector14.x_elem = -vector12.y_elem;
    vector14.y_elem = vector12.x_elem;
    // p4 = p1 + vector14
    p4 = shift_point(p1, vector14);
    // p3.y_elem = p4.y_elem + vector12.y_elem;
    p3 = shift_point(p4, vector12);

    // 値の出力
    printf("%d %d %d %d\n", p3.x_elem, p3.y_elem, p4.x_elem, p4.y_elem);

    return 0;
}

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

typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return y*(x/gcd(x,y));}

int main(){
  int N;
  cin>>N;
  ll T[100];
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  ll ans=1;
  for(int i=0;i<N;i++) ans=lcm(ans,T[i]);
  cout <<ans<<endl;
}
      


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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool can = true;
  for (int i = 0; i < N; ++i) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }
  if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}
   

Measured memory_bytes: 1408
use std::io;


/// https://beta.atcoder.jp/contests/abc050/tasks/abc050_b
fn main() {
    let _n = read_one::<usize>();
    let t = read::<usize>();
    let m = read_one::<usize>();
    let mut vec = Vec::new();

    for _ in 0..m {
        let i = read::<usize>();
        vec.push(i);
    }

    let sum_t: usize = t.iter().sum();

    for j in 0..m {
        println!("{}", sum_t - t[vec[j][0] - 1] + vec[j][1]);
    }

}


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

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

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

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

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

int n, m;

int main(){
    cin >> n;
    m = n % 10;
    if (m == 3){
        cout << "bon";
    }
    else if (m == 0 || m == 1 || m == 6 || m == 8){
        cout << "pon";
    }
    else{
        cout << "hon";
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){

  int array[1000], n, i;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&array[i]);

  for(i=n-1;i>=0;i--){
    printf("%d",array[i]);
  if(i!=0) printf(" ");
}

  printf("\n");

  return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n;
  cin >> n;
  lol ans = 0, memo = n, i = 2;
  map<int, int> nasu;
  while(memo % i == 0){
    nasu[i] ++;
    memo /= i;
  }
  reps(j, 55){
    if(nasu[i] >= j){
      ans ++;
    } else {
      break;
    }
    nasu[i] -= j;
  }
  for(i = 3;i * i <= n;i += 2){
    if(memo % i == 0){
      while(memo % i == 0){
	nasu[i] ++;
	memo /= i;
      }
      reps(j, 55){
	if(nasu[i] >= j){
	  ans ++;
	} else {
	  break;
	}
	nasu[i] -= j;
      }
    }
  }
  if(memo != 1){
    ans ++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3660
using System;

namespace AOJ.intro
{
    namespace ITP_1_2_D
    {
        public static class CircleInRectangle
        {
            public static void Main()
            {
                // [W, H, x, y, r]
                string[] circleElements = Console.ReadLine().Split();
                int W, H, x, y, r;
                W = int.Parse(circleElements[0]);
                H = int.Parse(circleElements[1]);
                x = int.Parse(circleElements[2]);
                y = int.Parse(circleElements[3]);
                r = int.Parse(circleElements[4]);
                
                // ロジック
                // 水平方向: x - r < 0, x + r > W → OUT
                // 鉛直方向: y - r < 0, y + r > H → OUT
                if (x - r >= 0 &&
                         x + r <= W &&
                         y - r >= 0 &&
                         y + r <= H)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 8972
import java.util.Scanner;

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



        System.out.println((t / a) * b);
    }
}


Measured memory_bytes: 23380