akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int oc[3];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    for (char c: s) oc[c-'a'] ++;
    if (max(max(oc[0],oc[1]),oc[2]) <= min(min(oc[0],oc[1]),oc[2])+1) {
        cout << "YES";
        exit(0);
    }
    cout << "NO";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String,Integer> map = new HashMap<>();
		for (int i = 0 ; i < n ; i++) {
			String key = sc.next();
			if (map.keySet().contains(key)) map.put(key, map.get(key) + 1);
			else map.put(key, 1);
		}
		int m = sc.nextInt();
		for (int i = 0 ; i < m ; i++) {
			String key = sc.next();
			if (map.keySet().contains(key)) map.put(key, map.get(key) - 1);
			else map.put(key, -1);
		}
		int n2 = 0;
		for (int i = 0 ; i < map.size() ; i++) {
			int val = (int)map.values().toArray()[i];
			if (n2 < val) {
				n2 = val;
			}
		}
		System.out.println(n2);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> pmemo(101);
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        pmemo[p]++;
    }
    int mindif=10000;
    int minindex=0;
    for(int i=0;i<=101;i++){
        if(pmemo[i]>0) continue;
        int dif=abs(x-i);
        if(mindif>dif){
            mindif=dif;
            minindex=i;
        }
    }
    cout<<minindex<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n; // the number of nodes
vector<ll> dist; // distance from s
vector<vector<ll>> g; // adjacency list

void dfs(int v, int d, int p) {
  dist[v] = d;
  for (int nv : g[v]) {
    if (nv == p) { continue; } // skip parent
    dfs(nv, d+1, v);
  }
}

vector<ll> calcDist(int s) {
  dist.assign(n, 0); // reset
  dfs(s, 0, -1);
  return dist;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll u, v;
  cin >> n >> u >> v;
  --u; --v; // 0-indexed
  g.resize(n);

  rep(i, n-1) {
    ll a, b;
    cin >> a >> b;
    --a; --b; // 0-indexed
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<ll> dist_t = calcDist(u); // takahashi
  vector<ll> dist_a = calcDist(v); // aoki
  // Here, we want to find maximum distance where dist_t[i] < dist_a[i]
  ll ans = 0;
  rep(i, n) {
    if (dist_t[i] < dist_a[i]) {
      ans = max(ans, dist_a[i] - 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 12160
#include <stdio.h>

int main(void)
{
	int num[3];
	int i, j, tmp;
	
	for(i = 0;i < 3;i++){
		scanf("%d", &num[i]);
	}
	
	for(i = 0;i < 3;i++){
		for(j = 2;j > i;j--){
			if( num[j-1] > num[j] ){
				tmp  = num[j];
				num[j] = num[j-1];
				num[j-1] = tmp;
			}
		}
	}
	
	for(i = 0;i < 3;i++){
		printf("%d", num[i]);
		if( i != 2 ){
			printf(" ");
		}
		else{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

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

    Graph G(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }

    for (int i = 0; i < N; i++) {
        if ((int)G[i].size() % 2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 8520
#include<cstdio>
#include<queue>
using namespace std;
int n,i;
long long a[300010],f[300010],g[300010],s,ans;
priority_queue<long long>q;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=3*n;i++) scanf("%lld",&a[i]);
	for (i=1;i<=n;i++)
	{
		q.push(-a[i]);
		s-=a[i];
	}
	f[n]=s;
	for (i=n+1;i<=2*n;i++)//ending of the first half
	{
		long long x=q.top();
		q.pop();
		f[i]=f[i-1]-x-a[i];
		q.push(-a[i]);
	}
	while (!q.empty()) q.pop();
	s=0;
	for (i=2*n+1;i<=3*n;i++)
	{
		q.push(a[i]);
		s+=a[i];
	}
	g[2*n+1]=s;
	for (i=2*n;i>=n+1;i--)
	{
	    q.push(a[i]);
		long long x=q.top();
		q.pop();
		g[i]=g[i+1]-x+a[i];	
	}
	ans=f[n]+g[n+1];
	for (i=n+1;i<=2*n;i++)
	{
		ans=min(ans,f[i]+g[i+1]);
	}
	printf("%lld\n",-ans); 
}

Measured memory_bytes: 6900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] tall_array = br.readLine().split(" ");
        int tmp = 0;
        long result = 0;

        for(int i = 0; i < N; i++) {

            int target = Integer.parseInt(tall_array[i]);

            if(target < tmp) {
                result += tmp - target;
            } else {
                tmp = target;
            }
        }

        pw.println(result);
        br.close();
        pw.close();
    }
}

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

int main()
{
  int n;
  cin >> n;
  int a[n], dp[n]={};
  for(int i=0; i<n; i++) cin >> a[i];
  dp[1] = abs(a[1]-a[0]);
  if(n>2) dp[2] = min(dp[1]+abs(a[2]-a[1]), abs(a[2]-a[0]));
  for(int i=2; i<n; i++) dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
  cout << dp[n-1];
  return 0;
}

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

int main() {
  ll A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  vector<ll> mod(5);
  bool zero = false;
  vector<ll> amari(1,100000007);
  ll time = 0;
  mod.at(0) = A%10;
  mod.at(1) = B%10;
  mod.at(2) = C%10;
  mod.at(3) = D%10;
  mod.at(4) = E%10;
  time = A/10 + B/10 + C/10 + D/10 + E/10;
  time *= 10;
  rep(i,5){
    if(mod.at(i) == 0){
      continue;
    }
    else{
      amari.push_back(mod.at(i));
      time += 10;
      zero = true;
    }
  }
  sort(amari.begin(),amari.end());
  if(zero){
    time = time - 10+amari.at(0);} 
    cout << time << endl;
}
  
  
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int i;
    vector <int> v(n);
    for(i = 0; i < n; i ++)
    {
    	cin >> v[i];
    }

    sort(v.begin(), v.end());

    if(n % 2 == 1)
    {
    	cout << "0" << endl;
    }
    else
    {
    	int mid = n / 2 - 1;
    	cout << v[mid + 1] - v[mid] << endl;
    }
}

Measured memory_bytes: 640
// Problem : C - Triangular Relationship
// Contest : AtCoder - AtCoder Regular Contest 102
// URL : https://atcoder.jp/contests/arc102/tasks/arc102_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n , k;
	cin >> n >> k;
	if(k%2==1)
		cout<<(n/k)*(n/k)*(n/k);
	else
	{
		ll t=(n+k/2)/k;
		cout<<((n/k)*(n/k)*(n/k))+(t*t*t);
	}
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

 int A,B,C;

 int main(){

  cin >> A >> B >> C;

  if ((A * C) <= B) cout << C << endl;
   else if ((A * C) > B) cout << B / A << endl; 
   else if (A < B) cout << "0" << endl;


 return 0;
}




Measured memory_bytes: 256
# l,r,d =map(int, input().split()))
n = int(input())
d = list(map(int, input().split()))

# s = [map(int, input()) for i in range(3)]
ans =0

for i in range(0,n):
  
    for j in range(i+1,n):
       
        ans += d[i]*d[j]

print (ans)

Measured memory_bytes: 9172
def create_list(col):
    result = []

    for _ in range(col):
        result.append(list(map(int,input().split())))
    return result

n,m,l = map(int,input().split())
a_list = create_list(n)
b_list = create_list(m)
ans_list = []

for i in range(n):
    temp_list =[]
    for j in range(l):
        ans = 0
        for k in range(m):
            ans += a_list[i][k]*b_list[k][j]
        temp_list.append(str(ans))
    ans_list.append(temp_list)

for ans in ans_list:
    print(' '.join(ans))



Measured memory_bytes: 7044
n,m = map(int,input().split())
a = []
for i in range(m):
    x,y = map(int,input().split())
    a.append([x,y])
b = a.copy()
c = sorted(b, key=lambda x:(x[0],x[1]))
d = [{}for i in range(10**5+1)]
count = 1
s = '%d' % c[0][0]
s = s.zfill(6)
s2 = '%d' % count
s2 = s2.zfill(6)

d1 = {c[0][1]:s+s2}
for i in range(1,m):
    if c[i][0] == c[i-1][0]:
        count +=1
        s2 = '%d' % count
        s2 = s2.zfill(6)
        d1[c[i][1]] = s+s2
    else:
        d[c[i-1][0]] = d1
        count = 1
        s = '%d' % c[i][0]
        s = s.zfill(6)
        s2 = '%d' % count
        s2 = s2.zfill(6)
        d1 = {c[i][1]:s+s2}
d[c[-1][0]] = (d1)
for i in range(m):
    d2 = d[a[i][0]]
    print(d2.get(a[i][1]))

Measured memory_bytes: 56136
#include<iostream>
#include<cstdio>

int main(void) {
	int H, A, AA;
	using namespace std;
	cin >> H >> A;

	AA = (H / A);
	if (AA != 0) {
		if (H % A != 0) {



			AA += 1;
		}
	}
	else {
		AA +=1;
	}
	cout << AA << endl;

}

Measured memory_bytes: 256
program bomber
  implicit none
  integer :: h, w, m, nx, ny, mx = 0, my = 0, d, i
  integer, dimension(300000) :: x = 0, y = 0, a = 0, b = 0
  logical, dimension(300000) :: ux = .false., uy = .false.
  read(*,*) h, w, m
  do i = 1, m
    read(*,*) x(i), y(i)
    a(x(i)) = a(x(i)) + 1
    b(y(i)) = b(y(i)) + 1
  end do
  nx = maxval(a(1:h))
  ny = maxval(b(1:w))
  do i = 1, h
    if (a(i) == nx) then
      ux(i) = .true.
      mx = mx + 1
    end if
  end do
  do i = 1, w
    if (b(i) == ny) then
      uy(i) = .true.
      my = my + 1
    end if
  end do
  d = mx * my
  do i = 1, m
    if (ux(x(i)) .and. uy(y(i))) d = d - 1
  end do
  write(*,'(i0)') nx + ny - merge(1, 0, d == 0)
end program bomber

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

class Program
{
    static long Mod = 1000000007;

    static Dictionary<int,int> Factorize(int M)
    {
        Dictionary<int, int> r = new Dictionary<int, int>();
        while (M % 2 == 0)
        {
            M = (M - (M % 2)) / 2;
            if (r.ContainsKey(2))
                r[2]++;
            else
                r.Add(2, 1);
        }
        for(int i = 3; i <= M; i += 2)
        {
            while (M % i == 0)
            {
                M = (M - (M % i)) / i;
                if (r.ContainsKey(i))
                    r[i]++;
                else
                    r.Add(i, 1);
            }
        }
        return r;
    }
        
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int M = int.Parse(s[1]);

        var r = Factorize(M);


        int maxduality;
        if (r.Count > 0)
            maxduality = r.Max(x => x.Value);
        else
            maxduality = 1;

        long[][] dp = new long[maxduality + 1][];
        for (int i = 0; i <= maxduality; i++)
            dp[i] = new long[N + 1];

        for (int i = 0; i <= N; i++)
        {
            dp[1][i] = i;
            dp[0][i] = i;
        }
        for (int i = 0; i <= maxduality; i++)
        {
            dp[i][1] = 1;
            dp[i][0] = 1;
        }
        for(int i = 2; i <= maxduality; i++)
        {
            for (int j = 2; j <= N; j++)
            {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % Mod;
            }
        }
        long q = 1;
        if (r.Count > 0)
            foreach (var i in r)
            q = (q * dp[i.Value][N]) % Mod;
        Console.WriteLine(q);
    }
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int getdist(pair<int, int> a,pair<int, int> b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main(){
    int N,M;
    int bufx,bufy;
    int dist;
    int mind;
    int res;

    scanf("%d%d",&N,&M);
    vector<pair<int, int> > st(N),ch(M);

    for(int i=0;i<N;i++){
        scanf("%d%d",&bufx,&bufy);
        st[i] = make_pair(bufx,bufy);
    }
    for(int i=0;i<M;i++){
        scanf("%d%d",&bufx,&bufy);
        ch[i] = make_pair(bufx,bufy);
    }

    for(int i=0;i<N;i++){
        mind = getdist(st[i],ch[0]);
        res = 0;
        if(M==1){
            printf("%d\n",res+1);
            continue;
        }
        for(int j=1;j<M;j++){
            dist = getdist(st[i],ch[j]);
            if(mind>dist){
                mind = dist;
                res = j;
            }
        }
        printf("%d\n",res+1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>

std::vector<int> G;

int insertion_sort(int a[], int n, int g){
    int cnt = 0;
    for(int i = g; i < n; i++){
        int key = a[i];
        int j = i - g;
        while(j >= 0 && a[j] > key){
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j+g] = key;
    }
    return cnt;
}

int shell_sort(int a[], int n){
    int cnt = 0;
    //how to prepare for the array G
    for(int h = 1; ;){
        if(h > n) break;
        G.push_back(h);
        h = 3 * h + 1;
    }

    for(int i = G.size()-1; i >= 0; i--){
        cnt += insertion_sort(a, n, G[i]);
    }

    return cnt;
}

int main(void){
    int n;
    std::cin >> n;

    int a[1000100];
    for(int i = 0; i < n; i++){
        std::scanf("%d", &a[i]);
    }

    int count = shell_sort(a, n);

    std::cout << G.size() << std::endl;

    for(int i = G.size()-1; i >= 0; i--){
        std::printf("%d", G[i]);
        if(i){
            std::cout << " ";
        }
    }
    std::printf("\n");

    std::cout << count << std::endl;

    for(int i = 0; i < n; i++) std::printf("%d\n", a[i]);

    return 0;
}


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

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

string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	int mi=1010;
	FOR(i,S.size()-T.size()+1) {
		int dif=0;
		FOR(j,T.size()) dif+=S[i+j]!=T[j];
		mi=min(mi,dif);
	}
	cout<<mi<<endl;
}


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


Measured memory_bytes: 3616
#include <cstdio>
typedef long long ll;
int mod = 1e9+7;

ll inv(ll a, ll mo) {
	a %= mo;
	ll v[] = { 0, 1, mo };
	ll u[] = { 1, 0, a };
	while (v[2] != 1) {
		if (v[2] < u[2]) {
			ll tmp[] = {v[0], v[1], v[2]};
			v[0] = u[0];v[1] = u[1];v[2] = u[2];
			u[0] = tmp[0];u[1] = tmp[1];u[2] = tmp[2];
			continue;
		}
		ll coe = v[2] / u[2];
		for (int i = 0; i < 3; ++i) {
			v[i] = v[i] - u[i] * coe;
		}
	}
	return v[0] < 0 ? v[0] + mo : v[0];
}

int main() {
	ll X, Y;
	scanf("%lld%lld", &X, &Y);

	if ((X + Y) % 3 != 0 || X < (X+Y)/3 || Y < (X+Y)/3) {
		printf("0\n");
		return 0;
	}

	ll a = (X+Y) / 3;
	ll b = X - (X+Y) / 3;

	ll ans1 = 1;
	ll ans2 = 1;

	for (int i = a; i > a - b; i--) {
		ans1 *= i;
		ans1 %= mod;
	}
	for (int i = b; i > 0; i--) {
		ans2 *= i;
		ans2 %= mod;
	}

	ans2 = inv(ans2, mod);

	ll ans = ans1 * ans2 % mod;

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

	return 0;
}

Measured memory_bytes: 128
from collections import deque

def bfs(maze, y, x, h, w):
  queue = deque([[y, x]])
  visited = list([-1] * w for i in range(h))
  visited[y][x] = 0
  num = 0

  while queue:
    a, b = queue.popleft()
    for i, j in ([0, 1], [0, -1], [1, 0], [-1, 0]):
       new_y, new_x = a + i, b + j
       if(new_y >= 0 and new_x >= 0 and new_y < h and new_x < w):
        if(maze[new_y][new_x] == '.' and visited[new_y][new_x] == -1):
          visited[new_y][new_x] = visited[a][b] + 1
          num = max(num, visited[new_y][new_x])
          queue.append([new_y, new_x])
  return num
  
if __name__ == '__main__':
  y, x = map(int, input().split())
  maze = list(input() for i in range(y))
  num = -1
  for i in range(y):
    for j in range(x):
      if(maze[i][j] == '.'):
        num = max(num, bfs(maze, i, j, y, x))

  print(num)



Measured memory_bytes: 3316
import java.util.Scanner;

class Main{
	public static void main(String[] main) {
		Scanner sc=new Scanner(System.in);

		int a=sc.nextInt();
		if(a<1200) {
			System.out.println("ABC");
		}
		else if(a>=1200 && a<2800) {
			System.out.println("ARC");
		}

		else if(a>=2800) {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 22352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n;
    cin >> n;
    int dp[n + 5][3] = {};
    f1(n) {
    	fr(j,0,3) {
    		int x;
    		cin >> x;
    		fr(k,0,3) {
    			if (k ^ j) {
    				dp[i][j] = max(dp[i][j], dp[i - 1][k] + x);
    			}
    		}
    	}
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int N, M;
  cin >> N >> M;
  char a = '0' + N;
  char b = '0' + M;
  string A(N, b);
  string B(M, a);
  if (A > B) {
    cout << B << endl;
  } else {
    cout << A << 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 < (n); ++i)

const int MAX=INT_MAX;

int main(){
  int n;
  std::cin >> n;
  std::vector<int> cnt(n+1,0);
  rep(i,n+1)cnt[i]=i;

  int num[3]={1,6,9};
  for (int i = 2; i >= 1; i--) {

    std::vector<int> exp;
    int nmax=num[i];
    while (nmax<=n) {
      exp.push_back(nmax);
      nmax*=num[i];
    }

    // for (int num : exp) {
    //   std::cout << num << ' ';
    // }
    // std::cout << "" << '\n';


    for (int j = exp.size()-1; j >=0 ; j--) {
      int now=exp[j];
      // std::cout << now << '\n';
      for (int k = now; k <=n ;k+=1) {
        cnt[k]=min(cnt[k],cnt[k-now]+1);
        // std::cout << " " <<k<<" : "<< cnt[k]<<'\n';
      }

    }

    // for (int num : cnt) {
    //   std::cout << num << ' ';
    // }
    // std::cout << "" << '\n';

  }

  std::cout << cnt[n] << '\n';


  return 0;
}


Measured memory_bytes: 640
using System;
class TEST
{
    public static void Main()
    {
        string value = Console.ReadLine();

        switch (value.Substring(value.Length-1, 1))
        {
            case "2":
            case "4":
            case "5":
            case "7":
            case "9":
                Console.WriteLine("hon");
                break;
            case "0":
            case "1":
            case "6":
            case "8":
                Console.WriteLine("pon");
                break;
                default:
                Console.WriteLine("bon");
                break;

        }
    }

}

Measured memory_bytes: 25844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int X[M];
  vector<int> X_;
  for(int i=0;i<M;i++) cin >> X[i];
  for(int i=0;i<M;i++) X_.push_back(X[i]);
  sort(X_.begin(),X_.end());
  vector<int> length;
  for(vector<int>::iterator e=X_.begin()+1;e!=X_.end();e++){
    length.push_back(*e-*(e-1));
  }
  sort(length.begin(),length.end());
  vector<int>::iterator e=length.begin();
  int ans=0;
  for(int i=0;i<M-N;i++){
    ans+=*e;
    e++;
  }
  cout << ans;
}


Measured memory_bytes: 1784
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(' ');
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
    var ans = "win";
	if(a + b + c > 21){
      ans = "bust";
    }
	console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
h, w, k = map(int, input().split())
dp = [1] + [0] * (w - 1)

facts = [1, 1, 2, 3, 5, 8, 13, 21, 34]

for _ in range(h):
    ndp = [0] * w
    for b in range(w):
        if b > 0:
            ndp[b] += dp[b - 1] * facts[b - 1] * facts[w - b - 1]
        ndp[b] += dp[b] * facts[b] * facts[w - b - 1]
        if b < w - 1:
            ndp[b] += dp[b + 1] * facts[b] * facts[w - b - 2]
        ndp[b] %= 1000000007
    dp = ndp

print(dp[k - 1])


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

int belong_group_num[100001] = {0};
int group_member_cnt[100001] = {0};

vector <vector <int>> frineds_group;

void make_group(const int person, const int group_num, const vector <vector<int>> &friends_link)
{
  if (belong_group_num[person] != 0) return;

  belong_group_num[person] = group_num;
  group_member_cnt[group_num]++;
  for (int i = 0; i < friends_link[person].size(); i++) {
    int next_member = friends_link[person][i];
    make_group(next_member, group_num, friends_link);

  }
}

int main(void) {
  int N, M, K;
  cin >> N >> M >> K;
  vector <vector<int>> friends_link(N+1);
  vector <vector<int>> blocks(N+1);

  for (int i = 1; i <= N; i++) {
    belong_group_num[i] = 0;
    group_member_cnt[i] = 0;
  }

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    friends_link[A].push_back(B);
    friends_link[B].push_back(A);
  }

  for (int i = 0; i < K; i++) {
    int A, B;
    cin >> A >> B;
    blocks[A].push_back(B);
    blocks[B].push_back(A);
  }

  int group_cnt = 0;
  frineds_group.clear();
  for (int i = 1; i <= N; i++) {
    if (belong_group_num[i] != 0) continue;

    group_cnt++;
    make_group(i, group_cnt, friends_link);
  }

  // output answer
  for (int i = 1; i <= N; i++) {
    int ans = group_member_cnt[belong_group_num[i]];
    ans -= friends_link[i].size(); // 直接のお友達を引く
    ans -= 1; // 自分自身を引く

    // blockしている人を引く
    for (int j = 0; j < blocks[i].size(); j++) {
      int block_member = blocks[i][j];
      if (belong_group_num[block_member] == belong_group_num[i]) {
        ans--;
      }
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N,A,B; cin >> N >> A >> B;

    vector<int>vec(3);

    REP(i,3) vec[i]=0;

    REP(i,N){
        int x; cin >> x;

        if(x<=A){
            vec[0] ++;
        }else if(B<x){
            vec[2] ++;
        }else{
            vec[1] ++;
        }
    }
    int cnt=0;
    while(true){

        
        if(vec[0]>0&&vec[1]>0&&vec[2]){
            cnt ++;
        }else{
            break;
        }
        vec[0]--;
        vec[1]--;
        vec[2]--;
    }

    cout << cnt <<endl;
}

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

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;

    vector<int> w(N), v(N);
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1));

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            if (w[i - 1] <= j)
                dp[i][j] =
                    max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    cout << dp[N][W];

    return 0;
}


Measured memory_bytes: 83168
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e9
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	while (true) {
		int n, p;
		cin >> n >> p;
		if (n == 0) return 0;
		int geko[51] = {};
		int now = p;
		for (int i = 0;; i++) {
			if (now == 0) {
				now = geko[i%n];
				geko[i%n] = 0;
			}
			else {
				geko[i%n] += 1;
				now--;
				if (geko[i%n] == p) {
					cout << i%n << endl;
					break;
				}
			}
		}
	}
}


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

int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if (a==0) cout<<1;
    if (b==0) cout<<2;
    if (c==0) cout<<3;
    if (d==0) cout<<4;
    if (e==0) cout<<5;


}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int dp[50][50];
vector<pii> cl[50];

int main(){
	int n=read(),m=read(),l=read();
	REP(i,m){
		int d=read(),a=read()-1,k=read(),t=read();
		cl[d*n+a+k].PB(MP(d*n+a,t));
	}
	REP(i,5*n+1){
		FOR(u,1,l+1){
			for(auto c:cl[i])
				dp[i][u]=max(dp[i][u],dp[c.first][u-1]+c.second);
			dp[i+1][u]=dp[i][u];
		}
	}
	cout<<dp[5*n][l]<<endl;
}

Measured memory_bytes: 3232
s = input()
top = ''
n = int(input())
isReverse = False
for i in range(n):
    Q = input().split()
    if(Q[0] == '1'):
        isReverse = not isReverse
    else:
        if Q[1] == '1':
            if isReverse: s += Q[2]
            else: top += Q[2]
        else:
            if isReverse: top += Q[2]
            else: s += Q[2]
if isReverse: s = s[::-1] + top
else: s = top[::-1] + s
print(s)


Measured memory_bytes: 4172
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var nums = new List<int>();
        nums.Add(int.Parse(Console.ReadLine()));

        while (true)
        {
            if (nums.Last() % 2 == 0)
            {
                nums.Add(nums.Last() / 2);
            }
            else
            {
                nums.Add(nums.Last() * 3 + 1);
            }


            for (int i = 0; i < nums.Count; i++)
            {
                for (int j = i + 1; j < nums.Count - 1; j++)
                {
                    if (nums[i] == nums[j])
                    {
                        Console.WriteLine(j + 1);
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

// 最大公約数
lint gcd(lint a, lint b) {
    // 引数の一方が 0 なら他方の値を返す
    return b ? gcd(b, a%b) : a;
}

int main(void) {
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    repeat(i, n) cin >> p[i].fst >> p[i].snd;
    
    auto normalized_line = [](pair<int, int> p, pair<int, int> q) {
        tuple<int, int, int> t;
        int x1 = p.fst, y1 = p.snd;
        int x2 = q.fst, y2 = q.snd;
        int a = y1 - y2;
        int b = x2 - x1;
        int c = x1 * y2 - x2 * y1;
        if (a < 0) {
            a = -a; b = -b; c = -c;
        }
        int g = gcd(a, b); g = gcd(g, c);
        a /= g; b /= g; c /= g;
        t = tuple<int, int, int>{a, b, c};
        return t;
    };
    
    map<tuple<int, int, int>, set<pair<int, int>>> mp;
    
    repeat(i, n) {
        repeat_from(j, i + 1, n) {
            auto t = normalized_line(p[i], p[j]);
            mp[t].insert(p[i]);
            mp[t].insert(p[j]);
        }
    }
    
    lint MOD = 998244353LL;
    lint ans = 1;
    rep(n) {
        (ans *= 2) %= MOD;
    }
    ((ans += MOD) -= 1) %= MOD;
    ((ans += MOD) -= n) %= MOD;
    
    for(auto e: mp) {
        lint t = 1;
        rep(e.snd.size()) {
            (t *= 2) %= MOD;
        }
        ((t += MOD) -= 1) %= MOD;
        ((t += MOD) -= e.snd.size()) %= MOD;
        ((ans += MOD) -= t) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
(function () {
   var input = '';

   function main () {
     var a, b, nums,
         TSUBO = 3.305785;
     
     nums = input[0].split(' ');
     a = parseInt(nums[0], 10);
     b = parseInt(nums[1], 10);
     
     console.log(a * b / TSUBO);
   }

   process.stdin.resume();
   process.stdin.setEncoding('utf8');
   process.stdin.on('data', function (chunk) {
     input += chunk;
   });

   process.stdin.on('end', function () {
     input = input.split('\n');
     main();
   });
}());

Measured memory_bytes: 7652
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    ans = 0
    for i in range(len(S)//2):
        if S[i] != S[len(S)-i-1]:
            ans += 1
    return ans


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6852
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h) cin >> a[i];

    queue<P> que;
    vector<vector<bool>> used(h, vector<bool>(w, false));
    REP(i, h) REP(j, w) if(a[i][j] == '#') que.push(make_pair(i, j)), used[i][j] = true;

    int ans = -1;
    while(!que.empty())
    {
        queue<P> next;
        while(!que.empty())
        {
            auto cur = que.front();
            que.pop();
            if(cur.first < h-1 && !used[cur.first + 1][cur.second]) next.push(make_pair(cur.first + 1, cur.second)), used[cur.first+1][cur.second] = true;
            if(cur.first > 0 && !used[cur.first - 1][cur.second]) next.push(make_pair(cur.first - 1, cur.second)), used[cur.first-1][cur.second] = true;
            if(cur.second < w-1 && !used[cur.first][cur.second + 1]) next.push(make_pair(cur.first, cur.second + 1)), used[cur.first][cur.second+1] = true;
            if(cur.second > 0 && !used[cur.first][cur.second - 1]) next.push(make_pair(cur.first, cur.second - 1)), used[cur.first][cur.second-1] = true;
        }
        que = next;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9856
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> d = new HashMap<>();
        for (int i = 0 ; i < n ; i++) {
            int D = sc.nextInt();
            if (d.containsKey(D)) {
                d.put(D, d.get(D) + 1);
            } else {
                d.put(D, 1);
            }
        }
        int m = sc.nextInt();
        Map<Integer, Integer> t = new HashMap<>();
        for (int i = 0 ; i < m ; i++) {
            int D = sc.nextInt();
            if (t.containsKey(D)) {
                t.put(D, t.get(D) + 1);
            } else {
                t.put(D, 1);
            }
        }

        for (Integer num : t.keySet()) {
            if (d.containsKey(num) && d.get(num) >= t.get(num)) {

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

}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 998244353 ;
const double PI = acos(-1);

int n,i,j,k,t;
int a[100002][3];
int dp[100002][3];


int main(){
    scanf("%d", &n);
    for(i=1;i<=n;++i)
        scanf("%d %d %d", a[i], a[i]+1, a[i]+2);
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(i=1;i<=n;++i){
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
	return 0;
}

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

long long int N,A,B;

int main()
{
    scanf("%d%d%d",&N,&A,&B);
    long long int AA = A * (N - 1) + B;
    long long int BB = B * (N - 1) + A;
    printf("%lld\n",max((long long int)0,BB - AA + 1));
}



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

a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,10**6+1):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k+1):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Measured memory_bytes: 48548
#abc080d

N,C=map(int,raw_input().split())
l=[[0 for i in xrange(C)] for j in xrange(10**5)]
for i in xrange(N):
 s,t,c=map(int,raw_input().split())
 s-=1
 for j in xrange(s,t):
  l[j][c-1]=1

res=0
for i in xrange(10**5):
 if sum(l[i])>res:
  res=sum(l[i])
print res


Measured memory_bytes: 40580
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n;
map <int,int> mp;
int main(){
	cin>>n;
	int cnt=0;
	while (n--){
		int x;cin>>x;
		if (!mp[x]) cnt++;
		mp[x]++;
	}
	printf("%d",mp.size()%2==1?mp.size():mp.size()-1);
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int max_element(vector<int> cnt){
    int max = cnt[0];
    int idx = 0;
    for(int i = 0; i < cnt.size();i++){
        if(max < cnt[i]){
            max = cnt[i];
            idx = i;
        }
    }
    return idx;
}
int main(){
    int N;
    cin >> N;
    int num;
    vector<int> cnt(N,0);//1~Nに対応する配列。添え字が-1なので注意
    for(int i = 0; i < N; i++){
        num = i + 1; 
        while(num % 2 == 0){
            num /= 2;
            cnt[i]++;
        }
    }
    cout << max_element(cnt)+1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		
		char[] words = new char[6];
		for (int i=0;i<6;i++)
		{
			words[i] = s.charAt(i);
		}

		if (
			words[2]==words[3]&&
			words[4]==words[5]&&
			words[0]!=words[2]&&
			words[0]!=words[4]&&
			words[1]!=words[2]&&
			words[1]!=words[4]&&
			words[0]!=words[1]
			)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<b;i--)

int main() {
	int N;
	cin >> N;
	int W[200];
	rep(i, 0, N)cin >> W[i];
	int res = 100000;
	rep(i, 0, N) {
		int l = 0, r = 0;
		rep(j, 0, i+1)l += W[j];
		rep(j, i+1, N)r += W[j];
		//cout << abs(l - r) << endl;
		res = min(res, abs(l - r));
	}
	cout << res << endl;
}


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

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int h, w;
    std::cin >> h >> w;

    if (h <= 1 || w <= 1) {
        std::cout << 1;
        return 0;
    }

    int64_t ans = 1LL * h * w;

    std::cout << (ans + 1) / 2;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)

//=========================

void run_test() {
	int x, y; cin >> x >> y;
    int a = (4 * x - y) / 2;
    int b = x - a;
    if(a >= 0 && b >= 0 && 2 * a == 4 * x - y) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int t = 1, _t; cin >> _t; while(t <= _t) { cout << "Case #" << t++ << ": "; run_test(); }
	// int t; cin >> t; while(t--) run_test();
	run_test();
	return 0;	
}



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

const long long MOD = 1000000007;

long  long myPow(long long x,long long n){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % MOD, n / 2);
  else
    return x * myPow(x, n - 1) % MOD;
}

void solve(long long N, long long K){
    long long ans =0;
    long long dp[K] = {};
    for(int i=K;i>0;i--){
        int num = K/i;
        long long temp =0;
        temp += myPow(num,N);
        temp %= MOD;
        for(int j=2;j<=num;j++){
            temp =temp-  dp[i*j-1] +MOD;
            temp%=MOD;
        }
        dp[i-1] = temp;
        ans += temp *i;
        ans %= MOD;
        // cerr << "i=" << i << "val =" << dp[i-1] << endl;
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

int main() {
	vector<int> t(3);
	for (int i = 0; i < 3; i++)
		cin >> t.at(i);

	sort(t.begin(), t.end());
	if (t[0] == 5 && t[1] == 5 && t[2] == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
S = input()
ok = True
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'L':
            ok = False
            break
    else:
        if S[i] == 'R':
            ok = False
            break
if ok:
    print("Yes")
else:
    print("No")

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

int main() {
  int a, b, c, d;
    cin >> a;

  if (a == 0 ){
    cout <<  0  << endl;
  }
  else if (a == 1 ){
    cout <<  1  << endl;
  }
    else if (a == 10 ){
    cout <<  1  << endl;
  }
    else if (a == 11 ){
    cout <<  2  << endl;
  }
    else if (a == 100 ){
    cout <<  1  << endl;
  }
    else if (a == 101 ){
    cout <<  2  << endl;
  }
    else if (a == 110 ){
    cout <<  2  << endl;
  }
    else if (a == 111 ){
    cout <<  3  << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, l, sum;
  sum = 0;
  vector<int> v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> l;
    v.push_back(l);
  }
  sort(v.begin(), v.end());
  for(int i=0;i<n-1;i++){
    sum += v[i];
  }
  if(sum > v[n-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256