akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());
        int C = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());
        //// スペース区切りの整数の入力
        //string[] input = Console.ReadLine().Split(' ');

        int count = 0;

        for (int a = 0; a <= A; a++)
        {
            for (int b = 0; b <= B; b++)
            {
                for (int c = 0; c <= C; c++)
                {
                    if (a*500+b*100+c*50 == X)
                    {
                        count++;
                    }

                }

            }
        }
        
        //// 文字列の入力
        //string s = Console.ReadLine();
        //出力
        Console.WriteLine(count.ToString());
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 1;
    
    String[] ary = s.split("");
    
    for(int i = 1; i < n; i++) {
        if(!ary[i].equals(ary[i-1])) ans += 1;
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 32364
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

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

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

int main() {
  ll N, X;
  RI(N, X);
  PL(3 * (N - __gcd(N, X)));
  return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

//http://hos.ac/slides/20140319_bit.pdf
int MAX_N=1000010;
vector<int>bit(MAX_N+1,0);//1-index
void add(int a,int w){
    for (int x = a; x <=MAX_N; x+=x&-x)bit[x]+=w;
}
int sum(int a){//sum v[1]～v[a]
    int ret=0;
    for (int x = a; x>0;x-=x&-x)ret+=bit[x];
    return ret;
}

int main(){
    //input

    ll n,q;cin >>n>>q;
    vector<ll>c(n+1);
    for (int i = 1; i <=n; ++i) {
        cin >>c[i];
    }
    //pre calc ok
    vector<ll>pre(n+1,-1);
    vector<vector<ll>>num(n+1,vector<ll>());
    for (int i = n; i>=1; --i) {
        num[c[i]].push_back(i);
    }

    vector<ll>w(n+1,0);
    for (int i = n; i >=1;--i) {
        if((ll)num[c[i]].size()>w[c[i]]+1) {
            w[c[i]]++;
            pre[i] = num[c[i]][w[c[i]]];
        }
    }

//    for (int i = 1; i <=n; ++i) {
//        cout <<pre[i]<<" ";
//    }
//    cout <<endl;
    vector<pair<ll,P>>rl;
    for (int i = 0; i < q; ++i) {
        ll l,r;cin >>l>>r;
        rl.push_back({r,{l,i}});
    }
    sort(all(rl));
    vector<bool>ch(n+1,true);
    for (int i = rl[0].first; i>=1; --i) {
        if(ch[c[i]]){
            add(i,1);
            ch[c[i]]=false;
        }
    }
    ll r=rl[0].first;
    ll a=0;
    vector<ll>ans(q);
    while(a<q){
        ll l=rl[a].second.first;
        if(rl[a].first==r){
            ans[rl[a].second.second]=sum(r)-sum(l-1);
            a++;
        }
        else {
            r++;
            if(pre[r]>0){
                add(pre[r],-1);
            }
            add(r,1);
        }
    }
    for (int i = 0; i < q; ++i) {
        cout <<ans[i]<<endl;
    }
}


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

int main(){
string S;
cin >> S;
if (S.at(0) != S.at(1) && S.at(0) != S.at(2) && S.at(1) != S.at(2)){
    cout << "Yes" << endl;
}
else {
    cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int a, b;
    cin>>a>>b;
    cout<<(a + b - 1)/a<<endl;
}



Measured memory_bytes: 3156
#include<stdio.h>
int main(void)
{
	int H,W;
		int i,j,k,n;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;
			for(i = 0; i < H; i++){
				for(j = 0; j < W; j++){
					k = i % 2;
					n = j % 2;
					if(k == 0 && n == 0){
						printf("#");
					}
					else if(k == 1 && n == 0){
						printf(".");
					}
					else if(k == 0 && n == 1){
						printf(".");
					}
					else if(k == 1 && n == 1){
						printf("#");
					}
			}
				printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

struct Eratosthenes {
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }

  void init(int n) {
    prime.resize(n + 1);
    for(int i = 0; i < prime.size(); ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i = 2; i < sqrt(n); i++) {
      if (prime[i]) {
        for (int j = 0; i * (j + 2) < n; j++) {
					prime[i * (j + 2)] = false;
				}
      }
    }
  }
};

signed main() {
  INIT;
	
	VAR(int, n);
	Eratosthenes e(55556);
	vector< int > ans;
	int cnt = 0;
	FOR(i, 2, 55556) {
		if (!e.prime[i]) continue;
		if (i % 5 == 1) {
			ans.push_back(i);
			cnt++;
		}

		if (cnt == n) break;
	}

	REP(i, n) {
		OUT(ans[i]);
		if (i < n - 1) SP;
	}
	BR;
	// debug(n);
	
  return 0;
}


Measured memory_bytes: 256
#include<stdlib.h>
#include<malloc.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#define LL long long

int n,i,r=0,b=0;
char s[1000];

int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    for (i=0;i<=n-1;i++)
    {
        if (s[i]=='R')
        {
            r++;
        }
        if (s[i]=='B')
        {
            b++;
        }
    }
    //printf("%d %d\n",r,b);
    if (r>b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}


Measured memory_bytes: 128
from operator import itemgetter

n, m = map(int, input().split())
cake = []
for i in range(n):
    x, y, z = map(int, input().split())
    cake.append([x + y + z, x + y - z, x - y + z, x - y - z,
                 -x + y + z, -x + y - z, -x - y + z, -x - y - z])
if m == 0:
    print(0)
else:
    print(max([sum(a[-m:]) for a in list(map(sorted, list(zip(*cake))))]))

Measured memory_bytes: 3672
#include <stdio.h>

int main(){

  int a[1000002];

  scanf("%d",&a[0]);

  int i = 0, j = 0, flag = 0;
  do{
    if( a[i] % 2 == 0 ){
      a[ i + 1 ] = a[i] / 2;
    }
    else{
      a[ i + 1 ] = a[i] * 3 + 1;
    }
    i++;

    for( j = 0; j < i; j++ ){
      if( a[i] == a[j] ){
        flag = 10;
      }
    }
  }while( flag < 1 );

  printf("%d \n",i+1);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = int(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

int n, d[2][MAX_N];
vector<vector<int> > G;

void bfs(int k){
    queue<P> que;
    int s = (k?n-1:0);
    que.push({s,0});
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int v = p.first;
        if(d[k][v]!=-1)continue;
        d[k][v] = p.second;
        for(auto u : G[v]){
            if(d[k][u]!=-1)continue;
            que.push({u,p.second+1});
        }
    }
}

int main() {
    cin >> n;
    G.resize(n);
    REP(i,n-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    REP(i,2) fill(d[i],d[i]+n,-1);
    REP(i,2) bfs(i); // 各頂点とFennec,Snukeの距離を求める
    int cnt = 0; // Fennecのとれる数
    REP(i,n){
        if(d[0][i]<=d[1][i])cnt++; // Fennecに近い
    }
    cout << (cnt > n/2 ? "Fennec":"Snuke") << endl; // とれる個数が過半数なら勝ち
    return 0;
}


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

int main(){
    ll N,D;
    cin>>N>>D;
    
    ll D2=D*D;
    
    int ans=0;
    for(ll i=0;i<N;++i){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=D2)++ans;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
ll n  ,mx , m , a , cnt , ans , d , k;
string s;
int main(){
    cin >> s;
    for( int i = 0;i < s.size();i ++ ){
        if( s[i] == 'R' )
            cnt ++ ;
        else
            mx = max( mx , cnt ) , cnt = 0;
    }
    mx = max( mx , cnt );
    cout << mx << endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int n,i;
double a[104],res=0;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        res+=(1.0/a[i]);
    }
    res=1.0/res;
    cout<<res;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  f80 l;
  cin >> l;
  cout << exp(l / 3, 3) << endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
c = 0
for i in range(N):
    if X[i]**2 + Y[i]**2 <= D**2:
        c += 1
print(c)

Measured memory_bytes: 24912
def main(x: int):
    ans = set([1])

    for b in range(1, x + 1):
        for p in range(2, x + 1):
            if b**p > x:
                break

            ans.add(b**p)

    print(max(ans))


if __name__ == "__main__":
    x = int(input())

    main(x)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const ll inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll cnt[20][20];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    string s;
    cin >> s;
    int idx = 0;
    while (idx < s.size() && s[idx] != '.') {
      a[i] *= 10;
      a[i] += s[idx] - '0';
      idx++;
    }
    idx++;
    rep(_, 9) {
      a[i] *= 10;
      if (idx < s.size()) {
        a[i] += s[idx] - '0';
        idx++;
      }
    }
  }

  rep(i, n) {
    array<ll, 2> res = {0, 0};
    while (a[i] % 2 == 0) {
      res[0]++;
      a[i] /= 2;
    }
    while (a[i] % 5 == 0) {
      res[1]++;
      a[i] /= 5;
    }
    chmin(res[0], 18LL);
    chmin(res[1], 18LL);
    cnt[res[0]][res[1]]++;
  }
  ll ans = 0;
  rep(i, 20) {
    rep(j, 20) {
      rep(k, 20) {
        rep(l, 20) {
          if (i + k >= 18 && j + l >= 18) {
           ll res = cnt[i][j] * cnt[k][l];
           if (i == k && j == l) res = cnt[i][j] * (cnt[i][j] - 1);
           ans += res;
           //if (cnt[i][j] && cnt[k][l]) cout << i << ' ' << j << ' ' << k << ' ' << l << ' ' << res << '\n';
          }
        }
      }
    }
  }
  //rep(i, 20) rep(j, 20) if (cnt[i][j]) cout << i << ' ' << j << ' ' << cnt[i][j] << '\n';
  cout << ans / 2 << '\n';






  




  
  return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int k;cin>>k;
  int a,b;cin>>a>>b;
  rep(i,a,b) {
    if(i%k==0) {
      pr("OK");
      return 0;
    }
  }
  pr("NG");
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
	ALL(it, v) {
		cout << *it << " ";
	}
	cout << endl;

}

int alk(int n) {
	int res = 0;
	For(i, 1, n + 1) {
		if (n % i == 0)
			res++;
	}
	return res;
}

int main() {
	int n; cin >> n;
	int dp[205];
	For(i,105, 201){
		if (i % 2 == 0)
			continue;
		dp[i] = alk(i);
	}

	int res = 0;
	rep(i, n + 1) {
		if (dp[i] == 8)
			res++;
	}
	cout << res << endl;


}



Measured memory_bytes: 888
// ABC062A - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int a[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x, y;
	cin >> x >> y;

	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    if length(s)<4 || s[1:4]!="YAKI"
        println("No")
    else
        println("Yes")
    end
end
main()

Measured memory_bytes: 108976
n = int(input())
p = list(map(int, input().split()))

p0 = [i + 1 for i in range(n)]
count = 0
for i in range(n):
    if p[i] != p0[i]:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 10
 
struct Edge{
    int dst,weight;
    Edge(int dst,int weight) : dst(dst),weight(weight) {}
};
 
int V,E;
int ans_dist;
vector<int> ans;
vector<Edge> G[MAX];
bool visited[MAX][MAX];
 
void dfs(int v,int dist,vector<int> &routes){
    if(ans_dist < dist){
	ans_dist = dist;
	ans = routes;
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	int to = G[v][i].dst;
	if(visited[v][to]) continue;
	visited[v][to] = visited[to][v] = true;
	routes.push_back(to+1);
	dfs(to,dist+G[v][i].weight,routes);
	routes.pop_back();
	visited[v][to] = visited[to][v] = false;
    }
}
 
int main(){
    int a,b,c;
    while(cin >> V >> E, (V | E)){
	ans_dist = 0; ans.clear();
	for(int i = 0 ; i < V ; i++){
	    G[i].clear();
	}
	memset(visited,false,sizeof(visited));
	for(int i = 0 ; i < E ; i++){
	    cin >> a >> b >> c; a--, b--;
	    G[a].push_back(Edge(b,c));
	    G[b].push_back(Edge(a,c));
	}
	vector<int> vec;
	for(int i = 0 ; i < V ; i++){
	    vec.push_back(i+1);
	    dfs(i,0,vec);
	    vec.pop_back();
	}
	cout << ans_dist << endl;
	for(int i = 0 ; i < (int)ans.size() ; i++){
	    if(i) cout << " ";
	    cout << ans[i];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3032
h,w = gets.chomp.split(' ').map{|n| n.to_i}
s = []
h.times do |i|
  s << gets.chomp
  s[i].insert(0, "#")
  s[i].insert(-1, "#")
end
def hash_print(w)
  (w + 2).times do 
    print '#'
  end
  puts ""
end

hash_print(w)
h.times do |i|
  puts s[i]
end
hash_print(w)

Measured memory_bytes: 1788
#はじめてのDP
n = int(input())
h = [0] + list(map(int, input().split()))

dp = [-1] * (n+1)

dp[1]=0
dp[2]=abs(h[2]-h[1])
for i in range(3, n+1):
    dp[i] = min([dp[i-j] + abs(h[i-j]-h[i]) for j in [1,2]])

print(dp[n])

Measured memory_bytes: 13928
a,b,c=map(int,input().split())
if a==b and b==c and a%2==0:
    print(-1)
else:
    ans=0
    while a%2==0 and b%2==0 and c%2==0:
        a0,b0,c0=(b+c)//2,(c+a)//2,(a+b)//2
        a,b,c=a0,b0,c0
        ans+=1
    print(ans)

Measured memory_bytes: 3064
/*

0576: homework

*/

#include <stdio.h>


int main(void){
	
	int n, a, b, c, d;
	
	scanf("%d", &n);
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	
	while(a > 0 || b > 0){
		
		a -= c;
		b -= d;
		n--;
		
	}
	
	printf("%d\n", n);
	
	return 0;
	
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
const int INF = 1001001001;
int main(){
  int x, y;
  cin >> x >> y;
  int ry = y * -1;
  int rx = x * -1;
  int a1 = INF, a2 = INF, a3 = INF;
  if(x <= y){
    a1 = y - x;
    if(rx <= y) a2 = y - rx + 1;
    if(x <= ry) a3 = ry - x + 1;
  }else{
    a1 = ry - rx + 2;
    if(x <= ry) a2 = ry - x + 1;
    if(rx <= y) a3 = y - rx + 1;
  }
  if(a1 < a2 && a1 < a3) cout << a1 << endl;
  else if(a2 < a3) cout << a2 << endl;
  else cout << a3 << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;cin>>n;
  vector<long long> t(n),x(n),y(n);
  for(int i=0;i<n;++i)cin>>t[i]>>x[i]>>y[i];
  for(int i=0;i<n;++i){
    long long k,s;
    if(i==0)k=t[i],s=x[i]+y[i];
    else k=abs(t[i]-k),s=abs(s-(x[i]+y[i]));
    int a=k%2,b=s%2;
    if(s>k||a!=b)return cout<<"No",0;
  }
  cout<<"Yes",0;
}

Measured memory_bytes: 2560
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int l, r;
    cin >> l >> r;
    vi v;
    for(int i = l; i <= r; i++){
        if(i%2019==0){
            cout << 0;
            return 0;
        }
        v.pb(i%2019);
    }
    sort(all(v));
    int mini = INF;
    for(int i = 0; i < v.size()-1; i++){
        for(int j = i+1; j < v.size(); j++){
            if(mini > (v[i] * v[j])%2019) mini = (v[i]*v[j])%2019;
        }
    }
    cout << mini;
}


Measured memory_bytes: 256
from itertools import permutations
N,M=map(int,input().split())
G=[[] for _ in range(N)]
 
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)            #ペアのリストに格納、a=1,b=7ならb=7をリスト0に格納
    G[b-1].append(a-1)            #ペアのリストに格納、a=1,b=7ならa=1をリスト6に格納
  
P=permutations(range(0,N),N)      #(リスト,順列の要素の数)
ans=0

for A in P:
  if A[0]!=0:                     #先頭が1でなければ下は実行されずに次のループへ
    continue
  for i in range(N-1):
    if not (A[i+1]  in G[A[i]]):
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int n; cin >> n;
	vector<int> t(n), x(n), y(n);
	for (int i = 0; i < n; i++) cin >> t[i] >> x[i] >> y[i];

	int dis = 0;
	bool flag = true;
	for (int i = 0; i < n; i++)
	{
		dis = abs(x[i]) + abs(y[i]);
		if (dis > t[i])
		{
			flag = false;
			break;
		}

		if (dis % 2 != t[i] % 2)
		{
			flag = false;
			break;
		}
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vvi vector < vector < int >  >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define fore(i,c) for(int i = 1; i <= (int)c; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
// #define double long double
// #define a first
// #define b second

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);

    int n;
    string s;
    cin >> n >> s;
    rep(i, 1, s.length()){
        if(s[i] == s[i - 1])
            n--;
    }
    cout << n << endl;

  
    return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc044/tasks/abc044_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string w;
    cin >> w;
    map<char, int> cnts;
    for (int i = 0; i < w.size(); ++i)
    {
        ++cnts[w[i]];
    }
    for (const auto& e : cnts)
    {
        if (e.second % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#pragma GCC target("popcnt")

#define ll unsigned long long
#define all(x) (x).begin(),(x).end()
#define dlog(x) cerr<<#x<<'='<<x<<endl
#define dnew cerr<<endl;
#define f first
#define s second
#define endl '\n'
#define max3(a,b,c)  max(a,max(b,c))

using namespace std;
using pii=pair<int,int>;

int mas[100000][3];

map< pii, int > dp;

int solve (int n,int x) {
      if (n==0) return max3(mas[0][0],mas[0][1],mas[0][2]);
      int res=0;
      for (int i=0; i<3; i++) {
            if (i==x) continue;
            if (!dp.count({n-1,i})) dp[{n-1,i}]=solve(n-1,i);
            res=max(res,dp[{n-1,i}]+mas[n][i]);
      }
      return res;
}



int main(){
      ios::sync_with_stdio(false); cin.tie(nullptr);
      int n; cin>>n;
      for (int i=0; i<n; i++) {
            cin>>mas[i][0]>>mas[i][1]>>mas[i][2];
      }

      cout<<solve(n-1,-1)<<endl;

      return 0;
}

Measured memory_bytes: 32640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  vector<vector<int> > a(3, vector<int>(3));
  for (auto &x: a) {
    for (auto &y: x) cin >> y;
  }
  int n;
  cin >> n;
  vector<int> b(n);
  for (auto &x: b) cin >> x;

  vector<vector<bool> > open(3, vector<bool>(3));
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[i][j] == b[k]) {
          open[i][j] = true;
        }
      }
    }
  }

  for (int i = 0; i < 3; i++) {
    if (open[i][0] && open[i][1] && open[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  for (int j = 0; j < 3; j++) {
    if (open[0][j] && open[1][j] && open[2][j]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (open[0][0] && open[1][1] && open[2][2]) {
    cout << "Yes" << endl;
    return 0;
  }
  if (open[0][2] && open[1][1] && open[2][0]) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


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

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

    int a, max = 0, max_index = -1, second = 0;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        if (max < a) {
            max       = a;
            max_index = i;
        } else if (second < a) {
            second = a;
        }
    }

    for (int i = 0; i < N; ++i) {
        if (i != max_index) {
            printf("%d\n", max);
        } else {
            printf("%d\n", second);
        }
    }

    return 0;
}


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

int main(){
    int n, m, c, a, cnt=0; cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            cin >> a; sum += a * b[j];
        }
        if(sum+c > 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {

    int r, g, b, total;
    cin >> r >> g >> b;

    total = 100*r + 10*g + b;

    if(total %4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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


int main(){
    int N;
    cin >> N;
    ll mod = 1e9+7;
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    sum %= mod;
    ll ans = 0;
    for (int i = 0; i < N; i++) ans += mod-A[i]*A[i]%mod;
    ans += sum*sum%mod;
    ans %= mod;
    if (ans%2 == 0) ans /= 2;
    else ans = ans*((mod+1)/2)%mod;
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4840
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, s = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = LI()
    G[u - 1] += [(v - 1, a, b)]
    G[v - 1] += [(u - 1, a, b)]

change = LIR(n)

def dijkstra(s):
    hq = [(0, 0, s)]
    dist = [[INF] * 2451 for _ in range(n)]
    dist[0][s] = 0
    while hq:
        t, u, coin = heappop(hq)
        if t > dist[u][coin]:
            continue
        if t + change[u][1] < dist[u][min(2450, coin + change[u][0])]:
            dist[u][min(2450, coin + change[u][0])] = t + change[u][1]
            heappush(hq, (t + change[u][1], u, min(2450, coin + change[u][0])))
        for v, c, d in G[u]:
            if coin - c >= 0 and t + d < dist[v][coin - c]:
                dist[v][coin - c] = t + d
                heappush(hq, (t + d, v, coin - c))
    return dist

D = dijkstra(min(2450, s))
for t in range(1, n):
    print(min(D[t]))

Measured memory_bytes: 102176
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (ll i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (ll i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vll a(n);
    cin >> a;
    vll s(n+1);
    s[0] = 0;
    s[1] = a[0];
    FOR(i,1, n)
    {
        s[i + 1] = s[i] + a[i];
    }
    REP(i,n + 1){
        s[i] = (s[i] - i) % k;
    }
    map<ll, ll> ma;
    ll ans = 0;
    FOR(i, 1, n + 1)
    {
        if (i >= k){
            ma[s[i - k]]--;
            ma[s[i - 1]]++;
            ans += ma[s[i]];
        }
        else
        {
            ma[s[i - 1]]++;
            ans += ma[s[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int64_t gcd(int64_t a,int64_t b)
{
  return (a%b==0? b:gcd(b,a%b));
}

int main()
{
  int64_t a,b;
  cin>>a>>b;
  cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int x1, y1, w1, h1; std::cin >> x1 >> y1 >> w1 >> h1;
	int x2, y2, w2, h2; std::cin >> x2 >> y2 >> w2 >> h2;
	if (x1 + w1 <= x2 || x2 + w2 <= x1 || y1 + h1 <= y2 || y2 + h2 <= y1) {
		std::cout << w1 * h1 + w2 * h2 << '\n';
	}
	else {
		std::cout << w1 * h1 + w2 * h2 - 2 * (std::min(x1 + w1, x2 + w2) - std::max(x1, x2)) * (std::min(y1 + h1, y2 + h2) - std::max(y1, y2)) << '\n';
	}
}


Measured memory_bytes: 3120
import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import cmp_to_key, lru_cache, reduce
from operator import add, sub
from itertools import count

sys.setrecursionlimit(10**6 + 1)
input = sys.stdin.buffer.readline

MOD = 10**9 + 7


def solve(g, clr, n):
    def dfs(v, par):
        nonlocal total
        sub[v] = 1
        bfr = cnt[clr[v]]

        for u in g[v]:
            if u == par:
                continue
            pre = total - cnt[clr[v]]
            sub[v] += dfs(u, v)
            nxt = total - cnt[clr[v]]
            ans[clr[v]] -= (nxt-pre) * (nxt-pre-1) // 2

        cnt[clr[v]] = bfr + sub[v]
        total += 1
        return sub[v]

    ans = [(n-1)*n//2] * (n+1)
    cnt = [0] * (n+1)
    sub = [0] * (n+1)
    total = 0

    dfs(1, -1)
    # print(cnt)
    for i in range(1, n+1):
        pre, nxt = 0, n-cnt[i]
        ans[i] -= (nxt-pre) * (nxt-pre-1) // 2

    for c in clr:
        ans[c] += 1
    print(*ans[1:], sep='\n')


if __name__ == "__main__":
    n = int(input())
    colors = [0] + [int(s) for s in input().split()]
    g = defaultdict(set)

    for _ in range(n-1):
        a, b = map(int, input().split())
        g[a].add(b)
        g[b].add(a)

    solve(g, colors, n)


Measured memory_bytes: 338064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto N = readln.chomp.to!int;
    for (int a = 0; a * 4 <= 100; ++a) {
        for (int b = 0; b * 7 <= 100; ++b) {
            if (a * 4 + b * 7 == N) {
                writeln("Yes");
                return;
            }
        }
    }
    writeln("No");
}

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

char str[200001];

int main() {
	
	scanf("%s", str);

	int size = strlen(str);

	int b = 0;
	long long ans = 0;
	for (int i = 0; i < size; i++) {
		if (str[i] == 'B') b++;
		else ans += b;
	}
	
	printf("%lld\n", ans);
}

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

int main() {
  string s;
  cin >> s;
  int a = 0, b = 0;
  for (char ch : s) {
    if (ch == 'A') ++a;
    else ++b;
  }
  if (a && b) {
   cout << "Yes\n";
  } else {
   cout << "No\n";
  }
}

Measured memory_bytes: 256
N=int(input())
S1=input()
S2=input()


mod=1000000007
ans=3
i=0
flag=0
while N-1>=i:
    if S1[i]==S2[i]:
        if i!=0:
            if flag==0:
                ans*=2
        else:
            ans=3
        flag=0
        i+=1
    else:
        if i!=0:
            if flag==0:
                ans*=2
            else:
                ans*=3
        else:
            ans=6
        flag=1
        i+=2

print(ans%mod)

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int x, a, b; cin >> x >> a >> b;
    x -= a;
    x -= x / b * b;
    cout << x << endl;
}


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

int min(int a,int b){
if(a>b)return b;
return a;
}


int main(){
char str[MAX];
char taro[MAX];
char hanako[MAX];
int i,j;
int n;
int Taro,Hana;
int x,y,max;
Taro=0;
Hana=0;

scanf("%d",&n);
for(i=0;i<n;i++){
 
 scanf("%s %s",taro,hanako);

 if(strcmp(taro,hanako)==0){Taro++;Hana++;}

 else{
  x=strlen(taro);
  y=strlen(hanako);
  max=min(x,y);
  for(j=0;j<max;j++){
   if(taro[j]>hanako[j]){Taro+=3;break;}
   else if(taro[j]<hanako[j]){Hana+=3;break;}
  }
  if(j==max && taro[j]!='\0')Taro+=3;
  else if(j==max && hanako[j]!='0')Hana+=3;
 }

}


printf("%d %d\n",Taro,Hana);

return 0;
}


Measured memory_bytes: 2104
#include<cstdio>
#include<algorithm>
#include<cmath>
#define MOD 1000000007
using namespace std;
long long n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
	if(abs(n-m)>1) {puts("0");return 0;}
	long long n1=1,n2=1;
	for(long long i=2;i<=n;++i) n1=(n1*i)%MOD;
	for(long long i=2;i<=m;++i) n2=(n2*i)%MOD;
	if(n!=m) printf("%lld\n",n1*n2%MOD);
	else printf("%lld\n",n1*n2*2%MOD);
	return 0;
}

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

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

  int a[3][10] = {}, e[3][10] = {}, c[3][10] = {}, d[3][10] = {};
  int b,f,r,v;
  for(int i = 0; i < n; i++){

    cin >> b >> f >> r >> v;
    f--;
    r--;
    if(b == 1){
      if(v > 0){
        a[f][r] += v;
      }else{
        a[f][r] -= abs(v);
      }
    }

    if(b == 2){
      if(v > 0){
        e[f][r] += v;
      }else{
        e[f][r] -= abs(v);
      }
    }

    if(b == 3){
      if(v > 0){
        c[f][r] += v;
      }else{
        c[f][r] -= abs(v);
      }
    }

    if(b == 4){
      if(v > 0){
        d[f][r] += v;
      }else{
        d[f][r] -= abs(v);
      }
    }
  }

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 10; j++){
        cout << " " << a[i][j];
    }
    cout << endl;
  }

  cout << "####################" << endl;

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 10; j++){
        cout << " " << e[i][j];
    }
    cout << endl;
  }

  cout << "####################" << endl;

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 10; j++){
        cout << " " << c[i][j];
    }
    cout << endl;
  }

  cout << "####################" << endl;

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 10; j++){
        cout << " " << d[i][j];
      }
    cout << endl;
  }
}



Measured memory_bytes: 3100
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
def summ(n, nn=0):
  nn = max(nn, 0)
  return n*(n+1)/2 - nn*(nn+1)/2

n, k = map(int, input().split())

a = 1
for i in range(k, n + 1):
  mmin = summ(i - 1)
  mmax = summ(n, n - i)
  m = mmax - mmin + 1
  a += m

k = 10**9 + 7
print(int(a%k))

Measured memory_bytes: 9200
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		//100の位を求める
		String digits = String.valueOf(n / 100);
		
		String s = digits + digits + digits;
		
		int continuing = Integer.valueOf(s);
		
		
		if (continuing >= n) {
			System.out.println(continuing);
		} else {
			String digits2 = String.valueOf(n / 100 + 1);
			
			String str2 = digits2 + digits2 + digits2;
			
			int continuing2 = Integer.valueOf(str2);
			System.out.println(continuing2);
		}
		
	}
}

Measured memory_bytes: 21460
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i=0;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
  }
  cout << str << endl;
}

Measured memory_bytes: 1172
import math
def fib(q):
   fibonacci = [0,1]
   for i in range(2,q):
       fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
   return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]))
out%=c
print(out)

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

using namespace std;

int main() {

	int h, w, flag = 0,count = 0;

	cin >> h >> w;
	vector<vector<char>> vec(h, vector<char>(w));

	for (int i = 0; i < h; i++) {
		flag = 0;
		for (int j = 0; j < w; j++) {

			cin >> vec.at(i).at(j);

			if (vec.at(i).at(j) == '#') flag = 1;
			if (j == w - 1 && flag == 0){

				for (int j = 0; j < w; j++) {
					vec.at(i).at(j) = '0';
				}
			}
		}
	}

	for (int i = 0; i < w; i++) {
		flag = 0;
		for (int j = 0; j < h; j++) {
			if (vec.at(j).at(i) == '#') flag = 1;
			if (j == h - 1 && flag == 0) {

				for (int j = 0; j < h; j++) {
					vec.at(j).at(i) = '0';
				}
			}
		}
	}

	for (int i = 0; i < h; i++) {
		flag = 0;
		count = 0;
		for (int j = 0; j < w; j++) {
			if (vec.at(i).at(j) != '0') cout << vec.at(i).at(j);
			else count++;
		}
		if (count != w)cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ss second
#define pb push_back
const int mod = 998244353;
const ll INF = -(ll)1e10;

int main()
{
    int n, k;
    cin>>n>>k;
    vector<pii> arr(k);
    for(int i = 0; i<k; i++)
    {
        int l, r;
        cin>>l>>r;
        arr[i]={l, r};
    }
    vll dp(n+2);
    dp[1]=1;
    for(int i = 1; i<=n; i++)
    {
        dp[i]+=dp[i-1];
        dp[i]%=mod; 
        for(int j = 0; j<k; j++)
        {
            if(i+arr[j].ff>n)continue;
            int start = i+arr[j].ff;
            int end = min(n, i+arr[j].ss);
            dp[start]+=dp[i];
            dp[start]%=mod;
            dp[end+1]-=dp[i];
            dp[end+1]%=mod;        
        }
        dp[1]=0;   
    }
    if(dp[n]<0)dp[n]+=mod;      
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4836
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{
    

    class Program
    {

        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            //最大値を特定する
            var max = Max(A.Max(),K);
            var max2base = Convert.ToString(max, 2);
            var SumOfZero = new long[max2base.Length];

            //各数値の２進数の情報を登録
            for (int i = 0; i < N; i++)
            {
                var tmp = Convert.ToString(A[i], 2);
                //Console.WriteLine(tmp);
                for (int j = 0; j < max2base.Length; j++)
                {
                    if (j < tmp.Length)
                    {
                        if (tmp[tmp.Length - 1 - j] == '0')
                        {
                            SumOfZero[max2base.Length - 1-j]++;
                        }
                    }
                    else
                    {
                        SumOfZero[max2base.Length - 1 - j]++;
                    }
                }
            }

            var ans = 0L;
            for (int i = 0; i < max2base.Length; i++)
            {
                //1にできるかどうか
                var tmp = ans+ (long)Pow(2, max2base.Length - 1 - i);
                if (tmp > K)
                {
                    continue;
                }
                var ZeroOrOne = (SumOfZero[i] > N - SumOfZero[i]) ? 1 : 0;
                ans += ZeroOrOne * (long)Pow(2, max2base.Length - 1 - i);
            }
            //Console.WriteLine(len);


            ////愚直
            //for (K = 1;K <= 100;K++) {
            //    ans = 0;
            //    for (int i = 1; i <= K; i++)
            //    {
            //        var tmp = 0L;
            //        for (int j = 0; j < N; j++)
            //        {
            //            tmp += (A[j] ^ i);
            //        }

            //        ans = Max(ans, tmp);
            //    }
            //    Console.WriteLine(K+" "+ans);
            //}

            long ans2 = 0;
            for (int i = 0; i < N; i++)
            {
                ans2 += A[i] ^ ans;
            }

            Console.WriteLine(ans2);
        }


    }
}


Measured memory_bytes: 31324