akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,total,h,a,b,x,y;
    	cin>>a>>b;
    	x=0; y=0;
    	rep(i,0,b)
    	x=x*10+a;
    	rep(i,0,a)
    	y=y*10+b;
    	if(x>=y)
    	cout<<x;
    	else
    	cout<<y;
    } 
	return 0;
}

Measured memory_bytes: 256
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;

int main()
{
	int D,T,S;
	read(D,T,S);
	printf(T*S>=D?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int d1 = sc.nextInt();
		int d2 = sc.nextInt();
		int d3 = sc.nextInt();
		int d4 = sc.nextInt();
		int d5 = sc.nextInt();
		int d6 = sc.nextInt();
		int num = sc.nextInt();
		
		int ary1[] = {d1, d2, d6, d5, d1};
		int ary2[] = {d1, d3, d6, d4, d1};
		int ary3[] = {d2, d3, d5, d4, d2};
		
		int rd1 = 0;
		int rd2 = 0;
		for(int i=0; i<num; i++){
			rd1 = sc.nextInt();
			System.out.print("");
			rd2 = sc.nextInt();
			int ans = 0;
			for(int j=0; j<4; j++){
				if(rd1==ary1[j]&&rd2==ary1[j+1]){
					ans = d3;
				}else if(rd2==ary1[j]&&rd1==ary1[j+1]){
					ans = d4;
				}else if(rd1==ary2[j]&&rd2==ary2[j+1]){
					ans = d5;
				}else if(rd2==ary2[j]&&rd1==ary2[j+1]){
					ans = d2;
				}else if(rd1==ary3[j]&&rd2==ary3[j+1]){
					ans = d1;
				}else if(rd2==ary3[j]&&rd1==ary3[j+1]){
					ans = d6;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ld poww(ld a, ld b, ll n){
    ld ret = 1, d = abs(a - b);
    while(n--){
        ret *= d;
    }
    return ret;
}
int main() {
    init();
    ll N;
    cin >> N;
    vc<ld> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    ld r1 = 0, r2 = 0, r3 = 0, rinf = 0;
    rep(i,N){
        r1 += poww(A[i], B[i], 1);
        r2 += poww(A[i], B[i], 2);
        r3 += poww(A[i], B[i], 3);
        chmax(rinf, abs(A[i] - B[i]));
    }
    r2 = sqrtl(r2);
    r3 = cbrtl(r3);

    cout << r1 << endl
         << r2 << endl
         << r3 << endl
         << rinf << endl;
}


Measured memory_bytes: 3420
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

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

int main() {
  for (int n; cin >> n, n; ) {
      int A = 0, B = 0;
      REP(i, n) {
          int a, b; cin >> a >> b;
          if (a > b) A += a + b;
          else if (a < b) B += a + b;
          else {
              A += a;
              B += b;
          }
      }
      cout << A << " " << B << endl;
  }
  return 0;
}

Measured memory_bytes: 0
S=int(input())
MOD=10**9+7

MAX = 10**5

def COMinit():
    """
    逆元テーブルをつくる前処理
    計算量はO(n)
    1 <= k <= n <= 1e7程度
    p: 素数
    """
    fac = [0]*MAX
    finv = [0]*MAX
    inv = [0]*MAX

    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[0], inv[1] = 1, 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
    return fac, finv, inv

fac, finv, inv = COMinit()

def comb(n, k):
    """
    nCk mod MODを求める.
    この部分はO(1)
    """
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return int(fac[n] * (finv[k] * finv[n-k] % MOD) % MOD)
ans = 0
for n in range(1000):
    tmp = S-3*n
    if tmp < 0:
        break
    ans += comb(tmp+n-1, n-1)
    ans %= MOD
print(ans%MOD)

Measured memory_bytes: 66900
#include<stdio.h>
#include<stdlib.h>

void sort(int[],int);
void tra(int[],int);
int main()
{
    int N,A[100],i;
    scanf("%d",&N);
        
    for(i=0; i<N; i++)        scanf("%d",&A[i]);
    
    tra(A,N);
    sort(A,N);
    
    return 0;
}   

void sort(int A[],int N)
{
    int i,j,v;
    for(i=1; i<N; i++)
    {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v)
        {
            A[j+1]=A[j];
            j--;
        }  
        A[j+1]=v;
        tra(A,N);
    }
}

void tra(int A[],int N)
{
    int i;
    for(i=0; i<N; i++)
    {
      
       if(i>0)  printf(" ");
      
       printf("%d",A[i]);
    }
    printf("\n");
}



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

int main(){
    string s;
    cin >> s;
    int flag = 0;

    if(s.length()== 1){
        if(s[0] == 'L') cout << "No" << endl;
        else cout << "Yes" << endl;
    return 0;
    }

    for(int i = 0; i < s.length()-1;i++){
        if(i % 2 == 1){
            if(s[i] == 'L' || s[i] == 'U' ||s[i] == 'D') continue;
            else{
                // cout << s[i] << endl;
                cout << "No" << endl;
                flag = 1;
                break;
            } 
        }
        if(i % 2 == 0) {
            if(s[i] == 'R' || s[i] == 'U' ||s[i] == 'D') continue;
            else{
                cout << "No" << endl;
                flag = 1;
                break;
            } 

        }
    }
    if(flag == 1) return 0;

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000009];
int dp[1000009];
int f(int x)
{
    if(x>=(n*3)-2)
        return 0;
      {
          if(dp[x]!=-1)
            return dp[x];
      }
    int y=10000009;

    {if(x%3==1)
    {
        y=max(f(x+4)+a[x+4],f(x+5)+a[x+5]);
    }
    else if(x%3==2)
    {
        y=max(f(x+2)+a[x+2],f(x+4)+a[x+4]);
    }
    else if(x%3==0)
    {
        y=max(f(x+2)+a[x+2],f(x+1)+a[x+1]);
    }
    dp[x]=y;
    return y;}

}
int main()
{memset(dp,-1,sizeof dp);
    cin>>n;
for(int i=1;i<=3*n;i++)
{
    cin>>a[i];

}

    cout<<max(max(f(1)+a[1],f(2)+a[2]),f(3)+a[3]);
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    comb_init();

    ll ans = 0;
    REP(i,H-A){
        ans += (comb(B-1+i,B-1)*comb(W-1-B+H-1-i,W-1-B));
        ans %= MOD;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 12160
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<random>
using namespace std;

class Dice{
  public:
    vector<int> n;
    int top;
    Dice(){
      n.resize(6);
      top = 0;
    }
    void roll(char c){
      int tmp = n[0];
      if( c == 'E' ){
        n[0] = n[3];
        n[3] = n[5];
        n[5] = n[2];
        n[2] = tmp;
      }else if( c == 'W' ){
        n[0] = n[2];
        n[2] = n[5];
        n[5] = n[3];
        n[3] = tmp;
      }else if( c == 'N' ){
        n[0] = n[1];
        n[1] = n[5];
        n[5] = n[4];
        n[4] = tmp;
      }else if( c == 'S' ){
        n[0] = n[4];
        n[4] = n[5];
        n[5] = n[1];
        n[1] = tmp;
      }else if( c == 'R' ){
        tmp = n[4];
        n[4] = n[3];
        n[3] = n[1];
        n[1] = n[2];
        n[2] = tmp;
      }else if( c == 'L' ){
        tmp = n[4];
        n[4] = n[2];
        n[2] = n[1];
        n[1] = n[3];
        n[3] = tmp;
      }

    }
    void input(){
      for(int i=0; i<6; i++) cin >> n[i];
    }

    void output_top(){
      cout << n[top] << endl;
    }
};

bool diff_check(Dice d, Dice d2){
  random_device rnd;
  string con = "NSEW";

  int cnt = 0;
  while(true){
    if( cnt >= 1000 ) break;
    d2.roll( con[rnd()%4] );
    if( d.n[0] == d2.n[0] ){
      if( d.n[5] != d2.n[5] ) break;

      for(int i=0; i<4; i++){
        d2.roll('R');
        bool f = true;
        for(int i=1; i<5; i++){
          if( d.n[i] != d2.n[i] ) f = false;
        }
        if( f ){
          return true;;
        }
      }

      break;
    }
    cnt++;
  }
  return false;
}

int main(){
  random_device rnd;
  string con = "NSEW";

  Dice d;
  d.input();

  int q;
  cin >> q;
  for(int i=0; i<q; i++){
    int a, b;
    cin >> a >> b;

    int cnt = 0;
    while(true){
      if( cnt >= 1000 ) break;
      d.roll( con[rnd()%4] );
      if( d.n[0] == a ){
        for(int i=0; i<4; i++){
          d.roll('R');
          if( d.n[1] == b ){
            cout << d.n[2] << endl;
          }
        }

        break;
      }
      cnt++;
    }

  }

  // d.output_top();

  return 0;
}





// EOF

Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<functional>
#include<iomanip>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) > abs(x - b)) {
	cout << "B" << endl;
  }
  else {
	cout << "A" << endl;
  }

}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var n=int.Parse(Console.ReadLine());
        int[,,] data = new int[4,3,10];   
        for (var i = 1; i <= n; i++)
        {
            var line = Console.ReadLine().Split(' ');
            int b = int.Parse(line[0]);
            int f = int.Parse(line[1]);
            int r = int.Parse(line[2]);
            int v = int.Parse(line[3]);

            data[b-1, f-1, r-1] += v;
        }

        for(var i=0; i<data.GetLength(0); i++)
        {
            if (i != 0)Console.WriteLine("####################");

            for (var j = 0; j < data.GetLength(1); j++)
            {
                for(var k=0; k < data.GetLength(2); k++)
                {
                    Console.Write(" " + data[i, j, k]);
                    if (k == data.GetLength(2) - 1) Console.WriteLine();
                }
            }
        }
    }

}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int R,G;
    cin >> R >> G;
    int ans = 2*G - R;
    cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    n = int(input())
    a = list(map(int, input().split()))

    lcm_a = 1
    for i in range(n):
        lcm_a = lcm(lcm_a, a[i])

    ans = 0
    for i in range(n):
        ans += (lcm_a-1) % a[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<cstdlib>
using namespace std;
typedef pair<int,const char*>parsed;
parsed expr(const char *p);
parsed term(const char *p);
parsed fact(const char *p);
parsed expr(const char *p){
  parsed r=term(p);
 while(*r.second=='+'||*r.second=='-'){
    char op =*r.second;
    int tmp=r.first;
    r=term(r.second+1);
    if(op=='+')r.first=tmp+r.first;
    else r.first=tmp-r.first;
  }
  return r;
}
parsed term(const char *p){
  parsed r=fact(p);
  while(*r.second=='*'||*r.second=='/'){
    char op=*r.second;
    int tmp=r.first;
    r=fact(r.second+1);
    if(op=='*')r.first=tmp*r.first;
    else r.first=tmp/r.first;
  }
  return r;
}
parsed fact(const char *p){
  if(isdigit(*p)){
    int t=*(p++)-'0';
    while(isdigit(*p))t=t*10+*(p++)-'0';
    return parsed(t,p);
  }
  else if(*p=='('){
    parsed r=expr(p+1);
    if(*r.second!=')')exit(0);
    return parsed(r.first,r.second+1);
  }
  else exit(0);
}
main(){
  string str;
  int n;
  cin>>n;
  while(n--){
	  cin>>str;
    cout<<expr(str.c_str()).first<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <iostream>

struct node {
    int len;
    atcoder::modint998244353 x;
};

struct func {
    atcoder::modint998244353 a, b;
};

node ope(node a, node b) {
    return node{a.len + b.len, a.x + b.x};
}

node node_e() {
    return node{0, atcoder::modint998244353::raw(0)};
}

node mappi(func f, node x) {
    return node{x.len, f.a * x.x + f.b * x.len};
}

func compo(func f, func g) {
    return func{f.a * g.a, g.b * f.a + f.b};
}

func func_e() {
    return func{atcoder::modint998244353::raw(1), atcoder::modint998244353::raw(0)};
}


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n, q;
    std::cin >> n >> q;
    std::vector<node> a(n, node{1, atcoder::modint998244353::raw(0)});
    for (int i = 0; i < n; ++i) {
        int num;
        std::cin >> num;
        a[i].x = atcoder::modint998244353::raw(num);
    }
    
    atcoder::lazy_segtree<node, ope, node_e, func, mappi, compo, func_e> st(a);
    
    for (int i = 0; i < q; ++i) {
        int type;
        std::cin >> type;
        if (type == 0) {
            int l, r, b, c;
            std::cin >> l >> r >> b >> c;
            st.apply(l, r, func{atcoder::modint998244353::raw(b), atcoder::modint998244353::raw(c)});
        } else {
            int l, r;
            std::cin >> l >> r;
            std::cout << st.prod(l, r).x.val() << "\n";
        }
    }
    
    return 0;
}



Measured memory_bytes: 19496
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import heapq

def main():
    mod=10**9+7
    N=I()
    a=LI()
    q1=a[:N]
    s1=[0]*(N+1)#境界を決めたときの，a'前半部分の最大値
    s1[0]=sum(q1)
    heapq.heapify(q1)
        
    q2=[]
    heapq.heapify(q2)
    s2=[0]*(N+1)
    for i in range(N):
        b=a[-1-i]*(-1)
        s2[0]+=b
        heapq.heappush(q2,b)
    
    
    for i in range(N):
        bb=a[i+N]
        heapq.heappush(q1,bb)
        b=heapq.heappop(q1)
        s1[i+1]=s1[i]+bb-b
        
        cc=a[-1-N-i]*(-1)
        heapq.heappush(q2,cc)
        c=heapq.heappop(q2)
        s2[i+1]=s2[i]+cc-c
        
    L=[0]*(N+1)
    ans=-1*10**16
    for i in range(N+1):
        temp=s1[i]+s2[-1-i]
        if ans<temp:
            ans=temp
    print(ans)
        
        
    

main()


Measured memory_bytes: 127248
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a<b)swap(a,b);
    if(a<c)swap(a,c);
    cout<<a*pow(2,k)+b+c;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;



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

    rep(i, S.size()){
        cout << (char)((S[i] - 'A' + N) % 26 + 'A');
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

string S;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;
    if (S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 200005
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}

ull a[maxn];
const ll maxx=1e18;
bool flow(ull a, ull b) {
    if (ULLONG_MAX/a<b) {
        return true;
    }
    ull ans = a*b;
    if (ans>maxx) {
        return true;
    }
    return false;
}
 
main() {
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>a[i];
        if (a[i]==0) {
            printf("0\n");
            return 0;
        }
    }
    ll ans=1;
    for (int i=0;i<n;i++) {
        if (flow(ans,a[i])) {
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;


}
 

Measured memory_bytes: 4404
import math
from decimal import *

a,b,h,m=map(int,input().split())

a_kakudo=30*h+30*(m/60)
b_kakudo=6*m

kakudo=abs(a_kakudo-b_kakudo)

if kakudo==0:
  print(abs(a-b))
  exit()

x=a**2 + b**2 -2*a*b*(math.cos(math.radians(kakudo)))
print(x**0.5)

Measured memory_bytes: 10248
package dsu;
sub new{
	return bless[(-1)x$_[1]],$_[0];
}
sub merge{
	my$self=shift;
	my$x=$self->leader($_[0]);
	my$y=$self->leader($_[1]);
	return$x if$x==$y;
	($x,$y)=($y,$x)if-$self->[$x]<-$self->[$y];
	$self->[$x]+=$self->[$y];
	return$self->[$y]=$x;
}
sub same{
	my$self=shift;
	return$self->leader($_[0])==$self->leader($_[1]);
}
sub leader{
	my$self=shift;
	my$a=shift;
	return$a if$self->[$a]<0;
	return$self->[$a]=$self->leader($self->[$a]);
}
sub size{
	return-$_[0]->[$_[1]];
}
sub groups{
	#TODO
}
package main;
my($N,$Q)=split$",<>;
my$dsu=dsu->new($N);
for(1..$Q){
	my($t,$u,$v)=split$",<>;
	if($t==0){
		$dsu->merge($u,$v);
	}
	else{
		print $dsu->same($u,$v)?1:0,$/;
	}
}


Measured memory_bytes: 15004
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	string s, t;
	cin >> s >> t;
	int count = 0;
	rep(i, s.size()) {
		if(s[i] == t[i]) count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int i,n,a,b,c;

    cin >> n;

    for(i = 0;i < n;i++){
        cin >> a >> b >> c;

        if(a == double(sqrt(pow(b,2) + pow(c,2)))){
            cout << "YES" << endl;
        }

        else if(b == double(sqrt(pow(a,2) + pow(c,2)))){
            cout << "YES" << endl;
        }

        else if(c == double(sqrt(pow(a,2) + pow(b,2)))){
            cout << "YES" << endl;
        }

        else{
            cout << "NO" << endl;
        }
    }

    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}
template<std::int_fast64_t divisor> struct modint {
  using i64 = std::int_fast64_t;

  i64 val;

  constexpr modint(i64 v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }

  constexpr modint operator + (const modint& rhs) const noexcept {
    return modint(*this) += rhs;
  }

  constexpr modint operator - (const modint& rhs) const noexcept {
    return modint(*this) -= rhs;
  }

  constexpr modint operator * (const modint& rhs) const noexcept {
    return modint(*this) *= rhs;
  }

  constexpr modint operator / (const modint& rhs) const noexcept {
    return modint(*this) /= rhs;
  }

  constexpr modint operator ~ () const noexcept {
    i64 a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      i64 t = a / b;
      a -= t * b;
      u -= t * v;
      i64 c = a; a = b; b = c;
      i64 w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }

  constexpr modint& operator += (const modint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }

  constexpr modint& operator -= (const modint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }

  constexpr modint& operator *= (const modint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }

  constexpr modint& operator /= (const modint& rhs) noexcept {
    val = val * (~(modint(rhs))).val % divisor;
    return *this;
  }
};

namespace solver {
  using namespace std;
  using ll = long long;
  using mint = modint<I_1000000007>;

  int N, A, B;

  void init() {
    cin >> N >> A >> B;
  }

  mint modpow(mint n, int m) {
    mint ans = 1, b = n;
    while(m > 0) {
      if(m&1) ans *= b;
      b *= b;
      m >>= 1;
    }
    return ans;
  }

  void solve() {
    mint ans = modpow(2, N) - 1;
    mint d = 1;
    REPC(i, 1, max(A, B)) {
      d *= N-i+1;
      d /= i;
      if(i == A || i == B) ans -= d;
    }
    cout << ans.val << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,a[200010];
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < k;i++){
		int imos[200010] = {};
		bool allN = true;
		for(int j = 0;j < n;j++){
			if(a[j] != n) allN = false;
			imos[max(0ll,j - a[j])]++;
			if(j + a[j] + 1 <= n) imos[j + a[j] + 1]--;
		}
		if(allN) break;
		for(int j = 0;j < n;j++){
			imos[j + 1] += imos[j];
			a[j] = imos[j];
		}
	}
	for(int i = 0;i < n;i++) printf("%lld%c",a[i]," \n"[i == n - 1]);
}

Measured memory_bytes: 6800
//a quadrangle a by b,

#include<stdio.h>
int area(int,int);
int langth(int,int);

int main()
{
	int a,b;

	scanf("%d %d",&a,&b); 

	printf("%d %d\n",area(a,b),langth(a,b));

	return 0;
}

int area(int a,int b)
{
	int s;
	s=a*b;
	return s;
}

int langth(int a,int b)
{
	int d;
	d=a*2+b*2;
	return d;
}

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

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class T> ostream& operator<<(ostream &os, set<T> S){os << "{ "; for(auto s:S) os<<s<<" "; return os<<"}";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}";}

#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "<<arg1<<endl;}
template<typename Arg1, typename ... Args>void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,','); cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
	
	char c ; cin >> c ;
	if(c=='A') cout << 'T';
	if(c=='C') cout << 'G';
	if(c=='G') cout << 'C';
	if(c=='T') cout << 'A';
    
    

#ifdef np
    cerr <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
 return 0; 
 }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] f = new int[n + 1];
    for (int x = 1; x <= 100; x++) {
      if (x * x > n) break;
      for (int y = 1; y <= 100; y++) {
        if (y * y > n) break;
        if (x * y > n) break;
        for (int z = 1; z <= 100; z++) {
          int val = x * x + y * y + z * z + x * y + y * z + z * x;
          if (val <= n) f[val]++;
        }
      }
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= n; i++) {
      if (sb.length() > 0) sb.append("\n");
      sb.append(f[i]);
    }
    System.out.println(sb.toString());
  }
}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll tc=1;
   // cin>>tc;
    while(tc--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll ans = max({ a*c , a*d , b*c , b*d });
        cout<<ans;
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int K, N, a0, a1, a2, maxnum;
    std::cin >> K >> N;
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            std::cin >> a1 >> a2;
            a0 = a1;
            maxnum = a2 - a1;
        }
        else if (i == N - 1)//はじめと最後の距離を測る
        {
            maxnum = std::max(K - (a2 - a0), maxnum);
        }
        else
        {
            a1 = a2;
            std::cin >> a2;
            maxnum = std::max(a2 - a1, maxnum);
        }
    }
    std::cout << K - maxnum << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int z=0;z<n;z++){cin>>Array[z];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int N, D;
	cin >> N >> D;

	Graph dis(N, vector<int>(D));

	rep(i, N)
		repin(dis[i], D);

	int ans = 0;
	rep(i, N)
		for (int j = i + 1; j < N; j++) {
			int now = 0;
			rep(k, D)
				now += pow(abs(dis[i][k] - dis[j][k]), 2.0);

			for (int k = 1; k * k <= now; k++)
				if (k * k == now)
					ans++;
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int ans[4] = {0,0};
	cin >> s;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'N') {
			ans[0]=1;
		}
		else if (s[i] == 'S') {
			ans[1]=1;
		}
		else if (s[i] == 'W') {
			ans[2]=1;
		}
		else if (s[i] == 'E') {
			ans[3]=1;
		}

	}
	if (ans[0] == ans[1] && ans[2] == ans[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static final FS sc = new FS();
    static final PrintWriter out = new PrintWriter(System.out);
    static final int mod = 1000000007;

    public static void main(String[] args) {
        solve();
        out.close();
    }

    static void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int area1 = a * b;
        int area2 = c * d;
        out.println(area1 >= area2 ? area1 : area2);

    }
}


Measured memory_bytes: 32448
using System;
using System.Collections.Generic;
using System.Linq;


namespace CSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var strings = Console.ReadLine().Split(' ');
            var N = int.Parse(strings[0]);
            var M = int.Parse(strings[1]);
            var list = new List<Set>();
            for (int i = 0; i < N; i++)
            {
                strings = Console.ReadLine().Split(' ');
                list.Add(new Set {Yen = long.Parse(strings[0]), Count = long.Parse(strings[1])});
            }

            long money = 0;
            long drinkCount = 0;
            foreach (var val in list.OrderBy(val => val.Yen))
            {
                long count = Math.Min(M - drinkCount, val.Count);
                money += val.Yen * count;
                drinkCount += count;
                if (drinkCount >= M) break;
            }

            Console.WriteLine(money);
        }
    }

    class Set
    {
        public long Yen { get; set; }
        public long Count { get; set; }
    }
}

Measured memory_bytes: 26052
#include<stdio.h>
#include<string.h>
int main(void) {
	int i, count = 0;
	char S[100];
	scanf("%s", S);
	for (i = 0; i < strlen(S); i++) {
		if ((i + 1) % 2 == 0 && S[i] != 'R') count += 1;
		else if ((i + 1) % 2 == 1 && S[i] != 'L') count += 1;
	}
	if (count == strlen(S)) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <cstdint>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

struct Node {
  Node(int64_t u) : v(u) {}
  int64_t v;
  Node* next = nullptr;
};

vector<int64_t> MakeVec(unordered_map<int64_t, Node*>& nodes, int64_t st) {
  Node* st_adr = nodes[st];
  vector<int64_t> vec;
  vec.push_back(st_adr->v);
  Node* cur = st_adr->next;
  while (cur != nullptr && cur != st_adr) {
    vec.push_back(cur->v);
    cur = cur->next;
  }
  return vec;
}

int main() {
  int64_t N, X, M;
  cin >> N >> X >> M;

  unordered_map<int64_t, Node*> nodes;
  
  Node* pre = new Node(X);
  nodes[X] = pre;
  vector<int64_t> loop;
  int64_t sum = X;
  int64_t n = 1;
  for (; n < N; ++n) {
    int64_t cur = (pre->v * pre->v) % M;
    if (nodes.count(cur)) {
      loop = MakeVec(nodes, cur);
      break;
    }
    Node* cur_node = new Node(cur);
    pre->next = cur_node;
    pre = cur_node;
    nodes[cur] = cur_node;
    sum += cur;
  }
  if (n == N) {
    cout << sum << endl;
  } else {
    int64_t loop_sum = loop[0];
    vector<int64_t> sums(loop.size()+1, 0);
    sums[1] = loop[0];
    for (size_t i = 1, size = loop.size(); i < size; ++i) {
      sums[i+1] = sums[i] + loop[i];
      loop_sum += loop[i];
    }
    int64_t rest = N - n;
    cout << sum + loop_sum * (rest / loop.size()) + sums[rest % loop.size()] << endl;
  }
  
  for (auto& p : nodes) {
    delete p.second;
  }
  return 0;
}


Measured memory_bytes: 7656
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

  if(R < 1200){
    cout << "ABC" << endl;
  }else if(R < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;    
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] L = new int[N];
	  for(int i=0; i<N; i++)
		  L[i] = sc.nextInt();
	  int sum = 0;
	  
	  Arrays.sort(L);
	  
	 for(int i=N-1; i>1; i--) {
		 for(int j=0; j+1<i; j++ ) {
			 int index = meguruSearch(L,j,i);
			 int count = i-index;
			 sum += count;
		 }
	 }
	  	 
	  out.println(sum);
  	}
    //二分探索。左端、右端は毎回変わる
	static int meguruSearch( int[] list, int left, int right) {
		int Left = left;
		int Right = right;
		
		while (right - left > 1) {
			int mid = left + (right - left) / 2;
			if(lower_bound(mid, list, Left, Right)) right = mid; 
			else left = mid;
		}		
		return right;		
	}
	//条件判定
	static boolean lower_bound(int index, int[] list, int Left, int Right) {
		if( list[Left] + list[index] > list[Right]) return true;
		else return false;
	}
  }	

Measured memory_bytes: 26344
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next(), b = sc.next(), c = sc.next();
		char t = 'a';
		int ac = 0, bc = 0, cc = 0;		
		while(true){
			if(t == 'a'){
				if(ac == a.length()){
					System.out.println("A");
					break;
				}
				t = a.charAt(ac);
				ac++;
			}else if(t == 'b'){
				if(bc == b.length()){
					System.out.println("B");
					break;
				}
				t = b.charAt(bc);
				bc++;
			}else if(t == 'c'){
				if(cc == c.length()){
					System.out.println("C");
					break;
				}
				t = c.charAt(cc);
				cc++;
			}
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int t;
ll a,b,c,d;

ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}

bool solve(){
	if(b>d)return false;
	if(b-a>0LL)return false;
	if(c>=b)return true;
	if(a-b<0)return false;
	ll g=gcd(d-b,b);
	ll n=(a-b+g)/g;
	ll val=b-a+g*n;
	ll val2=c-a+g*n;
	//printf("%lld %lld %lld %lld\n",g,n,val,val2);
	if(val>0 && val2<0)return false;
	return true;
}

int main(void){
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		printf("%s\n",solve()?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
e = [[int(x) for x in input().split()] for _ in range(m)]

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

def find(x):
  return x if u[x] < 0 else find(u[x])

t = n*(n-1)// 2
s = [t]

for i in range(m-1,0,-1):
  a = find(e[i][0])
  b = find(e[i][1])
  if a > b:
    a, b = b, a
  if a != b:
    t -= u[a]*u[b]
    u[a] += u[b]
    u[b] = a
  s.append(t)

for i in reversed(s):
  print(i)


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

typedef long long ll;
ll N;

int main() {
  cin >> N;
  int ans = 100;
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i != 0) continue;
    string s1 = to_string(i);
    string s2 = to_string(N / i);
    ans = min(ans, max((int)s1.size(), (int)s2.size()));
  }
  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::Read;
fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut s = s.split_whitespace();
    let n: isize = s.next().unwrap().parse().ok().unwrap();
    let mut ip = vec![0; n as usize];
    for i in 0..n {
        let p: usize = s.next().unwrap().parse().ok().unwrap();
        ip[p - 1] = i;
    }
    let mut li: Vec<_> = (-1..n).collect();
    let mut ri: Vec<_> = (1..n + 1).collect();
    let mut a = 0;
    for pi in 0..n {
        let i = g(&ip, pi);
        let l = g(&li, i);
        let r = g(&ri, i);
        let l2 = if l == -1 { -1 } else { g(&li, l) };
        let r2 = if r == n { n } else { g(&ri, r) };
        a += (pi + 1) * ((l - l2) * (r - i) + (r2 - r) * (i - l));
        if l >= 0 {
            ri[l as usize] = r
        }
        if r < n {
            li[r as usize] = l
        }
    }
    println!("{}", a)
}
fn g(v: &[isize], i: isize) -> isize {
    v[i as usize]
}


Measured memory_bytes: 8444
#include <iostream>
#include <cmath>

void process() {
	int64_t H {};
	std::cin >> H;

	int64_t cnt {};
	for(int i = 0; i <= static_cast<int>(log2(H)); ++i)
		cnt += static_cast<uint64_t>(std::pow(2, i));

	std::cout << cnt << std::endl;
}

int main() {
	process();
}

Measured memory_bytes: 512