akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  string str = readString();

  if (str == "A") {
    cout << 'T' << endl;
  } else if (str == "T") {
    cout << 'A' << endl;
  } else if (str == "C") {
    cout << 'G' << endl;
  } else if (str == "G") {
    cout << 'C' << endl;
  }

  return 0;
}


Measured memory_bytes: 2304
s = input()
a = int(s[:2])
b = int(s[2:])

if 1 <= a and a <= 12 and 1<= b and b <=12:
    print("AMBIGUOUS")
elif 1 <= a <=12 and (12 < b or b < 1):
    print("MMYY")
elif (12 < a or a < 1) and 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9128
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int ans = inpt[0] - inpt[1] + 1;
        Console.WriteLine(ans);

    
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





15 11


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int M=1e9+7;
vector<vector<int>> dp(21,vector<int>(1<<21));
int n;
int mat[21][21];
int calc(int i,int left){
    if(i==n){
        return 1;
    }
    if(dp[i][left]!=-1){
        return dp[i][left];
    }
    int ans=0;
    for(int j=0;j<n;j++){
        if(mat[i][j]==1){
            int res=1<<j;
            if(left&res){
                ans+=calc(i+1,left^res)%M;  
                ans%=M;
            }
        }
    }
    return dp[i][left]=ans;
}
void solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>mat[i][j];
            dp[i].assign(1<<21,-1);
        }
    }
    int sol=calc(0,(1<<21)-1);
    cout<<sol<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 183340
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static long mod = 1000000007;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	char[] S = sc.next().toCharArray();
    	long[] ocr = new long[26];
    	for(int i=0; i<N; i++) {
    		ocr[S[i]-'a']++;
    	}
    	long ans = 1;
    	for(int i=0; i<26; i++) {
    		ans = ans * (ocr[i]+1) % mod;
    	}
    	System.out.println(ans-1);
    }

    static long power(long m , long n){
    	if(n == 0) {
    		return 1;
    	}else if(n == 1){
            return m;
        }else if(n % 2 == 0){
            long s = power(m, n/2);
            return ( (s % mod) * (s % mod) ) % mod;
        }else{
            return ( (m % mod) * (power(m, n-1) % mod) ) % mod;
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void){
	int a,b,c,d;
	int Pictures[100][100];
	scanf("%d %d",&a,&b);
	for(c=0;c<a;c++){
		scanf("%s",Pictures[c]);
	}
	for(c=0;c<b+2;c++)printf("#");
	printf("\n");
	
	for(c=0;c<a;c++)printf("#%s#\n",Pictures[c]);
	
	for(c=0;c<b+2;c++)printf("#");
	return 0;
	
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int dp[100010];
int H[100010];
int N, K;

int main(){

    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 1; i < N; i++){
        dp[i] = 2000000000;
        for(int j = 1; j <= K; j++){
            int p = i - j;
            if(p >= 0)
                dp[i] = min(dp[i], dp[p] + abs(H[p] - H[i]));
        }
    }
    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar
#define putchar putchar
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(0<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(1<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(2<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(3<<3))+0x80]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(3<<3))+0x80]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	free(b);
}

long p10[16];

int s(long x){
	int ans=0;
	while(x>0){
		ans+=x%10;
		x/=10;
	}
	return ans;
}

long f(long x){
	long ans=x;
	double min=(double)x/s(x);
	for(int i=0; i<15; i++){
		long y=p10[i+1]*(x/p10[i+1]+1)-1;
		double now=(double)y/s(y);
		if(now<min){ min=now; ans=y; }
	}
	return ans;
}

int main(void){
	p10[0]=1;
	for(int i=1; i<16; i++){
		p10[i]=p10[i-1]*10;
	}
	int k=nextint();
	long x=1;
	for(int i=0; i<k; i++){
		printf("%ld\n", x);
		x=f(x+1);
	}
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    int n , k ;
    cin >> n >> k ;
    vector < int > a(n);
    for( int i = 0 ; i < n ; i++) cin >> a[i] ;
    sort(a.begin(),a.end());
    ll s = 0 ;
    for( int i = 0 ; i < k ; i++) s+= a[i] ;
    cout << s;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    int case1 = 1 ;
    while(t--){
        //cout << "Case #" << case1 << ": " ;
        case1++;
        solve( );
    }
}


Measured memory_bytes: 3640
#include<stdio.h>
typedef struct{
  int jo;
  int su;
  int ri;
  int ei;
  int to;
}TEST;
int main(){
  TEST test[2];
  int a,b,c,d;
  for(a=0;a<2;a++){
    scanf("%d %d %d %d",&test[a].jo,&test[a].su,&test[a].ri,&test[a].ei);
    test[a].to=test[a].jo+test[a].su+test[a].ri+test[a].ei;
  }
  if(test[0].to>=test[1].to){
    printf("%d\n",test[0].to);
  }
  else{
    printf("%d\n",test[1].to);
  }
  return 0;
}

Measured memory_bytes: 592
N = int(input())
rls = []
rlog = [0]*N
bls = []
blog = [0]*N
for i in range(N):
  a, b = map(int, input().split())
  rls += [(a,b)]
for i in range(N):
  a, b = map(int, input().split())
  bls += [(a,b)]

bls.sort(key=lambda x:x[0])
ans = 0
for i in range(N):
  c, d = bls[i]
  mb = -1
  mj = 0
  for j in range(N):
    a, b = rls[j]
    if a<c and b<d and rlog[j]==0:
      if mb<b:
        mb = b
        mj = j
  if mb!=-1:
    rlog[mj] = 1
    ans += 1
  
print(ans)

Measured memory_bytes: 3064
main :: IO ()
main = do
  [n,m,k] <- map read . words <$> getLine
  putStrLn $ if solve n m k then "Yes" else "No"
  
solve :: Int -> Int -> Int -> Bool
solve n m k = k `elem` [a*n+b*m-2*a*b | a <- [0..m], b <- [0..n]]


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

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = (1 << 21) + 100;
const int maxM = 3e5 + 100;
const long long oo = 4e18;
const int INF = 2e9 + 100;
const int MOD = 1e9 + 7;
const int Base = 311;
const long double du = 1e-9;
const string YES = "YES";
const string NO = "NO";
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

typedef pair<int, int> i2;
void solve() {
    int n, m, q;
    cin >> n >> m >> q;
    vector <i2> adj[n];
    vector <i2> bdj[m];
    vector <int> a(n), b(m);
    for (int &x : a) cin >> x;
    int res = 2e9;
    for (int &x : b) cin >> x;
    int x = *min_element(a.begin(), a.end());
    int y = *min_element(b.begin(), b.end());
    while (q--) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        adj[u].push_back({v, w});
        bdj[v].push_back({u, w});
    }
    for (int i = 0; i < n; i++) {
        res = min(res, a[i] + y);
        int val = 2e9;
        for (auto x : adj[i]) {
            int j = x.first;
            int w = x.second;
            val = min(val, a[i] + b[j] - w);
        }
        res = min(res, val);
    }
    cout << res;
}
int main(int argc,char *argv[]) {
    srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ///doc();
    solve();
}


Measured memory_bytes: 9984
n = int(input())
a = map(int, input().split())

count = 0
flag = True

while(flag):
    tmp_a = []
    for i in a:
        if i % 2 !=0:
            flag = False
            break
        tmp_a.append(i/2)
    a = tmp_a
    if flag == True:
        count += 1

print(count)

Measured memory_bytes: 3060
import bisect
from itertools import permutations


def submit():
    n = int(input())
    p = "".join(input().split())
    q = "".join(input().split())
    
    patterns = list(map(lambda x: "".join(x), permutations(map(str, range(1, n + 1)))))
    a = bisect.bisect_left(patterns, p)
    b = bisect.bisect_left(patterns, q)
    print(abs(a - b))


if __name__ == "__main__":
    submit()


Measured memory_bytes: 6052
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

bool isPrime[(1<<15)+1];

int main(){
    std::fill(isPrime, isPrime+(1<<15)+1, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=4;i<=(1<<15);i+=2){isPrime[i] = false;}
    for(int i=3;i<=(1<<15);i+=2){
        if(isPrime[i]){
            for(int j=2*i;j<=(1<<15);j+=i){
                isPrime[j] = false;
            }
        }
    }

    int n;
    while(std::cin >> n, n){
        int res = 0;
        for(int i=2;i<=n/2;i++){
            if(isPrime[i] && isPrime[n-i]){res += 1;}
        }
        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 1192
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n,h;
    cin>>h>>n;
    ll arr[n];
    ll res=0;
    loop(n,i,0)
        cin>>arr[i],res+=arr[i];
    cout<<(res>=h?"Yes":"No")<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 4268
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, K;
int A[200001];
int main(void){
    cin >> N >> K;
    REP(i,N) cin >> A[i];
    for(int i=K;i<N;i++){
        if(A[i-K] < A[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int x = N;
  int k = 0;
  while (N != 0){
    k += N % 10;
    N /= 10;
  }
  
  if (x % k == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
  long N, M;
  long s, c;
  long ans;
  
  scanf("%ld %ld", &N, &M);

  if(2*N == M) {
    printf("%ld\n", M);
  } else if(2*N > M) {
    printf("%ld\n", M/2);
  } else if(2*N < M) {
    c = M-2*N;
    printf("%ld\n", c/4 + N);
  }
  

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a<1200){
    cout<<"ABC"<<endl;
  }else if(1200<=a&&a<=2799){
    cout<<"ARC"<<endl;
  }else{
    cout<<"AGC"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; ll dp[N][N];
  rep(i, N){
    rep(j, N){
      cin >> dp[i][j];
    }
  }
  ll ans = 0; ll tmp[N][N];
  rep(i, N){
    rep(j, N){
      tmp[i][j] = longinf;
    }
  }
  rep(k, N){
    rep(i, N){
      rep(j, N){
        if(k!=i && k!=j) tmp[i][j] = min(dp[i][k]+dp[k][j], tmp[i][j]);
      }
    }
  }
  rep(i, N){
    rep(j, N){
      if(tmp[i][j]<dp[i][j]){
        cout << -1 << endl; return 0;
      }
      if(tmp[i][j]>dp[i][j]){
        ans+=dp[i][j];
      }
    }
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 1664
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<vector<P>>an(n);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a--){
            int x,y;cin>>x>>y;
            an[i].pb(mp(x,y));
        }
    }
    int maxm=-1;
    for(int bit=0;bit<(1<<n);bit++){
        bool abc=true;
        for(int i=0;i<n;i++){
            if((bit&(1<<i))){
                for(int j=0;j<siz(an[i]);j++)
                    if(((bit>>(an[i][j].fi-1))&1)!=an[i][j].se)//
                        abc=false;
            }
        }
        if(abc==true)
            chmax(maxm,counter(bit));
    }
    cout<<maxm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int a, b;
    cin >> a >> b;
    rep1(i, 1300) {
        if(floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string S;
    cin >>S;
    int s[20];
    for(int i = 0;i < S.size();i++){
        for(int j = 0;j < 10;j++){
            if(S[i] == '1' + j) s[i] = j+1;
            else continue;
        }
    }
    int ans = 987654321;
    for(int i = 0;i < S.size()-2;i++){
        ans = min(abs(753 - (100*s[i]+10*s[i+1]+s[i+2])),ans);
    }
    cout << ans << endl;

}

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

int main(){

    while(1){
        int n, t, l, b; cin >> n >> t >> l >> b;
        if(n == 0) break;
        vector<int> a(n + 1, 0);
        for(int i = 0; i < l; i++){
            int in; cin >> in;
            a[in] = 1;
        }
        for(int i = 0; i < b; i++){
            int in; cin >> in;
            a[in] = 2;
        }

        vector<vector<double> > dp(t + 2, vector<double> (n + 1, 0.0));
        dp[0][0] = 1.0;
        double ans = 0.0; 
        for(int i = 0; i < t; i++){
            for(int j = 0; j < n; j++){
                for(int k = 1; k <= 6; k++){
                    int next = j + k;
                    if(next > n) next -= 2*(next - n);
                    if(a[next] == 2) next = 0;
                    
                    if(a[next] == 1){
                        dp[i + 2][next] += dp[i][j] * (1.0/6);
                    }else{
                        dp[i + 1][next] += dp[i][j] * (1.0/6);
                        //if(i == 1 && next == n) cout << i << " " << j << endl;
                    }
                }
            }
        }
        
        //出力
        /*for(int i = 0; i <= t; i++){
            for(int j = 0; j <= n; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/

        for(int i = 1; i <= t; i++){
            ans += dp[i][n];
        }

        printf("%.10f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int check(char str[]);

int main(void){
  char str[16],substr[16];
  int i,j,k,l,maxans=0,tmp;
  scanf("%15s%*c",str);
  l=strlen(str);
  tmp=(1<<l);
  for(i=0;i<tmp;i++){
    k=0;
    for(j=0;j<l;j++)
      if((i>>j)&1) substr[k++]=str[j];
    substr[k]=0;
    if(check(substr)){
      //puts(substr);
      if(maxans<(j=strlen(substr))) maxans=j;
    }
  }
  printf("%d\n",maxans);
  return 0;
}

int check(char str[]){
  int i,j,k,l,flg=0;
  l=strlen(str);
  for(i=0;i<l;i++){
    if(strncmp(str+i,"iwi",3)==0 && flg==0){
      i+=2;
      flg=1;
      continue;
    }else if(str[i]=='i' || str[i]=='w') return 0;
  }
  if(flg==0) return 0;
  for(i=0;i<l;i++){
    if(str[i]=='(' && str[l-1-i]!=')') return 0;
    if(str[i]==')' && str[l-1-i]!='(') return 0;
    if(str[i]=='{' && str[l-1-i]!='}') return 0;
    if(str[i]=='}' && str[l-1-i]!='{') return 0;
    if(str[i]=='[' && str[l-1-i]!=']') return 0;
    if(str[i]==']' && str[l-1-i]!='[') return 0;
  }
  return 1;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int l, r = N;
    l = max(0, (int)count(A.begin(), A.end(), 1)-1);
    while (r-l > 1) {
        int c = (9*l+r+8)/10;
        map<int, int> mp;
        for (int i = 1; i < N; i++) {
            if (A[i-1] >= A[i]) {
                if (c == 1) {
                    mp[0] = 1;
                    break;
                }
                int t = A[i];
                mp[t]++;
                auto it = mp.upper_bound(t);
                mp.erase(it, mp.end());
                while (t > 0 && mp[t] == c) {
                    mp[t] = 0;
                    mp[t-1]++;
                    t--;
                }
            }
            if (mp[0] > 0) break;
        }
        if (mp[0] == 0) r = c;
        else l = c;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] y = new int[m];
		for (int i = 0; i < m; i++) {
			y[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 1000000007;
		long sumx = calc(x, mod);
		long sumy = calc(y, mod);
		System.out.println(sumx * sumy % mod);
	}

	static long calc(int[] x, int mod) {
		int n = x.length;
		long ret = 0;
		for (int i = 1; i < n; i++) {
			long d = x[i] - x[i - 1];
			d *= i;
			d %= mod;
			d *= (n - i);
			d %= mod;
			ret += d;
		}
		ret %= mod;
		return ret;
	}
}


Measured memory_bytes: 53596
/**
*    created: 30.06.2020 17:54:39
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = inf;
    rep2(i,0,100001) {
        int sum = 2*c*i;
        sum += max(0LL,x-i) * a;
        sum += max(0LL,y-i) * b;
        chmin(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n,i;
    double x[1001],y[1001];
    double sum,ans;
    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%lf", &x[i]);
    }
    for (i = 0; i < n; i++) {
        scanf("%lf", &y[i]);
    }

    // p = 1のとき
    for (i = 0; i < n; i++) {
        sum = sum + fabs(x[i]-y[i]);
    }
    ans = sum;
    printf("%lf\n", ans);
    //p = 2 のとき
    sum = 0;
    for (i = 0; i < n; i++) {
        sum = sum + fabs(x[i]-y[i])*fabs(x[i]-y[i]);
    }
    ans = sqrt(sum);
    printf("%lf\n", ans);
    sum = 0;
    //p = 3のとき
    for(i = 0;i < n;i++){
        sum = sum + fabs(x[i] - y [i]) * fabs(x[i] - y [i]) * fabs(x[i] - y [i]);
    }
    ans = pow(sum,1.0/3.0);
    printf("%lf\n",ans);

    sum = 0;
    for(i = 0;i < n;i++){
        if(sum < fabs(x[i] - y [i])){
            sum = fabs(x[i] - y [i]);
        }
    }
    ans = sum;

    printf("%lf\n",ans);

    return 0;
}



Measured memory_bytes: 2064
a = int(input())
l = list(map(int,input().split()))
l2 = []
l3 = []
for i in l:
  if i%2 == 0:
    l2.append(i)
for i in l2:
  if i%3 == 0 or i%5 == 0:
    l3.append(i)
   
print("APPROVED" if len(l2) == len(l3) else "DENIED")

Measured memory_bytes: 3060
N, P = map(int, input().split())
S = input()
if P == 2:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['2', '4', '6', '8', '0']:
            counter += i + 1
    print(counter)
elif P == 5:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['5', '0']:
            counter += i + 1
    print(counter)
else:
    list_a = [0] * P
    list_a[0] += 1
    counter = 0
    temp = 0
    power = 1
    for i in range(N):
        power *= 10
        power %= P
        temp += power * int(S[N-i-1])
        temp %= P
        counter += list_a[temp]
        list_a[temp] += 1
    print(counter)



Measured memory_bytes: 41308
#include <iostream>

using namespace std;

int gcd(int x, int y);

int main(){
	int x, y;

	cin >> x >> y;
	cout << gcd(x, y) << endl;

	return 0;
}

int gcd(int x, int y){
	if(x < y){
		swap(x, y);
	}

	while (0 < y){
		int r = x % y;
		x = y;
		y = r;
	}
	return x;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char>> vv(H,vector<char>(W));
    REP(i,H) {
        string s;
        cin >> s;
        REP(j,W) vv[i][j] = s[j];
    }
    int ans = 0;
    for(int height_bit = 0; height_bit < (1 << H); ++height_bit) {
        for(int width_bit = 0; width_bit < (1 << W); ++ width_bit) {
            int black_cnt = 0;
            REP(i,H) REP(j,W) if((vv[i][j] == '#') && !(height_bit & (1 << i)) && !(width_bit & (1 << j))) black_cnt++;
            if(black_cnt == K) ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3628
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            Map<String, Integer> items = new HashMap<String, Integer>();
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                int cost = sc.nextInt();
                items.put(s, cost);
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                String recipeName = sc.next();
                int k = sc.nextInt();
                int sum = 0;
                for (int j = 0; j < k; j++) {
                    String name = sc.next();
                    if (items.containsKey(name))
                        sum += items.get(name);
                }
                items.put(recipeName, Math.min(sum, items.get(recipeName)));
            }
            String query = sc.next();
            System.out.println(items.get(query));
        }
    }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    ll bk = 1e10;
    vector<ll> A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] > B[i]) bk = min(bk, B[i]);
        sum += B[i];
    }
    bool ok = true;
    rep(i, N) {
        if (A[i] != B[i]) {
            ok = false;
        }
    }

    if (ok) {
        cout << 0 << endl;
        return 0;
    }

    cout << sum - (bk < 1e10 ? bk : 0) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main(void) {
  int n, x;
  int l;  
  int cnt = 0;

  cin >> n;
  cin >> x;
 

 
  int i=0;
  while ((i<n) && (x >= 0)){
    cin >> l;
    x -= l;
    cnt += 1;
    i++;
  }

  if (x >= 0){ cnt++; }
 
  cout << cnt << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define false -1 
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b;
	if((a<1||a>9)||(b<1||b>9))
		cout<<false;
	else
	{
		c=a*b;
		cout<<c<<endl;
	}
	return 0;
}

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

#define N 100000
#define Q 50000
int n,S[N];

int binarySearch(int);
main(){
  int i,T[Q],s=0,q;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);
  for(i=0;i<q;i++){
   s+= binarySearch(T[i]);
  }
  printf("%d\n",s);
  return 0;
}
 
int binarySearch(int key){
  int left=0,right,mid;
  
  right = n;
  while(left<right){
    mid = (right + left) / 2;
    if(key == S[mid]) return 1;
    if(key > S[mid]) left = mid+1;
    else if(key < S[mid]) right = mid;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  string n; cin >> n;
  rep(i, (int)n.size()) {
    if (n[i] == '1')
      cout << "9";
    else if (n[i] == '9')
      cout << "1";
    else
      cout << n[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r)
  in doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (f x; doit l; doit r)
  in doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (doit l; f x; doit r)
  in doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        doit s1 (String.sub s (i + 1) (String.length s - String.length s1 - 1) :: acc)
  in doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | _ -> (print t; read (i + 1) t)
    end in
  read 0 (create ())

Measured memory_bytes: 31856
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int a,b,c; cin >> a >> b >> c;
  if(c <= b/a) cout << c << endl;
  else cout << b/a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int bsr(int x) { return 31 - __builtin_clz(x); }
int bsr(ll x) { return 63 - __builtin_clzll(x); }
int bsf(int x) { return __builtin_ctz(x); }
int bsf(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=LINF,sum,mn;
	cin>>n;
	vl v(n),sign1,sign2;
	rep(i,n){
		cin>>v[i];
	}
	sort(all(v));
	if(n%2==1){
		sign1.push_back(v[n/2]);
		sign2.push_back(v[n/2]);
	}
	rep(i,n/2){
		sign2.push_back(v[n-1-i]);
		sign1.push_back(v[i]);
		sign2.push_back(v[i]);
		sign1.push_back(v[n-1-i]);
	}
	sum=mn=abs(sign1[0]-sign1[n-1]);
	rep(i,n-1){
		sum+=abs(sign1[i+1]-sign1[i]);
		mn=min(mn,abs(sign1[i+1]-sign1[i]));
	} 
	ans=sum-mn;
	sum=mn=abs(sign2[0]-sign2[n-1]);
	rep(i,n-1){
		sum+=abs(sign2[i+1]-sign2[i]);
		mn=min(mn,abs(sign2[i+1]-sign2[i]));
	} 
	ans=max(ans,sum-mn);
	cout<<ans<<endl;
}

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

int main() {

//とりあえずAにすべての高さを入れる
  int N;
  cin >> N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
//iより海に近い最大の高さの集合を作る
vector<int> v(N);
v.at(0) = vec.at(0);

for (int i =1; i<N;i++){
if (v.at(i-1)<vec.at(i))
  v.at(i) = vec.at(i);
else
v.at(i) = v.at(i-1);
}

//海を見れる旅館の数を求める
int a = 0;

for (int i = 0; i<N;i++){
if (vec.at(i)==v.at(i))
a++;
}
cout << a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
string N, ans;
int main(void)
{
	cin >> N;
	int n = N.length();
	if (n == 2)cout << N << endl;
	else {
		for (int i = 2; i >= 0; i--) {
			cout << N[i];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, k, nums[10];
int vis[10];
void just_do_it( int rt ){
	for( int i = 0; i <= 9; ++i )
		vis[i] = 0;
	while( rt ){
		int t = rt % 10;
		++vis[t];
		rt /= 10;
	}
}
bool check( int i ){
	just_do_it(i);
	for( int j = 1; j <= k; ++j )
		if( vis[nums[j]] )
			return false;
	return true;
}
int solve(){
	for( int i = n; true; ++i ){
		if( check(i) )
			return i;
	}
}
int main(){
	scanf("%d%d", &n, &k);
	for( int i = 1; i <= k; ++i )
		scanf("%d", &nums[i]);
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 256
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;


void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(a*b,c) << endl;
}


int main(){ 
	speedhack()
	int n;
	do(1);
	return 0;
}


Measured memory_bytes: 256
W = int(input())

w3 = []

while W > 0:
    w3.append(W % 3)
    W = W // 3
w3.append(0)

for i in range(len(w3)-1):
    if w3[i] > 1:
        w3[i] = w3[i] - 3
        w3[i+1] = w3[i+1] + 1

w3.reverse()

if w3[0] == 1:
    print("+", end="")
elif w3[0] == -1:
    print("-", end="")
    
for i in range(1, len(w3)):
    if w3[i] == 1:
        print("+", end="")
    elif w3[i] == 0:
        print("0", end="")
    elif w3[i] == -1:
        print("-", end="")
        
print("")



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

int main()
{
	int sosuu[100001];
	for(int i = 0; i < 100001; i++)
		sosuu[i] = -1;
	sosuu[1] = 0;
	sosuu[2] = -1;
	for(int i = 2; i < 100001; i++){
		if(sosuu[i] == -1){
			sosuu[i] = 1;
			for(int j = i * 2; j < 100001; j += i){
				sosuu[j] = 0;
			}
		}
	}
	
	int hanteiRuiseki[100001];
	hanteiRuiseki[1] = 0;
	for(int i = 3; i < 100001; i += 2){
		hanteiRuiseki[i] = hanteiRuiseki[i-2];
		if(sosuu[i] == 1 && sosuu[(i+1)/2] == 1){
			hanteiRuiseki[i]++;
		}
	}
	
	int q;
	cin >> q;
	int l,r;
	for(int i = 0; i < q; i++){
		cin >> l >> r;
		cout << hanteiRuiseki[r] - hanteiRuiseki[l] + min(sosuu[l], sosuu[(l+1)/2]) << "\n";
	}

	return 0;
}


Measured memory_bytes: 1408
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[]ABC=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(ABC);
    int count=0;
    if(ABC[0]%2==ABC[1]%2)count+=(2*ABC[2]-ABC[0]-ABC[1])/2;
    else if(ABC[1]%2!=ABC[0]%2)count+=((2*ABC[2]-ABC[0]-ABC[1]+1)/2+1);
    Console.WriteLine(count);
  }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y=x;
    if(z->key < x->key) x =x->left;
    else x = x->right;
  }
  z->parent=y;
  if(y==NIL) root =z; 
  else if(z->key < y->key){
    y->left=z;
  }
  else y->right=z;
  
}     
void inorder(Node u){
  if(u != NIL){
     inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if(u != NIL ){
    printf(" %d",u->key);
    preorder(u->left); 
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
  } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24040
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // ans: dequeue(array)において次の3種類の操作をk回までできる時の最大価値
        // 操作A: 左端から1個取り出す
        // 操作B: 右端から1個取り出す
        // 操作C: 手持ちから1個捨てる
        int ans = 0;
        
        // 左からi個右からj個取るパターンを全探索する
        for (int i = 0; i <= k; i++) {
            if (i == n + 1) break;
            
            for (int j = 0; j <= k-i; j++) {
                if (i + j == n + 1) break;
                
                PriorityQueue<Integer> que = new PriorityQueue<>();
                
                // 操作A
                for (int x = 0; x < i; x++) {
                    que.add(array[x]);
                }
                // 操作B
                for (int x = n - 1; x > n - 1 - j; x--) {
                    que.add(array[x]);
                }
                // 操作C
                for (int x = 0; x < k - i - j; x++) {
                    if (que.isEmpty()) break;
                    int num = que.peek();
                    if (num <= 0) {
                        que.poll();
                    }
                }
                
                int sum = 0;
                while (!que.isEmpty()) {
                    sum += que.poll();
                }
                
                ans = Math.max(ans, sum);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 39336