akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    for (int i = 2; i < n+1; i++) {
        ll fl = 0;
        for (int j = 2; j < i; j++) {
            if (i % j == 0)fl = 1;
        }
        if (fl == 1)continue;
        ll t = n;
        ll zans = 0;
        while (t > 0) {
            t /= i;
            zans += t;
        }
        ans = (zans+1) * ans % 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define N 200010
ll n,q;
unordered_map<ll,ll> mas;
struct ver{
  ll l,r,t;
  bool operator<(const ver&key)const{
      return this->t<key.t;
  }  
  ver(ll l,ll r,ll t){
      this->l=l,this->r=r,this->t=t;
  }
};
vector<ver> v;
ll ans[N];
int main(){
  cin>>n>>q;
  for(int i=0;i<n;i++){
      ll a,b,c;cin>>a>>b>>c;
      v.push_back(ver(a-c,b-c,c));
  }
  sort(v.begin(),v.end());
  set<ll> s;
  for(int i=0;i<q;i++){
      ll x;cin>>x;
      mas[x]=i;
      s.insert(x);
      ans[i]=-1;
  }
  for(auto p:v){
      ll l=p.l,r=p.r,t=p.t;
      while(s.size()>0){
	  auto it=s.lower_bound(l);
	  if(it==s.end())break;
	  if(*it>=r)break;
	  ans[mas[*it]]=t;
	  s.erase(it);
      }
  }
  for(int i=0;i<q;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 26860
// Work.cpp : This file contains the 'main' function. Program execution begins and ends there.


/*
ID: your_id_here
LANG: C++
TASK: greed
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;


int main() {
    long double A, B;
    cin >> A >> B;
    cout << (long long)(A * B + 0.001) << endl;
}





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

#define INF 1000000000

string mem[4000], origin[4000];
char N;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, H, W, sx, sy, d[4000][4000];

int dfs(char p)
{
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++)
      d[i][j] = INF;
  queue<int> q;
  q.push(sx);
  q.push(sy);
  d[sy][sx] = 0;
  while(1)
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();
    if(mem[y][x] == p)
    {
      sx = x;
      sy = y;
      return d[y][x];
    }
    for(int i = 0; i < 4; i++)
    {
      int tx = x + dx[i], ty = y + dy[i];
      if(tx >= 0 && tx < W && ty >= 0 && ty < H && d[ty][tx] == INF && mem[ty][tx] != 'X')
      {
        q.push(tx);
        q.push(ty);
        d[ty][tx] = d[y][x] + 1;
      }
    }
   
  }
}

int main()
{
  cin >> H >> W >> N;
  sx = -1; sy = -1;
  for(int i = 0; i < H; i++)
  {
    cin >> mem[i];
    origin[i] = mem[i];
    if(sx != -1)
      continue;
    for(int j = 0; j < mem[i].length(); j++)
    {
      if(mem[i][j] == 'S')
      {
        sx = j;
        sy = i;
      }
    }
  }
  int ans = 0; 
  for(char i = '1'; i <= N; i++)
  {
    for(int j = 0; j < H; j++)
      mem[j] = origin[j];
    ans += dfs(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 18672
#include<bits/stdc++.h>
using namespace std;
int main ( void ) {
	string s;
	cin>>s;
	if (s[0]=='S')
		puts("Cloudy");
	else if(s[0]=='C')
		puts("Rainy");
	else if(s[0]=='R')
		puts("Sunny");
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string s[N];
  vector<int> yen(N,0);
  for(int i=0;i<N;i++){
    cin >> s[i];
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        yen[j]++;
      }
    }
    yen[i]++;
  }
  int M;
  cin >> M;
  for(int i=0;i<M;i++){
    string x;
    cin >> x;
    for(int j=0;j<N;j++){
      if(x==s[j])yen[j]--;
    }
  }
  sort(yen.begin(),yen.end());
  cout << max(0,yen[N-1]) << endl;
}

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

int a[8][8];

int check(int y,int x){
	if(x<0 || x>7 || y<0 || y>7)return 0;
	else return a[y][x];
}

int main(void){
	int i,j,ok;
	while(1){
		for(i=0;i<8;i++){
			if(scanf("%1d%1d%1d%1d%1d%1d%1d%1d",&a[i][0],&a[i][1],&a[i][2],&a[i][3],&a[i][4],&a[i][5],&a[i][6],&a[i][7])==EOF)return 0;
		}
		ok=0;
		for(i=0;i<8&&ok<1;i++){
			for(j=0;j<8&&ok<1;j++){
				if(a[i][j]==1)ok++;
			}
		}
		i--;j--;
		if(check(i,j+1)==1){
			if(check(i+1,j+1)==1){
				if(check(i+1,j)==1)printf("A\n");
				else printf("E\n");
			}
			else{
				if(check(i+1,j)==1)printf("G\n");
				else printf("C\n");
			}
		}
		else{
			if(check(i+1,j-1)==1)printf("D\n");
			else if(check(i+1,j+1)==1)printf("F\n");
			else printf("B\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(isEasyToTap(s) ? "Yes" : "No");
    }

    private static boolean isEasyToTap(String s) {
        char[] ca = s.toCharArray();
        int l = ca.length;
        for (int i = 0; i < l; i++) {
            if (i % 2 == 0) {
                if (ca[i] == 'L') {
                    return false;
                }
            } else {
                if (ca[i] == 'R') {
                    return false;
                }
            }
        }
        return true;
    }
}


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

int main(void){
  int g,b,r,n,temp;
  cin >> g >> b >> r >> n;
  int ans = 0;
  for(int i = 0; i != (n / g) + 1; i++){
    for(int j = 0; j != (n / b) + 1; j++){
      temp = n - (i * g) - (j * b);
      if(temp >= 0 && temp % r == 0){
        //cout << i << j << temp << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int cnt[100001] = {};
int main() {
  int N, M, a, b;
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &a, &b);
    if (a != 1) cnt[a]++;
    if (b != 1) cnt[b]++;
  }
  int ok = 1;
  for (int i = 1; i <= N; i++) {
    if (cnt[i] % 2 != 0) ok = 0;
  }

  if (ok == 1) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 512
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int max = 0;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }
        int mid = 0;
        int x = (max + 1) / 2;
        for(int i = 0; i < n; i++){
            if(Math.abs(a[i] - x) < Math.abs(mid - x)){
                mid = a[i];
            }
        }
        System.out.println(max + " " + mid);
    }
}


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

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

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

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

struct UniTree {
    int *par, *rank, *sz;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        sz = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
            sz[x] += sz[y];
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int siz(int x) {
        return sz[root(x)];
    }
};

double bin(double left, double right) {
    return 0;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a - b * 2, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=999999999999999;
    cin >> n;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ll tmp=n/i;
            ans=min(ans,(tmp-1)+(i-1));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,max,mi,k,d;
  while(scanf("%d %d",&n,&max),n||max){
    int b[150]={0};
    while(n--){
      scanf("%d",&k);
      while(k--){
	scanf("%d",&d);
	b[d]++;
      }
    }
    max--;
    for(n=mi=0;n<101;n++){
      if(max<b[n])max=b[mi=n];
    }
    printf("%d\n",mi);
  }
  return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3
import sys
import math

def solve(N: int, D: int, X: "List[List[int]]"):
    count = 0
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            sum = 0
            for k in range(0, D):
                sum += (X[i][k] - X[j][k]) ** 2
            if math.sqrt(sum).is_integer():
                count += 1
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [[int(next(tokens)) for _ in range(D)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D, X)

if __name__ == '__main__':
    main()


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
int n;



signed main()
{
    cin >> n;

    cout << pow(n, 3) << endl;;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		
		for (int i=1; i<=N; i++) {
			A[sc.nextInt()-1] = i;
		}
		for (int a : A) {
			System.out.println(a + " ");
		}
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
ll mo=1000000007;
int num[101010];
int num2[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) num[abs(i-(N-(i+1)))]++;
	FOR(i,N) {
		cin>>A[i];
		num2[A[i]]++;
	}
	ll ret=1;
	FOR(i,N) {
		if(num[i]!=num2[i]) return _P("0\n");
		if(num[i]==2) ret=ret*2%mo;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B;
	cin >> A >> B;

	if (A == 1)
		A = 14;
	if (B == 1)
		B = 14;

	if (A < B)
	{
		cout << "Bob" << endl;
	}
	else if (A == B)
		cout << "Draw" << endl;
	else
		cout << "Alice" << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import bisect

def nearlr(l, x):
    n = bisect.bisect(l, x)
    return n-1, n

A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]

for _x in x:
    s_1, s_2 = nearlr(s, _x)
    t_1, t_2 = nearlr(t, _x)
    s_cand = []
    t_cand = []
    if s_1 < 0:
        s_cand = [s[s_2] - _x]
    elif s_2 >= len(s):
        s_cand = [s[s_1] - _x]
    else:
        s_cand = [s[s_1] - _x, s[s_2] - _x]
    if t_1 < 0:
        t_cand = [t[t_2] - _x]
    elif t_2 >= len(t):
        t_cand = [t[t_1] - _x]
    else:
        t_cand = [t[t_1] - _x, t[t_2] - _x]
    ans = float('inf')
    for _s in s_cand:
        for _t in t_cand:
            if _t * _s < 0:
                ans = min(ans, abs(_s) * 2 + abs(_t), abs(_s) + abs(_t) * 2)
            else:
                ans = min(ans, max(abs(_s), abs(_t)))
    print(ans)

Measured memory_bytes: 16152
#include <iostream>

using namespace std;

int main(void)
{
    int N, M, i, a[51], b[51], c[51];

    cin >> N >> M;

    for(i=1; i<=N; i++){
        c[i] = 0;
    }

    for(i=1; i<=M; i++){
        cin >> a[i] >> b[i];

        c[a[i]]++;
        c[b[i]]++;
    }

    for(i=1; i<=N; i++){
        cout << c[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        books: [[usize; m+1]; n],
    }

    let mut combination = vec![false; n];
    let ans = calc(0, n, m, x, &mut combination, &books);
    if ans != std::usize::MAX {
        println!("{}", ans);
    } else {
        println!("{}", -1);
    }
}

fn calc(index: usize, n: usize, m: usize, x: usize, combination: &mut Vec<bool>, books: &Vec<Vec<usize>>) -> usize {
    if index == n {
        let mut understandings = vec![0; m];
        let mut cost = 0;
        for (i, c) in combination.iter().enumerate() {
            if *c {
                cost += books[i][0];
                //println!("books {}", books[i][0]);
                for (j, understanding) in books[i].iter().skip(1).enumerate() {
                    understandings[j] += *understanding;
                }
            }
        }

        if understandings.iter().all(|num| *num >= x) {
            return cost;
        } else {
            return std::usize::MAX;
        }
    }

    combination[index] = true;
    let cost1 = calc(index+1, n, m, x, combination, books);
    combination[index] = false;
    let cost2 = calc(index+1, n, m, x, combination, books);

    return cmp::min(cost1, cost2);
}


Measured memory_bytes: 2160
n,m=gets.split.map &:to_i
g=n-m
g=g.abs
a=[1]
101100.times do |i|
  a<< (a[-1]*(i+2))%(10**9+7)
end
if g==0
  p (2*a[n-1]*a[m-1])%(10**9+7)
elsif g==1
  p (a[n-1]*a[m-1])%(10**9+7)
else
  p 0
end

Measured memory_bytes: 2684
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        if W%2==0:
            for i in range(1,H+1):
                a=W//2
                if i%2==1:
                    print(a*"#.",end="")
                    print("")
                else:
                    print(a*".#",end="")
                    print("")
        else:
            for j in range(1,H+1):
                a=W//2
                if j%2==1:
                    print(a*"#."+"#",end="")
                    print("")
                else:
                    print(a*".#"+".",end="")
                    print("")
        
    print("")


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  for( int i = 0; i < N; i++ ) cin >> B.at(i);
  
  vector<int> Aplus(N+1,0);
  vector<int> Bplus(N+1,0);
  for( int i = 0; i < N; i++ ){
    Aplus.at(i+1) = Aplus.at(i) + A.at(i);
    Bplus.at(i+1) = Bplus.at(i) + B.at(i);
  }
  
  int ans = 0;
  for( int i = 1; i < N+1; i++ ){
    if( Aplus.at(i) + Bplus.at(N) - Bplus.at(i-1) > ans ){
      ans = Aplus.at(i) + Bplus.at(N) - Bplus.at(i-1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int main()
{
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	int v = 0;
	for (int i = 1; i <= N; i++) {
		int c = 0, t = i;
		for (int j = 0; j < 5; j++) {
			c += t % 10;
			t /= 10;
		}
		if (A <= c && c <= B) v += i;
	}
	printf("%d\n", v);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int max(int a, int b){
    if(a<b)return b;
    else return a;
}
int min(int a, int b){
    if(a<b)return a;
    else return b;
}
int main(void){
    char s[500000+5];
    scanf("%s", s);
    int n=strlen(s);
    
    long int ans=0;
    int i=0;
    while(i<n){
        int l=0, r=0;
        for(; s[i]=='<'; i++, l++){}
        for(; s[i]=='>'; i++, r++){}

        for(int j=1; j<min(r, l); j++)ans+=j;
        for(int j=1; j<=max(r, l); j++)ans+=j;
    }
    printf("%ld\n", ans);
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] fact = new long[1010];
		long[] ifact = new long[1010];
		fact[0] = ifact[0] = 1;
		for(int i=1;i<=1000;i++){
			fact[i] = (long) i * fact[i-1];
			fact[i] %= mod;
			ifact[i] = ModInv(fact[i]);
		}
		
		long[][] nCr = new long[N+1][];
		for(int i=0;i<=N;i++) nCr[i] = new long[N+1];
		nCr[0][0] = 1;
		for(int i=1;i<=N;i++){
			nCr[i][0] = 1;
			for(int j=1;j<=i;j++){
				nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j]; if(nCr[i][j] >= mod) nCr[i][j] -= mod;
			}
		
		}
		
		
		
		long[][] dp = new long[B+1][];
		for(int i=0;i<=B;i++){
			dp[i] = new long[N+1];
		}
		
		dp[0][0] = 1;
		
		for(int i=0;i<N;i++){
			long sum = dp[0][i];
			for(int j=1;j<=B;j++){
				if(j >= A){
					for(int k=C;k<=D;k++){
						if(i + k * j > N) break;
						// comb = (rest) C (k * j) * (k * j) ! / (j!)^k / k!
						long comb = nCr[N - i][k * j];
						comb *= fact[k * j]; if(comb >= mod) comb %= mod;
						comb *= ModPow(ifact[j],k); if(comb >= mod) comb %= mod;
						comb *= ifact[k]; if(comb >= mod) comb %= mod;
						dp[j][i + k * j] += sum * comb; if(dp[j][i + k * j] >= mod) dp[j][i + k * j] %= mod;
					}
				}
				sum += dp[j][i]; if(sum >= mod) sum -= mod;
			}
		}
		
		long ans = 0;
		for(int j=A;j<=B;j++){
			ans += dp[j][N]; if(ans >= mod) ans -= mod;
		}
		Console.WriteLine(ans);
		
		
	}
	
	const long mod = (long) 1e9 + 7;
	
	long ModInv(long x){
		return ModPow(x, mod - 2);
	}
	long ModPow(long x, long n){
		if(n == 0) return 1;
		if(x == 0) return 0;
		if(x == 1) return 1;
		long ret = 1;
		long v = x;
		while(n > 0){
			if((n & 1) == 1) { ret *= v; ret %= mod; }
			v *= v; v %= mod;
			n >>= 1;
		}
		return ret;
	}
	
	
	int N;
	int A,B,C,D;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1]; B = d[2]; C = d[3]; D = d[4];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27232
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 11/21/2018, 10:34:50 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int W, a, b;
  cin >> W >> a >> b;
  if (a > b)
  {
    swap(a, b);
  }
  cout << max(0, b - a - W) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

ll a[111111];

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

int main(void)
{
	ll n, m, i, LCM = 1;

	scanf("%lld %lld", &n, &m);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		a[i] /= 2;
		LCM = lcm(LCM, a[i]);

		if (LCM > m)
		{
			puts("0");
			return 0;
		}
	}

	for (i = 0; i < n; i++)
		if (!(LCM / a[i] % 2))
		{
			puts("0");
			return 0;
		}

	printf("%lld", m / LCM % 2 == 0 ? m / LCM / 2 : m / LCM / 2 + 1);
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
vector<ll> v[100001];
ll b[100001], dist[100001][2];
void dfs(ll x, ll i)
{
	b[x] = 1;
	for(auto u: v[x])
	{
		if(!b[u])
		{
			dist[u][i] = dist[x][i] + 1;
			dfs(u, i);
		}
	}
	return;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, u1, v1, i, x, y, ans = 0;
    cin>>n>>u1>>v1;
    for(i=0; i<n-1; i++)
    {
    	cin>>x>>y;
    	v[x].pb(y);
    	v[y].pb(x);
    }
    dist[u1][0] = dist[v1][1] = 0;
    dfs(u1, 0);
    for(i=1; i<=n; i++)
    	b[i] = 0;
    dfs(v1, 1);
    for(i=1; i<=n; i++)
    {
    	if(dist[i][0] < dist[i][1])
    	{
    		ans = max(ans, dist[i][1] - 1);
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12160
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
    n: usize, w: usize,
    items: [(usize, i64); n]
  };

  let mut dp = vec![vec![-1; w+1]; n+1];

  dp[0][0] = 0;
  for i in 0..n {
    for j in 0..w+1 {
      let base = dp[i][j];
      if base == -1 {
        continue
      }

      dp[i+1][j] = max(dp[i+1][j], base);
      let tj = j+items[i].0;
      if tj <= w {
        dp[i+1][tj] = max(dp[i+1][tj], base+items[i].1);
      }
    }
  }

  let best = dp[n].iter().max().unwrap();
  println!("{}", best);
}

Measured memory_bytes: 106748
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b == c || a + c == b || b + c == a){
    cout << "Yes\n";
  }
  else
  {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

s = S()

temp = 0
ans = 0

for char in s:
    if char in 'ACGT':
        temp += 1
    else:
        temp = 0
    ans = max(ans,temp)
print(ans)

Measured memory_bytes: 9084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<int>> G(N);
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    auto NO=[]() {
        cout << "NO" << ln;
        exit(0);
    };

    auto dfs=[&](auto self, int v, int pv)->ll {
        ll S = 0;
        ll MIN = -1;
        for (auto nv:G[v]) {
            if (nv==pv) continue;
            ll val = self(self,nv,v);
            S += val;
            chmax(MIN,val);
        }
        if (MIN==-1) return A[v];
        chmax(MIN,(S+1)/2);
        if (v) {
            if (A[v] < MIN or A[v] > S) NO();
            return A[v] - (S-A[v]);
        } else {
            if (G[v].size()==1) {
                if (S != A[v]) NO();
                return 1;
            } else {
                if (S&1 or S/2 != A[v]) NO();
                return 1;
            }
        }

    };

    dfs(dfs,0,-1);
    cout << "YES" << ln;
}

Measured memory_bytes: 12928
import copy

while True:
    n = input()
    if n == 0: break
    L = []
    for i in range(n):
        f, w, s = raw_input().split()
        L.append([f, int(w), int(s)])
    else:
        L = sorted(L, key=lambda x: x[1], reverse=True)
    
    ans = []
    while len(L) != 1:
        for i in range(len(L)):
            _L = copy.deepcopy(L)
            f = _L[i][0]
            s = _L[i][2]
            del _L[i]
            t = sum([_L[o][1] for o in range(len(_L))])
            if t <= s:
                ans.append(f)
                del L[i]
                break
    else:
        ans.append(L[0][0])
        for f in ans:
            print f

Measured memory_bytes: 4280
s = input()
left = int(s[:2])
right = int(s[2:])
left_y = False
left_m = False
right_y = False
right_m = False
if 1 <= left <= 12:
    left_m = True
if 0 <= left:
    left_y = True
if 1 <= right <= 12:
    right_m = True
if 0 <= right:
    right_y = True

mmyy = False
yymm = False
if left_m and right_y:
    mmyy = True
if left_y and right_m:
    yymm = True
if mmyy and yymm:
    print("AMBIGUOUS")
elif mmyy and yymm == False:
    print("MMYY")
elif mmyy == False and yymm:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	if (n%k == 0) cout << 0 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def count(k):
    return k // 4 - k // 100 + k // 400
def solve(i):
    a, b = map(int, readline().split())
    if a == b == 0:
        return False
    if i:
        write("\n")
    ans = []
    for k in range((a+3)//4*4, b+1, 4):
        if k % 100 > 0 or k % 400 == 0:
            ans.append(k)
    if ans:
        for k in ans:
            write("%d\n" % k)
    else:
        write("NA\n")
    return True
i = 0
while solve(i):
    i += 1



Measured memory_bytes: 5720
import sys

# sys.stdin = open('c1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


n = read_int()
a0 = read_int_list()
res = 10 ** 20
for first in [-1, 1]:
    a = list(a0)
    sign = first
    r = 0
    s = 0
    for i in range(n):
        if (s + a[i]) * sign <= 0:
            if sign < 0:
                dif = s + a[i] + 1
                a[i] -= dif
                r += dif
            if sign > 0:
                dif = -(s + a[i]) + 1
                a[i] += dif
                r += dif
        sign *= -1
        s += a[i]
    if res > r:
        res = r
print(res)


Measured memory_bytes: 14468
import Control.Applicative
main = do
  s <- map read . words <$> getLine
  op <- getLine
  putStrLn . show . head $ trans op s
  
trans :: [Char] -> [Int] -> [Int]
trans [] x = x
trans (x:xs) d = case x of
  'E' -> trans xs (opE d)
  'W' -> trans xs (opW d)
  'N' -> trans xs (opN d)
  'S' -> trans xs (opS d)
  
opE :: [Int] -> [Int]
opE [x1,x2,x3,x4,x5,x6] = [x4,x2,x1,x6,x5,x3]

opW :: [Int] -> [Int]
opW [x1,x2,x3,x4,x5,x6] = [x3,x2,x6,x1,x5,x4]

opN :: [Int] -> [Int]
opN [x1,x2,x3,x4,x5,x6] = [x2,x6,x3,x4,x1,x5] 

opS :: [Int] -> [Int]
opS [x1,x2,x3,x4,x5,x6] = [x5,x1,x3,x4,x6,x2]

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

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


struct RangeTree{
    // xの各値がyのソート済み配列を持つ
    vector<vector<int>>seg;
    vector<int>x;
    int sz;
    RangeTree(vector<pair<int,int>> a){
        sz=1;
        while((int)a.size()>sz)sz<<=1;
        sort(begin(a),end(a));
        if(a.size())x.push_back(a[0].first);
        for(auto &p:a)if(x.back()!=p.first)x.push_back(p.first);
        while(x.size()<sz)x.push_back(INF);
        seg.resize(2*sz);
        int pos=0;
        for(auto &p:a){
            if(x[pos]!=p.first)pos++;
            seg[pos+sz].push_back(p.second);
        }
        for(int i=sz-1;i>0;i--){
            seg[i].resize(seg[2*i].size()+seg[2*i+1].size());
            merge(begin(seg[2*i]),end(seg[2*i]),begin(seg[2*i+1]),end(seg[2*i+1]),begin(seg[i]));
        }
    }
    // [x1,x2),[y1,y2)
    int count(int x1,int y1,int x2,int y2){
        int l=lower_bound(begin(x),end(x),x1)-begin(x),r=lower_bound(begin(x),end(x),x2)-begin(x);
        l+=sz,r+=sz;
        int ret=0;
        for(;l<r;l>>=1,r>>=1){
            if(l&1){
                ret+=lower_bound(begin(seg[l]),end(seg[l]),y2)-lower_bound(begin(seg[l]),end(seg[l]),y1);
                l++;
            }
            if(r&1){
                r--;
                ret+=lower_bound(begin(seg[r]),end(seg[r]),y2)-lower_bound(begin(seg[r]),end(seg[r]),y1);
            }
        }
        return ret;
    }
};

int c[500010];
map<int,int> pre;

signed main(){

    int n,q;cin>>n>>q;
    rep(i,n) cin>>c[i];

    vector<pair<int,int>> d;
    rep(i,n){
        if(pre.count(c[i])) d.push_back({i,pre[c[i]]});
       pre[c[i]]=i;
    }

    RangeTree seg(d);

    while(q--){
        int l,r;
        cin>>l>>r;l--;

        int ans=r-l-seg.count(l,l,r,r);
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 102040
#include <iostream>
using namespace std;
int main(void){
    int n;
    int minv;
    long max;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    minv=0;
    max=-100000000000;
    for(int i=1;i<n;i++){
        if(A[i]-A[minv]>max)max=A[i]-A[minv];
        if(A[minv]>A[i])minv=i;
    }
    cout<<max<<endl;
    return 0;
}



Measured memory_bytes: 3876
#include <iostream>
using namespace std;
 
typedef long long ll;
 
int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  n%=10;
  m%=4;
 
  int a=n,d[4];
  for(int i=0; i<4; i++){
    d[i]=a;
    a=a*n%10;
  }
 
  ll ans=0;
  for(int i=0; i<4; i++) {
    ans+=k/4*d[m*i%4];
    if(i<k%4) ans+=d[m*i%4];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
renew = [0] * n
b = 0
for i, h in enumerate(t):
	if b < h:
		if h > a[i]:
			print(0)
			exit()
		renew[i] = 1
		b = h
b = 0
for i, h in enumerate(a[::-1]):
	if b < h:
		if h > t[n - i - 1]:
			print(0)
			exit()
		renew[n - i - 1] = 1
		b = h
ans = 1
for f, th, ah in zip(renew, t, a):
	if not f:
		ans *= min(th, ah)
		ans %= mod
print(ans)

Measured memory_bytes: 19136
N = int(input())
A = list(map(int, input().split()))
temp = 1
B = []
for i in range(len(A)):
  if A[i] == temp:
    B.append(temp)
    temp += 1
if len(B) == 0:
  print(-1)
else:
  print(len(A) - len(B))


Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin>>str;
  int sum=0;
  for(auto x:str){
    sum+=x-'0';
    sum=sum%9;
  }
  if(sum%9)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
    int s;
    cin >> s;
    map<int, int> a;
    int count = 0;
    while(true){
        count++;
        if(a[s] != 0){
            break;
        }
        a[s] = 1;
        if(s % 2 == 0){
            s /= 2;
        }else{
            s = 3 * s + 1;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"

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

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

signed main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];
    const int DIGIT_NUM = 61;
    vector<ll> oneCountPerDigit(DIGIT_NUM);
    REP(i,0,N) {
        REP(d,0,DIGIT_NUM) {
            if ((1LL << d) & A[i]) oneCountPerDigit[d]++;
        }
    }
    ll answer = 0;
    ll multiplier = 1;
    REP(d,0,DIGIT_NUM) {
        ll add = oneCountPerDigit[d] * (N - oneCountPerDigit[d]);
        add %= MOD;
        add *= multiplier;
        add %= MOD;
        answer += add;
        answer %= MOD;
        multiplier *= 2;
        multiplier %= MOD;
    }
    cout << answer << "\n";

    return 0;
}



Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int p = a + b;
        int m = a - b;
        int k = a * b;
        if(p < m){
            p = m;
        }
        if(p < k){
            p = k;
        }
        System.out.println(p);
        sc.close();
    }
}

Measured memory_bytes: 20948
// Aizu 1135: Ohgas' Fortune
// 2017.9.13 bal4u@uu

#include <stdio.h>

int main()
{
	int m, i, j, a0, a, b, c, y, n, k, f, ans;
	double r;

	scanf("%d", &m);
	while (m-- > 0) {
		scanf("%d%d%d", &a0, &y, &n);
		for (ans = 0, i = 0; i < n; i++) {
			scanf("%d%lf%d", &k, &r, &f);
			if (k) {
				for (a = a0, j = 0; j < y; j++) b = (int)(a * r), a += b - f;
				if (a > ans) ans = a;
			} else {
				for (c = 0, a = a0, j = 0; j < y; j++) b = (int)(a * r), a -= f, c += b;
				a += c;	if (a > ans) ans = a;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
	int num = (x == w / 2 && y == h / 2) ? 1 : 0;
    double ans;
	ans = (double)w * h / 2.0;
	printf("%.10f %d\n", ans, num);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    const int MOD = 1e9+7;
    int n;
    cin >> n;
    // current_power *= i;の結果が32bit整数に収まらないので64bit整数を使う
    long long current_power = 1;
    for (int i = 1; i <= n; i++) {
        current_power *= i;
        current_power %= MOD;
    }
    cout<<current_power<<endl;
    return 0;
}


Measured memory_bytes: 256
def lcs(str1, str2):
    lcslist = []
    for s in str2:
        m = n = 0
        for index in lcslist:
            t = str1.find(s, m) + 1
            if t <= 0:
                break
            elif t < index:
                lcslist[n] = t
            m = index
            n += 1
        else:
            t = str1.find(s, m) + 1
            if t > 0:
                lcslist.append(t)
    return len(lcslist)

if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        str1 = input()
        str2 = input()
        print(lcs(str1, str2))


Measured memory_bytes: 5616
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(void){
    int i,n,x;
    
    scanf("%d",&n);
    for(i = 3;i <= n;i++){
        if(i % 3 == 0)
            printf(" %d",i);
        else{
            x = i;
            while(x){
                if(x % 10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
    
    return 0;
}






Measured memory_bytes: 3196
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char** argv) {

        int s;
        vector<int> a;
        int n=1;
        int ans;

        cin >> s;
        a.push_back(s);
        while(1){
                if(s%2 == 0){
                        s=s/2;
                }else{
                        s=3*s+1;
                }

                auto j = find(a.begin(), a.end(), s);
//                printf("j: %d\n", *j);
                if(j != a.end()){
                                ans = n+1;
                                break;
                }
                a.push_back(s);
                n++;
        }
        cout << ans << endl;
        return 0;

}

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

int main () {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v.at(i);
    }
    for(int i = v.size(); i > 0; i--) {
        if(i != v.size()) cout << " ";
        cout << v[i - 1];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] lst= new int[n+1];
		for(int i=0;i<n;i++){
		    lst[i]=sc.nextInt();lst[i+1]=sc.nextInt();
		}
		sc.close();
		
		int[][] table = new int[n+1][n+1];
		for(int i=1;i<=n;i++)table[i][i]=0;
		
		for(int l=2;l<=n;l++) {
			for(int i=1;i<=n-l+1;i++) { //gain table[j][i+j]
				int min = Integer.MAX_VALUE;
				int j=i+l-1;
				for(int k=i;k<=j-1;k++){
				    int x = table[i][k] + table[k+1][j] + lst[i-1]*lst[k]*lst[j];
				    min = Math.min(min,x);
				}
				table[i][j]=min;
			}
			
		}
		System.out.println(table[1][n]);
	}
}


Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define TOP 0
#define FRONT 1
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
int dice[6]={1,2,4,3,5,6};

void rotN(){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);
}

void rotS(){rotN(),rotN(),rotN();}


void rotE(){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

void rotW(){rotE(),rotE(),rotE();}


void rotCW(){
  swap(dice[FRONT],dice[RIGHT]);
  swap(dice[RIGHT],dice[BACK]);
  swap(dice[BACK],dice[LEFT]);
}

void rotCCW(){rotCW(),rotCW(),rotCW();}


int main(){
  cin>>dice[TOP]>>dice[FRONT]>>dice[RIGHT];
  cin>>dice[LEFT]>>dice[BACK]>>dice[BOTTOM];

  int q;
  cin>>q;
  while(q--){
    int top, front;
    cin>>top>>front;
    for(int i=0;i<3&&dice[TOP]!=top;i++) rotN();
    for(int i=0;i<3&&dice[TOP]!=top;i++) rotE();
    while(dice[FRONT]!=front) rotCW();
    cout << dice[RIGHT]<<endl;
  }
  
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
# define pb push_back
typedef long long ll;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<tuple<ll,ll,ll>> d;
    rep(i,m){
        ll p,y;
        cin >> p >> y;
        d.pb(make_tuple(p,y,i));
    }
    sort(d.begin(),d.end());
    vector<tuple<ll,ll>> a(m);
    ll tmp = 0;
    ll count = 1;
    rep(j,m){
        ll p = get<0>(d[j]);
        ll y = get<1>(d[j]);
        ll i = get<2>(d[j]);
        if(tmp != p){
            count = 1;
            tmp = p;
        }
        else{
            count ++;
        }
        a[i]=make_tuple(p,count);
    }
    rep(i,m){
        ll p = get<0>(a[i]);
        ll q = get<1>(a[i]);
        cout << setw(6) << setfill('0') << p  << setw(6) << setfill('0')<< q << endl;
    }
}

Measured memory_bytes: 6256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    char[] chars = s.ToCharArray();

    int n = chars.Length-2;
    string t = n.ToString();

    Console.WriteLine(chars[0] + t + chars[chars.Length-1]);

  }
}

Measured memory_bytes: 11092
#include <cstdio>
#define ll long long
#define MAXN 200005
int a[MAXN];
int main() {
	int n, t;
	ll sum = 0;
	scanf("%d%d", &n, &t);
	scanf("%d", &a[1]);
	for(int i = 2; i <= n; i++) {
		scanf("%d", &a[i]);
		if(a[i] - a[i-1] >= t)	
			sum += t;
		else 
			sum += a[i] - a[i-1];
	}
	sum += t;
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 896