akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Ni = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(Ni[0]-(Ni[1]-1));
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int R, G, B, N; cin >> R >> G >> B >> N;
    int cnt = 0;
    for (int x = 0; x <= 3000; x++) {
        for (int y = 0; y <= 3000; y++) {
            int v = (N - R * x - G * y);
            // cout << v << '\n';
            if (v >= 0 && v % B == 0) {
                cnt++;
            }
        }
    }

    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 384
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

ans = float('inf')
for X in A:  # 下限候補

    # 下限候補未満の数で分割
    S = " ".join([(str(a) if a >= X else "x") for a in A])
    S = [list(map(int, Sx.split())) for Sx in S.split("x")]

    # Max候補を列挙
    C = []
    for s in S:
        s.sort(reverse=True)
        if len(s) >= K:
            for ss in s[K-1:]:
                C.append(ss)

    # Max候補の中の小さいほうからQ番目がMax
    C.sort()
    if len(C) >= Q:
        ans = min(ans, C[Q-1]-X)

print(ans)

Measured memory_bytes: 101596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, x; cin >> a >> b >> x;
  if (a <= x && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

using namespace std;

const int maxN = 500000;
const int mod = 1000000007;
const int maxX = 1 << 20;

int N;
int A[maxN];
int X[maxN + 1];
int g[maxN + 1];
int c[maxN + 1];
vector<int> idx[maxX];

template <class T>
inline int remainder(const T & x) {
	if (x < 0)
		return x + mod;
	else if (x < mod)
		return x;
	else
		return x - mod;
}

void initialize() {
	g[0] = 1;
	for (int i = 1; i <= maxN; i++)
		g[i] = remainder(g[i - 1] << 1);
}

int answer() {
	for (int i = 0; i < N; i++) {
		X[i + 1] = X[i] ^ A[i];
		c[i + 1] = c[i] + (X[i + 1] == 0);
		idx[X[i + 1]].push_back(i + 1);
	}

//	for (int i = 0; i < N; i++)
//		cerr << X[i + 1] << ' ';
//	cerr << endl;
//	
//	for (int i = 0; i < N; i++)
//		cerr << c[i + 1] << ' ';
//	cerr << endl;
		
	vector<int> vtr;
	if (X[N] == 0) {
		for (int i = 1; i <= N; i++)
			vtr.push_back(X[i]);
		sort(vtr.begin(), vtr.end());
		vtr.resize(unique(vtr.begin(), vtr.end()) - vtr.begin());
	} else
		vtr.push_back(X[N]);

	int ans = 0;
	int f[2];
	bool b = X[N];
	for (const auto & x : vtr) {
		if (x == 0)
			ans = remainder(ans + g[idx[0].size() - 1]);
		else {
			f[0] = 1;
			f[1] = 0;
			for (int i = 0; i < idx[x].size(); i++) {
				if (i > 0)
					f[0] = remainder(f[0] + (long long)f[1] * (c[idx[x][i]] - c[idx[x][i - 1]]) % mod);
				f[1] = remainder(f[0] + f[1]);
//				cerr << "f = " << f[0] << ' ' << f[1] << endl;
			}
			f[0] = remainder(f[0] + (long long)f[1] * (c[N] - c[idx[x].back()]) % mod);
			ans = remainder(ans + f[b ^ 1]);
//			cerr << "x = " << x << ", f[0] = " << f[0] << ", f[1] = " << f[1] << endl;
		}
	}

	return ans;
}

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

	initialize();

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

	cout << answer() << '\n';

	return 0;
}


Measured memory_bytes: 44404
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
    return 0;
}

Measured memory_bytes: 3644
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

void solve()
  {
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	int dp[n+1][3];
	memset(dp,0,sizeof dp);
	dp[1][0]=a[0];dp[1][1]=b[0];dp[1][2]=c[0];	
	
	repA(i,2,n)
	{
		dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
		dp[i][1]=max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
		dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
		
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 8296
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

Measured memory_bytes: 256
n, m, l = map(int, input().split())

Amatrix = []
Bmatrix = []

for ia in range(n):
    Amatrix.append(list(map(int, input().split())))

for ib in range(m):
    Bmatrix.append(list(map(int, input().split())))

Cmatrix = [[0 for ic in range(l)] for ie in range(n)]

for ig in range(n):
    for ih in range(l):
        SUM = 0
        for ii in range(m):
            SUM += Amatrix[ig][ii] *  Bmatrix[ii][ih]
        Cmatrix[ig][ih] = str(SUM)
        
for ij in range(n):
    print(' '.join(Cmatrix[ij]),end='\n')


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define MOD 1000000007

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  ll n, a, b, map[100001], ans = 0;
  cin >> n >> a >> b;
  rep(i, 0, n) cin >> map[i];

  rep(i, 0, n - 1) {
    if((map[i + 1] - map[i]) * a > b) ans += b;
    else ans += (map[i + 1] - map[i]) * a;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	static int m,n,k;
	static char e[1002][1002];
	static int a[100010],b[100010],c[100010],d[100010];
	
	scanf("%d%d%d",&m,&n,&k);
	rep1(i,m){
		scanf("\n");
		rep1(j,n){
			scanf("%c",&e[i][j]);
		}
	}
	rep(i,k){
		scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	}
	
	static int imos_J[1002][1002],imos_O[1002][1002],imos_I[1002][1002];
	
	rep1(i,m){
		rep1(j,n){
			imos_J[i][j] = imos_J[i][j-1] + ((e[i][j] == 'J')?1:0) ;
			imos_O[i][j] = imos_O[i][j-1] + ((e[i][j] == 'O')?1:0) ;
			imos_I[i][j] = imos_I[i][j-1] + ((e[i][j] == 'I')?1:0) ;
		}
	}
	rep1(i,m){
		rep1(j,n){
			imos_J[i][j] = imos_J[i][j] + imos_J[i-1][j];
			imos_O[i][j] = imos_O[i][j] + imos_O[i-1][j];
			imos_I[i][j] = imos_I[i][j] + imos_I[i-1][j];
		}
	}
	
	rep(i,k){
		printf("%d %d %d\n"
			,imos_J[c[i]][d[i]] - imos_J[c[i]][b[i]-1] - imos_J[a[i]-1][d[i]] + imos_J[a[i]-1][b[i]-1]
			,imos_O[c[i]][d[i]] - imos_O[c[i]][b[i]-1] - imos_O[a[i]-1][d[i]] + imos_O[a[i]-1][b[i]-1]
			,imos_I[c[i]][d[i]] - imos_I[c[i]][b[i]-1] - imos_I[a[i]-1][d[i]] + imos_I[a[i]-1][b[i]-1]
		);
	}
}

Measured memory_bytes: 15428
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main() {
	// your code goes here
	ll a,b,k;
	cin>>a>>b>>k;
	ll g=__gcd(a,b);
	ll count=0;
	for(ll i=g;i>=0;i--)
	{
	    if(g%i==0)
	    {
	        count+=1;
	    }
	    if(count==k)
	    {
	        cout<<i<<endl;
	        exit(0);
	    }
	}
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ans = [0] * n
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for aa in a:
        ans[aa-1] = 1
cnt = 0
for i in range(n):
    if ans[i] == 0:
        cnt += 1
print(cnt)


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

int main()
{
    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;
    
    int t;
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    
    if (b > c) {
        t = b;
        b = c;
        c = t;
    }
    
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main() {
	int N, X;
	cin >> N >> X;
	int g = -1;
	for (int i = 0; i < N; ++i) {
		int p;
		cin >> p;
		p -= X;
		if (p < 0) p *= -1;
		if (g == -1) g = p;
		else g = gcd(g, p);
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

import heapq

q = [(-Ai, i) for i, Ai in enumerate(A)]
heapq.heapify(q)

M_tmp = M
while M_tmp > 0:
    penalty, i = heapq.heappop(q)
    #
    Ai_tmp = (-penalty) // 2
    heapq.heappush(q, (-Ai_tmp, i))
    M_tmp -= 1

ans = sum([-penalty for penalty, i in q])
print(ans)

Measured memory_bytes: 24592
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll r,g,b;
    std::cin >> r>>g>>b;
    string ans = ( (10*g+b)%4 == 0 ) ? "YES" : "NO";
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
s = input()

M = ["01","02","03","04","05","06","07","08","09","10","11","12"]

s1 = s[0:2]
s2 = s[2:4]

if s1 in M:
    if s2 in M:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif s2 in M:
    if s1 in M:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    print('NA')

Measured memory_bytes: 3064
N,S=*$<
t=1
"RGB".chars{|c|t*=S.count c}
N.to_i.times{|i|0.upto(i/2){|j|S[i]!=S[i-j]&&S[i-j]!=S[i-j*2]&&S[i-j*2]!=S[i]&&t-=1}}
p t

Measured memory_bytes: 14276
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_set>
#include <vector>

int main()
{
  int n, k;
  std::cin >> n >> k;

  std::unordered_set<int> sss;
  for (int i = 0; i < k; ++i) {
    int d;
    std::cin >> d;
    for (int j = 0; j < d; ++j) {
      int a;
      std::cin >> a;
      sss.insert(a);
    }
  }

  std::cout << std::setprecision(20);
  std::cout << n - static_cast<int>(sss.size()) << std::endl;
}


Measured memory_bytes: 3632
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int x;
  cin >> x;
  int c500 = 500;
  int c5 = 5;
  int ans = (x / 500) * 1000 + ((x % 500) / 5) *5;
  cout << ans;
 
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] strArray = sc.next().toCharArray();

		int max = 0;
		int i = 0;

		for (char c : strArray) {
			if (c == 'A' || c == 'G' || c == 'C' || c == 'T') {
				i++;
			} else {
				if (max < i)
					max = i;
				i = 0;
			}
		}
		if (max < i)
			max = i;
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll x,ans=0;

int main(){
	ios::sync_with_stdio(false);
	cin>>x;
	ll tmp=100;
	while(tmp<x){
		++ans;
		tmp+=tmp/100;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <list>
using namespace std;
enum Query
{
    Insert = 0,
    Move = 1,
    Erase = 2,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
void print_list(list<int> L)
{
    for (list<int>::iterator it = L.begin(); it != L.end(); it++)
    {
        cout << *it << endl;
    }
}
int main()
{
    list<int> L;
    list<int>::iterator it = L.end();
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        Query query;
        cin >> query;
        if (query == Insert)
        {
            int x;
            cin >> x;
            it = L.insert(it, x);
        }
        else if (query == Move)
        {
            int d;
            cin >> d;
            advance(it, d);
        }
        else if (query == Erase)
        {
            it = L.erase(it);
        }
    }
    print_list(L);
}
//Runtime error　分からない。


Measured memory_bytes: 34160
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  long s;
  cin >> s;
  long l = min(1000000000L, long(sqrt(s)+1));
  long ab=l*l-s, a, b;
  cerr << ab;
  if(ab==0){
    a=b=0;
  }
  else {
    for(int i=sqrt(ab); i>=1; i--){
      if(ab%i==0){
        a=i;
        b=ab/i;
        break;
      }
    }
  }
  cout << 0 << ' ' << 0 << ' ' << l << ' ' << a << ' ' << b << ' ' << l << endl;
  return 0;
}


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

using namespace std;

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


struct edge {long int u, v, cost;};

bool func(edge x, edge y){
    return x.cost > y.cost;
}

int main(){
    long int const INF = 1000000000;
    long int n;
    cin >> n;
    long int a[n][n];
    rep(i, n)rep(j, n) cin >> a[i][j];
    long int dp[n+1][n][n];
    rep(i, n+1)rep(j, n)rep(k, n) dp[i][j][k] = INF;
    rep(k, n + 1)rep(i, n)rep(j, n) dp[k][i][j] = a[i][j];
    rep(k, n)rep(i, n)rep(j, n){
        if(dp[k][i][j] > dp[k][i][k] + dp[k][k][j]){
            cout << -1 << endl;
            return 0;
        }
    }
    
    vector<edge> G;
    for (long int i = 0; i < n - 1; i++){
        for (long int j = i + 1; j < n; j++){
            edge g;
            g.u = i;
            g.v = j;
            g.cost = a[i][j];
            G.push_back(g);
        }
    }
    sort(G.begin(), G.end(), func);
    long int ans = 0;
    for (long int i = 0; i < G.size(); i++){
        edge g = G[i];
        long int flag = true;
        for (long int j = 0; j < n; j++){
            if (j != g.u && j != g.v){
                if (a[g.u][j] + a[j][g.v] == a[g.u][g.v]){
                    flag = false;
                    break;
                }
            }

        }
        if (flag){
            ans += a[g.u][g.v];
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int D[30][30];
int T[500][500];
ll cost[3][30];

int main2() {
  int N = nextInt();
  int C = nextInt();
  REP(i, C) REP(j, C) D[i][j] = nextInt();
  REP(i, N) REP(j, N) T[i][j] = nextInt()-1;
  CLR(cost, 0);
  REP(c, C) {
    REP(i, N) REP(j, N) {
      cost[(i+j)%3][c] += D[T[i][j]][c];
    }
  }

  ll ans = 1LL << 58;
  REP(a, C) REP(b, C) REP(c, C) {
    if (a == b || b == c || c == a) continue;
    chmin(ans, cost[0][a] + cost[1][b] + cost[2][c]);
  }

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();
        if (B < A) {
            System.out.println(0);
            return;
        }
        if (N == 1) {
            if (A == B) {
                System.out.println(1);
                return;
            } else {
                System.out.println(0);
                return;
            }
        }
        long min = A + B + (N - 2) * A;
        long max = A + B + (N - 2) * B;
        System.out.println(max - min + 1);
    }
}


Measured memory_bytes: 22868
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let ab: Vec<u32> = read_vec();
  let ans = match ab[0] {
    0...5  => 0,
    6...12 => ab[1] / 2,
    _      => ab[1]
  };

  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int D;
    cin >> D;
    
    int c = 25-D;
    cout << "Christmas ";
    for(int i =0; i < c; i++)
        cout << "Eve ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int data[100];
  int i,j,n,key;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  
  for(j=0;j<n-1;j++){
    printf("%d ",data[j]);
  }
  printf("%d",data[j]);
  printf("\n");
  
  for(i=1;i<n;i++){
    key = data[i];
    j = i-1;
    while(j>=0 && key < data[j]){
      data[j+1] = data[j];
      j--;
      data[j+1] = key;
    }

    for(j=0;j<n-1;j++){
      printf("%d ",data[j]);
    }
    printf("%d",data[j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a<b){
    swap(a,b);
  }
  int r;
  while(b>0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int g[n];
  for(int i=0; i<n; i++){
    if(i==0){
      g[i] = a[0];
    }
    g[i] = gcd(g[i-1],a[i]);
    //cout << g[i] << endl;
  }
  cout << g[n-1] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

// 桁DPの遷移
// - 2進数の計算
// https://atcoder.jp/contests/abc117/tasks/abc117_d

// N=63435 について、
// dp[3][true]  : 634○○未満となる数(00000 - 63399)についての暫定の答え
// dp[3][false] : 634○○ となる数(63400 ~ 63429)についての暫定の答え

// dp[i][true] から dp[i+1][true]にのみ遷移
// (i桁目まででNより小さいなら、i+1桁目をどのように選んでもNより小さい）
// dp[i][false] から dp[i+1][true]へ遷移
// (i桁目までNと同じで、 i+1桁目はNより小さい数の時)
// dp[i][false] から dp[i+1][false]へ遷移
// (i桁目までNと同じで、 i+1桁目もNと同じ数の時)

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    INIT;

    string L;
    cin >> L;

    ll N = SZ(L);
    vector<vector<mint>> dp(N + 5, vector<mint>(2, 0));
    dp[0][0] = 1;

    rep(i, N) {
        if (L[i] == '0') {
            dp[i + 1][1] = dp[i][1] * 3;
            dp[i + 1][0] = dp[i][0];
        } else {
            dp[i + 1][1] = dp[i][0] + dp[i][1] * 3;
            dp[i + 1][0] = dp[i][0] * 2;
        }
    }

    // rep(i, N + 2) { cout << dp[i][1] << "\t"; }
    // cout << endl;
    // rep(i, N + 2) { cout << dp[i][0] << "\t"; }
    // cout << endl;
    cout << dp[N][0] + dp[N][1] << endl;

    return 0;
}

Measured memory_bytes: 8712
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int i,N,coodinates[1100];
    int maxcoodinate = 0;
    int mincoodinate = 0;
    

    cin >> N;

    for(i = 0; i < N; i++) {
        cin >> coodinates[i];
    }
    mincoodinate = coodinates[0];
    maxcoodinate = coodinates[0];

    for(i = 1; i < N; i++) {
        if(coodinates[i] <= mincoodinate) {
            mincoodinate = coodinates[i];
        }
        if(coodinates[i] >= maxcoodinate) {
            maxcoodinate = coodinates[i];
        }
    }

    cout << maxcoodinate - mincoodinate << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main() {
  	int a;
  	cin >> a;
  	long long ans = 1;
  	for(int i = 1; i <= a; ++i)
    {
      ans *= i;
      ans = fmod(ans, pow(10, 9) + 7);
    }
  	cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, y, z;
  cin >> x >> y >> z;
  int ans = 0;
  x -= z;
  ans = x / (y + z);
  cout << ans << endl;
  return 0;
}

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

int main() {
	int n, q;
	cin >> n;
	vector<int> s(n);
	rep(i, n) cin >> s[i];
	cin >> q;
	vector<int> t(q);
	rep(i, q) cin >> t[i];
	int ans = 0;
	rep(i, q) {
		ans += !!(upper_bound(all(s), t[i]) - lower_bound(all(s), t[i]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3324
input_data = []
data = input()


memory="first"
i=0
k=0

#最後二つが同じなら削除
if data[-1]==data[-2]:
    k+=1
    data=data[:-2]

max_len=len(data)
while max_len!=i:
    try:
        if data[i] != memory:
            memory=data[i]
            i+=1             
        else:
            memory=data[i:i+2]
            i+=2
    except:
        break
    k+=1
    
print(k)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    // 入力
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> pq; // ソートの状態でデータを保持
    for(int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        pq.push(a);
    }

    // M回分、最大値を半分に
    for(int i = 0; i < M; i++)
    {
        ll maxv = pq.top() / 2LL;
        pq.pop();
        pq.push(maxv);
    }

    // 合計値を計算
    ll sum = 0;
    for(int i = 0; i < N; i++)
    {
        sum += pq.top();
        pq.pop();
    }

    // 解を出力
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int ans[101][101];
int a[100001];

int main () {      	
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	int dir = 1;
	int id = 1;
	for (int i = 1;i <= h;i ++) {
		if (dir == 1) {
			for (int j = 1;j <= w;j ++) {
				ans[i][j] = id;
				a[id] --;
				if (a[id] == 0) id ++;
			}
		}
		else {
			for (int j = w;j >= 1;j --) {
				ans[i][j] = id;
				a[id] --;
				if (a[id] == 0) id ++;
			}
		}
		dir = 3 - dir;
	}
	for (int i = 1;i <= h;i ++) {
		for (int j = 1;j <= w;j ++) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll x; cin >> x;
    cout << x / 500 * 1000 + (x % 500) / 5 * 5 << "\n";
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]+[0]

ans = 0
for i in range(N):
    if A[i] % 2 == 0:
        ans += A[i]//2
        A[i] = 0
    else:
        ans += A[i]//2
        if A[i+1] > 0:
            ans += 1
            A[i+1] -= 1
            A[i] = 0
print(ans)


Measured memory_bytes: 7840
#include<iostream>
#include<queue>

using namespace std;

priority_queue<int> q;

int main() {

	int n, m,a,b;
	cin >> n >> m;
	
	for (int i = 0;i < n;i++) {
		cin >> a;
		q.push(a);
	}

	for (int i = 0;i < m;i++) {
		b = q.top(), q.pop();
		b /= 2,q.push(b);

	}

	long long ans=0;
	for (int i = 0;i < n;i++) {
		ans += q.top();
		q.pop();
	}

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

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
using namespace std;

/*
1 partition(A, p, r)
2   x = A[r]
3   i = p-1
4   for j = p to r-1
4     if A[j] <= x
5       i = i+1
6       A[i] と A[j] を交換
7   A[i+1] と A[r] を交換
8   return i+1
*/

void swap(int &a, int &b){
	int x = a;
	a = b;
	b = x;
	return;
}

int main(){

	int n;
	cin >> n;
	int* A = new int[n];
	for (int j = 0; j < n; j++) cin >> A[j];

	int x = A[n - 1];
	int i = -1;
	for (int j = 0; j < n - 1; j++){
		if (A[j] <= x){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[n - 1]);

	for (int j = 0; j < n; j++) cout << (j == 0 ? "" : " ") << (j == i + 1 ? "[" : "") << A[j] << (j == i + 1 ? "]" : "");
	cout << endl;

	delete[] A;

	return 0;
}


Measured memory_bytes: 3136
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for (int i = L; i <= R; i++) {
            if (i%d == 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35608
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        boolean isYes = false;
        for(int i =1 ; i<= b ; i++) {
            if(a * i % b == c) {
                isYes = true;
                break;
            }
        }

        if (isYes) {
            System.out.println("YES");
        } else {
            System.out.println("NO");

        }
    }
}

Measured memory_bytes: 22868
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		String S = next();
		char[] C = S.toCharArray();
		int[][] dp = new int[5005][5005];

		for(int i=N-1;i>=0;i--) {
			for(int j=N-1;j>=0;j--) {
				if(C[i] != C[j]) dp[i][j] = 0;
				else dp[i][j] = dp[i+1][j+1]+1;
			}
		}
		int res = 0;
		for(int i=0;i<N;i++) {
			for(int j=i+1;j<N;j++) {
				int now = Math.min(dp[i][j], Math.abs(j-i));
				res = Math.max(res, now);
			}
		}
		out.println(res);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 168480
N, M = map(int, input().split())
pSs = [list(map(str, input().split())) for _ in range(M)]

#%%

ACs = [False for _ in range(N)]
WAs = [0 for _ in range(N)]

for pS in pSs:
    problem = int(pS[0]) -1
    answer = pS[1]
    if ACs[problem] == True:
        continue
    else:
        if answer == "WA":
            WAs[problem] += 1
        else:
            ACs[problem] = True

num_WA = 0
for i, WA in enumerate(WAs):
    if ACs[i] == True:
        num_WA += WA

print(sum(ACs), num_WA)

Measured memory_bytes: 108192
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
map<long long,int> prime_factor(long long n){
	map<long long,int> ret;
	for(long long i = 2; i * i <= n; i++){
		while(n % i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n]++;
	return ret;
}
 
int main(){
	ll n,p;
	cin >> n >> p;
	map<ll,int> mp = prime_factor(p);
	ll ans = 1;
	for(auto i : mp){
		int j = i.second / n;
		REP(k,j) ans *= i.first;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    vi arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    ll dp[n];
    dp[0] = 0;
    dp[1] = llabs(arr[1] - arr[0]);

    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + llabs(arr[i] - arr[i - 1]), dp[i - 2] + llabs(arr[i] - arr[i - 2]));

    cout << dp[n - 1] << "\n";
}


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

#define int long long int

int32_t main()
{
  int n, k;
  cin>>n>>k;
  
  vector<int> arr(n);
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  if(k>=n)
  {
    cout<<"0";
  }
  else
  {
  	sort(arr.begin(), arr.end(), greater<int> ());
   	cout<<accumulate(arr.begin()+k, arr.end(), (int)0);
  }
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define MOD 1000000007
#define MAX 1000001

long long int fac[MAX], finv[MAX], inv[MAX];

void init(){
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    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 int combination(long long int n,long long int r){
    if(r<0||n<0){
        return 0;
    }
    if(n < r){
        return 0;
    }
    return (fac[n] * (finv[r] * finv[n-r] % MOD)) % MOD;
}
int main(){
    long long int x, y;
    scanf("%lld%lld", &x, &y);
    long long int ans = 0;
    init();
    if((x+y)%3 == 0){
        int a=x, b=0;
        while(2*a + b != y){
            a -= 2;
            b += 1;
        }
        ans = combination(a+b, a);
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int a, b, c;
    cin >> a >> b >>c;
    cout << a*b/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main()
{	
	int a,b;
	scanf("%d %d", &a, &b);
	if(a+b<24)
	{
		printf("%d", a+b);
	}
	else if(a+b==24)
	{
		printf("0");
	}
	else if(a+b>24)
	{
		printf("%d",(a+b)-24);
	}
}
	


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  cout<<(n+1)*n/2<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
string s1,s2;
int a[27]={0},b[27]={0};
int main()
{
    int i,j,k,f;
    cin >> s1 >> s2;
    for(i=0;i<s1.size();i++)
    {
        a[s1[i]-'a']++;
    }
    for(i=0;i<s2.size();i++)
    {
        b[s2[i]-'a']++;
    }
    f=0;
    sort(a,a+26);
    sort(b,b+26);
    for(i=0;i<26;i++)
    {
        if(a[i]!=b[i])
        {
            f=1;
            break;
        }
    }

    if(f==0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 776
c = [list(map(int, input().split())) for _ in range(3)]

b = c[0]
a = [0, c[1][0] - b[0], c[2][0] - b[0]]

flag = True
for i in range(3):
  for j in range(3):
    if c[i][j] != a[i] + b[j]:
      flag = False
      
print("Yes" if flag else "No")

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

int main(){
  int64_t A;
  long double B;
  cin >> A >> B;
  int64_t C=B*100+0.5;
  int64_t ans=A*C;
  ans/=100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xmod (int)(1e9+7)
using namespace std;

int n,t,dp[3005],ans;
pii a[3005];
bool used[3005];
int main(){
	scanf("%d%d",&n,&t);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+1+n);
	used[0]=true;
	for (int i=1;i<=n;i++){
		for (int j=t;j>=0;j--){
			if (j+a[i].x > t && used[j] && j != t){
				used[t]=true;
				dp[t]=max(dp[t],dp[j]+a[i].y);
			}
			else
			if (j+a[i].x <= t && used[j]){
				used[j+a[i].x]=true;
				dp[j+a[i].x]=max(dp[j+a[i].x],dp[j]+a[i].y);
			}
		}
	}
	for (int i=1;i<=t;i++){
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const A = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const sorted = A.sort((a,b)=>b-a)

const ans = _ => {
  let res = 0
  for (let i = 0; i < sorted.length; i++) {
    if(i%2===0){
      res += sorted[i]
    } else {
      res -= sorted[i]
    }
  }
  return res
}

console.log(ans())


Measured memory_bytes: 7500
using System;
using System.Linq;

namespace abc151a
{
    class Program
    {
        static void Main(string[] args)
        {

            string input = Console.ReadLine();

            string[] alpha = {"a","b","c","d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };

            int index = alpha.ToList().FindIndex(x => x == input);

            Console.WriteLine(alpha[index+1]);
        }
    }
}


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

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,k,A[300000],s[300000];
inline void deal(int x,int y)
{
	A[x]=y; s[y]=1;
}
int main()
{
	n=read(); k=read();
	if(k==1||k==n*2-1)
	{
		puts("No"); return 0;
	}
	else puts("Yes");
	if(n==2)
	{
		puts("1 2 3"); return 0;
	}
	if(k==2)
		deal(n,1), deal(n+1,2),
		deal(n+2,3), deal(n-1,4);
	else 
		deal(n,k), deal(n+1,k+1),
		deal(n+2,k-2), deal(n-1,k-1);
	for(int i=1,j=1;i<=2*n-1;i++) if(!A[i])
	{
		while(s[j]) j++;
		A[i]=j++;
	}
	for(int i=1;i<2*n;i++) printf("%d\n",A[i]);
	return 0;
}


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

using namespace std;

int main(){
    long long int x;
    cin >> x;
    long long int a=500,b=5;
    long long int ans = (x/500 )*1000LL ;
    int l = x/500;
    
    ans += ((x - (x/500)*500LL)/5 )*5LL;
    
 cout << ans;   
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0011&lang=jp

#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;

//テ」ツδ榲」ツつッテ」ツδュテ・ツョツ堙ァツセツゥ
#define ALL(v) (v).begin(),(v).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define SORT(x) sort(begin(x),end(x))
#define SELECT_SORT(x, n) sort(begin(x),begin(x)+n)
#define SWAP(type, a, b) do {type tmp = a; a = b; b = tmp;} while (0)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))

//テ・ツョツ堙ヲツ閉ー
#define INF 2000000000000
#define MAX 10

//DEBUGテァツ板ィ
#define BAR() cout << "----------------------------" << endl;
#define DUMP(v) (cerr << #v << ": " << v << endl)
#define PRINT(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

vector<int> amida;


int main()
{
	int w=0;
	cin >> w;
	amida.push_back(0);
	REP(i,1,w+1){
		amida.push_back(i);
	}
	
	int n=0;
	cin >> n;
	int a,b=0;
	while(n){
		scanf("%d,%d",&a,&b);
		SWAP(int, amida[a], amida[b]);
		n--;
	}
	
	REP(i,1,w+1){
		cout << amida[i] << endl;
	}
	
}

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

int main(){
   int A,B;
   cin >> A >> B;
   
    if(A == 1){
        if(B == 2)
            cout << 3 << endl;
        else
            cout << 2 << endl;
    }else if(A == 2){
        if(B == 1)
            cout << 3 << endl;
        else
            cout << 1 << endl;
    }else{
        if(B==1)
            cout << 2 << endl;
        else
        {
            cout << 1 << endl;
        }
         
    }
}

Measured memory_bytes: 256
import java.lang.Long.parseLong
import java.util.*

fun main(args:Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (N, K) = reader.readLine()!!.split(" ").map(String::toInt)
//    val S = reader.readLine()!!.split(" ").map(String::toInt).toIntArray()
//    val T = reader.readLine()!!.split(" ").map(String::toInt).toIntArray()
//    val mod = 1000000007
//    var ans = 1L

    var C = (N-1)*(N-2)/2

    if (K > C) {
        println(-1)
        return
    }
    var ans = mutableListOf<String>()

    for (n in 2 .. N) {
        ans.add("1 $n")
    }
    var k = 0
    for (i in 2 until N) {
        for (j in i+1..N) {
            if (C - K == k) break
            k++
            ans.add("$i $j")
        }
    }
    println(N-1+k)
    println(ans.joinToString("\n"))
}

Measured memory_bytes: 35880