akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String... args) {
	  Scanner sc = new Scanner(System.in);
	  String s = sc.next();
	  if (s.contains("a") && s.contains("b") && s.contains("c")) {
		  System.out.println("Yes");
	  } else {
		  System.out.println("No");
	  }
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void solve(){
ll n,k,r,p,s;
cin>>n;
cin>>k>>r>>s>>p;
string str1,str2;
cin>>str1;

//cin>>str1;
map<char,pair<ll,char>>m;
m['r']={p,'p'};
m['s']={r,'r'};
m['p']={s,'s'};
map<char,ll>mm;
mm['r']=r;
mm['s']=s;
mm['p']=p;

ll ans=0;
for(ll i=0;i<n;i++){
    char nw=str1[i];
    if(i-k>=0){
        if(m[nw].ss==str2[i-k]){
          // ans+=mm[nw];
           str2.pb('x');

        }
        else{ans+=m[nw].ff;
        str2.pb(m[nw].ss);
        }
    
    }
    else {
        ans+=m[nw].ff;
        str2.pb(m[nw].ss);
    }

}
//cout<<str2<<endl;
cout<<ans;
}

int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
     cout<<endl;
    }
    return 0;
}


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (unsigned i = (a); i <= (b); ++i)
#define per(i, a, b) for (unsigned i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

L TempVar(L h, L s, L t) {
  if (h > 0) { return -s * h; }
  else { return -t * h; }
}


int main(int argc, char const *argv[]) {
  L n = kMax4, m = kMax4;
  L ans = 0;
  VL v;
  for (unsigned i = 0; i < 3; i++) {
    L a;
    cin >> a;
    if (a < n) { n = a; }
  }
  for (unsigned i = 0; i < 2; i++) {
    L a;
    cin >> a;
    if (a < m) { m = a; }
  }
  cout << n + m - 50 << "\n";
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

class UnionFind {
  public:
  // 親の番号を格納。ルートだった場合は-(その集合のサイズ)
  vector<ll> parents;

  UnionFind(ll N) {
    parents = vector<ll>(N, -1);
  }

  // iがどのグループに属しているか
  ll root(ll i) {
    if (parents[i] < 0) {
      return i;
    } else {
      return parents[i] = root(parents[i]);
    }
  }

  // iが属しているグループの大きさ
  ll size(ll i) {
    return -parents[root(i)];
  }

  // root(a)とroot(b)を接続する
  bool connect(ll a, ll b) {
    ll rootA = root(a);
    ll rootB = root(b);
    if (rootA == rootB) {
        return false;
    } else {
      // 大きいほう(a)に小さいほう(b)をくっつける
      // 大小が逆の場合はスワップ
      if (size(rootA) < size(rootB)) {
        swap(rootA, rootB);
      }

      // aグループのサイズを増やす
      parents[rootA] += parents[rootB];
      // bの親をaのルートに変更する
      parents[rootB] = rootA;

      return true;
    }
  }

};

int main() {
  ll N, K, L;
  cin >> N >> K >> L;
  UnionFind uni(N);
  for (ll i = 0; i < K; i++) {
    ll l, r;
    cin >> l >> r;
    uni.connect(l-1, r-1);
  }
  UnionFind uniAir(N);
  for (ll i = 0; i < L; i++) {
    ll l, r;
    cin >> l >> r;
    uniAir.connect(l-1, r-1);
  }

  map<string, ll> connectivies;
  for (ll i = 0; i < N; i++) {
    std::stringstream ss;
    ss << uni.root(i) << '-' << uniAir.root(i);
    string s = ss.str();
    connectivies[s]++;
  }
  for (ll i = 0; i < N; i++) {
    std::stringstream ss;
    ss << uni.root(i) << '-' << uniAir.root(i);
    string s = ss.str();
    cout << connectivies[s];
    if (i != N-1) {
      cout << ' ';
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 23680
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scan = new Scanner(System.in);
      int n, m, i = 0, j = 0;

      n = Integer.parseInt(scan.next());
      String s[] = new String[n];

      while(i < n){
        s[i] = scan.next();
        i = ++i;
      }

      m = Integer.parseInt(scan.next());
      String t[] = new String[m];
      i = 0;
      while(i < m){
        t[i] = scan.next();
        i = ++i;
      }

      int count[] = new int[n];

      for(i = 0; i < n; i++){
        count[i] = 0;
        for(j = 0; j < n; j++){
          if(s[i].equals(s[j])){
            count[i] = ++count[i];
          }
        }
        for(j = 0; j < m; j++){
          if(s[i].equals(t[j])){
            count[i] = --count[i];
          }
        }
      }

      for(i = 0; i < n-1; i++){
        if(count[i] > count[i+1]){
          count[i+1] = count[i];
        }
      }
      if(count[n-1]>0){
        System.out.println(count[n-1]);
      }else{
        System.out.println(0);
      }
    }
    catch (Exception e) {

    }
  }
}


Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
#define mod 1000000007
int  exist[26]={};

int main(){

int N;
cin>>N;
/* 
long long dp[N+1][N+1]={};
dp[0][0]=1;
for(int i=1;i<=N;i++){
dp[i][0]=1;
    for(int k=1;k<=i;k++){
        dp[i][k]=dp[i-1][k]+dp[i-1][k-1];
    }
}
*/
char s[N];
map<char,int>c;
for(int i=0;i<N;i++){
    cin >>s[i];
    exist[s[i]-'a']++;
    c.insert(make_pair(s[i],i));
}
long long ans=1;

auto iter=c.begin();
//各文字について0~出現回数通り選ぶことができるので
while(iter !=c.end()){
ans*=exist[iter->first-'a']+1;
if(ans>=mod){
    ans%=mod;
}
iter++;
}
cout<<ans-1<<endl;


return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int n, m;
    while(cin >> n >> m, n || m){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(i + 1);
        }
        set<int>::iterator it = s.begin();
        while(s.size() > 1){
            for(int i = 0; i < m - 1; ++i){
                it++;
                if(it == s.end()) it = s.begin();
            }
            s.erase(it++);
            if(it == s.end()) it = s.begin();
        }
        
        cout << *(s.begin()) << endl;
    }
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;

vector<int>a;

bool rec(int now,int sum){
        if(sum==0)return true;
        else if(now==a.size()||sum<0)return false;
        return rec(now+1,sum-a[now])||rec(now+1,sum);
}

int main(){
        int n;
        cin>>n;
        a.resize(n);
        for(int i=0;i<n;i++)cin>>a[i];
        int q;
        cin>>q;
        vector<int>m(q);
        for(int i=0;i<q;i++){
                cin>>m[i];
                cout<<(rec(0,m[i])?"yes":"no")<<endl;
        }
        return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define TRUE 3
#define FALSE 2
void initialize(void);
void printboard(void);
void recursive(int);
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int Q[N][N];
 
 
void initialize(){
  int i;
  for ( i = 0; i < N; i++ ){
    row[i] = FREE; col[i] = FREE;
  }
  for ( i = 0; i < 2*N - 1; i++ ) {
    dpos[i] = FREE; dneg[i] = FREE;
  }
}
   
 
 
 
 
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(Q[i][j] == TRUE){
    if(row[i] != j)return;
      }
    }
  }
  for (i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%s",(row[i] == j)?"Q":".");
    }
    printf("\n");
  }
 
}
 
void recursive (int i ){
  int j;
  if ( i == N){
 
    printBoard();
    return ;
  }
  for (j =0 ;j <N;j++){
    if (col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] ==NOT_FREE)continue;
 
    row[i] =j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    recursive(i+1);
    row[i] = col[j]=dpos[i+j]=dneg[i-j+N-1] = FREE;
  }
}
 
   
int main(){
  int i,j,k,r,c;
   
  initialize();
    
  for (i = 0; i< N;i++)
    for (j = 0; j< N;j++)
      Q[i][j] = FALSE;
 
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    Q[r][c] = TRUE;
    
  }
    
    
  recursive( 0 );
    return 0;
}

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

signed main(void)
{
	string s, t;
	cin >> s >> t;
	rep(i, t.size())
	{
		cout << s[i] << t[i];
	}
	if (s.size() > t.size())
		cout << s[s.size() - 1];
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
let rec pow_int a n = if n <= 0 then 1 else a * pow_int a (n-1)
let rec sum_dig x = if x = 0 then x else x mod 10 + sum_dig (x/10)
let rec digs x = if x = 0 then 0 else 1 + digs (x/10)
let s x = float_of_int x /. float_of_int (sum_dig x)

let () =
  Scanf.scanf "%d" @@ fun k ->
  let rec loop c n =
    if c >= k then []
    else
      Array.init (digs n) (fun i ->
        let m = pow_int 10 (i+1) in
        (n / m + 1) * m - 1)
      |> Array.fold_left (fun v x -> if s x < s v then x else v) n
      |> fun n' -> n' :: loop (c+1) (n'+1)
  in
  loop 0 1 |> List.iter (Printf.printf "%d\n")

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n, m;
  scanf("%d %d",&n,&m);
  
  int cnt[30] = {};
  int k, a;
  for(int i = 0; i < n; i++){
    scanf("%d",&k);
    for(int j = 0; j < k; j++){
      scanf("%d",&a);
      cnt[a-1]++;
    }
  }
  
  int s = 0;
  for(int i = 0; i < m; i++){
    if(cnt[i] == n){
      s++;
    }
  }
  printf("%d",s);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[100005],b[100005],A[100005],B[100005],c[100005];
long long MX=1e9+7;

int main()
{
    int n,i;
    long long res=1;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    for(i=1;i<=n;i++){
        scanf("%d", &b[i]);
    }
    for(i=1;i<=n;i++){
        if(a[i]>a[i-1])A[i]=a[i];
    }
    for(i=n;i>=1;i--){
        if(b[i]>b[i+1])B[i]=b[i];
    }
    for(i=1;i<=n;i++){
        if(A[i]&&B[i]&&A[i]!=B[i]){
            printf("0");
            return 0;
        }
    }
    for(i=1;i<=n;i++){
        if(A[i]>b[i]||B[i]>a[i]){
            printf("0");
            return 0;
        }
    }
    for(i=1;i<=n;i++){
        if(A[i])c[i]=A[i];
        if(B[i])c[i]=B[i];
    }
    for(i=1;i<=n;i++){
        if(c[i])continue;
        res=res*min(a[i],b[i]);
        res%=MX;
    }
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 1664
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll modpow(ll a, ll n, ll mod);

int main(){
  ll x,y,s,t,n;
  cin >> x >> y;
  if((2*x-y)%3 != 0 || (2*y-x)%3 != 0 || (2*x-y) < 0 || (2*y-x) < 0){
    printf("0\n");
    return 0;
  }else{
    s = (2*y-x)/3;
    t = min((2*x-y)/3,s);
  }
  n = (x+y)/3;
  ll ans = 1;
  for(int i = n-t+1; i <= n; i++){
    ans = ans*i%1000000007;
    // printf("%lld\n", ans);
  }
  for(int i = 1; i <= t; i++){
    ans = ans*modpow(i,1000000005,1000000007)%1000000007;
    // printf("%lld %d\n", ans,i);
  }
  printf("%lld\n", ans);
  return 0;
}

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


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

int main() {
  int X, Y;
  bool flag=false;
  cin >> X >> Y;
  for (int i=0; i<X+1; i++){
    if (4*X-2*i == Y){
      flag=true;
      break;
    }
  }
    if(flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
}

Measured memory_bytes: 3628
x=list(input().split())
x1=list(x[0])
x2=list(x[1])
x3=list(x[2])
word=[]
word.append(x1[0].upper())
word.append(x2[0].upper())
word.append(x3[0].upper())
word=''.join(word)

print(word)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n, k, r, s, p;
  string a;
  cin >> n >> k >> r >> s >> p >> a;
  int ans=0;
  rep(i,n) {
      if(a[i]=='r') ans+=p;
      if(a[i]=='s') ans+=r;
      if(a[i]=='p') ans+=s;
      if(i>=k) {
          if(a[i]==a[i-k]) {
              if(a[i]=='r') ans-=p;
              if(a[i]=='s') ans-=r;
              if(a[i]=='p') ans-=s;
              a[i]='b';
          }
      }
    
  }
  pt(ans);
  return 0;
}

Measured memory_bytes: 512
H,W,K = list(map(int,input().split()))
C = [list(input()) for _ in range(H)]

def F1(c):
    for i in range(W):
        for j in range(H-1,-1,-1):
            if c[j][i] != 'X': continue
            for k in range(j-1,-1,-1):
                if c[k][i] != 'X':
                    c[j][i], c[k][i] = c[k][i], c[j][i]
                    break
    return c

def F2(c):
    delete_sum = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == 'X': continue
            tmp = c[i][j]
            count = 1
            for k in range(j+1,W):
                if c[i][k] == tmp:
                    count += 1
                else:
                    break
            if count >= K:
                for k in range(j,W):
                    if c[i][k] == tmp:
                        delete_sum += int(c[i][k])
                        c[i][k] = 'X'
                    else:
                        break
    return c, delete_sum

MAX = 0
for i in range(H):
    for j in range(W):
        tmpC = []
        for k in range(H):
            tmpC.append(C[k][:])
        tmpC[i][j] = 'X'
        tmpC = F1(tmpC)
        point = 0
        for k in range(1000):
            tmpC, delete_sum = F2(tmpC)
            if delete_sum == 0:
                break
            tmpC = F1(tmpC)
            point += 2**k*delete_sum
        MAX = max(MAX,point)
print(MAX)

Measured memory_bytes: 75220
#include<bits/stdc++.h>
using namespace std;
#define N 1000100
#define ll long long
int f[N];
int find(int x){
    if(f[x] != x) f[x] = find(f[x]);
    return f[x];
}
int merge(int a,int b){
    int t1 = find(a);
    int t2 = find(b);
    if(t1 != t2){
        f[t2] = t1;
        return 1;
    }
    return 0;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i = 0; i <= n; i++){
        f[i] = i;
    }
    int sum = 0;
    while(m--){
        int x,y;
        cin>>x>>y;
        if(merge(x,y)){
            sum++;
        }
    }
    cout<<n-1-sum;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for (int i = 0; i < n-1; i++)
    {
        if(a[i] == a[i+1])
        {cout << "NO" <<endl;
        return 0;}
    }
    cout << "YES" <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;


int main()
{
    int N;
    int hap[100100][3];
    long long int dp[100100][3];
  
    cin >> N;
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
                cin >> hap[i][j];
        }
    }

    for(int i=0; i<N; i++){
        dp[i+1][0] = max(dp[i][1] + hap[i][0],dp[i][2] + hap[i][0]);
        dp[i+1][1] = max(dp[i][0] + hap[i][1],dp[i][2] + hap[i][1]);
        dp[i+1][2] = max(dp[i][0] + hap[i][2],dp[i][1] + hap[i][2]);

    }

    long long ans;
    ans = max(dp[N][0], dp[N][1]);
    ans = max(ans, dp[N][2]);

    cout << ans;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

# define ll long long
//#define forn(i,n) for(int i = 0; i < (n); ++i)

const int N = 100001;
ll dp[N];

int main()
{
	int n, tot;
	cin >> n >> tot;
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		for (int j = tot - x; j >= 0; j--) {
			dp[j + x] = max(dp[j + x], dp[j] + y);
		}
	}
	cout << dp[tot] << endl;
	return 0;
}

Measured memory_bytes: 4404
#include<iostream>
int main()
{
	char c;
	std::cin >> c;
	if (c == 'a') {
		std::cout << "vowel" << std::endl;
	}
	else if (c == 'e') {
		std::cout << "vowel" << std::endl;
	}
	else if (c == 'i') {
		std::cout << "vowel" << std::endl;
	}
	else if (c== 'o') {
		std::cout << "vowel" << std::endl;
	}
	else if (c == 'u') {
		std::cout << "vowel" << std::endl;
	}
	else {
		std::cout << "consonant" << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main( void )
{
  double x1,y1,x2,y2,x3,y3,xp,yp,s1,s2,s3;
  while( 1 ){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
    if( cin.eof() ) break;
    s1 = (x2-x1)*(yp-y1) - (xp-x1)*(y2-y1);
    s2 = (x3-x2)*(yp-y2) - (xp-x2)*(y3-y2);
    s3 = (x1-x3)*(yp-y3) - (xp-x3)*(y1-y3);
    if     ( s1 < 0 && s2 < 0 && s3 < 0 ) cout << "YES" << endl;
    else if( s1 > 0 && s2 > 0 && s3 > 0 ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
	while (1) {
		int s = 1150;
		int a;
		cin >> a;
		if (a==-1)break;
		for (int b = 11; b <= a; b++) {
			if (b < 21)s += 125;
			else if (b < 31)s += 140;
			else s += 160;
		}
		cout << 4280-s<<endl;
	}
}

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

int main() {
    int A, B, H, M; cin >> A >> B >> H >> M;
    long double h, m, c, rad;
    m = M / 60.0 * 360;
    h = H / 12.0 * 360 + M / 60.0 * 30;
    if (abs(h - m) > 180) rad = abs(360-(h - m));
    else rad = h - m;
    long double k = A * B * cosl(rad/180 * M_PI);
    c = (long double)(A * A + B * B) - 2*k;
    cout << fixed << setprecision(10);
    cout << sqrt(c) << endl;
}

Measured memory_bytes: 4156
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int m = Integer.parseInt(str[1]);
		List<String> list = new ArrayList<String>();
		Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
		while (m > 0) {
			String r = br.readLine();
			list.add(r);
			String[] row = r.split(" ");
			int p = Integer.parseInt(row[0]);
			int y = Integer.parseInt(row[1]);
			if (map.containsKey(p)) {
				map.get(p).add(y);
			} else {
				List<Integer> l = new ArrayList<Integer>();
				l.add(y);
				map.put(p, l);
			}
			m--;
		}
		Map<Integer, Map<Integer, Integer>> nm = new HashMap<Integer, Map<Integer, Integer>>();
		for (Entry<Integer, List<Integer>> en : map.entrySet()) {
			int key = en.getKey();
			List<Integer> value = en.getValue();
			Collections.sort(value);
			Map<Integer, Integer> subm = new HashMap<Integer, Integer>();
			for (int i = 1; i < value.size() + 1; i++) {
				subm.put(value.get(i - 1), i);
			}
			nm.put(key, subm);
		}
		for (String r : list) {
			String[] row = r.split(" ");
			int p = Integer.parseInt(row[0]);
			int y = Integer.parseInt(row[1]);
			int num = nm.get(p).get(y);
			String str1 = "000000" + p;
			String font = str1.substring(str1.length() - 6);
			String str2 = "000000" + num;
			String end = str2.substring(str2.length() - 6);
			System.out.println(font + end);
		}
	}
}

Measured memory_bytes: 137008
#include<iostream>
using namespace std;
int main(){
  char c;cin>>c;
  switch(c){
    case 'T':cout<<'A';break;
    case 'A':cout<<'T';break;
    case 'C':cout<<'G';break;
    case 'G':cout<<'C';break;
  }
  cout<<endl;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int month = 10 * (s[5] - '0') + (s[6] - '0');
    if (month <= 4)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 610000
ll n,m,k;
ll dp[4000][4000];
ll a[N];
ll b[N];
int mp[2000][2000];
int main(){
    n=in(),m=in();
    rep(i,n)rep(j,m){
        char c;cin>>c;
        if(c=='#')mp[i][j]=1;
    }
    dp[0][0]=1;
    rep(i,n){rep(j,m){
        if(!mp[i+1][j]){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
        }
        if(!mp[i][j+1]){
            dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
        }

    }
    }
    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 41216
//取り出し方と答えが1対1対応。初期状態（最初に箱にある赤い積み木の個数）が決まっていれば, 取り出し方を重複なく数えるのは簡単。
//理由：最終状態(最後に箱にある赤い積み木の個数)は「取り出し方」と「初期状態」によるが、初期状態が1つであれば、取り出し方を数えるだけでよいから。
//初期状態が複数あると, 異なる最終状態で「同じ取り出し方」をすることがある。たとえばRRRB -> RRB, と, RRBB -> RBBでは、積み木はどちらも「R」になる。
//これを除くには…「途中で青だけになるような取り出し方」だけを数えればよさそう。
//理由：取り出し方を固定すると, その取り出し方で「途中青だけになるような」初期状態が存在する。また, 異なる初期状態A,Bがあったとき,(取り出し方を固定すると)
//Aで「途中青だけになる」ならば、Bでは「途中で青だけにならない or 不正操作」になる。よって不足もなければ, 重複数え上げも起きない。

#include <iostream>
#define int long long
using namespace std;

int n, m;
int dp[3001][3001][2];

signed main() {
	int i, j, k;
	
	cin >> n >> m;
	for (j = 0; j <= n; j++) {
		dp[0][j][j == 0] = 1;
	}
	
	for (i = 0; i < m; i++) {
		for (j = 0; j <= n; j++) {
			for (k = 0; k < 2; k++) {
				dp[i][j][k] %= 1000000007;
				
				//赤赤
				if (j >= 1) {
					dp[i + 1][j - 1][(j == 1) || k] += dp[i][j][k];
				}
				//赤青
				if (j >= 1) {
					dp[i + 1][j][(j == 1) || k] += dp[i][j][k];
				}
				//青赤
				if (n - j >= 1) {
					dp[i + 1][j][k] += dp[i][j][k];
				}
				//青青
				if (n - j >= 1) {
					dp[i + 1][j + 1][k] += dp[i][j][k];
				}
			}
		}
	}
	
	int ans = 0;
	for (j = 0; j <= n; j++) {
		ans += dp[m][j][1];
		ans %= 1000000007;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;

    int n;
    cin>>n;
    int ans=1;
    rep(i,n){
        int a;
        cin>>a;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
        if(ans==-1||__int128(ans)*a>1000000000000000000){
            ans=-1;
        }
        else ans*=a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int N=1407;
	int K=38;
	printf("%d %d\n",N,K);
	for(int i=0;i<K;i++){
		printf("%d",N);
		for(int j=0;j<K-1;j++){
			printf(" %d",1+i*(K-1)+j);
		}
		printf("\n");
	}
	for(int j=0;j<K-1;j++){
		for(int k=0;k<K-1;k++){
			printf("%d",(K-1)*(K-1)+j+1);
			for(int l=0;l<K-1;l++){
				printf(" %d",(k+l*j)%(K-1)+1+(K-1)*l);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
  	cin >> A[i];
    A[i] -= i;
  }
  sort(A.begin(), A.end());
  ll sum = 0;
  for(int i = 0; i < N; i++) {
    sum += abs(A[N / 2] - A[i]);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vl A(M), B(M);
  scc_graph g(N);
  REP(i, M) {
    cin >> A[i] >> B[i];
    g.add_edge(A[i], B[i]);
  }
  auto ans = g.scc();
  cout << ans.size() << endl;
  AUTO(as, ans) {
    cout << as.size() << " ";
    AUTO(a, as) { cout << a << " "; }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 48420
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int max = a+b;
		max = Math.max(max,a-b);
		max = Math.max(max,a*b);

		System.out.println(max);
	}
 
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int n, k;
    int a[1024];

    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);

    cout << accumulate(a, a + k, 0) << endl;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char[][] ch=new char[2][3];
    ch[0]=sc.next().toCharArray();
    ch[1]=sc.next().toCharArray();
    int f=0;
    for(int i=0;i<3;i++){
      if(ch[0][i]==ch[1][2-i]){
        f++;
      }
    }
    if(f==3){
      System.out.print("YES");
    }else{
      System.out.print("NO");
    }
  }
}


Measured memory_bytes: 23764
from collections import deque
n,m=map(int,input().split())
adj=[[] for _ in range(n)]
for _ in range(m):
  a,b =map(int,input().split())
  a-=1
  b-=1
  adj[a].append(b)
  adj[b].append(a)
ans=[0]*n
que=deque([])
que.append(0)
while que:
  e=que.popleft()
  for i in adj[e]:
    if ans[i]!=0:
      continue
    ans[i]=e+1
    que.append(i)
print("Yes")
for i in range(1,n):
  print(ans[i])

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

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {}

    int find(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) {
        return -par[find(x)];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n), q(1, 1);
    UnionFind uf(n - k + 1);
    rep(i, 0, n) {
        cin >> p[i];
        if (i) {
            if (p[i] > p[i - 1])
                q.back()++;
            else
                q.emplace_back(1);
        }
    }
    int sum = 0;
    vector<int> sx;
    rep(i, 0, q.size()) {
        if (q[i] >= k) {
            sx.emplace_back(sum);
        }
        sum += q[i];
    }
    rep(i, 0, int(sx.size() - 1)) {
        uf.unite(p[sx[i]], p[sx[i + 1]]);
    }

    set<int> st;
    rep(i, 0, k) st.insert(p[i]);
    rep(i, 0, n - k) {
        st.insert(p[i + k]);
        if (*st.begin() == p[i] && *st.rbegin() == p[i + k]) {
            uf.unite(p[i], p[i + 1]);
        }
        st.erase(p[i]);
    }

    int ans = 0;
    rep(i, 0, n - k + 1) if (uf.par[i] < 0) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10872
/*
 * Author : Sadi
 * Fri 03/07/2020
 * 16:36:22.84
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;

    return 0;
}


Measured memory_bytes: 3556
//============================================================================
// Name        : 0077.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main(void){
	int i, j;
	char str[1024];
	while(scanf("%s",str) != EOF){
		for(i = 0;i < strlen(str);i++){
			if(i + 1 < strlen(str) && str[i] == '@'){
				for(j = 0;j < (str[i + 1] - '0');j++){
					printf("%c",str[i + 2]);
				}
				i += 2;
			}else{
				printf("%c",str[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 936
/*author : Yashvardhan
Wednesday, January 30, 2019
10:55 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;
const int N = 1005;

int h,w;
int dp[N*N];
string grid;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
bool inBound(int x){
	if(x >= 1 && x <= h*w){
		return true;
	}
	return false;
}
int solve(int s){
	if (dp[s] != -1)
		return dp[s];
	if (s == 1)
		return dp[1] = 1;
	int up = s - w;
	int left;
	if (s % w == 1)
		left = -1;
	else
		left = s - 1;
	int ans = 0;
	if (inBound(up))
	{
		if (grid[up] != '#')
			ans = ((ans % mod) + (solve(up) % mod)) % mod;
	}
	if (left != -1)
	{
		if (grid[left] != '#')
			ans = ((ans % mod) + (solve(left) % mod)) % mod;
	}
	return dp[s] = ans;
}
signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	cin>>h>>w;
	grid = "Y";
	for(int i = 0; i < h ; i++){
		string inp;
		cin>>inp;
		grid += inp;
	}
	memset(dp,-1,sizeof(dp));
	
	cout<<solve(h*w)<<endl;
	
	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    vector<pair<int, pair<int, int>>> table;
    REP(i, N) {
        int a, b;
        std::cin >> a >> b;
        table.emplace_back(a + b, make_pair(a, b));
    }
    RSORT(table);

    ll takahashi_sum = 0;
    ll aoki_sum      = 0;
    REP(i, N) {
        if(i % 2 == 0) takahashi_sum += table[i].second.first;
        else aoki_sum += table[i].second.second;
    }

    std::cout << takahashi_sum - aoki_sum << std::endl;

    return 0;
}


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

class Dmondai {
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = line[0];
        var M = line[1];
        var A= Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).OrderBy(x=>x).ToArray();
        var cost = new int[] { 2,5,5,4,5,6,3,7,6};
        var dp = new int[N+1];
        dp[0] = 0;
        for (int i = 1; i <= N; ++i) dp[i] = int.MinValue;
        for (int i=0;i<=N;++i)
        {
            if (i != 0 && dp[i] == int.MinValue) continue;
            for (int j=0;j<M;++j)
            {
                if (N < i + cost[A[j] - 1]) continue;
                dp[i+cost[A[j] - 1]] = Math.Max(dp[i],dp[i]+1);
            }
        }
        var ans = string.Empty;
        for (int i=N;0<i;)
        {
            for (int j=M-1;-1<j;--j)
            {
                if (i - cost[A[j] - 1] < 0) continue;
                if (dp[i - cost[A[j] - 1]] == dp[i]-1) {
                    ans += A[j];
                    i = i - cost[A[j] - 1];
                    break;
                }
            }
        }
        Console.WriteLine(ans);
    }
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL k;
	cin >> k;
	LL a, b;
	cin >> a >> b;

	LL p = 0;

	for (LL i = a; i <= b; ++i) {
		if (i % k == 0) {
			p = 1;
			break;
		}
	} 

	if (p) {
		cout << "OK\n";
	}
	else {
		cout << "NG\n";
	}
}



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

using namespace std;

const int INF = 1 << 30;

int N, M, S[15], D[100];
int sum[1 << 15];
int dp[1 << 15];

int main()
{

  while(scanf("%d %d", &N, &M), N) {
    for(int i = 0; i < N; ++i) {
      scanf("%d", &S[i]);
    }
    for(int i = 0; i < M; ++i) {
      scanf("%d", &D[i]);
    }
    sort(D, D + M);

    for(int i = 0; i < (1 << N); i++) {
      sum[i] = 0;
      for(int j = 0; j < N; j++) {
        if((i >> j) & 1) continue;
        sum[i] += S[j];
      }
    }

    fill_n(dp, 1 << N, INF);
    dp[(1 << N) - 1] = 0;
    for(int i = 0; i < M; i++) {
      for(int k = (1 << N) - 1; k >= 0; k--) {
        int j = k;
        while(j > 0) {
          int pos = j & -j;
          j -= pos;
          dp[k - pos] = min(dp[k - pos], dp[k]);
        }
      }
      for(int k = 0; k < (1 << N); k++) {
        dp[k] += abs(D[i] - sum[k]);
      }
    }
    printf("%d\n", *min_element(dp, dp + (1 << N)));
  }
}

Measured memory_bytes: 3480
#include <iostream>
#include <queue>
#include <vector>
#include <list>
#include <algorithm>


using namespace std;


using ll = long long;


const ll MAX = 100;


vector<list<ll>> graph;
ll d[MAX + 1] = {};
ll n;
bool visited[MAX + 1] = {};

void bfs()
{
    queue<pair<ll, ll>> q;
    q.push(make_pair(1, 0));
    visited[1] = true;

    while (!q.empty()) {
        auto tmp = q.front(); q.pop();
        ll now = tmp.first; ll dis = tmp.second;

        d[now] = dis;

        for (auto e : graph[now]) {
            if (!visited[e]) {
                visited[e] = true;
                q.push(make_pair(e, dis + 1));
            }
        }
    }
}


int main()
{
    cin >> n;
    graph.resize(n + 1);
    for (ll i = 0; i < n; i++) {
        ll u, k;
        cin >> u >> k;
        for (ll j = 0; j < k; j++) {
            ll v;
            cin >> v;
            graph[u].push_back(v);
        }
    }

    bfs();

    for (ll i = 1; i <= n; i++) {
        if (visited[i]) {
            cout << i << " " << d[i] << endl;
        } else {
            cout << i << " " << -1 << endl;
        }
    }
}



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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
#define y0 I_love_Ryougi_Shiki_0
#define y1 I_love_Ryougi_Shiki_1

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

template<typename T>
inline void cmin(T& x,T y)
{
	if(!(x<y)) x=y;
}

template<typename T>
inline void cmax(T& x,T y)
{
	if(x<y) x=y;
}

const int inf=5000000000000000ll;
const int mul=7;
const int mod=998244353;

inline bool get(vector<int>& v,int i,int p,bool anti)
{
	bool res=(bool)(v[i]&(1<<p));
	if(anti) res^=1;
	return res;
}

main()
{
	ios::sync_with_stdio(false);
	
	int N; cin>>N;
	vector<int> a(N),b(N),res(N,0),mulP(N,1);
	for(int i=0;i<N;i++) cin>>a[i];
	for(int i=0;i<N;i++) cin>>b[i];
	for(int i=1;i<N;i++) mulP[i]=mulP[i-1]*mul%mod;
	for(int p=0;p<30;p++)
	{
		int va0=0,va1=0,vb=0;
		for(int i=0;i<N;i++)
		{
			va0=(va0*mul+get(a,i,p,0))%mod;
			va1=(va1*mul+get(a,i,p,1))%mod;
			vb=(vb*mul+get(b,i,p,0))%mod;
		}
		for(int i=0;i<N;i++)
		{
			if(i)
			{
				va0=(va0-get(a,i-1,p,0)*mulP[N-1]%mod+mod)%mod;
				va0=(va0*mul+get(a,i-1,p,0))%mod;
				va1=(va1-get(a,i-1,p,1)*mulP[N-1]%mod+mod)%mod;
				va1=(va1*mul+get(a,i-1,p,1))%mod;
			}
			if(va0==vb && res[i]!=-1) { /* do nothing*/ }
			else if(va1==vb && res[i]!=-1) res[i]|=(1<<p);
			else res[i]=-1;
		}
	}
	for(int i=0;i<N;i++)
	{
		if(res[i]!=-1) cout<<i<<" "<<res[i]<<endl;
	}
	
	return 0;
}






















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

void solver() {
  string s, t;
  cin >> s >> t;

  bool f = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      f = false;
      break;
    }
  }

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

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


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

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n - 1; i++) cin >> c[i];

    int res = 0;
    int formerFood = -3;
    for (int i = 0; i < n; i++) {
        res += b[a[i] - 1];
        if (a[i] == formerFood + 2) res += c[formerFood];
        formerFood = a[i] - 1;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
long long mi=1000000000000000LL;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	char c;
	cin >> c;
	if(isupper(c))
		cout << 'A';
	else
		cout << 'a';
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> cost(10,vector<int>(10));
  for (auto &v : cost) {
    for (int &e : v) cin >> e;
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        cost[j][k] = min (cost[j][k], cost[j][i]+cost[i][k]);
      }
    }
  }
  vector<int> lowest(10);
  for (int i = 0; i < 10; i++) lowest[i] = cost[i][1];
  
  int ans = 0;
  for (int i = 0; i < H*W; i++) {
    int n; cin >> n;
    if (n < 0) continue;
    ans += lowest[n];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int n;
vector<int> E[101010];
VI ok(n+1);

void dfs(int cu, int pa = -1) {
  ok[cu]=1;
  for(int to:E[cu]) {
    if (to != pa) {

      dfs(to,cu);
      
    }
  }
}

int main(){
  int i,j;
  cin>>n;
  vector<P> w;
  for(i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    E[a].pb(b);
    E[b].pb(a);
    w.pb(P(a,b));
  }
  int m;
  cin>>m;
  int u[m],v[m];
  for(i=0;i<m;i++){
    cin>>u[i]>>v[i];
    u[i]--;
    v[i]--;
  }

  VI val(n,0);

  for(i=0;i<n-1;i++){
    ok=VI(n,0);
    dfs(w[i].fi,w[i].se);
    for(j=0;j<m;j++){
      if(ok[u[j]]+ok[v[j]]==1) val[i]+=(1<<j);
    }
  }

  VI dp((1<<m),0);
  dp[0]=1;
  for(i=0;i<n-1;i++){
    for(j=(1<<m)-1;j>=0;j--){
      dp[(j|val[i])]+=dp[j];
    }
  }
  cout<<dp[(1<<m)-1]<<endl;



  return 0;
}


Measured memory_bytes: 10752
using System;
namespace codefestival_2016_qualB_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string s = "CODEFESTIVAL2016";
            int ans = 0;
            for(int i = 0; i < a.Length; i++)
            {
                if (a[i] != s[i]) { ans++; }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140