Problem:
 Score : 1600 points    Problem Statement For a string S , let f(S) be the lexicographically smallest cyclic shift of S .
For example, if S = babca , f(S) = ababc because this is the smallest among all cyclic shifts ( babca , abcab , bcaba , cabab , ababc ).  You are given three integers X, Y , and Z .
You want to construct a string T that consists of exactly X  a s, exactly Y  b s, and exactly Z  c s.
If there are multiple such strings, you want to choose one that maximizes f(T) lexicographically.  Compute the lexicographically largest possible value of f(T) .      Constraints  1 \leq X + Y + Z \leq 50  X, Y, Z are non-negative integers.         Input Input is given from Standard Input in the following format:  X  Y  Z       Output Print the answer.        Sample Input 1 2 2 0      Sample Output 1 abab  T must consist of two a s and two b s.   If T = aabb , f(T) = aabb .  If T = abab , f(T) = abab .  If T = abba , f(T) = aabb .  If T = baab , f(T) = aabb .  If T = baba , f(T) = abab .  If T = bbaa , f(T) = aabb .   Thus, the largest possible f(T) is abab .       Sample Input 2 1 1 1      Sample Output 2 acb

Solution (Python):
def work(a,b,c,A,B,C):
 if A==0:
  return work(b,c,'',B,C,0)
 if B==0:
  if C==0:
   return a*A
  else:
   return work(a,c,'',A,C,0)
 if C==0:
  return work(a+b*(B/A),a+b*(B/A+1),'',A-B%A,B%A,0)
 cmod = C%A
 if B <= A-cmod:
  return work(a+c*(C/A),a+c*(C/A)+b,a+c*(C/A+1),A-cmod-B,B,cmod)
 else:
  bmod = B%(A-cmod)
  return work(a+c*(C/A)+b*(B/(A-cmod)),a+c*(C/A)+b*(B/(A-cmod)+1),a+c*(C/A+1),A-bmod-cmod,bmod,cmod)

if __name__ == '__main__':
 s = raw_input()
 a,b,c = [int(i) for i in s.split()]
 print(work('a','b','c',a,b,c))

Solution (Python):
x, y, z = map(int, raw_input().split())
a = ['a'] * x + ['b'] * y + ['c'] * z

while len(a) > 1:
    a = sorted(a[1:-1] + [a[0] + a[-1]])

print a[0]

Solution (Python):
a,b,c = map(int,input().split())

L = [[0] for _ in range(a)] + [[1] for _ in range(b)] + [[2] for _ in range(c)]
while len(L) > 1:
  L[0] += L.pop()
  L.sort()
print(''.join(('a','b','c')[i] for i in L[0]))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    x,y,z = LI()
    a = ['a' for _ in range(x)] + ['b' for _ in range(y)] + ['c' for _ in range(z)]
    while len(a) > 1:
        a.sort()
        a[0] += a[-1]
        a = a[:-1]

    return a[0]


print(main())