akhauriyash/Code-Regression huggingface dataset:
def main():
    N = int(input())
    A = []
    dist = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        Ai = list(map(int, input().split()))
        A.append(Ai)
        for j in range(N):
            dist[i][j] = Ai[j]

    def wf(dist):
        need = [[1 for _ in range(N)] for _ in range(N)]
        for i in range(N):
            for j in range(N):
                for k in range(N):
                    if dist[i][j] > dist[i][k] + dist[k][j]:
                        print(-1)
                        exit()
                    elif dist[i][j] == dist[i][k] + dist[k][j]:
                        if i != k and j != k:
                            need[i][j] = 0
                            need[j][i] = 0
        return need

    need = wf(dist)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += need[i][j] * dist[i][j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace two1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int d = a / b;
            int r = a % b;
            double f = (double)a / (double)b;
            Console.WriteLine("{0} {1} {2:f6}", d, r, f);
 

        }
    }
}

Measured memory_bytes: 19920
//2904 GuruGuru
#include<stdio.h>
#include<string.h>
//余りが北で0、時計回りに+1
int main()
{
	char s[1024];
	int p,i,r=0;
	p=0;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		if(s[i]=='R'){
			p++;
		}else{
			p--;
		}
		if(p==4){
			p=0;
			r++;
		}
		if(p==-4)p=0;
	}
	printf("%d\n",r);
	return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n;
long long k;
int a[2005];
long long ans,q;
int num,tot;
int book[2005];
int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		book[a[i]]++;
	}
	for(int i=1;i<=n;i++) 
		for(int j=i+1;j<=n;j++) if(a[i]>a[j]) num++;
	ans=k*num;
	ans%=mod;
	tot=n;
	for(int i=2000;i>0;i--) {
		tot-=book[i];
		q=(k-1)*k/2;
		q%=mod;
		q*=book[i]*tot;
		q%=mod;
		ans+=q;
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}

Measured memory_bytes: 5884
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 c = sc.nextInt();
		if(a<b && b < c) {
				System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26136
#include<stdio.h>
int main(){
int a[11],i,j;
char b;
while(scanf("%c",&b)!=EOF){
a[0]=b-'0';
for(i=1;i<10;i++){
scanf("%c",&b);
a[i]=b-'0';
}
scanf("\n");
for(i=9;i>0;i--){
for(j=0;j<i;j++){
a[j]=(a[j]+a[j+1])%10;
}
}
printf("%d\n",a[0]);
}
return 0;
}


Measured memory_bytes: 2060
s = input()

while True:
    sep = s.find('LR')+1
    st = s[0:sep]
    if sep == 0:
        st = s
    tmp = st.find('RL')
    for i in range(len(st)):
        if i == tmp or i == tmp+1:
            if i % 2 == 1:
                print((len(st))//2, end=' ')
            else:
                print((len(st)+1)//2, end=' ')
        else:
            print('0', end=' ')
    # print(st)
    if sep == 0:
        break
    s = s[sep:]
print()

Measured memory_bytes: 4204
/*input
5
BBRGRRGRGGRBBGB
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
#define version 20190814
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int n;
string s;
int cnt[8];
int main(){
	IOS;
	cin>>n>>s;
	cnt[0]=n;
	ll ans=1;
	REP(i,3*n){
		int idx;
		if(s[i]=='R') idx=0;
		else if(s[i]=='G') idx=1;
		else idx=2;
		int mx=-1;
		REP(j,8) if(cnt[j]){
			if(j&(1<<idx));
			else{
				mx=max(mx,__builtin_popcount(j));
			}
		}
		int cur=0;
		REP(j,8) if(cnt[j]){
			if(j&(1<<idx));
			else if(mx==__builtin_popcount(j)){
				cur+=cnt[j];
				cnt[j]--;
				cnt[j|(1<<idx)]++;
				break;
			}
		}
		ans*=cur;
		ans%=MOD;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B, C, X, Y;
  cin>>A>>B>>C>>X>>Y;
  C *= 2;
  int ans = 0;
  if(X>Y) {
    swap(X, Y);
    swap(A, B);
  }
  ans += X*min(A+B, C);
  ans += (Y-X)*min(B, C);
  cout<<ans<<endl;
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int Ma = max(max(a, b), c);
  if (Ma * 2 == a + b + c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;cin>>S>>T;
  int i;
  for(i=S.size()-T.size();i>=0;i--){
    int j;
    for(j=0;j<T.size();j++)if(S.at(i+j)!=T.at(j)&&S.at(i+j)!='?')break;
    if(j==T.size()){
      for(j=0;j<T.size();j++)if(S.at(i+j)=='?')S.at(i+j)=T.at(j);
      for(j=0;j<S.size();j++){
        if(S.at(j)=='?')cout<<"a";
        else cout<<S.at(j);
      }
      cout<<endl;
      i=-2;
    }
  }
  if(i==-1)cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
//file_name:ABC83_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int ans = 0;
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    srep(i,1,n+1){
        int ii = i;
        int c = 0;
        while(ii>0){
            c+=ii%10;
            ii/=10;
        }
        if(x<=c&&c<=y){
            ans+=i;
        }
    }




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



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

signed main(){
  
  int N;
  cin>>N;
  
  int ans = 0;
  
  for(int i=1;i<=1000000;i++){
    int k = N / i - 1;
    if( k == 0 ) break;
    if( N / k == N % k ) ans += k;
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
const long long  INF = 1e18;
const long long mod=1e9+7 ;
void inputoutput()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	    
}

 
int32_t main()
{ 
	inputoutput() ;

	long long int n,w ;
	cin>>n>>w;

	vector<long long int> wt,v ;

	for(long long int i=0 ; i<n ; ++i)
	{
		long long int a,b;
		cin>>a>>b;
		wt.push_back(a);
		v.push_back(b);
	}

	long long int dp[n+1][w+1] ; // dp[i][j] => maximum possible sum of val could be carried
	               // with n first i elements and capacity j

	for(long long int i=0 ; i<=n ; ++i)
		dp[i][0]=0;
	for(long long int i=0 ; i<=w ; ++i)
		dp[0][i]=0;

	dp[0][0]=0;

	for(long long int i=1 ; i<=n ; ++i)
	{
		for(long long int j=1 ; j<=w ; ++j)
		{
			if(wt[i-1]<=j)
			{
				dp[i][j]=max(v[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}

	cout<<dp[n][w];




	return 0;
}


Measured memory_bytes: 82360
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
my (@s, @t);
{
    for (my $i=0; $i<$n; $i++)
    {
        my $in = <STDIN>;
        ($s[$i], $t[$i]) = split(" ", $in);
    }
}
my $x = <STDIN>;
chomp $x;

my $b = 0;
my $ans = 0;
for (my $i=0; $i<$n; $i++)
{
    if ($b==1)
    {
        $ans += $t[$i];
    }
    if ($s[$i] eq $x)
    {
        $b = 1;
    }
}

print "$ans\n";

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

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

int main() {
    init();
    
    ll w, h, c;
    cin >> w >> h >> c;
    cout << w * h / (int)pow(gcd(w, h), 2) *c << "\n";
}


Measured memory_bytes: 3192
import java.util.*;

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

        int h[] = new int[10];
        for (int i = 0; i < h.length; i++)
            h[i] = sc.nextInt();

        Arrays.sort(h);

        System.out.println(h[9]);
        System.out.println(h[8]);
        System.out.println(h[7]);
    }
}

Measured memory_bytes: 26368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int x=0;
  for(int i=0;i<n;i++){
    int l,r;
    cin >> l >> r;
    x+=r-l+1;
  }
  cout << x << endl;
}

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

int use[maxn], from[maxn];
vector<int> G[maxn];
int n, k;

int dfs(int x) {
    for(int i = 0; i < G[x].size(); i++) {
        int u = G[x][i];
        if(!use[u]) {
            use[u] = 1;
            if(from[u] == -1 || dfs(from[u])) {
                from[u] = x;
                return 1;
            }
        }
    }
    return 0;
}

int maxp() {
    memset(from, -1, sizeof(from));
    int sum = 0;
    for(int i = 1; i <= n; i++) {
        memset(use, 0, sizeof(use));
        sum += dfs(i);
    }
    return sum;
}

int a[maxn], b[maxn], c[maxn], d[maxn];

int main() {
    while(scanf("%d", &n) != EOF) {
        for(int i = 0; i < maxn; i++) G[i].clear();
        for(int i = 1; i <= n; i++) scanf("%d %d", &a[i], &b[i]);
        for(int i = 1; i <= n; i++) {
            scanf("%d %d", &c[i], &d[i]);
            for(int j = 1; j <= n; j++) {
                if(c[i] > a[j] && d[i] > b[j]) G[i].push_back(j);
            }

        }
        int ans = maxp();
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int main(){
   ll D,G;cin>>D>>G;
   VI p(D),c(D);
   rep(i,D)cin>>p[i]>>c[i];
   ll ans=INFTY;
   for(int bit=0;bit<=(1<<D);bit++){
      ll sum=0;
      ll tmp=0;
      rep(i,D){
         if(bit & (1<<i)){
            sum+=p[i]*100*(i+1);
            sum+=c[i];
            tmp+=p[i];
         }
      }
      for(int i=D;i>=1;i--){
         if(~bit & (1<<(i-1))){
            int j=0;
            while(sum<G){
               sum+=100*i;
               tmp++;
               j++;
               if(j==p[i-1])break;
            }
         }
      }
      if(sum>=G)chmin(ans,tmp);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int dfs(vv<int> &g,int v,int p,int d){
  if(!d) return 1;
  int re=1;
  for(int w:g[v])
    if(w!=p) re+=dfs(g,w,v,d-1);
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vv<int> g(n);
  vector<pii> es; es.reserve(n-1);
  int x,y;
  rep(i,n-1){
    cin>>x>>y; --x; --y;
    es.eb(x,y);
    g[x].pb(y);
    g[y].pb(x);
  }

  int re=n;
  if(t%2){
    for(pii e:es) MN(re,n-dfs(g,e.X,e.Y,t/2)-dfs(g,e.Y,e.X,t/2));
  }else{
    rep(i,n) MN(re,n-dfs(g,i,-1,t/2));
    //rep(i,n) cout<<i<<":"<<dfs(g,i,-1,t/2)<<endl;
  }
  cout<<re<<endl;
  return 0;
}


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

int main(){
  long long int a, b, c;
  cin >> a >> b >> c;
  
  if(a * b * c % 2 == 0) cout << 0 << endl;
  else{
    long long int ans = min(a * b, min(b * c, c * a));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() 
{
	string s;
	cin >> s;
	int count = 0;
	
	for(int i = 0; i < 3; ++i){
		if(s[i] == 'o') ++count;
	}
	cout << 700 + (100 * count) << endl;
}

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

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

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

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

int main(){
    int n; cin>>n;
    int a[2][100];
    for(int i=0; i<2; i++){
        for(int j=0; j<n; j++){
            cin>>a[i][j];
        }
    }

    int ans=0;
    for(int down=0; down<n; down++){
        int candy=0;
        for(int i=0; i<n; i++){
            if(i < down){
                candy += a[0][i];
            }
            else if(i == down){
                candy += a[0][i];
                candy += a[1][i];
            }
            else{
                candy += a[1][i];
            }
        }
        ans = max(ans, candy);
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

inline void rot(vector<int> &tile) {
  rotate(tile.begin(), tile.begin() + 1, tile.end());
}

inline void rm_tile(vector<int> &tile, map<vector<int>, int> &colors) {
  REP(i, 4) {
    colors[tile]--;
    rot(tile);
  }
}

inline void add_tile(vector<int> &tile, map<vector<int>, int> &colors) {
  REP(i, 4) {
    colors[tile]++;
    rot(tile);
  }
}

ll calc_tiles(vector<int> &upper, vector<int> &lower, map<vector<int>, int> &colors) {
  ll ret = 1;
  vector<vector<int>> side_tiles = {{upper[1], lower[0], lower[3], upper[2]},
                                    {upper[3], upper[2], lower[3], lower[2]},
                                    {lower[1], upper[0], upper[3], lower[2]},
                                    {lower[1], lower[0], upper[1], upper[0]}};
  vector<vector<int>> used;
  for (vector<int> &tile : side_tiles) {
    ret *= max(colors[tile], 0);
    if (ret == 0) break;
    rm_tile(tile, colors);
    used.emplace_back(tile);
  }

  for (vector<int> &tile : used) add_tile(tile, colors);
  return ret;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  vector<vector<int>> tiles(N);
  map<vector<int>, int> colors;
  REP(i, N) {
    int c0, c1, c2, c3; cin >> c0 >> c1 >> c2 >> c3;
    tiles[i] = {c0, c1, c2, c3};
    REP(j, 4) {
      colors[tiles[i]]++;
      rot(tiles[i]);
    }
  }

  ll ans = 0;
  REP(up, N) {
    rm_tile(tiles[up], colors);
    FOR(low, up+1, N) {
      rm_tile(tiles[low], colors);
      REP(k, 4) {
        ans += calc_tiles(tiles[up], tiles[low], colors);
        rot(tiles[low]);
      }
      add_tile(tiles[low], colors);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35328
<?php
    
    while($line = trim(fgets(STDIN))){
        if($line == "0")break;
        
        $line = array_map('intval',str_split($line));

        $sum =0;
        foreach($line as $value){
            $sum += $value;
        }
        
        echo $sum."\n";
        
    }
    
    // foreach($)
    
    
?>


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

struct Block {
    int a, b, x;
    friend istream& operator>>(istream& in, Block& block) {
        int s, t;
        in >> s >> t >> block.x;
        block.a = 2*s-1-2*block.x;
        block.b = 2*t-1-2*block.x;
        return in;
    }
};

bool first_start(Block b1, Block b2) {
    return make_tuple(b1.a, b1.b, b1.x) < make_tuple(b2.a, b2.b, b2.x);
}

bool first_end(Block b1, Block b2) {
    return make_tuple(b1.b, b1.a, b1.x) < make_tuple(b2.b, b2.a, b2.x);
}

bool first_x(Block b1, Block b2) {
    return make_tuple(b1.x, b1.a, b1.b) < make_tuple(b2.x, b2.a, b2.b);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<Block> blocks(n);
    for (auto& block : blocks) {
        cin >> block;
    }
    set<Block, function<bool (Block, Block)>> blocks_by_a(first_start);
    set<Block, function<bool (Block, Block)>> blocks_by_b(first_end);
    set<Block, function<bool (Block, Block)>> blocks_by_x(first_x);
    blocks_by_a.insert(blocks.begin(), blocks.end());
    while (q --> 0) {
        int d;
        cin >> d;
        d *= 2;
        while (blocks_by_a.size() > 0 && blocks_by_a.begin()->a < d) {
            blocks_by_b.insert(*blocks_by_a.begin());
            blocks_by_x.insert(*blocks_by_a.begin());
            blocks_by_a.erase(blocks_by_a.begin());
        }
        while (blocks_by_b.size() > 0 && blocks_by_b.begin()->b < d) {
            blocks_by_x.erase(*blocks_by_b.begin());
            blocks_by_b.erase(blocks_by_b.begin());
        }
        if (blocks_by_x.size() == 0) {
            cout << -1 << "\n";
        } else {
            cout << blocks_by_x.begin()->x << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 28672
#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;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int count = 1;
		int tmp = i;
		while (true)
		{
			if (tmp<10)
			{
				break;
			}
			count++;
			tmp /= 10;
			
		}
		if (count%2==1)
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;


int main() {
    int N;
    cin>>N;
    vector<int> A(N, 0);
    vector<int> B(N, 0);

    for(int i=0; i<N+1; i++){
        cin>>A[i];
    }

    for(int i=0; i<N; i++){
        cin>>B[i];
    }

    uint64_t count = 0;
    for(int i=0; i<N; i++){
        int kill = std::min(A[i], B[i]);
        A[i]-=kill;
        count+=kill;
        B[i] -= kill;

        int kill_next = std::min(A[i+1], B[i]);
        A[i+1]-=kill_next;
        count+=kill_next;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];

            Console.WriteLine((A - 1) * (B - 1));

        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define idx(x) (x-'a')
const int maxn=5e5+10;
const int inf=1061109567;
char s[maxn];
int n,q,next[maxn][27];
int main()
{
    int i,j,k;
    scanf("%s%d",s+1,&q);
    memset(next,inf,sizeof(next));
    for(n=0;s[n+1];n++); 
    for(i=1;i<=n;i++)
        next[i][idx(s[i])]=i;
    for(i=n;i;i--){
        for(k=idx(s[i])+1;k<27;k++){
            if(next[i][k-1]<inf){
                j=next[i][k-1];
                j=next[j+1][k-1];
                if(j<inf)
                    next[i][k]=std::min(next[i][k],j);
            }
        }
        if(next[i][26]<inf){
            for(k=0;k<idx(s[i]);k++){
                j=next[i][26];
                j=next[j+1][k];
                if(j<inf)
                    next[i][k]=std::min(next[i][k],j);
            }
        }
    }
    for(i=1;i<=n;i++) next[i][0]=next[i][26];
    for(k=1;k<=20;k++)
        for(i=1;i<=n;i++)
            if(next[i][k-1]==inf) next[i][k]=inf;
            else next[i][k]=next[next[i][k-1]+1][k-1];
    while(q--){
        scanf("%d%d",&i,&j);
        for(k=20;k>=0;k--)
            if(next[i][k]<=j)
                i=next[i][k]+1;
        puts(i>j?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 53888
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MAX 100000000
#define NIA 10000
#define in 1
#define out 2

int main(){
  int i,j,n,C[NIA],co=0;

  scanf("%d",&n);
  if(n>NIA||n<in){
    exit(1);
  }

  for(i=n;i>0;i--){
    scanf("%d",&C[i]);
    if(C[i]>=out&&C[i]<=MAX){
      if(C[i]!=2&&C[i]%2==0){
	co++;
      }
      else{
	for(j=3;j<=sqrt(C[i]);j+=2){
	  if(C[i]%j==0){
	    co++;
	    break;
	  }
	}
      }
    }
    else break;
  }

  printf("%d\n",n-co);

  return 0;
}



Measured memory_bytes: 2108
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 100*1000+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
ll a[maxn],par[maxn],plsz[maxn],mark[maxn];//par in pile and pile size

ll find_fad(ll x){//find the root in the pile
  if(par[x]==x)
    return x;
  else
    return find_fad(par[x]);
}

ll mergit(ll x,ll y){//for meging two pile
  if(x==y){
    return 0;
  }
  if(plsz[x]>plsz[y]){
    par[y]=x;
  }else if(plsz[x]<plsz[y]){
    par[x]=y;
  }else{
    par[y]=x;
    plsz[x]++;
  }
}

int main(){
  IO;
  ll n,m,comp=0,ans=0;
  cin>>n>>m;
  for(ll i=0;i<n;i++){
   cin>>a[i];
   par[i]=i,plsz[i]=1;
  }
  for(ll i=0;i<m;i++){
   ll u,v;
   cin>>u>>v;
   mergit( find_fad(u) , find_fad(v) );
  }
  pair<ll,ll> mn[n];
  for(ll i=0;i<n;i++){
   if(find_fad(i)==i){
     mn[i]={infll,infll};
   }
  }
  for(ll i=0;i<n;i++){
   mn[find_fad(i)]=min(mn[find_fad(i)],{a[i],i});
  }
  for(ll i=0;i<n;i++){
   if(find_fad(i)==i){
     comp++;
     ans+=mn[i].X;
     mark[mn[i].Y]=true;
   }
  }
  vector<ll> all;
  for(ll i=0;i<n;i++){
   if(!mark[i]){
     all.pb(a[i]);
   }
  }
  sort(all.begin(),all.end());
  if((ll)all.size()<(comp-2)){
    cout<<"Impossible";
    return 0;
  }
  for(ll i=0;i<comp-2;i++){
    ans+=all[i];
  }
  if(comp-2>=0)
  cout<<ans;
  else
  cout<<0;
}


Measured memory_bytes: 6136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double v = a*a*b;
    double theta = 0;
    if(x <= v/2){
        theta = atan((a*b*b) / (2*x));
    }else{
        theta = atan((2*v-2*x) / (a*a*a));
    }
    cout << fixed << setprecision(10);
    cout << theta*(180/3.14159265359);
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int ch;
    ch = getchar();
    while (ch != EOF)
    {
        if (ch >= 'a' && ch <= 'z') {
            putchar(ch -'a' + 'A');
        }
        else if (ch >= 'A' && ch <= 'Z') {
            putchar(ch - 'A' + 'a');
        } else {
            putchar(ch);
        }
        ch = getchar();
    }
    return 0;
}


Measured memory_bytes: 2056
N, H = map(int, input().split())

a = [0] * N
b = [0] * N

ab = []
for i in range(N):
  ai, bi = map(int, input().split())
  a[i] = -ai
  b[i] = -bi
  ab.append((-ai, -bi))
  
ab.sort()
b.sort()
mina = ab[0][0]

ans = 0
for bi in b:
  if bi <= mina:
    H += bi
    ans += 1
    if H <= 0:
      print(ans)
      exit()
  else:
    ans += (H-1)//(-mina) + 1
    print(ans)
    exit()
ans += (H-1)//(-mina) + 1
print(ans)


Measured memory_bytes: 24888
import java.util.Scanner;

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

       for(;;){
           int m=scan.nextInt();
           int f=scan.nextInt();
           int r=scan.nextInt();

           if(m==-1 && f==-1 && r==-1){
               break;
           } else if(m==-1 || f==-1){
               System.out.println("F");
           } else if((m+f)>=80){
               System.out.println("A");
           } else if(65<=(m+f) && (m+f)<80){
               System.out.println("B");
           }else if(50<=(m+f) && (m+f)<65){
               System.out.println("C");
           }else if(30<=(m+f) && (m+f)<50){
               if(r>=50){
                   System.out.println("C");
               }else{
                   System.out.println("D");
               }
           }else{
               System.out.println("F");
           }
           
       }
    }
}



Measured memory_bytes: 26392
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

int main()
{
	int H, N;
	scanf("%d %d", &H, &N);
	
	int s = 0;
	for (int i = 1; i <= N; i++)
	{
		int n;
		scanf("%d", &n);
		s += n;
	}
	if (s >= H) printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    int n, a;
    cin >> n;
    vector<int> input(n*3);
    for (int i=0; i<n*3; ++i) {
        cin >> a;
        input[i] = a;
    }
    sort(input.begin(), input.end());
    ll sum = 0;
    for (int i=n; i<n*3; i+=2) {
        sum += input[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 1408
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S=one_str()

if len(set(S))<=1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

int main()
{
	string s;
	cin >> s;
	for (int i=0; i<(int)s.size()-1; i++)
	{
		if (s[i]=='A' && s[i+1]=='C')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pll pair<double,ll>

string s;
ll xs, ys, xt, yt;
int N;
priority_queue<pll, vector<pll>, std::greater<pll>> q;
vector<pll> g[2000];
ll x[2000];
ll y[2000];
ll r[2000];
bool visit[2000];

int main()
{
    cin >> xs >> ys >> xt >> yt;
    cin >> N;
    for(int i = 1;i <= N;i++)
    {
        cin >> x[i];
        cin >> y[i];
        cin >> r[i];
    }
    fill(visit, visit + 2000, false);
    x[0] = xs;
    y[0] = ys;
    r[0] = 0;
    x[N+1] = xt;
    y[N+1] = yt;
    r[N+1] = 0;
    for(int i = 0;i <= N;i++)
    {
        for(int j = i + 1;j <= N+1;j++)
        {
            if(i == j)
            {
                continue;
            }
            auto dx = x[j] - x[i];
            auto dy = y[j] - y[i];
            auto d = dx * dx + dy * dy;
            auto rSum = r[j] + r[i];
            auto diff = sqrt(d) - rSum;
            auto dist = max(diff, 0.0);
            g[i].push_back(make_pair(dist, j));
            g[j].push_back(make_pair(dist, i));
        }
    }
    for(int i = 0;i <= N+1;i++)
    {
        sort(g[i].begin(), g[i].end());
    }
    q.push(make_pair(0,0));
    while(!q.empty())
    {
        auto t = q.top();
        q.pop();
        if(visit[t.second])
        {
            continue;
        }
        visit[t.second] = true;
        if(t.second == N+1)
        {
            cout << std::fixed;
            cout << setprecision(11);
            cout << t.first << endl;
            return 0;
        }
        for(auto& e : g[t.second])
        {
            if(visit[e.second])
            {
                continue;
            }
            double d = t.first + e.first;
            q.push(make_pair(d, e.second));
        }
    }
    return 0;
}


Measured memory_bytes: 24848
#include <algorithm>
#include <cstdio>

typedef long long LL;

const int N = 1050;

int n, A[N];
int opt[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &A[i]);

  LL f0 = 0, f1 = 0;
  for (int i = 0; i < n; ++i)
    if (A[i] > 0) {
      if (i % 2 == 0) f0 += A[i];
      else f1 += A[i];
    }

  if (f0 == 0 && f1 == 0) {
    int i = 0;
    for (int j = 1; j < n; ++j) if (A[j] > A[i]) i = j;
    printf("%d\n%d\n", A[i], n - 1);
    for (int j = 0; j < i; ++j) printf("1\n");
    for (int j = n - i; j > 1; --j) printf("%d\n", j);
  } else if (f0 >= f1) {
    printf("%lld\n", f0);
    int s = 0;
    int i = 0;
    for (i = 0; i < n && A[i] < 0; i += 2) {
      opt[s++] = 1; opt[s++] = 1;
    }
    for (i += 2; i < n; i += 2)
      if (A[i] >= 0) opt[s++] = 2;
      else opt[s++] = 3;
    if (n % 2 == 0 || (n % 2 == 1 && A[n - 1] < 0)) opt[s++] = 2;
    printf("%d\n", s);
    for (int i = 0; i < s; ++i)
      printf("%d\n", opt[i]);
  } else {
    printf("%lld\n", f1);
    int s = 0;
    opt[s++] = 1;
    int i = 0;
    for (i = 1; i < n && A[i] < 0; i += 2) {
      opt[s++] = 1; opt[s++] = 1;
    }
    for (i += 2; i < n; i += 2)
      if (A[i] >= 0) opt[s++] = 2;
      else opt[s++] = 3;
    if (n % 2 == 1 || (n % 2 == 0 && A[n - 1] < 0)) opt[s++] = 2;
    printf("%d\n", s);
    for (int i = 0; i < s; ++i)
      printf("%d\n", opt[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	int ac = 0,  wa = 0;
	vector<int> P(N);
	for (int i = 0; i < M; i++) {
		int idx;
		cin >> idx;
		idx--;
		string s;
		cin >> s;
		if (s == "WA") P[idx]++;
		else if (P[idx] >= 0) {
			ac++;
			wa += P[idx];
			P[idx] = -INF;
		}

	}

	cout << ac << ' ' << wa << "\n";

	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scan(&s)
  ans := "Good"
  for i := 0; i < 3; i++ {
    if s[i] == s[i+1] {
      ans = "Bad"
      break
    }
  }
  fmt.Println(ans)
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};


void Main()
{
	int D;
	cin>>D;
	vec(c,26);
	vin(c);

	vecvec(s,D,26);
	rep(i, D){
		rep(j,26){
			cin>>s[i][j];
		}
	}

	dout<<_n2;
	vec(last, 26);
	int maxDev=0;
	rep(d,D){
		int day=d+1;
		int maxIndex=-1;
		ll maxDev=LLONG_MIN;
		rep(j,26){
			ll dev = s[d][j] + (c[j] * (day-last[j]));
			if(dev==maxDev){
				if(c[j]>c[maxIndex])maxIndex=j;
			}
			else if(dev>maxDev){
				maxDev=dev;
				maxIndex=j;
			}
		}
		last[maxIndex]=day;
		cout<<maxIndex+1<<_n;
	}
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;

int a[maxn];

int main() {
	int l = 100000, r = 100001;
	int n;
	cin >> n;
	int t = 0;
	while(n--) {
		int x;
		scanf("%d", &x);
		if(t) {
			a[r] = x; r ++;
		} else {
			a[l] = x; l--;
		}
		t ^= 1;
	}
	if(t) {
		for(int i=l+1; i<r; i++) {
			if(i!=l+1) printf(" ");
			printf("%d", a[i]);
		}
	} else {
		for(int i=r-1; i>l; i--) {
			if(i!=r-1) printf(" ");
			printf("%d", a[i]);
		}
	}
	printf("\n");
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n, d, x; cin >> n >> d >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = x;
	rep(i,n)
	{
		int t=(d-1)/a[i]+1;
		ans+=t;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

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

    int size = N.size();
    int a[size];

    for (int i = 0; i < size; i++)
    {
        a[i] = (int)(unsigned char)N[i] - '0';
    }

    int b = 0;

    for (int i = 0; i < size; i++)
    {
        b += a[i];
    }

    if (b % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4496
n = int(input())
li = list(map(int,input().split()))
li.sort()
sum = 0
al = 0
s = 0
for i in range(n):
    sum+=li[n-i-1]
    if ((i%2)==0):
        al +=li[n-i-1]
s = al -(sum -al)
print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int N;
ll A[100001];

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

    cin >> N;

    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }

    sort(A, A + N);

    ll a = 0;
    ll b = 0;
    int n =  N - 1;
    while(n > 0){
        if(A[n] == A[n - 1]){
            if(a == 0){
                a = A[n];
                --n;
            }
            else {
                b = A[n];
                break;
            }
        }
        --n;
    }

    cout << ll(a * b) << endl;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
L = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        if t < L[j][1]:
            t = L[j][1]
        elif t % L[j][2] == 0:
            pass
        else:
            t = t + L[j][2] - t % L[j][2]
        t += L[j][0]  
    print(t)
print(0)

Measured memory_bytes: 42220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    long long ans = 922337203685477580;
    int temp;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n-k+1;i++){
        if((x[i] >=0) && (x[i+k-1] >=0)){
            temp = x[i+k-1];
        }else if(x[i] <0 && x[i+k-1] <0){
            temp = abs(x[i]);
        }else if(x[i] <0 && x[i+k-1] >=0){
            
            temp = min(abs(x[i]) + abs(x[i]) + x[i+k-1],abs(x[i]) + (x[i+k-1]) + x[i+k-1]);
            }
        if(temp < ans){
            ans = temp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 1000000009
#define maxn 10000009
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
int a[100001];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    LL aa=0,b=0,flag=0;
    for(int i=n-2;i>=0;i--)
    {
        if(a[i]==a[i+1])
        {
            if(flag)
            {
                b=a[i];
                break;
            }
            else
            {
                aa=a[i];
                flag=1;
                i--;
            }
        }
    }
    //printf("%d %d",aa,b);
    printf("%lld\n",aa*b);
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int n, q;
    int i;
    char name[50001][10];
    int times[50001];
    int nowtime=0;
    int index[50000];
    int count=0;

    scanf("%d %d", &n, &q);
    for(i=0;i<n;i++){
        scanf("%s %d", name[i], &times[i]);
        index[i]=i;
    }
    do{
        count = 0;
        for(i=0;i<n;i++){
            if(times[index[i]]>q){
                times[index[i]]-=q;
                nowtime+=q;
                index[count++]=index[i];
            }else if(times[index[i]]!=0 && times[index[i]]<=q){
                nowtime+=times[index[i]];
                times[index[i]]=0;
                printf("%s %d\n", name[index[i]], nowtime);
            }
        }
        n = count;
    }while(n!=0);
    return 0;
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll sum = 0, sqsum = 0;
  REP(i, n) {
    ll d;
    cin >> d;
    sum += d;
    sqsum += d * d;
  }
  cout << (sum * sum - sqsum) / 2 << endl;
}

Measured memory_bytes: 256